CVS commit: src/sys/lib/libsa
Module Name:src Committed By: christos Date: Tue Feb 27 16:09:19 UTC 2024 Modified Files: src/sys/lib/libsa: netif.h Log Message: Put the standard NetBSD copyright on this file. Approved by John Brezak via a message on LinkedIn. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/lib/libsa/netif.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: christos Date: Tue Feb 27 16:09:19 UTC 2024 Modified Files: src/sys/lib/libsa: netif.h Log Message: Put the standard NetBSD copyright on this file. Approved by John Brezak via a message on LinkedIn. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/lib/libsa/netif.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/netif.h diff -u src/sys/lib/libsa/netif.h:1.7 src/sys/lib/libsa/netif.h:1.8 --- src/sys/lib/libsa/netif.h:1.7 Sat Jan 17 09:00:36 2009 +++ src/sys/lib/libsa/netif.h Tue Feb 27 11:09:19 2024 @@ -1,4 +1,30 @@ -/* $NetBSD: netif.h,v 1.7 2009/01/17 14:00:36 tsutsui Exp $ */ +/* $NetBSD: netif.h,v 1.8 2024/02/27 16:09:19 christos Exp $ */ + +/*- + * Copyright (c) 2024 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ #ifndef __SYS_LIBNETBOOT_NETIF_H #define __SYS_LIBNETBOOT_NETIF_H
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Thu Dec 14 05:39:00 UTC 2023 Modified Files: src/sys/lib/libsa: nfs.c Log Message: libsa: nfs: Fix NFS_NOSYMLINK option for previous Used only by mvme68k. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/lib/libsa/nfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/nfs.c diff -u src/sys/lib/libsa/nfs.c:1.51 src/sys/lib/libsa/nfs.c:1.52 --- src/sys/lib/libsa/nfs.c:1.51 Tue Dec 12 09:12:55 2023 +++ src/sys/lib/libsa/nfs.c Thu Dec 14 05:39:00 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs.c,v 1.51 2023/12/12 09:12:55 mlelstv Exp $ */ +/* $NetBSD: nfs.c,v 1.52 2023/12/14 05:39:00 rin Exp $ */ /*- * Copyright (c) 1993 John Brezak @@ -596,9 +596,9 @@ nfs_open(const char *path, struct open_f char namebuf[NFS_MAXPATHLEN + 1]; char linkbuf[NFS_MAXPATHLEN + 1]; int nlinks = 0; + n_long fa_type; #endif int error = 0; - n_long fa_type; #ifdef NFS_DEBUG if (debug)
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Thu Dec 14 05:39:00 UTC 2023 Modified Files: src/sys/lib/libsa: nfs.c Log Message: libsa: nfs: Fix NFS_NOSYMLINK option for previous Used only by mvme68k. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/lib/libsa/nfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mlelstv Date: Tue Dec 12 09:12:55 UTC 2023 Modified Files: src/sys/lib/libsa: nfs.c nfsv2.h rpcv2.h Added Files: src/sys/lib/libsa: nfsv3.h Log Message: Add NFSv3 support. Try NFSv3 and fall back to NFSv2. To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/lib/libsa/nfs.c cvs rdiff -u -r1.4 -r1.5 src/sys/lib/libsa/nfsv2.h cvs rdiff -u -r0 -r1.1 src/sys/lib/libsa/nfsv3.h cvs rdiff -u -r1.3 -r1.4 src/sys/lib/libsa/rpcv2.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/nfs.c diff -u src/sys/lib/libsa/nfs.c:1.50 src/sys/lib/libsa/nfs.c:1.51 --- src/sys/lib/libsa/nfs.c:1.50 Sun Jan 26 10:13:10 2020 +++ src/sys/lib/libsa/nfs.c Tue Dec 12 09:12:55 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs.c,v 1.50 2020/01/26 10:13:10 skrll Exp $ */ +/* $NetBSD: nfs.c,v 1.51 2023/12/12 09:12:55 mlelstv Exp $ */ /*- * Copyright (c) 1993 John Brezak @@ -53,46 +53,18 @@ #include "rpcv2.h" #include "nfsv2.h" +#include "nfsv3.h" #include "stand.h" #include "net.h" #include "nfs.h" #include "rpc.h" -/* Define our own NFS attributes */ -struct nfsv2_fattrs { - n_long fa_type; - n_long fa_mode; - n_long fa_nlink; - n_long fa_uid; - n_long fa_gid; - n_long fa_size; - n_long fa_blocksize; - n_long fa_rdev; - n_long fa_blocks; - n_long fa_fsid; - n_long fa_fileid; - struct nfsv2_time fa_atime; - struct nfsv2_time fa_mtime; - struct nfsv2_time fa_ctime; -}; - - -struct nfs_read_args { - u_char fh[NFS_FHSIZE]; - n_long off; - n_long len; - n_long xxx; /* XXX what's this for? */ -}; +/* Storage for any filehandle (including length for V3) */ +#define NFS_FHSTORE (NFS_FHSIZE < NFS_V3FHSIZE ? NFS_V3FHSIZE + 4: NFS_FHSIZE) /* Data part of nfs rpc reply (also the largest thing we receive) */ #define NFSREAD_SIZE 1024 -struct nfs_read_repl { - n_long errno; - struct nfsv2_fattrs fa; - n_long count; - u_char data[NFSREAD_SIZE]; -}; #ifndef NFS_NOSYMLINK struct nfs_readlnk_repl { @@ -102,16 +74,68 @@ struct nfs_readlnk_repl { }; #endif +static inline uint64_t +getnquad(n_long x[2]) { + return (uint64_t)ntohl(x[0]) << 32 | ntohl(x[1]); +} + +static inline void +setnquad(n_long x[2], uint64_t v) +{ + x[0] = htonl((n_long)(v >> 32)); + x[1] = htonl((n_long)(v & 0x)); +} + struct nfs_iodesc { struct iodesc *iodesc; off_t off; - u_char fh[NFS_FHSIZE]; - struct nfsv2_fattrs fa; /* all in network order */ + int version; + u_char fh[NFS_FHSTORE]; + union { + /* all in network order */ + struct nfsv2_fattr v2; + struct nfsv3_fattr v3; + } u_fa; }; +static inline size_t +fhstore(int version, u_char *fh) +{ + size_t len; + + switch (version) { + case NFS_VER2: + len = NFS_FHSIZE; + break; + case NFS_VER3: + len = fh[0] << 24 | fh[1] << 16 | fh[2] << 8 | fh[3]; + if (len > NFS_V3FHSIZE) + len = NFS_V3FHSIZE; + len = 4 + roundup(len, 4); + break; + default: + len = 0; + break; + } + + return len; +} + +static inline size_t +fhcopy(int version, u_char *src, u_char *dst) +{ + size_t len = fhstore(version, src); + memcpy(dst, src, len); + return len; +} + +#define setfh(d, s) fhcopy((d)->version, (s), (d)->fh) +#define getfh(d, s) fhcopy((d)->version, (d)->fh, (s)) + + struct nfs_iodesc nfs_root_node; -int nfs_getrootfh(struct iodesc *, char *, u_char *); +int nfs_getrootfh(struct iodesc *, char *, u_char *, int *); int nfs_lookupfh(struct nfs_iodesc *, const char *, int, struct nfs_iodesc *); int nfs_readlink(struct nfs_iodesc *, char *); @@ -122,7 +146,7 @@ ssize_t nfs_readdata(struct nfs_iodesc * * On error, return non-zero and set errno. */ int -nfs_getrootfh(struct iodesc *d, char *path, u_char *fhp) +nfs_getrootfh(struct iodesc *d, char *path, u_char *fhp, int *versionp) { int len; struct args { @@ -131,7 +155,7 @@ nfs_getrootfh(struct iodesc *d, char *pa } *args; struct repl { n_long errno; - u_char fh[NFS_FHSIZE]; + u_char fh[NFS_FHSTORE]; } *repl; struct { n_long h[RPC_HEADER_WORDS]; @@ -159,8 +183,14 @@ nfs_getrootfh(struct iodesc *d, char *pa (void)memcpy(args->path, path, len); len = 4 + roundup(len, 4); - cc = rpc_call(d, RPCPROG_MNT, RPCMNT_VER1, RPCMNT_MOUNT, + *versionp = NFS_VER3; + cc = rpc_call(d, RPCPROG_MNT, RPCMNT_VER3, RPCMNT_MOUNT, args, len, repl, sizeof(*repl)); + if (cc == -1 || cc < 4 || repl->errno) { + *versionp = NFS_VER2; + cc = rpc_call(d, RPCPROG_MNT, RPCMNT_VER1, RPCMNT_MOUNT, + args, len, repl, sizeof(*repl)); + } if (cc == -1) { /* errno was set by rpc_call */ return -1; @@ -173,7 +203,7 @@ nfs_getrootfh(struct iodesc *d, char *pa errno = ntohl(repl->errno); return -1; } - (void)memcpy(fhp, repl->fh, sizeof(repl->fh)); + fhcopy(*versionp, repl->fh, fhp); return 0; } @@ -185,58 +215,126 @@ int nfs_lookupfh(struct nfs_iodesc *d, const char *name, int len, struct nfs_iodesc *newfd) { - int rlen; - struct
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mlelstv Date: Tue Dec 12 09:12:55 UTC 2023 Modified Files: src/sys/lib/libsa: nfs.c nfsv2.h rpcv2.h Added Files: src/sys/lib/libsa: nfsv3.h Log Message: Add NFSv3 support. Try NFSv3 and fall back to NFSv2. To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/lib/libsa/nfs.c cvs rdiff -u -r1.4 -r1.5 src/sys/lib/libsa/nfsv2.h cvs rdiff -u -r0 -r1.1 src/sys/lib/libsa/nfsv3.h cvs rdiff -u -r1.3 -r1.4 src/sys/lib/libsa/rpcv2.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Thu Sep 14 03:08:31 UTC 2023 Modified Files: src/sys/lib/libsa: netif.c Log Message: netif_open: Fail with ENXIO instead of panic if no netif available Avoid undesirable freeze for efiboot/x86 when interfaces are really unavailable, or fail to be configured by buggy UEFI firmware. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/lib/libsa/netif.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/netif.c diff -u src/sys/lib/libsa/netif.c:1.26 src/sys/lib/libsa/netif.c:1.27 --- src/sys/lib/libsa/netif.c:1.26 Sun Mar 31 20:08:45 2019 +++ src/sys/lib/libsa/netif.c Thu Sep 14 03:08:31 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: netif.c,v 1.26 2019/03/31 20:08:45 christos Exp $ */ +/* $NetBSD: netif.c,v 1.27 2023/09/14 03:08:31 rin Exp $ */ /* * Copyright (c) 1993 Adam Glass @@ -292,8 +292,10 @@ fnd: (void)memset(s, 0, sizeof(*s)); netif_init(); nif = netif_select(machdep_hint); - if (!nif) - panic("netboot: no interfaces left untried"); + if (!nif) { + errno = ENXIO; + return -1; + } if (netif_probe(nif, machdep_hint)) { printf("%s: couldn't probe %s%d\n", __func__, nif->nif_driver->netif_bname, nif->nif_unit);
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Thu Sep 14 03:08:31 UTC 2023 Modified Files: src/sys/lib/libsa: netif.c Log Message: netif_open: Fail with ENXIO instead of panic if no netif available Avoid undesirable freeze for efiboot/x86 when interfaces are really unavailable, or fail to be configured by buggy UEFI firmware. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/lib/libsa/netif.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: christos Date: Wed Aug 30 18:47:37 UTC 2023 Modified Files: src/sys/lib/libsa: Makefile Log Message: We don't want SSP/FORTIFY here. To generate a diff of this commit: cvs rdiff -u -r1.95 -r1.96 src/sys/lib/libsa/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/Makefile diff -u src/sys/lib/libsa/Makefile:1.95 src/sys/lib/libsa/Makefile:1.96 --- src/sys/lib/libsa/Makefile:1.95 Thu May 27 02:54:44 2021 +++ src/sys/lib/libsa/Makefile Wed Aug 30 14:47:37 2023 @@ -1,7 +1,9 @@ -# $NetBSD: Makefile,v 1.95 2021/05/27 06:54:44 mrg Exp $ +# $NetBSD: Makefile,v 1.96 2023/08/30 18:47:37 christos Exp $ LIB= sa LIBISPRIVATE?= yes +NOSSP=yes +NOFORTIFY=yes SA_USE_CREAD?= no # Read compressed kernels SA_INCLUDE_NET?= yes # Netboot via TFTP, NFS @@ -18,8 +20,6 @@ CPPFLAGS= -I${SADIR} ${SACPPFLAGS} ${SAM # For testing #WARNS=6 -#NOSSP=yes -#NOFORTIFY=yes #COPTS+=-ffreestanding -Wpointer-sign #CPPFLAGS+= -I${.CURDIR}/../../ -I${.CURDIR}
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: christos Date: Wed Aug 30 18:47:37 UTC 2023 Modified Files: src/sys/lib/libsa: Makefile Log Message: We don't want SSP/FORTIFY here. To generate a diff of this commit: cvs rdiff -u -r1.95 -r1.96 src/sys/lib/libsa/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Wed Jun 14 00:28:55 UTC 2023 Modified Files: src/sys/lib/libsa: cread.c Log Message: Add /* FALLTHROUGH */ comment for sure. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/lib/libsa/cread.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/cread.c diff -u src/sys/lib/libsa/cread.c:1.28 src/sys/lib/libsa/cread.c:1.29 --- src/sys/lib/libsa/cread.c:1.28 Sun Jan 17 04:35:42 2016 +++ src/sys/lib/libsa/cread.c Wed Jun 14 00:28:55 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: cread.c,v 1.28 2016/01/17 04:35:42 tsutsui Exp $ */ +/* $NetBSD: cread.c,v 1.29 2023/06/14 00:28:55 rin Exp $ */ /* * Copyright (c) 1996 @@ -453,6 +453,7 @@ lseek(int fd, off_t offset, int where) switch(where) { case SEEK_CUR: offset += s->stream.total_out; + /* FALLTHROUGH */ case SEEK_SET: /* if seek backwards, simply start from the beginning */ if (offset < s->stream.total_out) {
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Wed Jun 14 00:28:55 UTC 2023 Modified Files: src/sys/lib/libsa: cread.c Log Message: Add /* FALLTHROUGH */ comment for sure. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/lib/libsa/cread.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Mon May 29 03:56:52 UTC 2023 Modified Files: src/sys/lib/libsa: subr_prf.c Log Message: libsa/printf: Do not fetch long va_arg as long long. This does real harm iff all of the following conditions are satisfied: (1) On ILP32 architectures. (2) Both LIBSA_PRINTF_LONGLONG_SUPPORT and LIBSA_PRINTF_WIDTH_SUPPORT compile-time options are enabled. (3) Width field is used with 'l' modifier. This is an implicit-fallthrough bug, but unfortunately, GCC 10.4 cannot find this out somehow... XXX Pull up to netbsd-10 and netbsd-9. netbsd-8 is not affected. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/lib/libsa/subr_prf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/subr_prf.c diff -u src/sys/lib/libsa/subr_prf.c:1.29 src/sys/lib/libsa/subr_prf.c:1.30 --- src/sys/lib/libsa/subr_prf.c:1.29 Sat Jun 6 15:45:47 2020 +++ src/sys/lib/libsa/subr_prf.c Mon May 29 03:56:52 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_prf.c,v 1.29 2020/06/06 15:45:47 thorpej Exp $ */ +/* $NetBSD: subr_prf.c,v 1.30 2023/05/29 03:56:52 rin Exp $ */ /*- * Copyright (c) 1993 @@ -209,6 +209,7 @@ reswitch: break; ++fmt; } + goto reswitch; #endif case 'l': #ifdef LIBSA_PRINTF_LONGLONG_SUPPORT
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Mon May 29 03:56:52 UTC 2023 Modified Files: src/sys/lib/libsa: subr_prf.c Log Message: libsa/printf: Do not fetch long va_arg as long long. This does real harm iff all of the following conditions are satisfied: (1) On ILP32 architectures. (2) Both LIBSA_PRINTF_LONGLONG_SUPPORT and LIBSA_PRINTF_WIDTH_SUPPORT compile-time options are enabled. (3) Width field is used with 'l' modifier. This is an implicit-fallthrough bug, but unfortunately, GCC 10.4 cannot find this out somehow... XXX Pull up to netbsd-10 and netbsd-9. netbsd-8 is not affected. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/lib/libsa/subr_prf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: christos Date: Thu Dec 1 18:06:09 UTC 2022 Modified Files: src/sys/lib/libsa: ufs.c Log Message: fix clang build To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/ufs.c diff -u src/sys/lib/libsa/ufs.c:1.87 src/sys/lib/libsa/ufs.c:1.88 --- src/sys/lib/libsa/ufs.c:1.87 Thu Nov 17 01:40:40 2022 +++ src/sys/lib/libsa/ufs.c Thu Dec 1 13:06:09 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs.c,v 1.87 2022/11/17 06:40:40 chs Exp $ */ +/* $NetBSD: ufs.c,v 1.88 2022/12/01 18:06:09 christos Exp $ */ /*- * Copyright (c) 1993 @@ -218,6 +218,7 @@ ffs_is_magic(FS *fs) return fs->fs_magic == FS_UFS1_MAGIC; } +#ifdef LIBSA_FFS_EI static __inline__ bool ffs_is_magic_swapped(FS *fs) { @@ -225,6 +226,8 @@ ffs_is_magic_swapped(FS *fs) } #endif +#endif + #ifdef LIBSA_FFSv2 static __inline__ bool ffs_is_magic(FS *fs) @@ -232,6 +235,7 @@ ffs_is_magic(FS *fs) return fs->fs_magic == FS_UFS2_MAGIC || fs->fs_magic == FS_UFS2EA_MAGIC; } +#ifdef LIBSA_FFS_EI static __inline__ bool ffs_is_magic_swapped(FS *fs) { @@ -240,6 +244,8 @@ ffs_is_magic_swapped(FS *fs) } #endif +#endif + #ifdef LIBSA_LFS static __inline__ bool ffs_is_magic(FS *fs) @@ -247,6 +253,7 @@ ffs_is_magic(FS *fs) return fs->fs_magic == LFS_MAGIC; } +#ifdef LIBSA_FFS_EI static __inline__ bool ffs_is_magic_swapped(FS *fs) { @@ -254,6 +261,8 @@ ffs_is_magic_swapped(FS *fs) } #endif +#endif + static __inline__ void ffs_fix_magic_swapped(struct file *fp, FS *fs) {
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: christos Date: Thu Dec 1 18:06:09 UTC 2022 Modified Files: src/sys/lib/libsa: ufs.c Log Message: fix clang build To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Sun Aug 7 05:51:55 UTC 2022 Modified Files: src/sys/lib/libsa: tftp.c Log Message: Consistently use ntohs() instead of htons() when converting from network to host byte order. No binary changes both for big and little endian. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/lib/libsa/tftp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/tftp.c diff -u src/sys/lib/libsa/tftp.c:1.37 src/sys/lib/libsa/tftp.c:1.38 --- src/sys/lib/libsa/tftp.c:1.37 Fri Mar 26 10:35:08 2021 +++ src/sys/lib/libsa/tftp.c Sun Aug 7 05:51:55 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tftp.c,v 1.37 2021/03/26 10:35:08 rin Exp $ */ +/* $NetBSD: tftp.c,v 1.38 2022/08/07 05:51:55 rin Exp $ */ /* * Copyright (c) 1996 @@ -114,7 +114,7 @@ recvtftp(struct iodesc *d, void *pkt, si t = (struct tftphdr *)pkt; switch (ntohs(t->th_opcode)) { case DATA: - if (htons(t->th_block) != d->xid) { + if (ntohs(t->th_block) != d->xid) { /* * Expected block? */
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Sun Aug 7 05:51:55 UTC 2022 Modified Files: src/sys/lib/libsa: tftp.c Log Message: Consistently use ntohs() instead of htons() when converting from network to host byte order. No binary changes both for big and little endian. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/lib/libsa/tftp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Sat Apr 30 09:24:05 UTC 2022 Modified Files: src/sys/lib/libsa: stand.h Log Message: Now, NULL is always defined correctly, as we include above. To generate a diff of this commit: cvs rdiff -u -r1.86 -r1.87 src/sys/lib/libsa/stand.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Sat Apr 30 09:24:05 UTC 2022 Modified Files: src/sys/lib/libsa: stand.h Log Message: Now, NULL is always defined correctly, as we include above. To generate a diff of this commit: cvs rdiff -u -r1.86 -r1.87 src/sys/lib/libsa/stand.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/stand.h diff -u src/sys/lib/libsa/stand.h:1.86 src/sys/lib/libsa/stand.h:1.87 --- src/sys/lib/libsa/stand.h:1.86 Fri Apr 29 07:42:07 2022 +++ src/sys/lib/libsa/stand.h Sat Apr 30 09:24:05 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: stand.h,v 1.86 2022/04/29 07:42:07 rin Exp $ */ +/* $NetBSD: stand.h,v 1.87 2022/04/30 09:24:05 rin Exp $ */ /* * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved. @@ -72,10 +72,6 @@ #include "saioctl.h" #include "saerrno.h" -#ifndef NULL -#define NULL 0 -#endif - #ifdef LIBSA_RENAME_PRINTF #define getchar libsa_getchar #define kgets libsa_kgets
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Fri Apr 29 07:42:07 UTC 2022 Modified Files: src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c Log Message: Re-introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is used instead of secsize obtained by SAIOSECSIZE ioctl. This hack avoids divdi3 and friends from being linked, in order to support variable secsize for some archs. Should be useful for ancient archs, for which secsize is fixed. Thanks christos@ for comment. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/lib/libsa/ext2fs.c cvs rdiff -u -r1.12 -r1.13 src/sys/lib/libsa/minixfs3.c cvs rdiff -u -r1.85 -r1.86 src/sys/lib/libsa/stand.h src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/ext2fs.c diff -u src/sys/lib/libsa/ext2fs.c:1.33 src/sys/lib/libsa/ext2fs.c:1.34 --- src/sys/lib/libsa/ext2fs.c:1.33 Wed Apr 27 14:48:50 2022 +++ src/sys/lib/libsa/ext2fs.c Fri Apr 29 07:42:07 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.c,v 1.33 2022/04/27 14:48:50 rin Exp $ */ +/* $NetBSD: ext2fs.c,v 1.34 2022/04/29 07:42:07 rin Exp $ */ /* * Copyright (c) 1997 Manuel Bouyer. @@ -415,15 +415,9 @@ read_sblock(struct open_file *f, struct struct ext2fs ext2fs; size_t buf_size; int rc; - u_int secsize; - - secsize = 0; - rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, ); - if (rc != 0 || secsize == 0) - secsize = DEV_BSIZE; rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ, - SBOFF / secsize, SBSIZE, sbbuf, _size); + SBOFF / GETSECSIZE(f), SBSIZE, sbbuf, _size); if (rc) return rc; Index: src/sys/lib/libsa/minixfs3.c diff -u src/sys/lib/libsa/minixfs3.c:1.12 src/sys/lib/libsa/minixfs3.c:1.13 --- src/sys/lib/libsa/minixfs3.c:1.12 Wed Apr 27 14:48:50 2022 +++ src/sys/lib/libsa/minixfs3.c Fri Apr 29 07:42:07 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: minixfs3.c,v 1.12 2022/04/27 14:48:50 rin Exp $ */ +/* $NetBSD: minixfs3.c,v 1.13 2022/04/29 07:42:07 rin Exp $ */ /*- * Copyright (c) 2012 @@ -449,7 +449,6 @@ read_sblock(struct open_file *f, struct static uint8_t sbbuf[MINBSIZE]; size_t buf_size; int rc; - u_int secsize; /* We must read amount multiple of sector size, hence we can't * read SBSIZE and read MINBSIZE. @@ -457,13 +456,8 @@ read_sblock(struct open_file *f, struct if (SBSIZE > MINBSIZE) return EINVAL; - secsize = 0; - rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, ); - if (rc != 0 || secsize == 0) - secsize = DEV_BSIZE; - rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ, - SUPER_BLOCK_OFF / secsize, MINBSIZE, sbbuf, _size); + SUPER_BLOCK_OFF / GETSECSIZE(f), MINBSIZE, sbbuf, _size); if (rc) return rc; Index: src/sys/lib/libsa/stand.h diff -u src/sys/lib/libsa/stand.h:1.85 src/sys/lib/libsa/stand.h:1.86 --- src/sys/lib/libsa/stand.h:1.85 Wed Apr 27 14:48:50 2022 +++ src/sys/lib/libsa/stand.h Fri Apr 29 07:42:07 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: stand.h,v 1.85 2022/04/27 14:48:50 rin Exp $ */ +/* $NetBSD: stand.h,v 1.86 2022/04/29 07:42:07 rin Exp $ */ /* * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved. @@ -64,6 +64,7 @@ #ifndef _LIBSA_STAND_H_ #define _LIBSA_STAND_H_ +#include #include #include #include @@ -320,4 +321,26 @@ void bzero(void *, size_t); int atoi(const char *); +#if !defined(SA_HARDCODED_SECSIZE) +#define GETSECSIZE(f) getsecsize(f) +static inline u_int +getsecsize(struct open_file *f) +{ + int rc; + u_int secsize = 0; + + rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, ); + if (rc != 0 || secsize == 0) + secsize = DEV_BSIZE; + + return secsize; +} +#else +/* + * For some archs, divdi3 and friends are required to support variable + * sector sizes. Shave them off by making secsize compile-time constant. + */ +#define GETSECSIZE(f) DEV_BSIZE +#endif + #endif /* _LIBSA_STAND_H_ */ Index: src/sys/lib/libsa/ufs.c diff -u src/sys/lib/libsa/ufs.c:1.85 src/sys/lib/libsa/ufs.c:1.86 --- src/sys/lib/libsa/ufs.c:1.85 Wed Apr 27 14:48:50 2022 +++ src/sys/lib/libsa/ufs.c Fri Apr 29 07:42:07 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs.c,v 1.85 2022/04/27 14:48:50 rin Exp $ */ +/* $NetBSD: ufs.c,v 1.86 2022/04/29 07:42:07 rin Exp $ */ /*- * Copyright (c) 1993 @@ -594,21 +594,15 @@ ffs_find_superblock(struct open_file *f, struct file *fp = (struct file *)f->f_fsdata; int rc; size_t buf_size; - u_int secsize; #ifdef LIBSA_FFSv2 static daddr_t sblock_try[] = SBLOCKSEARCH; int i; #endif - secsize = 0; - rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, ); - if (rc != 0 || secsize == 0) - secsize = DEV_BSIZE; - #ifdef LIBSA_FFSv2 for (i = 0; sblock_try[i] != -1; i++) { rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ, - sblock_try[i] / secsize, SBLOCKSIZE, fs, _size); + sblock_try[i] / GETSECSIZE(f), SBLOCKSIZE, fs, _size); if (rc) return rc; if (buf_size != SBLOCKSIZE) @@ -623,7 +617,7 @@ ffs_find_superblock(struct
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Fri Apr 29 07:42:07 UTC 2022 Modified Files: src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c Log Message: Re-introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is used instead of secsize obtained by SAIOSECSIZE ioctl. This hack avoids divdi3 and friends from being linked, in order to support variable secsize for some archs. Should be useful for ancient archs, for which secsize is fixed. Thanks christos@ for comment. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/lib/libsa/ext2fs.c cvs rdiff -u -r1.12 -r1.13 src/sys/lib/libsa/minixfs3.c cvs rdiff -u -r1.85 -r1.86 src/sys/lib/libsa/stand.h src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sys/lib/libsa
On 2022/04/28 3:29, Christos Zoulas wrote: In article <20220427144850.61383f...@cvs.netbsd.org>, Rin Okuyama wrote: -=-=-=-=-=- Module Name:src Committed By: rin Date: Wed Apr 27 14:48:50 UTC 2022 Modified Files: src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c Log Message: Revert previous at the moment. This is wrong reasoning; 68020 and above (incl. 040 and 060) support 32-bit displacements for PC relative addressing (via "fully extension addressing mode" with null index register). I've still not figured out what goes wrong with amiga/boot(8) when compiled without -l option for gas(1)... But that was a nice change :-) Thanks! Actually, it should be useful for ancient archs. Now, amiga/boot(8) is fixed. I will enable this again. rin
Re: CVS commit: src/sys/lib/libsa
In article <20220427144850.61383f...@cvs.netbsd.org>, Rin Okuyama wrote: >-=-=-=-=-=- > >Module Name: src >Committed By: rin >Date: Wed Apr 27 14:48:50 UTC 2022 > >Modified Files: > src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c > >Log Message: >Revert previous at the moment. > >This is wrong reasoning; 68020 and above (incl. 040 and 060) support >32-bit displacements for PC relative addressing (via "fully extension >addressing mode" with null index register). > >I've still not figured out what goes wrong with amiga/boot(8) when >compiled without -l option for gas(1)... But that was a nice change :-) christos
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Wed Apr 27 14:48:50 UTC 2022 Modified Files: src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c Log Message: Revert previous at the moment. This is wrong reasoning; 68020 and above (incl. 040 and 060) support 32-bit displacements for PC relative addressing (via "fully extension addressing mode" with null index register). I've still not figured out what goes wrong with amiga/boot(8) when compiled without -l option for gas(1)... On 2022/04/27 20:48, Rin Okuyama wrote: > Module Name: src > Committed By: rin > Date: Wed Apr 27 11:48:26 UTC 2022 > > Modified Files: > src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c > > Log Message: > Introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is > used instead of secsize obtained by SAIOSECSIZE ioctl. > > This hack avoids divdi3 and friends from being linked, in order to > support variable secsize. > > This is useful for amiga/boot(8); it is loaded by firmware into > unpredictable address, and therefore all symbols should be > addressable by PC relative mode with only 16-bit displacements. > > See sys/arch/amiga/stand/bootblock/{boot/bbstart.s,elf2bb,txlt} for > more details. > > > To generate a diff of this commit: > cvs rdiff -u -r1.31 -r1.32 src/sys/lib/libsa/ext2fs.c > cvs rdiff -u -r1.10 -r1.11 src/sys/lib/libsa/minixfs3.c > cvs rdiff -u -r1.83 -r1.84 src/sys/lib/libsa/stand.h src/sys/lib/libsa/ufs.c > > Please note that diffs are not public domain; they are subject to the > copyright notices on the relevant files. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/lib/libsa/ext2fs.c cvs rdiff -u -r1.11 -r1.12 src/sys/lib/libsa/minixfs3.c cvs rdiff -u -r1.84 -r1.85 src/sys/lib/libsa/stand.h src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/ext2fs.c diff -u src/sys/lib/libsa/ext2fs.c:1.32 src/sys/lib/libsa/ext2fs.c:1.33 --- src/sys/lib/libsa/ext2fs.c:1.32 Wed Apr 27 11:48:26 2022 +++ src/sys/lib/libsa/ext2fs.c Wed Apr 27 14:48:50 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.c,v 1.32 2022/04/27 11:48:26 rin Exp $ */ +/* $NetBSD: ext2fs.c,v 1.33 2022/04/27 14:48:50 rin Exp $ */ /* * Copyright (c) 1997 Manuel Bouyer. @@ -415,9 +415,15 @@ read_sblock(struct open_file *f, struct struct ext2fs ext2fs; size_t buf_size; int rc; + u_int secsize; + + secsize = 0; + rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, ); + if (rc != 0 || secsize == 0) + secsize = DEV_BSIZE; rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ, - SBOFF / GETSECSIZE(f), SBSIZE, sbbuf, _size); + SBOFF / secsize, SBSIZE, sbbuf, _size); if (rc) return rc; Index: src/sys/lib/libsa/minixfs3.c diff -u src/sys/lib/libsa/minixfs3.c:1.11 src/sys/lib/libsa/minixfs3.c:1.12 --- src/sys/lib/libsa/minixfs3.c:1.11 Wed Apr 27 11:48:26 2022 +++ src/sys/lib/libsa/minixfs3.c Wed Apr 27 14:48:50 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: minixfs3.c,v 1.11 2022/04/27 11:48:26 rin Exp $ */ +/* $NetBSD: minixfs3.c,v 1.12 2022/04/27 14:48:50 rin Exp $ */ /*- * Copyright (c) 2012 @@ -449,6 +449,7 @@ read_sblock(struct open_file *f, struct static uint8_t sbbuf[MINBSIZE]; size_t buf_size; int rc; + u_int secsize; /* We must read amount multiple of sector size, hence we can't * read SBSIZE and read MINBSIZE. @@ -456,8 +457,13 @@ read_sblock(struct open_file *f, struct if (SBSIZE > MINBSIZE) return EINVAL; + secsize = 0; + rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, ); + if (rc != 0 || secsize == 0) + secsize = DEV_BSIZE; + rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ, - SUPER_BLOCK_OFF / GETSECSIZE(f), MINBSIZE, sbbuf, _size); + SUPER_BLOCK_OFF / secsize, MINBSIZE, sbbuf, _size); if (rc) return rc; Index: src/sys/lib/libsa/stand.h diff -u src/sys/lib/libsa/stand.h:1.84 src/sys/lib/libsa/stand.h:1.85 --- src/sys/lib/libsa/stand.h:1.84 Wed Apr 27 11:48:26 2022 +++ src/sys/lib/libsa/stand.h Wed Apr 27 14:48:50 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: stand.h,v 1.84 2022/04/27 11:48:26 rin Exp $ */ +/* $NetBSD: stand.h,v 1.85 2022/04/27 14:48:50 rin Exp $ */ /* * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved. @@ -64,7 +64,6 @@ #ifndef _LIBSA_STAND_H_ #define _LIBSA_STAND_H_ -#include #include #include #include @@ -321,22 +320,4 @@ void bzero(void *, size_t); int atoi(const char *); -#if !defined(SA_HARDCODED_SECSIZE) -#define GETSECSIZE(f) getsecsize(f) -static inline u_int -getsecsize(struct open_file *f) -{ - int rc; - u_int secsize = 0; - - rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, ); - if (rc != 0 || secsize == 0) - secsize = DEV_BSIZE; - - return secsize; -} -#else -#define GETSECSIZE(f) DEV_BSIZE -#endif - #endif /* _LIBSA_STAND_H_ */ Index: src/sys/lib/libsa/ufs.c diff -u src/sys/lib/libsa/ufs.c:1.84 src/sys/lib/libsa/ufs.c:1.85 --- src/sys/lib/libsa/ufs.c:1.84 Wed Apr 27 11:48:26
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Wed Apr 27 14:48:50 UTC 2022 Modified Files: src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c Log Message: Revert previous at the moment. This is wrong reasoning; 68020 and above (incl. 040 and 060) support 32-bit displacements for PC relative addressing (via "fully extension addressing mode" with null index register). I've still not figured out what goes wrong with amiga/boot(8) when compiled without -l option for gas(1)... On 2022/04/27 20:48, Rin Okuyama wrote: > Module Name: src > Committed By: rin > Date: Wed Apr 27 11:48:26 UTC 2022 > > Modified Files: > src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c > > Log Message: > Introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is > used instead of secsize obtained by SAIOSECSIZE ioctl. > > This hack avoids divdi3 and friends from being linked, in order to > support variable secsize. > > This is useful for amiga/boot(8); it is loaded by firmware into > unpredictable address, and therefore all symbols should be > addressable by PC relative mode with only 16-bit displacements. > > See sys/arch/amiga/stand/bootblock/{boot/bbstart.s,elf2bb,txlt} for > more details. > > > To generate a diff of this commit: > cvs rdiff -u -r1.31 -r1.32 src/sys/lib/libsa/ext2fs.c > cvs rdiff -u -r1.10 -r1.11 src/sys/lib/libsa/minixfs3.c > cvs rdiff -u -r1.83 -r1.84 src/sys/lib/libsa/stand.h src/sys/lib/libsa/ufs.c > > Please note that diffs are not public domain; they are subject to the > copyright notices on the relevant files. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/lib/libsa/ext2fs.c cvs rdiff -u -r1.11 -r1.12 src/sys/lib/libsa/minixfs3.c cvs rdiff -u -r1.84 -r1.85 src/sys/lib/libsa/stand.h src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Wed Apr 27 11:48:26 UTC 2022 Modified Files: src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c Log Message: Introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is used instead of secsize obtained by SAIOSECSIZE ioctl. This hack avoids divdi3 and friends from being linked, in order to support variable secsize. This is useful for amiga/boot(8); it is loaded by firmware into unpredictable address, and therefore all symbols should be addressable by PC relative mode with only 16-bit displacements. See sys/arch/amiga/stand/bootblock/{boot/bbstart.s,elf2bb,txlt} for more details. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/lib/libsa/ext2fs.c cvs rdiff -u -r1.10 -r1.11 src/sys/lib/libsa/minixfs3.c cvs rdiff -u -r1.83 -r1.84 src/sys/lib/libsa/stand.h src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/ext2fs.c diff -u src/sys/lib/libsa/ext2fs.c:1.31 src/sys/lib/libsa/ext2fs.c:1.32 --- src/sys/lib/libsa/ext2fs.c:1.31 Sun Apr 24 06:48:15 2022 +++ src/sys/lib/libsa/ext2fs.c Wed Apr 27 11:48:26 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.c,v 1.31 2022/04/24 06:48:15 mlelstv Exp $ */ +/* $NetBSD: ext2fs.c,v 1.32 2022/04/27 11:48:26 rin Exp $ */ /* * Copyright (c) 1997 Manuel Bouyer. @@ -415,15 +415,9 @@ read_sblock(struct open_file *f, struct struct ext2fs ext2fs; size_t buf_size; int rc; - u_int secsize; - - secsize = 0; - rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, ); - if (rc != 0 || secsize == 0) - secsize = DEV_BSIZE; rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ, - SBOFF / secsize, SBSIZE, sbbuf, _size); + SBOFF / GETSECSIZE(f), SBSIZE, sbbuf, _size); if (rc) return rc; Index: src/sys/lib/libsa/minixfs3.c diff -u src/sys/lib/libsa/minixfs3.c:1.10 src/sys/lib/libsa/minixfs3.c:1.11 --- src/sys/lib/libsa/minixfs3.c:1.10 Sun Apr 24 06:48:15 2022 +++ src/sys/lib/libsa/minixfs3.c Wed Apr 27 11:48:26 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: minixfs3.c,v 1.10 2022/04/24 06:48:15 mlelstv Exp $ */ +/* $NetBSD: minixfs3.c,v 1.11 2022/04/27 11:48:26 rin Exp $ */ /*- * Copyright (c) 2012 @@ -449,7 +449,6 @@ read_sblock(struct open_file *f, struct static uint8_t sbbuf[MINBSIZE]; size_t buf_size; int rc; - u_int secsize; /* We must read amount multiple of sector size, hence we can't * read SBSIZE and read MINBSIZE. @@ -457,13 +456,8 @@ read_sblock(struct open_file *f, struct if (SBSIZE > MINBSIZE) return EINVAL; - secsize = 0; - rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, ); - if (rc != 0 || secsize == 0) - secsize = DEV_BSIZE; - rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ, - SUPER_BLOCK_OFF / secsize, MINBSIZE, sbbuf, _size); + SUPER_BLOCK_OFF / GETSECSIZE(f), MINBSIZE, sbbuf, _size); if (rc) return rc; Index: src/sys/lib/libsa/stand.h diff -u src/sys/lib/libsa/stand.h:1.83 src/sys/lib/libsa/stand.h:1.84 --- src/sys/lib/libsa/stand.h:1.83 Mon May 17 08:50:36 2021 +++ src/sys/lib/libsa/stand.h Wed Apr 27 11:48:26 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: stand.h,v 1.83 2021/05/17 08:50:36 mrg Exp $ */ +/* $NetBSD: stand.h,v 1.84 2022/04/27 11:48:26 rin Exp $ */ /* * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved. @@ -64,6 +64,7 @@ #ifndef _LIBSA_STAND_H_ #define _LIBSA_STAND_H_ +#include #include #include #include @@ -320,4 +321,22 @@ void bzero(void *, size_t); int atoi(const char *); +#if !defined(SA_HARDCODED_SECSIZE) +#define GETSECSIZE(f) getsecsize(f) +static inline u_int +getsecsize(struct open_file *f) +{ + int rc; + u_int secsize = 0; + + rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, ); + if (rc != 0 || secsize == 0) + secsize = DEV_BSIZE; + + return secsize; +} +#else +#define GETSECSIZE(f) DEV_BSIZE +#endif + #endif /* _LIBSA_STAND_H_ */ Index: src/sys/lib/libsa/ufs.c diff -u src/sys/lib/libsa/ufs.c:1.83 src/sys/lib/libsa/ufs.c:1.84 --- src/sys/lib/libsa/ufs.c:1.83 Sun Apr 24 06:52:59 2022 +++ src/sys/lib/libsa/ufs.c Wed Apr 27 11:48:26 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs.c,v 1.83 2022/04/24 06:52:59 mlelstv Exp $ */ +/* $NetBSD: ufs.c,v 1.84 2022/04/27 11:48:26 rin Exp $ */ /*- * Copyright (c) 1993 @@ -594,21 +594,15 @@ ffs_find_superblock(struct open_file *f, struct file *fp = (struct file *)f->f_fsdata; int rc; size_t buf_size; - u_int secsize; #ifdef LIBSA_FFSv2 static daddr_t sblock_try[] = SBLOCKSEARCH; int i; #endif - secsize = 0; - rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, ); - if (rc != 0 || secsize == 0) - secsize = DEV_BSIZE; - #ifdef LIBSA_FFSv2 for (i = 0; sblock_try[i] != -1; i++) { rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ, - sblock_try[i] / secsize, SBLOCKSIZE, fs, _size); + sblock_try[i] / GETSECSIZE(f), SBLOCKSIZE, fs, _size); if (rc) return rc; if (buf_size != SBLOCKSIZE) @@ -623,7 +617,7 @@
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Wed Apr 27 11:48:26 UTC 2022 Modified Files: src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c Log Message: Introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is used instead of secsize obtained by SAIOSECSIZE ioctl. This hack avoids divdi3 and friends from being linked, in order to support variable secsize. This is useful for amiga/boot(8); it is loaded by firmware into unpredictable address, and therefore all symbols should be addressable by PC relative mode with only 16-bit displacements. See sys/arch/amiga/stand/bootblock/{boot/bbstart.s,elf2bb,txlt} for more details. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/lib/libsa/ext2fs.c cvs rdiff -u -r1.10 -r1.11 src/sys/lib/libsa/minixfs3.c cvs rdiff -u -r1.83 -r1.84 src/sys/lib/libsa/stand.h src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mlelstv Date: Sun Apr 24 06:52:59 UTC 2022 Modified Files: src/sys/lib/libsa: ffsv1.c ffsv2.c files.c globals.c ufs.c Log Message: Don't load filessytem module for filesystem that was found but isn't used for booting. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/lib/libsa/ffsv1.c src/sys/lib/libsa/ffsv2.c cvs rdiff -u -r1.1 -r1.2 src/sys/lib/libsa/files.c cvs rdiff -u -r1.11 -r1.12 src/sys/lib/libsa/globals.c cvs rdiff -u -r1.82 -r1.83 src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/ffsv1.c diff -u src/sys/lib/libsa/ffsv1.c:1.8 src/sys/lib/libsa/ffsv1.c:1.9 --- src/sys/lib/libsa/ffsv1.c:1.8 Thu May 27 06:54:44 2021 +++ src/sys/lib/libsa/ffsv1.c Sun Apr 24 06:52:59 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ffsv1.c,v 1.8 2021/05/27 06:54:44 mrg Exp $ */ +/* $NetBSD: ffsv1.c,v 1.9 2022/04/24 06:52:59 mlelstv Exp $ */ #define LIBSA_FFSv1 @@ -19,8 +19,7 @@ #define FS_MAGIC FS_UFS1_MAGIC -#if 0 -#define FSMOD "wapbl/ufs/ffs" -#endif +/* #define FSMOD "wapbl/ufs/ffs" */ +#define FSMOD NULL #include "ufs.c" Index: src/sys/lib/libsa/ffsv2.c diff -u src/sys/lib/libsa/ffsv2.c:1.8 src/sys/lib/libsa/ffsv2.c:1.9 --- src/sys/lib/libsa/ffsv2.c:1.8 Thu May 27 06:54:44 2021 +++ src/sys/lib/libsa/ffsv2.c Sun Apr 24 06:52:59 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ffsv2.c,v 1.8 2021/05/27 06:54:44 mrg Exp $ */ +/* $NetBSD: ffsv2.c,v 1.9 2022/04/24 06:52:59 mlelstv Exp $ */ #define LIBSA_FFSv2 @@ -19,8 +19,7 @@ #define FS_MAGIC FS_UFS2_MAGIC -#if 0 -#define FSMOD "wapbl/ufs/ffs" -#endif +/* #define FSMOD "wapbl/ufs/ffs" */ +#define FSMOD NULL #include "ufs.c" Index: src/sys/lib/libsa/files.c diff -u src/sys/lib/libsa/files.c:1.1 src/sys/lib/libsa/files.c:1.2 --- src/sys/lib/libsa/files.c:1.1 Fri Mar 15 13:23:34 2002 +++ src/sys/lib/libsa/files.c Sun Apr 24 06:52:59 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: files.c,v 1.1 2002/03/15 13:23:34 simonb Exp $ */ +/* $NetBSD: files.c,v 1.2 2022/04/24 06:52:59 mlelstv Exp $ */ /* * files.c: @@ -10,3 +10,4 @@ #include "stand.h" struct open_file files[SOPEN_MAX]; +const char *fsmod = NULL; /* file system module name to load */ Index: src/sys/lib/libsa/globals.c diff -u src/sys/lib/libsa/globals.c:1.11 src/sys/lib/libsa/globals.c:1.12 --- src/sys/lib/libsa/globals.c:1.11 Sat Mar 29 14:30:16 2014 +++ src/sys/lib/libsa/globals.c Sun Apr 24 06:52:59 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: globals.c,v 1.11 2014/03/29 14:30:16 jakllsch Exp $ */ +/* $NetBSD: globals.c,v 1.12 2022/04/24 06:52:59 mlelstv Exp $ */ /* * globals.c: @@ -20,7 +20,6 @@ u_char bcea[ETHER_ADDR_LEN] = BA; /* bro char rootpath[FNAME_SIZE]; /* root mount path */ char bootfile[FNAME_SIZE]; /* bootp says to boot this */ char hostname[FNAME_SIZE]; /* our hostname */ -const char *fsmod = NULL; /* file system module name to load */ struct in_addr myip; /* my ip address */ struct in_addr rootip; /* root ip address */ struct in_addr gateip; /* swap ip address */ Index: src/sys/lib/libsa/ufs.c diff -u src/sys/lib/libsa/ufs.c:1.82 src/sys/lib/libsa/ufs.c:1.83 --- src/sys/lib/libsa/ufs.c:1.82 Sun Apr 24 06:48:15 2022 +++ src/sys/lib/libsa/ufs.c Sun Apr 24 06:52:59 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs.c,v 1.82 2022/04/24 06:48:15 mlelstv Exp $ */ +/* $NetBSD: ufs.c,v 1.83 2022/04/24 06:52:59 mlelstv Exp $ */ /*- * Copyright (c) 1993 @@ -857,9 +857,11 @@ ufs_open(const char *path, struct open_f out: if (rc) ufs_close(f); -#ifdef FSMOD /* Only defined for lfs */ else +#ifdef FSMOD fsmod = FSMOD; +#else + fsmod = NULL; #endif return rc; }
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mlelstv Date: Sun Apr 24 06:52:59 UTC 2022 Modified Files: src/sys/lib/libsa: ffsv1.c ffsv2.c files.c globals.c ufs.c Log Message: Don't load filessytem module for filesystem that was found but isn't used for booting. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/lib/libsa/ffsv1.c src/sys/lib/libsa/ffsv2.c cvs rdiff -u -r1.1 -r1.2 src/sys/lib/libsa/files.c cvs rdiff -u -r1.11 -r1.12 src/sys/lib/libsa/globals.c cvs rdiff -u -r1.82 -r1.83 src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mlelstv Date: Sun Apr 24 06:48:15 UTC 2022 Modified Files: src/sys/lib/libsa: ext2fs.c minixfs3.c saioctl.h ufs.c Log Message: Ask driver about sector size to support reading superblocks from fixed byte offsets. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/lib/libsa/ext2fs.c cvs rdiff -u -r1.9 -r1.10 src/sys/lib/libsa/minixfs3.c cvs rdiff -u -r1.4 -r1.5 src/sys/lib/libsa/saioctl.h cvs rdiff -u -r1.81 -r1.82 src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/ext2fs.c diff -u src/sys/lib/libsa/ext2fs.c:1.30 src/sys/lib/libsa/ext2fs.c:1.31 --- src/sys/lib/libsa/ext2fs.c:1.30 Tue Apr 19 09:25:38 2022 +++ src/sys/lib/libsa/ext2fs.c Sun Apr 24 06:48:15 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.c,v 1.30 2022/04/19 09:25:38 skrll Exp $ */ +/* $NetBSD: ext2fs.c,v 1.31 2022/04/24 06:48:15 mlelstv Exp $ */ /* * Copyright (c) 1997 Manuel Bouyer. @@ -415,9 +415,15 @@ read_sblock(struct open_file *f, struct struct ext2fs ext2fs; size_t buf_size; int rc; + u_int secsize; + + secsize = 0; + rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, ); + if (rc != 0 || secsize == 0) + secsize = DEV_BSIZE; rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ, - SBOFF / DEV_BSIZE, SBSIZE, sbbuf, _size); + SBOFF / secsize, SBSIZE, sbbuf, _size); if (rc) return rc; Index: src/sys/lib/libsa/minixfs3.c diff -u src/sys/lib/libsa/minixfs3.c:1.9 src/sys/lib/libsa/minixfs3.c:1.10 --- src/sys/lib/libsa/minixfs3.c:1.9 Tue Apr 19 09:25:38 2022 +++ src/sys/lib/libsa/minixfs3.c Sun Apr 24 06:48:15 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: minixfs3.c,v 1.9 2022/04/19 09:25:38 skrll Exp $ */ +/* $NetBSD: minixfs3.c,v 1.10 2022/04/24 06:48:15 mlelstv Exp $ */ /*- * Copyright (c) 2012 @@ -449,6 +449,7 @@ read_sblock(struct open_file *f, struct static uint8_t sbbuf[MINBSIZE]; size_t buf_size; int rc; + u_int secsize; /* We must read amount multiple of sector size, hence we can't * read SBSIZE and read MINBSIZE. @@ -456,8 +457,13 @@ read_sblock(struct open_file *f, struct if (SBSIZE > MINBSIZE) return EINVAL; + secsize = 0; + rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, ); + if (rc != 0 || secsize == 0) + secsize = DEV_BSIZE; + rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ, - SUPER_BLOCK_OFF / DEV_BSIZE, MINBSIZE, sbbuf, _size); + SUPER_BLOCK_OFF / secsize, MINBSIZE, sbbuf, _size); if (rc) return rc; Index: src/sys/lib/libsa/saioctl.h diff -u src/sys/lib/libsa/saioctl.h:1.4 src/sys/lib/libsa/saioctl.h:1.5 --- src/sys/lib/libsa/saioctl.h:1.4 Sun Dec 11 12:24:46 2005 +++ src/sys/lib/libsa/saioctl.h Sun Apr 24 06:48:15 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: saioctl.h,v 1.4 2005/12/11 12:24:46 christos Exp $ */ +/* $NetBSD: saioctl.h,v 1.5 2022/04/24 06:48:15 mlelstv Exp $ */ /*- * Copyright (c) 1993 @@ -46,3 +46,5 @@ #define SAIOSSDEV (('d'<<8)|12) /* is device skip sector type? */ #define SAIODEBUG (('d'<<8)|13) /* enable/disable debugging */ #define SAIOGBADINFO (('d'<<8)|14) /* get bad-sector table */ + +#define SAIOSECSIZE (('d'<<8)|15) /* get sector size */ Index: src/sys/lib/libsa/ufs.c diff -u src/sys/lib/libsa/ufs.c:1.81 src/sys/lib/libsa/ufs.c:1.82 --- src/sys/lib/libsa/ufs.c:1.81 Tue Apr 19 09:25:38 2022 +++ src/sys/lib/libsa/ufs.c Sun Apr 24 06:48:15 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs.c,v 1.81 2022/04/19 09:25:38 skrll Exp $ */ +/* $NetBSD: ufs.c,v 1.82 2022/04/24 06:48:15 mlelstv Exp $ */ /*- * Copyright (c) 1993 @@ -594,13 +594,21 @@ ffs_find_superblock(struct open_file *f, struct file *fp = (struct file *)f->f_fsdata; int rc; size_t buf_size; + u_int secsize; #ifdef LIBSA_FFSv2 static daddr_t sblock_try[] = SBLOCKSEARCH; int i; +#endif + + secsize = 0; + rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, ); + if (rc != 0 || secsize == 0) + secsize = DEV_BSIZE; +#ifdef LIBSA_FFSv2 for (i = 0; sblock_try[i] != -1; i++) { rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ, - sblock_try[i] / DEV_BSIZE, SBLOCKSIZE, fs, _size); + sblock_try[i] / secsize, SBLOCKSIZE, fs, _size); if (rc) return rc; if (buf_size != SBLOCKSIZE) @@ -615,7 +623,7 @@ ffs_find_superblock(struct open_file *f, return EINVAL; #else /* LIBSA_FFSv2 */ rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ, - SBLOCKOFFSET / DEV_BSIZE, SBLOCKSIZE, fs, _size); + SBLOCKOFFSET / secsize, SBLOCKSIZE, fs, _size); if (rc) return rc; if (buf_size != SBLOCKSIZE)
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mlelstv Date: Sun Apr 24 06:48:15 UTC 2022 Modified Files: src/sys/lib/libsa: ext2fs.c minixfs3.c saioctl.h ufs.c Log Message: Ask driver about sector size to support reading superblocks from fixed byte offsets. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/lib/libsa/ext2fs.c cvs rdiff -u -r1.9 -r1.10 src/sys/lib/libsa/minixfs3.c cvs rdiff -u -r1.4 -r1.5 src/sys/lib/libsa/saioctl.h cvs rdiff -u -r1.81 -r1.82 src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: skrll Date: Tue Apr 19 09:25:39 UTC 2022 Modified Files: src/sys/lib/libsa: ext2fs.c minixfs3.c ufs.c Log Message: Typo in comment. avoinds -> avoids To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/lib/libsa/ext2fs.c cvs rdiff -u -r1.8 -r1.9 src/sys/lib/libsa/minixfs3.c cvs rdiff -u -r1.80 -r1.81 src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: skrll Date: Tue Apr 19 09:25:39 UTC 2022 Modified Files: src/sys/lib/libsa: ext2fs.c minixfs3.c ufs.c Log Message: Typo in comment. avoinds -> avoids To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/lib/libsa/ext2fs.c cvs rdiff -u -r1.8 -r1.9 src/sys/lib/libsa/minixfs3.c cvs rdiff -u -r1.80 -r1.81 src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/ext2fs.c diff -u src/sys/lib/libsa/ext2fs.c:1.29 src/sys/lib/libsa/ext2fs.c:1.30 --- src/sys/lib/libsa/ext2fs.c:1.29 Fri Jan 24 13:20:33 2020 +++ src/sys/lib/libsa/ext2fs.c Tue Apr 19 09:25:38 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.c,v 1.29 2020/01/24 13:20:33 jakllsch Exp $ */ +/* $NetBSD: ext2fs.c,v 1.30 2022/04/19 09:25:38 skrll Exp $ */ /* * Copyright (c) 1997 Manuel Bouyer. @@ -544,7 +544,7 @@ ext2fs_open(const char *path, struct ope /* * We note that the number of indirect blocks is always * a power of 2. This lets us use shifts and masks instead - * of divide and remainder and avoinds pulling in the + * of divide and remainder and avoids pulling in the * 64bit division routine into the boot code. */ mult = EXT2_NINDIR(fs); Index: src/sys/lib/libsa/minixfs3.c diff -u src/sys/lib/libsa/minixfs3.c:1.8 src/sys/lib/libsa/minixfs3.c:1.9 --- src/sys/lib/libsa/minixfs3.c:1.8 Sun Mar 31 20:08:45 2019 +++ src/sys/lib/libsa/minixfs3.c Tue Apr 19 09:25:38 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: minixfs3.c,v 1.8 2019/03/31 20:08:45 christos Exp $ */ +/* $NetBSD: minixfs3.c,v 1.9 2022/04/19 09:25:38 skrll Exp $ */ /*- * Copyright (c) 2012 @@ -572,7 +572,7 @@ minixfs3_open(const char *path, struct o /* * We note that the number of indirect blocks is always * a power of 2. This lets us use shifts and masks instead - * of divide and remainder and avoinds pulling in the + * of divide and remainder and avoids pulling in the * 64bit division routine into the boot code. */ mult = MFS_NINDIR(fs); Index: src/sys/lib/libsa/ufs.c diff -u src/sys/lib/libsa/ufs.c:1.80 src/sys/lib/libsa/ufs.c:1.81 --- src/sys/lib/libsa/ufs.c:1.80 Thu May 27 06:54:44 2021 +++ src/sys/lib/libsa/ufs.c Tue Apr 19 09:25:38 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs.c,v 1.80 2021/05/27 06:54:44 mrg Exp $ */ +/* $NetBSD: ufs.c,v 1.81 2022/04/19 09:25:38 skrll Exp $ */ /*- * Copyright (c) 1993 @@ -701,7 +701,7 @@ ufs_open(const char *path, struct open_f /* * We note that the number of indirect blocks is always * a power of 2. This lets us use shifts and masks instead - * of divide and remainder and avoinds pulling in the + * of divide and remainder and avoids pulling in the * 64bit division routine into the boot code. */ mult = UFS_NINDIR(fs);
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: jmcneill Date: Sun Oct 17 14:12:21 UTC 2021 Modified Files: src/sys/lib/libsa: bootcfg.c Log Message: Only define DEFAULT_TIMEOUT if it is not already defined. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/lib/libsa/bootcfg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/bootcfg.c diff -u src/sys/lib/libsa/bootcfg.c:1.7 src/sys/lib/libsa/bootcfg.c:1.8 --- src/sys/lib/libsa/bootcfg.c:1.7 Tue Sep 7 11:41:31 2021 +++ src/sys/lib/libsa/bootcfg.c Sun Oct 17 14:12:21 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: bootcfg.c,v 1.7 2021/09/07 11:41:31 nia Exp $ */ +/* $NetBSD: bootcfg.c,v 1.8 2021/10/17 14:12:21 jmcneill Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -38,7 +38,9 @@ #define MENUFORMAT_LETTER 2 #define DEFAULT_FORMAT MENUFORMAT_AUTO +#ifndef DEFAULT_TIMEOUT #define DEFAULT_TIMEOUT 10 +#endif struct bootcfg_def bootcfg_info;
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: jmcneill Date: Sun Oct 17 14:12:21 UTC 2021 Modified Files: src/sys/lib/libsa: bootcfg.c Log Message: Only define DEFAULT_TIMEOUT if it is not already defined. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/lib/libsa/bootcfg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mrg Date: Wed May 26 04:28:15 UTC 2021 Modified Files: src/sys/lib/libsa: disklabel.c Log Message: in getdisklabel() swap the other-endian disklabel, #ifdef LIBSA_DISKLABEL_EI To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/lib/libsa/disklabel.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mrg Date: Wed May 26 04:28:15 UTC 2021 Modified Files: src/sys/lib/libsa: disklabel.c Log Message: in getdisklabel() swap the other-endian disklabel, #ifdef LIBSA_DISKLABEL_EI To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/lib/libsa/disklabel.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/disklabel.c diff -u src/sys/lib/libsa/disklabel.c:1.11 src/sys/lib/libsa/disklabel.c:1.12 --- src/sys/lib/libsa/disklabel.c:1.11 Mon May 17 08:50:36 2021 +++ src/sys/lib/libsa/disklabel.c Wed May 26 04:28:15 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: disklabel.c,v 1.11 2021/05/17 08:50:36 mrg Exp $ */ +/* $NetBSD: disklabel.c,v 1.12 2021/05/26 04:28:15 mrg Exp $ */ /*- * Copyright (c) 1993 @@ -54,6 +54,12 @@ getdisklabel(const char *buf, struct dis elp = (const void *)(buf + DEV_BSIZE - sizeof(*dlp)); for (dlp = (const void *)buf; dlp <= elp; dlp = (const void *)((const char *)dlp + sizeof(long))) { +#if defined(LIBSA_DISKLABEL_EI) + if (dlp->d_magic == bswap32(DISKMAGIC) && + dlp->d_magic2 == bswap32(DISKMAGIC)) { + disklabel_swap(__UNCONST(dlp), __UNCONST(dlp)); + } +#endif if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) { if (msg == NULL) msg = nolabel;
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: jmcneill Date: Fri May 21 21:52:16 UTC 2021 Modified Files: src/sys/lib/libsa: loadfile.c loadfile.h Log Message: Capture the endianness of the ELF file loaded in 'netbsd_elf_data', the same way we do already for the class in 'netbsd_elf_class'. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/lib/libsa/loadfile.c cvs rdiff -u -r1.14 -r1.15 src/sys/lib/libsa/loadfile.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/loadfile.c diff -u src/sys/lib/libsa/loadfile.c:1.32 src/sys/lib/libsa/loadfile.c:1.33 --- src/sys/lib/libsa/loadfile.c:1.32 Fri Apr 5 20:09:29 2019 +++ src/sys/lib/libsa/loadfile.c Fri May 21 21:52:15 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: loadfile.c,v 1.32 2019/04/05 20:09:29 christos Exp $ */ +/* $NetBSD: loadfile.c,v 1.33 2021/05/21 21:52:15 jmcneill Exp $ */ /*- * Copyright (c) 1997, 2008 The NetBSD Foundation, Inc. @@ -84,6 +84,7 @@ uint32_t netbsd_version; u_int netbsd_elf_class; +u_int netbsd_elf_data; /* * Open 'filename', read in program and return the opened file @@ -159,6 +160,7 @@ fdloadfile(int fd, u_long *marks, int fl if (memcmp(hdr.elf32.e_ident, ELFMAG, SELFMAG) == 0 && hdr.elf32.e_ident[EI_CLASS] == ELFCLASS32) { netbsd_elf_class = ELFCLASS32; + netbsd_elf_data = hdr.elf32.e_ident[EI_DATA]; rval = loadfile_elf32(fd, , marks, flags); } else #endif @@ -166,6 +168,7 @@ fdloadfile(int fd, u_long *marks, int fl if (memcmp(hdr.elf64.e_ident, ELFMAG, SELFMAG) == 0 && hdr.elf64.e_ident[EI_CLASS] == ELFCLASS64) { netbsd_elf_class = ELFCLASS64; + netbsd_elf_data = hdr.elf64.e_ident[EI_DATA]; rval = loadfile_elf64(fd, , marks, flags); } else #endif Index: src/sys/lib/libsa/loadfile.h diff -u src/sys/lib/libsa/loadfile.h:1.14 src/sys/lib/libsa/loadfile.h:1.15 --- src/sys/lib/libsa/loadfile.h:1.14 Sat Oct 7 10:26:39 2017 +++ src/sys/lib/libsa/loadfile.h Fri May 21 21:52:15 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: loadfile.h,v 1.14 2017/10/07 10:26:39 maxv Exp $ */ +/* $NetBSD: loadfile.h,v 1.15 2021/05/21 21:52:15 jmcneill Exp $ */ /*- * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. @@ -93,3 +93,4 @@ int loadfile_aout(int, struct exec *, u_ extern uint32_t netbsd_version; extern u_int netbsd_elf_class; +extern u_int netbsd_elf_data;
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: jmcneill Date: Fri May 21 21:52:16 UTC 2021 Modified Files: src/sys/lib/libsa: loadfile.c loadfile.h Log Message: Capture the endianness of the ELF file loaded in 'netbsd_elf_data', the same way we do already for the class in 'netbsd_elf_class'. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/lib/libsa/loadfile.c cvs rdiff -u -r1.14 -r1.15 src/sys/lib/libsa/loadfile.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mrg Date: Wed May 12 08:45:28 UTC 2021 Modified Files: src/sys/lib/libsa: ufs.c Log Message: push the FFSv1 superblock code into ffs_find_superblock() and hide all the ugliness in this function, out of ufs_open(). NFC, objects same size if not identical. To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/ufs.c diff -u src/sys/lib/libsa/ufs.c:1.78 src/sys/lib/libsa/ufs.c:1.79 --- src/sys/lib/libsa/ufs.c:1.78 Sat Dec 19 08:51:03 2020 +++ src/sys/lib/libsa/ufs.c Wed May 12 08:45:28 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs.c,v 1.78 2020/12/19 08:51:03 rin Exp $ */ +/* $NetBSD: ufs.c,v 1.79 2021/05/12 08:45:28 mrg Exp $ */ /*- * Copyright (c) 1993 @@ -201,9 +201,6 @@ static int search_directory(const char * #ifdef LIBSA_FFSv1 static void ffs_oldfscompat(FS *); #endif -#ifdef LIBSA_FFSv2 -static int ffs_find_superblock(struct open_file *, FS *); -#endif #ifdef LIBSA_LFS @@ -513,15 +510,14 @@ search_directory(const char *name, int l return ENOENT; } -#ifdef LIBSA_FFSv2 - -daddr_t sblock_try[] = SBLOCKSEARCH; - -static int +static __inline__ int ffs_find_superblock(struct open_file *f, FS *fs) { - int i, rc; + int rc; size_t buf_size; +#ifdef LIBSA_FFSv2 + static daddr_t sblock_try[] = SBLOCKSEARCH; + int i; for (i = 0; sblock_try[i] != -1; i++) { rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ, @@ -536,9 +532,20 @@ ffs_find_superblock(struct open_file *f, } } return EINVAL; -} - +#else /* LIBSA_FFSv2 */ + rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ, + SBLOCKOFFSET / DEV_BSIZE, SBLOCKSIZE, fs, _size); + if (rc) + return rc; + if (buf_size != SBLOCKSIZE || +#ifdef LIBSA_LFS + fs->lfs_version != REQUIRED_LFS_VERSION || #endif + fs->fs_magic != FS_MAGIC) + return EINVAL; + return 0; +#endif /* !LIBSA_FFSv2 */ +} /* * Open a file. @@ -571,26 +578,10 @@ ufs_open(const char *path, struct open_f fp->f_fs = fs; twiddle(); -#ifdef LIBSA_FFSv2 rc = ffs_find_superblock(f, fs); if (rc) goto out; -#else - { - size_t buf_size; - rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ, - SBLOCKOFFSET / DEV_BSIZE, SBLOCKSIZE, fs, _size); - if (rc) - goto out; - if (buf_size != SBLOCKSIZE || -#ifdef LIBSA_LFS - fs->lfs_version != REQUIRED_LFS_VERSION || -#endif - fs->fs_magic != FS_MAGIC) { - rc = EINVAL; - goto out; - } - } + #if defined(LIBSA_LFS) && REQUIRED_LFS_VERSION == 2 /* * XXX We should check the second superblock and use the eldest @@ -604,8 +595,6 @@ ufs_open(const char *path, struct open_f fs->lfs_dobyteswap = 0; fs->lfs_hasolddirfmt = (fs->fs_maxsymlinklen <= 0); #endif -#endif - #ifdef LIBSA_FFSv1 ffs_oldfscompat(fs); #endif
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mrg Date: Wed May 12 08:45:28 UTC 2021 Modified Files: src/sys/lib/libsa: ufs.c Log Message: push the FFSv1 superblock code into ffs_find_superblock() and hide all the ugliness in this function, out of ufs_open(). NFC, objects same size if not identical. To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Fri Mar 26 10:35:08 UTC 2021 Modified Files: src/sys/lib/libsa: tftp.c Log Message: Twiddle also for data transfer for seek. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/lib/libsa/tftp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/tftp.c diff -u src/sys/lib/libsa/tftp.c:1.36 src/sys/lib/libsa/tftp.c:1.37 --- src/sys/lib/libsa/tftp.c:1.36 Sun Mar 31 20:08:45 2019 +++ src/sys/lib/libsa/tftp.c Fri Mar 26 10:35:08 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tftp.c,v 1.36 2019/03/31 20:08:45 christos Exp $ */ +/* $NetBSD: tftp.c,v 1.37 2021/03/26 10:35:08 rin Exp $ */ /* * Copyright (c) 1996 @@ -288,11 +288,6 @@ tftp_read(struct open_file *f, void *add int needblock; size_t count; -#if !defined(LIBSA_NO_TWIDDLE) - if (!(tc++ % 16)) - twiddle(); -#endif - needblock = tftpfile->off / SEGSIZE + 1; if (tftpfile->currblock > needblock) { /* seek backwards */ @@ -306,6 +301,11 @@ tftp_read(struct open_file *f, void *add while (tftpfile->currblock < needblock) { int res; +#if !defined(LIBSA_NO_TWIDDLE) + if (!(tc++ % 16)) +twiddle(); +#endif + res = tftp_getnextblock(tftpfile); if (res) { /* no answer */ #ifdef DEBUG
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Fri Mar 26 10:35:08 UTC 2021 Modified Files: src/sys/lib/libsa: tftp.c Log Message: Twiddle also for data transfer for seek. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/lib/libsa/tftp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Sat Dec 19 08:51:03 UTC 2020 Modified Files: src/sys/lib/libsa: ufs.c Log Message: Fix previous; define missing lfs_version. To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/ufs.c diff -u src/sys/lib/libsa/ufs.c:1.77 src/sys/lib/libsa/ufs.c:1.78 --- src/sys/lib/libsa/ufs.c:1.77 Sat Dec 19 07:19:30 2020 +++ src/sys/lib/libsa/ufs.c Sat Dec 19 08:51:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs.c,v 1.77 2020/12/19 07:19:30 rin Exp $ */ +/* $NetBSD: ufs.c,v 1.78 2020/12/19 08:51:03 rin Exp $ */ /*- * Copyright (c) 1993 @@ -122,6 +122,7 @@ struct salfs { typedef struct salfs FS; #define fs_magic lfs_dlfs_u.u_32.dlfs_magic #define fs_maxsymlinklen lfs_dlfs_u.u_32.dlfs_maxsymlinklen +#define lfs_version lfs_dlfs_u.u_32.dlfs_version #define FS_MAGIC LFS_MAGIC #define SBLOCKSIZE LFS_SBPAD
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Sat Dec 19 08:51:03 UTC 2020 Modified Files: src/sys/lib/libsa: ufs.c Log Message: Fix previous; define missing lfs_version. To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Sat Dec 19 07:19:30 UTC 2020 Modified Files: src/sys/lib/libsa: ufs.c Log Message: ufs_open(): Check fs->lfs_version ifdef LIBSA_*L*FS, not LIBSA_*F*FS. This was harmless for FFS variants, that define LIBSA_FFSv[12], not LIBSA_FFS. To generate a diff of this commit: cvs rdiff -u -r1.76 -r1.77 src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/ufs.c diff -u src/sys/lib/libsa/ufs.c:1.76 src/sys/lib/libsa/ufs.c:1.77 --- src/sys/lib/libsa/ufs.c:1.76 Tue Apr 2 22:25:10 2019 +++ src/sys/lib/libsa/ufs.c Sat Dec 19 07:19:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs.c,v 1.76 2019/04/02 22:25:10 christos Exp $ */ +/* $NetBSD: ufs.c,v 1.77 2020/12/19 07:19:30 rin Exp $ */ /*- * Copyright (c) 1993 @@ -582,7 +582,7 @@ ufs_open(const char *path, struct open_f if (rc) goto out; if (buf_size != SBLOCKSIZE || -#ifdef LIBSA_FFS +#ifdef LIBSA_LFS fs->lfs_version != REQUIRED_LFS_VERSION || #endif fs->fs_magic != FS_MAGIC) {
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Sat Dec 19 07:19:30 UTC 2020 Modified Files: src/sys/lib/libsa: ufs.c Log Message: ufs_open(): Check fs->lfs_version ifdef LIBSA_*L*FS, not LIBSA_*F*FS. This was harmless for FFS variants, that define LIBSA_FFSv[12], not LIBSA_FFS. To generate a diff of this commit: cvs rdiff -u -r1.76 -r1.77 src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: simonb Date: Tue Sep 29 00:13:13 UTC 2020 Modified Files: src/sys/lib/libsa: twiddle.c Log Message: Add a slow twiddle option. This speeds up a pmax netboot by 15% and is only 1% slower than no twiddle. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/lib/libsa/twiddle.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: simonb Date: Tue Sep 29 00:13:13 UTC 2020 Modified Files: src/sys/lib/libsa: twiddle.c Log Message: Add a slow twiddle option. This speeds up a pmax netboot by 15% and is only 1% slower than no twiddle. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/lib/libsa/twiddle.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/twiddle.c diff -u src/sys/lib/libsa/twiddle.c:1.8 src/sys/lib/libsa/twiddle.c:1.9 --- src/sys/lib/libsa/twiddle.c:1.8 Wed Apr 30 16:18:09 2008 +++ src/sys/lib/libsa/twiddle.c Tue Sep 29 00:13:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: twiddle.c,v 1.8 2008/04/30 16:18:09 ad Exp $ */ +/* $NetBSD: twiddle.c,v 1.9 2020/09/29 00:13:12 simonb Exp $ */ /*- * Copyright (c) 1993 @@ -40,13 +40,24 @@ char twiddle_toggle; +#ifdef LIBSA_SLOW_TWIDDLE +#define TWIDDLE_DELAY 4 +#else +#define TWIDDLE_DELAY 0 +#endif + +#define TWIDDLE_MASK ((1 << TWIDDLE_DELAY) - 1) + void twiddle(void) { - static int pos; + static unsigned int pos; if (!twiddle_toggle) { - putchar(TWIDDLE_CHARS[pos++ & 3]); - putchar('\b'); + if ((pos & TWIDDLE_MASK) == 0) { + putchar(TWIDDLE_CHARS[(pos >> TWIDDLE_DELAY) & 3]); + putchar('\b'); + } + pos++; } }
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: jmcneill Date: Sun Sep 13 13:31:36 UTC 2020 Modified Files: src/sys/lib/libsa: loadfile_elf32.c Log Message: Elf64_Phdr::p_offset is 64 bits, not 32 To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/sys/lib/libsa/loadfile_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/loadfile_elf32.c diff -u src/sys/lib/libsa/loadfile_elf32.c:1.58 src/sys/lib/libsa/loadfile_elf32.c:1.59 --- src/sys/lib/libsa/loadfile_elf32.c:1.58 Sun Sep 13 11:09:01 2020 +++ src/sys/lib/libsa/loadfile_elf32.c Sun Sep 13 13:31:36 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: loadfile_elf32.c,v 1.58 2020/09/13 11:09:01 jmcneill Exp $ */ +/* $NetBSD: loadfile_elf32.c,v 1.59 2020/09/13 13:31:36 jmcneill Exp $ */ /* * Copyright (c) 1997, 2008, 2017 The NetBSD Foundation, Inc. @@ -174,7 +174,7 @@ internalize_phdr(Elf_Byte bo, Elf_Phdr * I32(phdr->p_align); #elif ELFSIZE == 64 I32(phdr->p_type); - I32(phdr->p_offset); + I64(phdr->p_offset); I64(phdr->p_vaddr); I64(phdr->p_paddr); I64(phdr->p_filesz);
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: jmcneill Date: Sun Sep 13 13:31:36 UTC 2020 Modified Files: src/sys/lib/libsa: loadfile_elf32.c Log Message: Elf64_Phdr::p_offset is 64 bits, not 32 To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/sys/lib/libsa/loadfile_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: jmcneill Date: Sun Sep 13 11:09:02 UTC 2020 Modified Files: src/sys/lib/libsa: loadfile_elf32.c Log Message: Elf64_Phdr::p_flags is 32 bits, not 64 To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/sys/lib/libsa/loadfile_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/loadfile_elf32.c diff -u src/sys/lib/libsa/loadfile_elf32.c:1.57 src/sys/lib/libsa/loadfile_elf32.c:1.58 --- src/sys/lib/libsa/loadfile_elf32.c:1.57 Thu May 7 18:02:48 2020 +++ src/sys/lib/libsa/loadfile_elf32.c Sun Sep 13 11:09:01 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: loadfile_elf32.c,v 1.57 2020/05/07 18:02:48 maxv Exp $ */ +/* $NetBSD: loadfile_elf32.c,v 1.58 2020/09/13 11:09:01 jmcneill Exp $ */ /* * Copyright (c) 1997, 2008, 2017 The NetBSD Foundation, Inc. @@ -179,7 +179,7 @@ internalize_phdr(Elf_Byte bo, Elf_Phdr * I64(phdr->p_paddr); I64(phdr->p_filesz); I64(phdr->p_memsz); - I64(phdr->p_flags); + I32(phdr->p_flags); I64(phdr->p_align); #else #error ELFSIZE is not 32 or 64
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: jmcneill Date: Sun Sep 13 11:09:02 UTC 2020 Modified Files: src/sys/lib/libsa: loadfile_elf32.c Log Message: Elf64_Phdr::p_flags is 32 bits, not 64 To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/sys/lib/libsa/loadfile_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mrg Date: Mon Sep 7 01:54:26 UTC 2020 Modified Files: src/sys/lib/libsa: Makefile Makefile.inc Log Message: oops, move GCC_NO_ADDR_OF_PACKED_MEMBER into the right header. To generate a diff of this commit: cvs rdiff -u -r1.92 -r1.93 src/sys/lib/libsa/Makefile cvs rdiff -u -r1.24 -r1.25 src/sys/lib/libsa/Makefile.inc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/Makefile diff -u src/sys/lib/libsa/Makefile:1.92 src/sys/lib/libsa/Makefile:1.93 --- src/sys/lib/libsa/Makefile:1.92 Mon Sep 7 00:32:49 2020 +++ src/sys/lib/libsa/Makefile Mon Sep 7 01:54:26 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.92 2020/09/07 00:32:49 mrg Exp $ +# $NetBSD: Makefile,v 1.93 2020/09/07 01:54:26 mrg Exp $ LIB= sa LIBISPRIVATE?= yes @@ -100,5 +100,3 @@ CPPFLAGS+= -Wno-pointer-sign .if defined(HAVE_GCC) && ${MACHINE_ARCH} == "vax" COPTS.bootp.c+= -O0 .endif - -CWARNFLAGS.gcc+= ${GCC_NO_ADDR_OF_PACKED_MEMBER} Index: src/sys/lib/libsa/Makefile.inc diff -u src/sys/lib/libsa/Makefile.inc:1.24 src/sys/lib/libsa/Makefile.inc:1.25 --- src/sys/lib/libsa/Makefile.inc:1.24 Sun May 27 01:14:51 2018 +++ src/sys/lib/libsa/Makefile.inc Mon Sep 7 01:54:26 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.24 2018/05/27 01:14:51 christos Exp $ +# $NetBSD: Makefile.inc,v 1.25 2020/09/07 01:54:26 mrg Exp $ # # Configuration variables (default values are below): # @@ -22,6 +22,7 @@ SA_AS?= library SADOTDIR?= ../../. CWARNFLAGS.clang+= -Wno-format-extra-args +CWARNFLAGS.gcc+= ${GCC_NO_ADDR_OF_PACKED_MEMBER} SADIR= ${S:S@^.@${SADOTDIR}@:q}/lib/libsa .if (${SA_AS} == "obj")
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mrg Date: Mon Sep 7 01:54:26 UTC 2020 Modified Files: src/sys/lib/libsa: Makefile Makefile.inc Log Message: oops, move GCC_NO_ADDR_OF_PACKED_MEMBER into the right header. To generate a diff of this commit: cvs rdiff -u -r1.92 -r1.93 src/sys/lib/libsa/Makefile cvs rdiff -u -r1.24 -r1.25 src/sys/lib/libsa/Makefile.inc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mrg Date: Mon Sep 7 00:32:49 UTC 2020 Modified Files: src/sys/lib/libsa: Makefile Log Message: apply GCC_NO_ADDR_OF_PACKED_MEMBER To generate a diff of this commit: cvs rdiff -u -r1.91 -r1.92 src/sys/lib/libsa/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mrg Date: Mon Sep 7 00:32:49 UTC 2020 Modified Files: src/sys/lib/libsa: Makefile Log Message: apply GCC_NO_ADDR_OF_PACKED_MEMBER To generate a diff of this commit: cvs rdiff -u -r1.91 -r1.92 src/sys/lib/libsa/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/Makefile diff -u src/sys/lib/libsa/Makefile:1.91 src/sys/lib/libsa/Makefile:1.92 --- src/sys/lib/libsa/Makefile:1.91 Sun Jul 21 16:53:17 2019 +++ src/sys/lib/libsa/Makefile Mon Sep 7 00:32:49 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.91 2019/07/21 16:53:17 rin Exp $ +# $NetBSD: Makefile,v 1.92 2020/09/07 00:32:49 mrg Exp $ LIB= sa LIBISPRIVATE?= yes @@ -100,3 +100,5 @@ CPPFLAGS+= -Wno-pointer-sign .if defined(HAVE_GCC) && ${MACHINE_ARCH} == "vax" COPTS.bootp.c+= -O0 .endif + +CWARNFLAGS.gcc+= ${GCC_NO_ADDR_OF_PACKED_MEMBER}
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: jmcneill Date: Sat Jun 27 17:22:12 UTC 2020 Modified Files: src/sys/lib/libsa: bootcfg.c Log Message: Support loading boot.cfg from non file-system based devices. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/lib/libsa/bootcfg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: jmcneill Date: Sat Jun 27 17:22:12 UTC 2020 Modified Files: src/sys/lib/libsa: bootcfg.c Log Message: Support loading boot.cfg from non file-system based devices. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/lib/libsa/bootcfg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/bootcfg.c diff -u src/sys/lib/libsa/bootcfg.c:1.4 src/sys/lib/libsa/bootcfg.c:1.5 --- src/sys/lib/libsa/bootcfg.c:1.4 Sun Mar 31 20:08:45 2019 +++ src/sys/lib/libsa/bootcfg.c Sat Jun 27 17:22:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: bootcfg.c,v 1.4 2019/03/31 20:08:45 christos Exp $ */ +/* $NetBSD: bootcfg.c,v 1.5 2020/06/27 17:22:12 jmcneill Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -99,7 +99,7 @@ perform_bootcfg(const char *conf, bootcf { char *bc, *c; int cmenu, cbanner; - ssize_t len, off; + ssize_t len, off, resid; int fd, err; struct stat st; char *next, *key, *value, *v2; @@ -119,8 +119,8 @@ perform_bootcfg(const char *conf, bootcf err = fstat(fd, ); if (err == -1) { - close(fd); - return EIO; + /* file descriptor may not be backed by a libsa file-system */ + st.st_size = maxsz; } /* if a maximum size is being requested for the boot.cfg enforce it. */ @@ -146,12 +146,14 @@ perform_bootcfg(const char *conf, bootcf * the storage anyway. */ off = 0; + resid = st.st_size; do { - len = read(fd, bc + off, 1024); + len = read(fd, bc + off, uimin(1024, resid)); if (len <= 0) break; off += len; - } while (len > 0); + resid -= len; + } while (len > 0 && resid > 0); bc[off] = '\0'; close(fd);
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: thorpej Date: Sat Jun 6 15:45:47 UTC 2020 Modified Files: src/sys/lib/libsa: subr_prf.c Log Message: Make libsa's vsnprintf() work as expected when passed a NULL destinatino buffer. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/lib/libsa/subr_prf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/subr_prf.c diff -u src/sys/lib/libsa/subr_prf.c:1.28 src/sys/lib/libsa/subr_prf.c:1.29 --- src/sys/lib/libsa/subr_prf.c:1.28 Sun Feb 3 11:59:43 2019 +++ src/sys/lib/libsa/subr_prf.c Sat Jun 6 15:45:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_prf.c,v 1.28 2019/02/03 11:59:43 mrg Exp $ */ +/* $NetBSD: subr_prf.c,v 1.29 2020/06/06 15:45:47 thorpej Exp $ */ /*- * Copyright (c) 1993 @@ -127,6 +127,12 @@ do {\ #endif /* LIBSA_PRINTF_LONGLONG_SUPPORT */ static void +null_sputchar(int c) +{ + sbuf++; +} + +static void sputchar(int c) { @@ -147,8 +153,9 @@ vsnprintf(char *buf, size_t size, const sbuf = buf; ebuf = buf + size - 1; - kdoprnt(sputchar, fmt, ap); - *sbuf = '\0'; + kdoprnt(buf == NULL ? null_sputchar : sputchar, fmt, ap); + if (buf != NULL) + *sbuf = '\0'; return sbuf - buf; }
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: thorpej Date: Sat Jun 6 15:45:47 UTC 2020 Modified Files: src/sys/lib/libsa: subr_prf.c Log Message: Make libsa's vsnprintf() work as expected when passed a NULL destinatino buffer. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/lib/libsa/subr_prf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: maxv Date: Thu May 7 18:02:48 UTC 2020 Modified Files: src/sys/lib/libsa: loadfile_elf32.c Log Message: Update the comments. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/sys/lib/libsa/loadfile_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/loadfile_elf32.c diff -u src/sys/lib/libsa/loadfile_elf32.c:1.56 src/sys/lib/libsa/loadfile_elf32.c:1.57 --- src/sys/lib/libsa/loadfile_elf32.c:1.56 Thu Oct 17 14:00:28 2019 +++ src/sys/lib/libsa/loadfile_elf32.c Thu May 7 18:02:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: loadfile_elf32.c,v 1.56 2019/10/17 14:00:28 maxv Exp $ */ +/* $NetBSD: loadfile_elf32.c,v 1.57 2020/05/07 18:02:48 maxv Exp $ */ /* * Copyright (c) 1997, 2008, 2017 The NetBSD Foundation, Inc. @@ -332,9 +332,9 @@ ELFNAMEEND(readfile_global)(int fd, u_lo /* * Load a dynamic ELF binary into memory. Layout of the memory: - * ++-+-+--+ - * | ELF HEADER | SECTION HEADERS | KERNEL SECTIONS | SYM+REL SECTIONS | - * ++-+-+--+ + * ++--+++ + * | ELF HEADER | SECT HEADERS | KERN SECTS | REL/RELA/SYM/STR SECTS | + * ++--+++ * The ELF HEADER start address is marks[MARK_END]. We then map the rest * by increasing maxp. An alignment is enforced between the code sections. * @@ -438,7 +438,7 @@ ELFNAMEEND(loadfile_dynamic)(int fd, Elf maxp = roundup(maxp, KERNALIGN_LARGE); /* - * Load the SYM+REL SECTIONS. + * Load the REL/RELA/SYM/STR SECTIONS. */ maxp = roundup(maxp, ELFROUND); for (i = 0; i < elf->e_shnum; i++) {
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: maxv Date: Thu May 7 18:02:48 UTC 2020 Modified Files: src/sys/lib/libsa: loadfile_elf32.c Log Message: Update the comments. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/sys/lib/libsa/loadfile_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: skrll Date: Sun Jan 26 10:13:10 UTC 2020 Modified Files: src/sys/lib/libsa: nfs.c Log Message: Make a debug printf compile for all platforms To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sys/lib/libsa/nfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/nfs.c diff -u src/sys/lib/libsa/nfs.c:1.49 src/sys/lib/libsa/nfs.c:1.50 --- src/sys/lib/libsa/nfs.c:1.49 Sun Mar 31 20:08:45 2019 +++ src/sys/lib/libsa/nfs.c Sun Jan 26 10:13:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs.c,v 1.49 2019/03/31 20:08:45 christos Exp $ */ +/* $NetBSD: nfs.c,v 1.50 2020/01/26 10:13:10 skrll Exp $ */ /*- * Copyright (c) 1993 John Brezak @@ -566,7 +566,7 @@ nfs_read(struct open_file *f, void *buf, #ifdef NFS_DEBUG if (debug) - printf("%s: size=%zu off=%td\n", __func__, size, fp->off); + printf("%s: size=%zu off=%" PRIx64 "\n", __func__, size, fp->off); #endif while ((int)size > 0) { #if !defined(LIBSA_NO_TWIDDLE)
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: skrll Date: Sun Jan 26 10:13:10 UTC 2020 Modified Files: src/sys/lib/libsa: nfs.c Log Message: Make a debug printf compile for all platforms To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sys/lib/libsa/nfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: jakllsch Date: Fri Jan 24 13:20:33 UTC 2020 Modified Files: src/sys/lib/libsa: ext2fs.c Log Message: Use dp->e2d_namlen rather than strlen(dp->e2d_name) in ext2fs_ls(). Prevents garbage beyond the end of the name from appearing on screen. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/lib/libsa/ext2fs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: jakllsch Date: Fri Jan 24 13:20:33 UTC 2020 Modified Files: src/sys/lib/libsa: ext2fs.c Log Message: Use dp->e2d_namlen rather than strlen(dp->e2d_name) in ext2fs_ls(). Prevents garbage beyond the end of the name from appearing on screen. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/lib/libsa/ext2fs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/ext2fs.c diff -u src/sys/lib/libsa/ext2fs.c:1.28 src/sys/lib/libsa/ext2fs.c:1.29 --- src/sys/lib/libsa/ext2fs.c:1.28 Mon Jun 24 13:58:24 2019 +++ src/sys/lib/libsa/ext2fs.c Fri Jan 24 13:20:33 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.c,v 1.28 2019/06/24 13:58:24 pgoyette Exp $ */ +/* $NetBSD: ext2fs.c,v 1.29 2020/01/24 13:20:33 jakllsch Exp $ */ /* * Copyright (c) 1997 Manuel Bouyer. @@ -866,7 +866,7 @@ ext2fs_ls(struct open_file *f, const cha goto out; } lsadd(, pattern, dp->e2d_name, - strlen(dp->e2d_name), fs2h32(dp->e2d_ino), t); + dp->e2d_namlen, fs2h32(dp->e2d_ino), t); } fp->f_seekp += buf_size; }
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: martin Date: Wed Jan 22 06:11:28 UTC 2020 Modified Files: src/sys/lib/libsa: dosfs.c Log Message: To support big partitions we need to make sure all byte offsets are calculated in 64 bit arithmetic. Pointed out by Rob Newberry. Unfortunately this causes a code size increase breaking some boot blocks, so conditionalize it and use 32 bit arithmetic if SA_DOSFS_NO_BIG_PART_SUPPORT is defined. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/lib/libsa/dosfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: martin Date: Wed Jan 22 06:11:28 UTC 2020 Modified Files: src/sys/lib/libsa: dosfs.c Log Message: To support big partitions we need to make sure all byte offsets are calculated in 64 bit arithmetic. Pointed out by Rob Newberry. Unfortunately this causes a code size increase breaking some boot blocks, so conditionalize it and use 32 bit arithmetic if SA_DOSFS_NO_BIG_PART_SUPPORT is defined. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/lib/libsa/dosfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/dosfs.c diff -u src/sys/lib/libsa/dosfs.c:1.22 src/sys/lib/libsa/dosfs.c:1.23 --- src/sys/lib/libsa/dosfs.c:1.22 Sun Mar 31 20:08:45 2019 +++ src/sys/lib/libsa/dosfs.c Wed Jan 22 06:11:28 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dosfs.c,v 1.22 2019/03/31 20:08:45 christos Exp $ */ +/* $NetBSD: dosfs.c,v 1.23 2020/01/22 06:11:28 martin Exp $ */ /* * Copyright (c) 1996, 1998 Robert Nordier @@ -108,12 +108,18 @@ static const struct direntry dot[2] = { {0, 0}, {0x21, 0}, {0, 0}, {0, 0, 0, 0}} }; +#ifdef SA_DOSFS_NO_BIG_PART_SUPPORT +#define BYTE_OFF_T u_int +#else +#define BYTE_OFF_T uint64_t +#endif + /* The usual conversion macros to avoid multiplication and division */ #define bytsec(n) ((n) >> SSHIFT) -#define secbyt(s) ((s) << SSHIFT) +#define secbyt(s) ((BYTE_OFF_T)(s) << SSHIFT) #define entsec(e) ((e) >> DSHIFT) #define bytblk(fs, n) ((n) >> (fs)->bshift) -#define blkbyt(fs, b) ((b) << (fs)->bshift) +#define blkbyt(fs, b) ((BYTE_OFF_T)(b) << (fs)->bshift) #define secblk(fs, s) ((s) >> ((fs)->bshift - SSHIFT)) #define blksec(fs, b) ((b) << ((fs)->bshift - SSHIFT)) @@ -146,7 +152,7 @@ static off_t fsize(DOS_FS *, struct dire static int fatcnt(DOS_FS *, u_int); static int fatget(DOS_FS *, u_int *); static int fatend(u_int, u_int); -static int ioread(DOS_FS *, u_int, void *, u_int); +static int ioread(DOS_FS *, BYTE_OFF_T, void *, u_int); static int iobuf(DOS_FS *, u_int); static int ioget(struct open_file *, u_int, void *, u_int); @@ -733,7 +739,7 @@ fatend(u_int sz, u_int c) * Offset-based I/O primitive */ static int -ioread(DOS_FS *fs, u_int offset, void *buf, u_int nbyte) +ioread(DOS_FS *fs, BYTE_OFF_T offset, void *buf, u_int nbyte) { char *s; u_int off, n;
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mrg Date: Thu Nov 21 21:45:35 UTC 2019 Modified Files: src/sys/lib/libsa: ustarfs.c Log Message: apply the strncmp hack only to !clang. requested by tnn. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/lib/libsa/ustarfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/ustarfs.c diff -u src/sys/lib/libsa/ustarfs.c:1.36 src/sys/lib/libsa/ustarfs.c:1.37 --- src/sys/lib/libsa/ustarfs.c:1.36 Thu Nov 21 07:34:39 2019 +++ src/sys/lib/libsa/ustarfs.c Thu Nov 21 21:45:34 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ustarfs.c,v 1.36 2019/11/21 07:34:39 mrg Exp $ */ +/* $NetBSD: ustarfs.c,v 1.37 2019/11/21 21:45:34 mrg Exp $ */ /* [Notice revision 2.2] * Copyright (c) 1997, 1998 Avalon Computer Systems, Inc. @@ -388,7 +388,7 @@ init_volzero_sig(struct open_file *f) * Until the real cause is located, work around it by using -O1 * for this function. */ -#ifdef __i386__ +#if defined(__i386__) && !defined(__clang__) __attribute__((__optimize__("O1"))) #endif __compactcall int
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mrg Date: Thu Nov 21 21:45:35 UTC 2019 Modified Files: src/sys/lib/libsa: ustarfs.c Log Message: apply the strncmp hack only to !clang. requested by tnn. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/lib/libsa/ustarfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mrg Date: Thu Nov 21 07:34:39 UTC 2019 Modified Files: src/sys/lib/libsa: ustarfs.c Log Message: from the new comment: * XXX Hack alert. GCC 8.3 mis-compiles this function and calls * strncmp() with the wrong second pointer, as seen in PR#54703. * * Until the real cause is located, work around it by using -O1 * for this function. this hack is restricted to i386. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/lib/libsa/ustarfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/ustarfs.c diff -u src/sys/lib/libsa/ustarfs.c:1.35 src/sys/lib/libsa/ustarfs.c:1.36 --- src/sys/lib/libsa/ustarfs.c:1.35 Thu Mar 20 03:13:18 2014 +++ src/sys/lib/libsa/ustarfs.c Thu Nov 21 07:34:39 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ustarfs.c,v 1.35 2014/03/20 03:13:18 christos Exp $ */ +/* $NetBSD: ustarfs.c,v 1.36 2019/11/21 07:34:39 mrg Exp $ */ /* [Notice revision 2.2] * Copyright (c) 1997, 1998 Avalon Computer Systems, Inc. @@ -381,6 +381,16 @@ init_volzero_sig(struct open_file *f) return 0; } +/* + * XXX Hack alert. GCC 8.3 mis-compiles this function and calls + * strncmp() with the wrong second pointer, as seen in PR#54703. + * + * Until the real cause is located, work around it by using -O1 + * for this function. + */ +#ifdef __i386__ +__attribute__((__optimize__("O1"))) +#endif __compactcall int ustarfs_open(const char *path, struct open_file *f) {
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mrg Date: Thu Nov 21 07:34:39 UTC 2019 Modified Files: src/sys/lib/libsa: ustarfs.c Log Message: from the new comment: * XXX Hack alert. GCC 8.3 mis-compiles this function and calls * strncmp() with the wrong second pointer, as seen in PR#54703. * * Until the real cause is located, work around it by using -O1 * for this function. this hack is restricted to i386. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/lib/libsa/ustarfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: maxv Date: Thu Oct 17 14:00:28 UTC 2019 Modified Files: src/sys/lib/libsa: loadfile_elf32.c Log Message: Make sure we're dealing with a static binary. Otherwise we could crash if the user mistakenly tries to boot a KASLR kernel with 'boot' instead of 'pkboot'. Now we fail cleanly. Reported by cryo@. To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sys/lib/libsa/loadfile_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/loadfile_elf32.c diff -u src/sys/lib/libsa/loadfile_elf32.c:1.55 src/sys/lib/libsa/loadfile_elf32.c:1.56 --- src/sys/lib/libsa/loadfile_elf32.c:1.55 Sun Jul 21 16:53:17 2019 +++ src/sys/lib/libsa/loadfile_elf32.c Thu Oct 17 14:00:28 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: loadfile_elf32.c,v 1.55 2019/07/21 16:53:17 rin Exp $ */ +/* $NetBSD: loadfile_elf32.c,v 1.56 2019/10/17 14:00:28 maxv Exp $ */ /* * Copyright (c) 1997, 2008, 2017 The NetBSD Foundation, Inc. @@ -699,6 +699,11 @@ ELFNAMEEND(loadfile_static)(int fd, Elf_ internalize_ehdr(elf->e_ident[EI_DATA], elf); + if (elf->e_type != ET_EXEC) { + errno = EINVAL; + return 1; + } + sz = elf->e_phnum * sizeof(Elf_Phdr); phdr = ALLOC(sz); ret = ELFNAMEEND(readfile_local)(fd, elf->e_phoff, phdr, sz);
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: maxv Date: Thu Oct 17 14:00:28 UTC 2019 Modified Files: src/sys/lib/libsa: loadfile_elf32.c Log Message: Make sure we're dealing with a static binary. Otherwise we could crash if the user mistakenly tries to boot a KASLR kernel with 'boot' instead of 'pkboot'. Now we fail cleanly. Reported by cryo@. To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sys/lib/libsa/loadfile_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Sun Jul 21 16:53:17 UTC 2019 Modified Files: src/sys/lib/libsa: Makefile loadfile_elf32.c Log Message: Add SA_ENABLE_BIENDIAN option, which enable us to load kernel image of opposite byte order (for arm EFI bootloader). XXX Currently, it is restricted to load_elf*.c. It would be nice if we can recognize disklabel and filesystem of opposite byte order. To generate a diff of this commit: cvs rdiff -u -r1.90 -r1.91 src/sys/lib/libsa/Makefile cvs rdiff -u -r1.54 -r1.55 src/sys/lib/libsa/loadfile_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/Makefile diff -u src/sys/lib/libsa/Makefile:1.90 src/sys/lib/libsa/Makefile:1.91 --- src/sys/lib/libsa/Makefile:1.90 Tue Apr 2 22:25:10 2019 +++ src/sys/lib/libsa/Makefile Sun Jul 21 16:53:17 2019 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.90 2019/04/02 22:25:10 christos Exp $ +# $NetBSD: Makefile,v 1.91 2019/07/21 16:53:17 rin Exp $ LIB= sa LIBISPRIVATE?= yes @@ -7,6 +7,8 @@ SA_USE_CREAD?= no # Read compressed ker SA_INCLUDE_NET?= yes # Netboot via TFTP, NFS SA_USE_LOADFILE?= no # Generic executable loading support SA_ENABLE_LS_OP?= no # Filesystems ls operation +SA_ENABLE_BIENDIAN?= no # Biendian support +# (currently only for loadfile_elf*) #DEBUGCPPFLAGS= -DBOOTP_DEBUG -DNETIF_DEBUG -DETHER_DEBUG -DNFS_DEBUG -DRPC_DEBUG -DRARP_DEBUG -DARP_DEBUG -DNET_DEBUG -DDEBUG -DPARANOID CPPFLAGS= -I${SADIR} ${SACPPFLAGS} ${SAMISCCPPFLAGS} \ @@ -73,6 +75,11 @@ SRCS+= bootp.c rarp.c bootparam.c SRCS+= nfs.c tftp.c .endif +.if (${SA_ENABLE_BIENDIAN} == "yes") +CPPFLAGS+= -DLIBSA_BIENDIAN_SUPPORT +SRCS+= byteorder.c +.endif + SRCS+= ffsv1.c ffsv2.c SRCS+= lfsv1.c lfsv2.c SRCS+= cd9660.c Index: src/sys/lib/libsa/loadfile_elf32.c diff -u src/sys/lib/libsa/loadfile_elf32.c:1.54 src/sys/lib/libsa/loadfile_elf32.c:1.55 --- src/sys/lib/libsa/loadfile_elf32.c:1.54 Thu Jun 20 17:33:30 2019 +++ src/sys/lib/libsa/loadfile_elf32.c Sun Jul 21 16:53:17 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: loadfile_elf32.c,v 1.54 2019/06/20 17:33:30 maxv Exp $ */ +/* $NetBSD: loadfile_elf32.c,v 1.55 2019/07/21 16:53:17 rin Exp $ */ /* * Copyright (c) 1997, 2008, 2017 The NetBSD Foundation, Inc. @@ -59,12 +59,18 @@ #define ELFROUND (ELFSIZE / 8) #ifndef _STANDALONE -#include "byteorder.h" - /* * Byte swapping may be necessary in the non-_STANDLONE case because * we may be built with a host compiler. */ +#ifndef LIBSA_BIENDIAN_SUPPORT +#define LIBSA_BIENDIAN_SUPPORT +#endif +#endif + +#ifdef LIBSA_BIENDIAN_SUPPORT +#include "byteorder.h" + #define E16(f)\ f = (bo == ELFDATA2LSB) ? sa_htole16(f) : sa_htobe16(f) #define E32(f)\ @@ -241,10 +247,10 @@ externalize_shdr(Elf_Byte bo, Elf_Shdr * #error ELFSIZE is not 32 or 64 #endif } -#else /* _STANDALONE */ +#else /* LIBSA_BIENDIAN_SUPPORT */ /* - * Byte swapping is never necessary in the _STANDALONE case because - * we are being built with the target compiler. + * Byte swapping is never necessary in the !LIBSA_BIENDIAN_SUPPORT case + * because we are being built with the target compiler. */ #define internalize_ehdr(bo, ehdr) /* nothing */ #define externalize_ehdr(bo, ehdr) /* nothing */ @@ -253,7 +259,7 @@ externalize_shdr(Elf_Byte bo, Elf_Shdr * #define internalize_shdr(bo, shdr) /* nothing */ #define externalize_shdr(bo, shdr) /* nothing */ -#endif /* _STANDALONE */ +#endif /* LIBSA_BIENDIAN_SUPPORT */ #define IS_TEXT(p) (p.p_flags & PF_X) #define IS_DATA(p) ((p.p_flags & PF_X) == 0) @@ -379,7 +385,7 @@ ELFNAMEEND(loadfile_dynamic)(int fd, Elf internalize_ehdr(elf->e_ident[EI_DATA], elf); maxp += sizeof(Elf_Ehdr); -#ifndef _STANDALONE +#ifdef LIBSA_BIENDIAN_SUPPORT for (i = 0; i < elf->e_shnum; i++) internalize_shdr(elf->e_ident[EI_DATA], [i]); #endif @@ -472,7 +478,7 @@ ELFNAMEEND(loadfile_dynamic)(int fd, Elf /* * Finally, load the SECTION HEADERS. */ -#ifndef _STANDALONE +#ifdef LIBSA_BIENDIAN_SUPPORT for (i = 0; i < elf->e_shnum; i++) externalize_shdr(elf->e_ident[EI_DATA], [i]); #endif @@ -526,7 +532,7 @@ ELFNAMEEND(loadsym)(int fd, Elf_Ehdr *el shpp = maxp; maxp += roundup(sz, ELFROUND); -#ifndef _STANDALONE +#ifdef LIBSA_BIENDIAN_SUPPORT for (i = 0; i < elf->e_shnum; i++) internalize_shdr(elf->e_ident[EI_DATA], [i]); #endif @@ -636,7 +642,7 @@ havesym: } } if (flags & LOAD_SYM) { -#ifndef _STANDALONE +#ifdef LIBSA_BIENDIAN_SUPPORT for (i = 0; i < elf->e_shnum; i++) externalize_shdr(elf->e_ident[EI_DATA], [i]); #endif
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: rin Date: Sun Jul 21 16:53:17 UTC 2019 Modified Files: src/sys/lib/libsa: Makefile loadfile_elf32.c Log Message: Add SA_ENABLE_BIENDIAN option, which enable us to load kernel image of opposite byte order (for arm EFI bootloader). XXX Currently, it is restricted to load_elf*.c. It would be nice if we can recognize disklabel and filesystem of opposite byte order. To generate a diff of this commit: cvs rdiff -u -r1.90 -r1.91 src/sys/lib/libsa/Makefile cvs rdiff -u -r1.54 -r1.55 src/sys/lib/libsa/loadfile_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: christos Date: Fri Apr 5 20:09:29 UTC 2019 Modified Files: src/sys/lib/libsa: bootp.c ext2fs.c loadfile.c rarp.c rpc.c Log Message: Go back ot using 0x%x instead of %#x because we don't always support the format. See subr_prf.c To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/lib/libsa/bootp.c cvs rdiff -u -r1.26 -r1.27 src/sys/lib/libsa/ext2fs.c cvs rdiff -u -r1.31 -r1.32 src/sys/lib/libsa/loadfile.c cvs rdiff -u -r1.33 -r1.34 src/sys/lib/libsa/rarp.c cvs rdiff -u -r1.30 -r1.31 src/sys/lib/libsa/rpc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: christos Date: Fri Apr 5 20:09:29 UTC 2019 Modified Files: src/sys/lib/libsa: bootp.c ext2fs.c loadfile.c rarp.c rpc.c Log Message: Go back ot using 0x%x instead of %#x because we don't always support the format. See subr_prf.c To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/lib/libsa/bootp.c cvs rdiff -u -r1.26 -r1.27 src/sys/lib/libsa/ext2fs.c cvs rdiff -u -r1.31 -r1.32 src/sys/lib/libsa/loadfile.c cvs rdiff -u -r1.33 -r1.34 src/sys/lib/libsa/rarp.c cvs rdiff -u -r1.30 -r1.31 src/sys/lib/libsa/rpc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/bootp.c diff -u src/sys/lib/libsa/bootp.c:1.42 src/sys/lib/libsa/bootp.c:1.43 --- src/sys/lib/libsa/bootp.c:1.42 Sun Mar 31 16:08:45 2019 +++ src/sys/lib/libsa/bootp.c Fri Apr 5 16:09:29 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: bootp.c,v 1.42 2019/03/31 20:08:45 christos Exp $ */ +/* $NetBSD: bootp.c,v 1.43 2019/04/05 20:09:29 christos Exp $ */ /* * Copyright (c) 1992 Regents of the University of California. @@ -323,7 +323,7 @@ bootprecv(struct iodesc *d, void *pkt, s if (bp->bp_xid != htonl(d->xid)) { #ifdef BOOTP_DEBUG if (debug) { - printf("%s: expected xid %#lx, got %#x\n", __func__, + printf("%s: expected xid 0x%lx, got 0x%x\n", __func__, d->xid, ntohl(bp->bp_xid)); } #endif Index: src/sys/lib/libsa/ext2fs.c diff -u src/sys/lib/libsa/ext2fs.c:1.26 src/sys/lib/libsa/ext2fs.c:1.27 --- src/sys/lib/libsa/ext2fs.c:1.26 Sun Mar 31 16:08:45 2019 +++ src/sys/lib/libsa/ext2fs.c Fri Apr 5 16:09:29 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs.c,v 1.26 2019/03/31 20:08:45 christos Exp $ */ +/* $NetBSD: ext2fs.c,v 1.27 2019/04/05 20:09:29 christos Exp $ */ /* * Copyright (c) 1997 Manuel Bouyer. @@ -992,7 +992,7 @@ dump_sblock(struct m_ext2fs *fs) printf("fs->e2fs.e2fs_log_bsize = %u\n", fs->e2fs.e2fs_log_bsize); printf("fs->e2fs.e2fs_bpg = %u\n", fs->e2fs.e2fs_bpg); printf("fs->e2fs.e2fs_ipg = %u\n", fs->e2fs.e2fs_ipg); - printf("fs->e2fs.e2fs_magic = %#x\n", fs->e2fs.e2fs_magic); + printf("fs->e2fs.e2fs_magic = 0x%x\n", fs->e2fs.e2fs_magic); printf("fs->e2fs.e2fs_rev = %u\n", fs->e2fs.e2fs_rev); if (fs->e2fs.e2fs_rev == E2FS_REV1) { Index: src/sys/lib/libsa/loadfile.c diff -u src/sys/lib/libsa/loadfile.c:1.31 src/sys/lib/libsa/loadfile.c:1.32 --- src/sys/lib/libsa/loadfile.c:1.31 Sun Mar 31 16:08:45 2019 +++ src/sys/lib/libsa/loadfile.c Fri Apr 5 16:09:29 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: loadfile.c,v 1.31 2019/03/31 20:08:45 christos Exp $ */ +/* $NetBSD: loadfile.c,v 1.32 2019/04/05 20:09:29 christos Exp $ */ /*- * Copyright (c) 1997, 2008 The NetBSD Foundation, Inc. @@ -185,7 +185,7 @@ fdloadfile(int fd, u_long *marks, int fl if (rval == 0) { if ((flags & LOAD_ALL) != 0) - PROGRESS(("=%#lx\n", + PROGRESS(("=0x%lx\n", marks[MARK_END] - marks[MARK_START])); return 0; } Index: src/sys/lib/libsa/rarp.c diff -u src/sys/lib/libsa/rarp.c:1.33 src/sys/lib/libsa/rarp.c:1.34 --- src/sys/lib/libsa/rarp.c:1.33 Sun Mar 31 16:08:45 2019 +++ src/sys/lib/libsa/rarp.c Fri Apr 5 16:09:29 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rarp.c,v 1.33 2019/03/31 20:08:45 christos Exp $ */ +/* $NetBSD: rarp.c,v 1.34 2019/04/05 20:09:29 christos Exp $ */ /* * Copyright (c) 1992 Regents of the University of California. @@ -196,7 +196,7 @@ rarprecv(struct iodesc *d, void *pkt, si if (etype != ETHERTYPE_REVARP) { #ifdef RARP_DEBUG if (debug) - printf("bad type=%#x\n", etype); + printf("bad type=0x%x\n", etype); #endif return -1; } @@ -217,7 +217,7 @@ rarprecv(struct iodesc *d, void *pkt, si if (ap->arp_op != htons(ARPOP_REVREPLY)) { #ifdef RARP_DEBUG if (debug) - printf("bad op=%#x\n", ntohs(ap->arp_op)); + printf("bad op=0x%x\n", ntohs(ap->arp_op)); #endif return -1; } Index: src/sys/lib/libsa/rpc.c diff -u src/sys/lib/libsa/rpc.c:1.30 src/sys/lib/libsa/rpc.c:1.31 --- src/sys/lib/libsa/rpc.c:1.30 Sun Mar 31 16:08:45 2019 +++ src/sys/lib/libsa/rpc.c Fri Apr 5 16:09:29 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: rpc.c,v 1.30 2019/03/31 20:08:45 christos Exp $ */ +/* $NetBSD: rpc.c,v 1.31 2019/04/05 20:09:29 christos Exp $ */ /* * Copyright (c) 1992 Regents of the University of California. @@ -127,7 +127,7 @@ rpc_call(struct iodesc *d, n_long prog, #ifdef RPC_DEBUG if (debug) - printf("%s: prog=%#x vers=%d proc=%d\n", __func__, + printf("%s: prog=0x%x vers=%d proc=%d\n", __func__, prog, vers, proc); #endif @@ -408,7 +408,7 @@ rpc_getport(struct iodesc *d, n_long pro #ifdef RPC_DEBUG if (debug) - printf("%s: prog=%#x vers=%d\n", __func__, prog, vers); + printf("%s: prog=0x%x vers=%d\n", __func__, prog, vers); #endif /* This one is fixed forever. */
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: christos Date: Tue Apr 2 22:25:10 UTC 2019 Modified Files: src/sys/lib/libsa: Makefile bootparam.c ufs.c Log Message: fix sign-compare and sign-passing errors. To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.90 src/sys/lib/libsa/Makefile cvs rdiff -u -r1.20 -r1.21 src/sys/lib/libsa/bootparam.c cvs rdiff -u -r1.75 -r1.76 src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: christos Date: Tue Apr 2 22:25:10 UTC 2019 Modified Files: src/sys/lib/libsa: Makefile bootparam.c ufs.c Log Message: fix sign-compare and sign-passing errors. To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.90 src/sys/lib/libsa/Makefile cvs rdiff -u -r1.20 -r1.21 src/sys/lib/libsa/bootparam.c cvs rdiff -u -r1.75 -r1.76 src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/Makefile diff -u src/sys/lib/libsa/Makefile:1.89 src/sys/lib/libsa/Makefile:1.90 --- src/sys/lib/libsa/Makefile:1.89 Sun Mar 31 16:08:45 2019 +++ src/sys/lib/libsa/Makefile Tue Apr 2 18:25:10 2019 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.89 2019/03/31 20:08:45 christos Exp $ +# $NetBSD: Makefile,v 1.90 2019/04/02 22:25:10 christos Exp $ LIB= sa LIBISPRIVATE?= yes @@ -15,9 +15,11 @@ CPPFLAGS= -I${SADIR} ${SACPPFLAGS} ${SAM #COPTS+= -ansi -pedantic -Wall # For testing -# WARNS=5 -# COPTS+=-ffreestanding -# CPPFLAGS+= -I${.CURDIR}/../../ -I${.CURDIR} +#WARNS=6 +#NOSSP=yes +#NOFORTIFY=yes +#COPTS+=-ffreestanding -Wpointer-sign +#CPPFLAGS+= -I${.CURDIR}/../../ -I${.CURDIR} .if defined(SA_EXTRADIR) .-include "${SA_EXTRADIR}/Makefile.inc" Index: src/sys/lib/libsa/bootparam.c diff -u src/sys/lib/libsa/bootparam.c:1.20 src/sys/lib/libsa/bootparam.c:1.21 --- src/sys/lib/libsa/bootparam.c:1.20 Sun Mar 31 16:08:45 2019 +++ src/sys/lib/libsa/bootparam.c Tue Apr 2 18:25:10 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: bootparam.c,v 1.20 2019/03/31 20:08:45 christos Exp $ */ +/* $NetBSD: bootparam.c,v 1.21 2019/04/02 22:25:10 christos Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross @@ -61,7 +61,7 @@ n_short bp_server_port; /* net order */ uint32_t hostnamelen; char domainname[FNAME_SIZE]; /* our DNS domain */ -int domainnamelen; +uint32_t domainnamelen; /* * RPC definitions for bootparamd @@ -247,7 +247,7 @@ bp_getfile(int sockfd, char *key, struct char *send_tail, *recv_head; /* misc... */ struct iodesc *d; - int sn_len, path_len; + uint32_t sn_len, path_len; ssize_t rlen; if (!(d = socktodesc(sockfd))) { @@ -296,7 +296,7 @@ bp_getfile(int sockfd, char *key, struct */ /* server name */ - sn_len = FNAME_SIZE-1; + sn_len = FNAME_SIZE - 1; if (xdr_string_decode(_head, serv_name, _len)) { RPC_PRINTF(("%s: bad server name\n", __func__)); return -1; @@ -391,7 +391,7 @@ xdr_inaddr_encode(char **pkt, struct in_ xi->atype = htonl(1); uia.l = ia.s_addr; cp = uia.c; - ip = xi->addr; + ip = (uint32_t *)xi->addr; /* * Note: the htonl() calls below DO NOT * imply that uia.l is in host order. @@ -427,7 +427,7 @@ xdr_inaddr_decode(char **pkt, struct in_ } cp = uia.c; - ip = xi->addr; + ip = (uint32_t *)xi->addr; /* * Note: the ntohl() calls below DO NOT * imply that uia.l is in host order. Index: src/sys/lib/libsa/ufs.c diff -u src/sys/lib/libsa/ufs.c:1.75 src/sys/lib/libsa/ufs.c:1.76 --- src/sys/lib/libsa/ufs.c:1.75 Sun Mar 31 16:08:45 2019 +++ src/sys/lib/libsa/ufs.c Tue Apr 2 18:25:10 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs.c,v 1.75 2019/03/31 20:08:45 christos Exp $ */ +/* $NetBSD: ufs.c,v 1.76 2019/04/02 22:25:10 christos Exp $ */ /*- * Copyright (c) 1993 @@ -422,7 +422,7 @@ buf_read_file(struct open_file *f, char off = ufs_blkoff(fs, fp->f_seekp); file_block = ufs_lblkno(fs, fp->f_seekp); #ifdef LIBSA_LFS - block_size = (size_t)dblksize(fs, >f_di, file_block); + block_size = (size_t)dblksize(fs, >f_di, (uint64_t)file_block); #else block_size = (size_t)ffs_sblksize(fs, (int64_t)fp->f_di.di_size, file_block); #endif
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: christos Date: Sun Mar 31 20:08:45 UTC 2019 Modified Files: src/sys/lib/libsa: Makefile alloc.c arp.c atoi.c bootcfg.c bootcfg.h bootp.c bootp.h bootparam.c cd9660.c checkpasswd.c dev_net.c dosfs.c ether.c ext2fs.c gets.c ip.c loadfile.c minixfs3.c net.c net.h netif.c nfs.c qsort.c rarp.c rpc.c tftp.c udp.c ufs.c Log Message: fix warnings, printf formats, etc. To generate a diff of this commit: cvs rdiff -u -r1.88 -r1.89 src/sys/lib/libsa/Makefile cvs rdiff -u -r1.27 -r1.28 src/sys/lib/libsa/alloc.c src/sys/lib/libsa/net.h cvs rdiff -u -r1.34 -r1.35 src/sys/lib/libsa/arp.c cvs rdiff -u -r1.1 -r1.2 src/sys/lib/libsa/atoi.c cvs rdiff -u -r1.3 -r1.4 src/sys/lib/libsa/bootcfg.c src/sys/lib/libsa/ip.c cvs rdiff -u -r1.2 -r1.3 src/sys/lib/libsa/bootcfg.h cvs rdiff -u -r1.41 -r1.42 src/sys/lib/libsa/bootp.c cvs rdiff -u -r1.9 -r1.10 src/sys/lib/libsa/bootp.h cvs rdiff -u -r1.19 -r1.20 src/sys/lib/libsa/bootparam.c cvs rdiff -u -r1.31 -r1.32 src/sys/lib/libsa/cd9660.c cvs rdiff -u -r1.10 -r1.11 src/sys/lib/libsa/checkpasswd.c cvs rdiff -u -r1.26 -r1.27 src/sys/lib/libsa/dev_net.c cvs rdiff -u -r1.21 -r1.22 src/sys/lib/libsa/dosfs.c cvs rdiff -u -r1.23 -r1.24 src/sys/lib/libsa/ether.c cvs rdiff -u -r1.25 -r1.26 src/sys/lib/libsa/ext2fs.c \ src/sys/lib/libsa/netif.c cvs rdiff -u -r1.14 -r1.15 src/sys/lib/libsa/gets.c cvs rdiff -u -r1.30 -r1.31 src/sys/lib/libsa/loadfile.c cvs rdiff -u -r1.7 -r1.8 src/sys/lib/libsa/minixfs3.c cvs rdiff -u -r1.35 -r1.36 src/sys/lib/libsa/net.c src/sys/lib/libsa/tftp.c cvs rdiff -u -r1.48 -r1.49 src/sys/lib/libsa/nfs.c cvs rdiff -u -r1.4 -r1.5 src/sys/lib/libsa/qsort.c cvs rdiff -u -r1.32 -r1.33 src/sys/lib/libsa/rarp.c cvs rdiff -u -r1.29 -r1.30 src/sys/lib/libsa/rpc.c cvs rdiff -u -r1.12 -r1.13 src/sys/lib/libsa/udp.c cvs rdiff -u -r1.74 -r1.75 src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/Makefile diff -u src/sys/lib/libsa/Makefile:1.88 src/sys/lib/libsa/Makefile:1.89 --- src/sys/lib/libsa/Makefile:1.88 Mon Jun 4 20:57:47 2018 +++ src/sys/lib/libsa/Makefile Sun Mar 31 16:08:45 2019 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.88 2018/06/05 00:57:47 christos Exp $ +# $NetBSD: Makefile,v 1.89 2019/03/31 20:08:45 christos Exp $ LIB= sa LIBISPRIVATE?= yes @@ -14,6 +14,11 @@ CPPFLAGS= -I${SADIR} ${SACPPFLAGS} ${SAM #COPTS+= -ansi -pedantic -Wall +# For testing +# WARNS=5 +# COPTS+=-ffreestanding +# CPPFLAGS+= -I${.CURDIR}/../../ -I${.CURDIR} + .if defined(SA_EXTRADIR) .-include "${SA_EXTRADIR}/Makefile.inc" .endif Index: src/sys/lib/libsa/alloc.c diff -u src/sys/lib/libsa/alloc.c:1.27 src/sys/lib/libsa/alloc.c:1.28 --- src/sys/lib/libsa/alloc.c:1.27 Sun Jun 5 09:44:48 2016 +++ src/sys/lib/libsa/alloc.c Sun Mar 31 16:08:45 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: alloc.c,v 1.27 2016/06/05 13:44:48 maxv Exp $ */ +/* $NetBSD: alloc.c,v 1.28 2019/03/31 20:08:45 christos Exp $ */ /* * Copyright (c) 1993 @@ -224,16 +224,16 @@ dealloc(void *ptr, size_t size) ALIGN(sizeof(unsigned int))); #ifdef DEBUG if (size > (size_t)f->size) { - printf("dealloc %zu bytes @%lx, should be <=%u\n", - size, (u_long)ptr, f->size); + printf("%s: %zu bytes @%p, should be <=%u\n", __func__, + size, ptr, f->size); } if (ptr < (void *)HEAP_START) - printf("dealloc: %lx before start of heap.\n", (u_long)ptr); + printf("%s: %p before start of heap.\n", __func__, ptr); #ifdef HEAP_LIMIT if (ptr > (void *)HEAP_LIMIT) - printf("dealloc: %lx beyond end of heap.\n", (u_long)ptr); + printf("%s: %p beyond end of heap.\n", __func__, ptr); #endif #endif /* DEBUG */ /* put into freelist */ Index: src/sys/lib/libsa/net.h diff -u src/sys/lib/libsa/net.h:1.27 src/sys/lib/libsa/net.h:1.28 --- src/sys/lib/libsa/net.h:1.27 Sat Mar 29 10:30:16 2014 +++ src/sys/lib/libsa/net.h Sun Mar 31 16:08:45 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: net.h,v 1.27 2014/03/29 14:30:16 jakllsch Exp $ */ +/* $NetBSD: net.h,v 1.28 2019/03/31 20:08:45 christos Exp $ */ /* * Copyright (c) 1993 Adam Glass @@ -133,4 +133,6 @@ int ip_cksum(const void *, size_t); /* Machine-dependent functions: */ #ifdef _STANDALONE /* XXX for mount_nfs(8) SMALLPROG hack */ satime_t getsecs(void); +#else +#define getsecs() time(NULL) #endif Index: src/sys/lib/libsa/arp.c diff -u src/sys/lib/libsa/arp.c:1.34 src/sys/lib/libsa/arp.c:1.35 --- src/sys/lib/libsa/arp.c:1.34 Sat Mar 29 10:25:10 2014 +++ src/sys/lib/libsa/arp.c Sun Mar 31 16:08:45 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: arp.c,v 1.34 2014/03/29 14:25:10 jakllsch Exp $ */ +/* $NetBSD: arp.c,v 1.35 2019/03/31 20:08:45 christos Exp $ */ /* * Copyright (c) 1992 Regents of the University of California. @@ -50,6 +50,7 @@ #ifdef _STANDALONE #include #else +#include #include #endif @@ -97,6 +98,7 @@ u_char * arpwhohas(struct iodesc *d, struct
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: christos Date: Sun Mar 31 20:08:45 UTC 2019 Modified Files: src/sys/lib/libsa: Makefile alloc.c arp.c atoi.c bootcfg.c bootcfg.h bootp.c bootp.h bootparam.c cd9660.c checkpasswd.c dev_net.c dosfs.c ether.c ext2fs.c gets.c ip.c loadfile.c minixfs3.c net.c net.h netif.c nfs.c qsort.c rarp.c rpc.c tftp.c udp.c ufs.c Log Message: fix warnings, printf formats, etc. To generate a diff of this commit: cvs rdiff -u -r1.88 -r1.89 src/sys/lib/libsa/Makefile cvs rdiff -u -r1.27 -r1.28 src/sys/lib/libsa/alloc.c src/sys/lib/libsa/net.h cvs rdiff -u -r1.34 -r1.35 src/sys/lib/libsa/arp.c cvs rdiff -u -r1.1 -r1.2 src/sys/lib/libsa/atoi.c cvs rdiff -u -r1.3 -r1.4 src/sys/lib/libsa/bootcfg.c src/sys/lib/libsa/ip.c cvs rdiff -u -r1.2 -r1.3 src/sys/lib/libsa/bootcfg.h cvs rdiff -u -r1.41 -r1.42 src/sys/lib/libsa/bootp.c cvs rdiff -u -r1.9 -r1.10 src/sys/lib/libsa/bootp.h cvs rdiff -u -r1.19 -r1.20 src/sys/lib/libsa/bootparam.c cvs rdiff -u -r1.31 -r1.32 src/sys/lib/libsa/cd9660.c cvs rdiff -u -r1.10 -r1.11 src/sys/lib/libsa/checkpasswd.c cvs rdiff -u -r1.26 -r1.27 src/sys/lib/libsa/dev_net.c cvs rdiff -u -r1.21 -r1.22 src/sys/lib/libsa/dosfs.c cvs rdiff -u -r1.23 -r1.24 src/sys/lib/libsa/ether.c cvs rdiff -u -r1.25 -r1.26 src/sys/lib/libsa/ext2fs.c \ src/sys/lib/libsa/netif.c cvs rdiff -u -r1.14 -r1.15 src/sys/lib/libsa/gets.c cvs rdiff -u -r1.30 -r1.31 src/sys/lib/libsa/loadfile.c cvs rdiff -u -r1.7 -r1.8 src/sys/lib/libsa/minixfs3.c cvs rdiff -u -r1.35 -r1.36 src/sys/lib/libsa/net.c src/sys/lib/libsa/tftp.c cvs rdiff -u -r1.48 -r1.49 src/sys/lib/libsa/nfs.c cvs rdiff -u -r1.4 -r1.5 src/sys/lib/libsa/qsort.c cvs rdiff -u -r1.32 -r1.33 src/sys/lib/libsa/rarp.c cvs rdiff -u -r1.29 -r1.30 src/sys/lib/libsa/rpc.c cvs rdiff -u -r1.12 -r1.13 src/sys/lib/libsa/udp.c cvs rdiff -u -r1.74 -r1.75 src/sys/lib/libsa/ufs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mlelstv Date: Sun Mar 31 16:14:48 UTC 2019 Modified Files: src/sys/lib/libsa: udp.c Log Message: correct debug message, d->myport has network byte order. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/lib/libsa/udp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/udp.c diff -u src/sys/lib/libsa/udp.c:1.11 src/sys/lib/libsa/udp.c:1.12 --- src/sys/lib/libsa/udp.c:1.11 Wed May 11 16:23:40 2011 +++ src/sys/lib/libsa/udp.c Sun Mar 31 16:14:48 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: udp.c,v 1.11 2011/05/11 16:23:40 zoltan Exp $ */ +/* $NetBSD: udp.c,v 1.12 2019/03/31 16:14:48 mlelstv Exp $ */ /* * Copyright (c) 1992 Regents of the University of California. @@ -117,7 +117,7 @@ readudp(struct iodesc *d, void *pkt, siz #ifdef NET_DEBUG if (debug) printf("readudp: bad dport %d != %d\n", -d->myport, ntohs(uh->uh_dport)); +ntohs(d->myport), ntohs(uh->uh_dport)); #endif return -1; }
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mlelstv Date: Sun Mar 31 16:14:48 UTC 2019 Modified Files: src/sys/lib/libsa: udp.c Log Message: correct debug message, d->myport has network byte order. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/lib/libsa/udp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mrg Date: Sun Feb 3 11:59:43 UTC 2019 Modified Files: src/sys/lib/libsa: subr_prf.c Log Message: - remove unreachable code To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/lib/libsa/subr_prf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/subr_prf.c diff -u src/sys/lib/libsa/subr_prf.c:1.27 src/sys/lib/libsa/subr_prf.c:1.28 --- src/sys/lib/libsa/subr_prf.c:1.27 Sat Aug 30 14:24:02 2014 +++ src/sys/lib/libsa/subr_prf.c Sun Feb 3 11:59:43 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_prf.c,v 1.27 2014/08/30 14:24:02 tsutsui Exp $ */ +/* $NetBSD: subr_prf.c,v 1.28 2019/02/03 11:59:43 mrg Exp $ */ /*- * Copyright (c) 1993 @@ -203,7 +203,6 @@ reswitch: ++fmt; } #endif - goto reswitch; case 'l': #ifdef LIBSA_PRINTF_LONGLONG_SUPPORT if (*fmt == 'l') {
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: mrg Date: Sun Feb 3 11:59:43 UTC 2019 Modified Files: src/sys/lib/libsa: subr_prf.c Log Message: - remove unreachable code To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/lib/libsa/subr_prf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: jmcneill Date: Thu Aug 23 17:35:42 UTC 2018 Modified Files: src/sys/lib/libsa: loadfile_elf32.c Log Message: Support loading read-only data sections. ARM64 ELF kernels need this. ok skrll@ To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/lib/libsa/loadfile_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/loadfile_elf32.c diff -u src/sys/lib/libsa/loadfile_elf32.c:1.52 src/sys/lib/libsa/loadfile_elf32.c:1.53 --- src/sys/lib/libsa/loadfile_elf32.c:1.52 Thu Dec 21 14:28:39 2017 +++ src/sys/lib/libsa/loadfile_elf32.c Thu Aug 23 17:35:42 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: loadfile_elf32.c,v 1.52 2017/12/21 14:28:39 maxv Exp $ */ +/* $NetBSD: loadfile_elf32.c,v 1.53 2018/08/23 17:35:42 jmcneill Exp $ */ /* * Copyright (c) 1997, 2008, 2017 The NetBSD Foundation, Inc. @@ -256,7 +256,7 @@ externalize_shdr(Elf_Byte bo, Elf_Shdr * #endif /* _STANDALONE */ #define IS_TEXT(p) (p.p_flags & PF_X) -#define IS_DATA(p) (p.p_flags & PF_W) +#define IS_DATA(p) ((p.p_flags & PF_X) == 0) #define IS_BSS(p) (p.p_filesz < p.p_memsz) #ifndef MD_LOADSEG /* Allow processor ABI specific segment loads */ @@ -708,7 +708,7 @@ ELFNAMEEND(loadfile_static)(int fd, Elf_ goto loadseg; if (phdr[i].p_type != PT_LOAD || - (phdr[i].p_flags & (PF_W|PF_X)) == 0) + (phdr[i].p_flags & (PF_W|PF_R|PF_X)) == 0) continue; if ((IS_TEXT(phdr[i]) && (flags & LOAD_TEXT)) ||
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: jmcneill Date: Thu Aug 23 17:35:42 UTC 2018 Modified Files: src/sys/lib/libsa: loadfile_elf32.c Log Message: Support loading read-only data sections. ARM64 ELF kernels need this. ok skrll@ To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/lib/libsa/loadfile_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: maxv Date: Wed May 9 06:49:48 UTC 2018 Modified Files: src/sys/lib/libsa: ip.c Log Message: Remove annoying things, style, and fix buffer overflows. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/lib/libsa/ip.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: maxv Date: Wed May 9 06:49:48 UTC 2018 Modified Files: src/sys/lib/libsa: ip.c Log Message: Remove annoying things, style, and fix buffer overflows. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/lib/libsa/ip.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/ip.c diff -u src/sys/lib/libsa/ip.c:1.2 src/sys/lib/libsa/ip.c:1.3 --- src/sys/lib/libsa/ip.c:1.2 Fri May 13 23:35:09 2011 +++ src/sys/lib/libsa/ip.c Wed May 9 06:49:48 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ip.c,v 1.2 2011/05/13 23:35:09 nakayama Exp $ */ +/* $NetBSD: ip.c,v 1.3 2018/05/09 06:49:48 maxv Exp $ */ /* * Copyright (c) 1992 Regents of the University of California. @@ -36,7 +36,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * */ #include @@ -63,7 +62,7 @@ * sends an IP packet, if it's alredy constructed */ static ssize_t -_sendip(struct iodesc * d, struct ip * ip, size_t len) +_sendip(struct iodesc *d, struct ip *ip, size_t len) { u_char *ea; @@ -82,15 +81,15 @@ _sendip(struct iodesc * d, struct ip * i * Caller must leave room for ethernet, ip and udp headers in front! */ ssize_t -sendip(struct iodesc * d, void *pkt, size_t len, u_int8_t proto) +sendip(struct iodesc *d, void *pkt, size_t len, u_int8_t proto) { ssize_t cc; struct ip *ip; - ip = (struct ip *) pkt - 1; + ip = (struct ip *)pkt - 1; len += sizeof(*ip); - (void) memset(ip, 0, sizeof(*ip)); + memset(ip, 0, sizeof(*ip)); ip->ip_v = IPVERSION; ip->ip_hl = sizeof(*ip) >> 2; @@ -105,7 +104,7 @@ sendip(struct iodesc * d, void *pkt, siz if (cc == -1) return -1; - if ((size_t) cc != len) + if ((size_t)cc != len) panic("sendip: bad write (%zd != %zu)", cc, len); return (cc - (sizeof(*ip))); } @@ -119,72 +118,51 @@ sendip(struct iodesc * d, void *pkt, siz * The size returned is the size indicated in the header. */ ssize_t -readip(struct iodesc * d, void *pkt, size_t len, time_t tleft, u_int8_t proto) +readip(struct iodesc *d, void *pkt, size_t len, time_t tleft, u_int8_t proto) { ssize_t n; size_t hlen; struct ip *ip; u_int16_t etype; - ip = (struct ip *) pkt - 1; + ip = (struct ip *)pkt - 1; n = readether(d, ip, len + sizeof(*ip), tleft, ); - if (n == -1 || (size_t) n < sizeof(*ip)) + if (n == -1 || (size_t)n < sizeof(*ip)) return -1; if (etype == ETHERTYPE_ARP) { - struct arphdr *ah = (void *) ip; + struct arphdr *ah = (void *)ip; + if (n < (sizeof(*ah) + 2 * (ah->ar_hln + ah->ar_pln))) { + return -1; + } if (ah->ar_op == htons(ARPOP_REQUEST)) { /* Send ARP reply */ arp_reply(d, ah); } return -1; } - if (etype != ETHERTYPE_IP) { -#ifdef NET_DEBUG - if (debug) - printf("readip: not IP. ether_type=%x\n", etype); -#endif return -1; } - /* Check ip header */ - if (ip->ip_v != IPVERSION || - ip->ip_p != proto) { /* half char */ -#ifdef NET_DEBUG - if (debug) { - printf("readip: wrong IP version or wrong proto " - "ip_v=%d ip_p=%d\n", ip->ip_v, ip->ip_p); - } -#endif + if (ip->ip_v != IPVERSION || ip->ip_p != proto) { return -1; } hlen = ip->ip_hl << 2; - if (hlen < sizeof(*ip) || ip_cksum(ip, hlen) != 0) { -#ifdef NET_DEBUG - if (debug) - printf("readip: short hdr or bad cksum.\n"); -#endif + if (hlen != sizeof(*ip) || ip_cksum(ip, hlen) != 0) { + return -1; + } + if (ntohs(ip->ip_len) < hlen) { return -1; } if (n < ntohs(ip->ip_len)) { -#ifdef NET_DEBUG - if (debug) - printf("readip: bad length %d < %d.\n", - (int) n, ntohs(ip->ip_len)); -#endif return -1; } if (d->myip.s_addr && ip->ip_dst.s_addr != d->myip.s_addr) { -#ifdef NET_DEBUG - if (debug) { - printf("readip: bad saddr %s != ", inet_ntoa(d->myip)); - printf("%s\n", inet_ntoa(ip->ip_dst)); - } -#endif return -1; } - return (ntohs(ip->ip_len) - 20); + + return (ntohs(ip->ip_len) - hlen); }
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: nonaka Date: Thu Mar 8 23:02:50 UTC 2018 Modified Files: src/sys/lib/libsa: cd9660.c Log Message: Add missed file in previous commit. > efiboot: system can boot from CD/DVD-ROM media. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/lib/libsa/cd9660.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/cd9660.c diff -u src/sys/lib/libsa/cd9660.c:1.30 src/sys/lib/libsa/cd9660.c:1.31 --- src/sys/lib/libsa/cd9660.c:1.30 Thu Mar 20 03:13:18 2014 +++ src/sys/lib/libsa/cd9660.c Thu Mar 8 23:02:50 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cd9660.c,v 1.30 2014/03/20 03:13:18 christos Exp $ */ +/* $NetBSD: cd9660.c,v 1.31 2018/03/08 23:02:50 nonaka Exp $ */ /* * Copyright (C) 1996 Wolfgang Solfrank. @@ -71,7 +71,9 @@ struct ptable_ent { #define PTFIXSZ 8 #define PTSIZE(pp) roundup(PTFIXSZ + isonum_711((pp)->namlen), 2) +#ifndef cdb2devb #define cdb2devb(bno) ((bno) * ISO_DEFAULT_BLOCK_SIZE / DEV_BSIZE) +#endif static int pnmatch(const char *, struct ptable_ent *); static int dirmatch(const char *, struct iso_directory_record *);
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: nonaka Date: Thu Mar 8 23:02:50 UTC 2018 Modified Files: src/sys/lib/libsa: cd9660.c Log Message: Add missed file in previous commit. > efiboot: system can boot from CD/DVD-ROM media. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/lib/libsa/cd9660.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: maxv Date: Thu Dec 21 14:28:39 UTC 2017 Modified Files: src/sys/lib/libsa: loadfile_elf32.c Log Message: Make sure we're loading a relocatable binary, to give the user a chance to correct the kernel name if he mistakenly typed pkboot on a static kernel, without having to reboot the machine (currently the prekern sees it's a static kernel and panics). To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/lib/libsa/loadfile_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: maxv Date: Thu Dec 21 14:28:39 UTC 2017 Modified Files: src/sys/lib/libsa: loadfile_elf32.c Log Message: Make sure we're loading a relocatable binary, to give the user a chance to correct the kernel name if he mistakenly typed pkboot on a static kernel, without having to reboot the machine (currently the prekern sees it's a static kernel and panics). To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/lib/libsa/loadfile_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/loadfile_elf32.c diff -u src/sys/lib/libsa/loadfile_elf32.c:1.51 src/sys/lib/libsa/loadfile_elf32.c:1.52 --- src/sys/lib/libsa/loadfile_elf32.c:1.51 Wed Nov 15 18:02:37 2017 +++ src/sys/lib/libsa/loadfile_elf32.c Thu Dec 21 14:28:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: loadfile_elf32.c,v 1.51 2017/11/15 18:02:37 maxv Exp $ */ +/* $NetBSD: loadfile_elf32.c,v 1.52 2017/12/21 14:28:39 maxv Exp $ */ /* * Copyright (c) 1997, 2008, 2017 The NetBSD Foundation, Inc. @@ -352,6 +352,11 @@ ELFNAMEEND(loadfile_dynamic)(int fd, Elf internalize_ehdr(elf->e_ident[EI_DATA], elf); + if (elf->e_type != ET_REL) { + errno = EINVAL; + return 1; + } + /* Create a local copy of the SECTION HEADERS. */ shdrsz = elf->e_shnum * sizeof(Elf_Shdr); shdr = ALLOC(shdrsz);
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: maxv Date: Mon Nov 13 20:21:10 UTC 2017 Modified Files: src/sys/lib/libsa: loadfile_elf32.c Log Message: Revert my last revision, that is to say, don't group sections into segments anymore. Initially I did this because I wanted to compress the sections by reducing the padding between them; but we'll handle that differently. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/lib/libsa/loadfile_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/loadfile_elf32.c diff -u src/sys/lib/libsa/loadfile_elf32.c:1.48 src/sys/lib/libsa/loadfile_elf32.c:1.49 --- src/sys/lib/libsa/loadfile_elf32.c:1.48 Wed Oct 18 16:29:56 2017 +++ src/sys/lib/libsa/loadfile_elf32.c Mon Nov 13 20:21:10 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: loadfile_elf32.c,v 1.48 2017/10/18 16:29:56 maxv Exp $ */ +/* $NetBSD: loadfile_elf32.c,v 1.49 2017/11/13 20:21:10 maxv Exp $ */ /* * Copyright (c) 1997, 2008, 2017 The NetBSD Foundation, Inc. @@ -341,7 +341,7 @@ ELFNAMEEND(loadfile_dynamic)(int fd, Elf { const u_long offset = 0; Elf_Shdr *shdr; - Elf_Addr shpp, addr, align; + Elf_Addr shpp, addr; int i, j, loaded; size_t size, shdrsz; Elf_Addr maxp, elfp = 0; @@ -383,101 +383,11 @@ ELFNAMEEND(loadfile_dynamic)(int fd, Elf maxp += roundup(shdrsz, ELFROUND); /* - * Load the KERNEL SECTIONS, and group them into segments. First text, - * then rodata, then data. Between sections, we align to the requested - * section alignment. Between segments, we align to KERNALIGN. + * Load the KERNEL SECTIONS. */ - - /* text */ - maxp = roundup(maxp, KERNALIGN); - for (i = 0; i < elf->e_shnum; i++) { - if (!(shdr[i].sh_flags & SHF_EXECINSTR)) { - continue; - } - align = shdr[i].sh_addralign; - if (align == 0) { - align = ELFROUND; - } - addr = roundup(maxp, align); - size = (size_t)shdr[i].sh_size; - - loaded = 0; - switch (shdr[i].sh_type) { - case SHT_NOBITS: - /* Zero out bss. */ - BZERO(addr, size); - loaded = 1; - break; - case SHT_PROGBITS: - ret = ELFNAMEEND(readfile_global)(fd, offset, - shdr[i].sh_offset, addr, size); - if (ret == -1) { -goto out; - } - loaded = 1; - break; - default: - loaded = 0; - break; - } - - if (loaded) { - shdr[i].sh_offset = addr - elfp; - maxp = addr + size; - } - } - - /* rodata */ - maxp = roundup(maxp, KERNALIGN); - for (i = 0; i < elf->e_shnum; i++) { - if ((shdr[i].sh_flags & (SHF_EXECINSTR|SHF_WRITE))) { - continue; - } - align = shdr[i].sh_addralign; - if (align == 0) { - align = ELFROUND; - } - addr = roundup(maxp, align); - size = (size_t)shdr[i].sh_size; - - loaded = 0; - switch (shdr[i].sh_type) { - case SHT_NOBITS: - /* Zero out bss. */ - BZERO(addr, size); - loaded = 1; - break; - case SHT_PROGBITS: - ret = ELFNAMEEND(readfile_global)(fd, offset, - shdr[i].sh_offset, addr, size); - if (ret == -1) { -goto out; - } - loaded = 1; - break; - default: - loaded = 0; - break; - } - - if (loaded) { - shdr[i].sh_offset = addr - elfp; - maxp = addr + size; - } - } - - /* data */ maxp = roundup(maxp, KERNALIGN); for (i = 0; i < elf->e_shnum; i++) { - if (!(shdr[i].sh_flags & SHF_WRITE) || - (shdr[i].sh_flags & SHF_EXECINSTR)) { - continue; - } - align = shdr[i].sh_addralign; - if (align == 0) { - align = ELFROUND; - } - addr = roundup(maxp, align); + addr = maxp; size = (size_t)shdr[i].sh_size; loaded = 0; @@ -501,15 +411,15 @@ ELFNAMEEND(loadfile_dynamic)(int fd, Elf } if (loaded) { - shdr[i].sh_offset = addr - elfp; - maxp = addr + size; + shdr[i].sh_offset = maxp - elfp; + maxp = roundup(maxp + size, KERNALIGN); } } /* * Load the SYM+REL SECTIONS. */ - maxp = roundup(maxp, KERNALIGN); + maxp = roundup(maxp, ELFROUND); for (i = 0; i < elf->e_shnum; i++) { addr = maxp; size = (size_t)shdr[i].sh_size;
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: maxv Date: Mon Nov 13 20:21:10 UTC 2017 Modified Files: src/sys/lib/libsa: loadfile_elf32.c Log Message: Revert my last revision, that is to say, don't group sections into segments anymore. Initially I did this because I wanted to compress the sections by reducing the padding between them; but we'll handle that differently. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/lib/libsa/loadfile_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: maxv Date: Wed Oct 18 16:29:56 UTC 2017 Modified Files: src/sys/lib/libsa: loadfile_elf32.c Log Message: Group the sections into segments, and align to KERNALIGN only between segments. Prerequisite for other changes. Unfortunately the code is not very compact, but whatever. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/lib/libsa/loadfile_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/lib/libsa/loadfile_elf32.c diff -u src/sys/lib/libsa/loadfile_elf32.c:1.47 src/sys/lib/libsa/loadfile_elf32.c:1.48 --- src/sys/lib/libsa/loadfile_elf32.c:1.47 Fri Oct 13 10:39:26 2017 +++ src/sys/lib/libsa/loadfile_elf32.c Wed Oct 18 16:29:56 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: loadfile_elf32.c,v 1.47 2017/10/13 10:39:26 maxv Exp $ */ +/* $NetBSD: loadfile_elf32.c,v 1.48 2017/10/18 16:29:56 maxv Exp $ */ /* * Copyright (c) 1997, 2008, 2017 The NetBSD Foundation, Inc. @@ -341,7 +341,7 @@ ELFNAMEEND(loadfile_dynamic)(int fd, Elf { const u_long offset = 0; Elf_Shdr *shdr; - Elf_Addr shpp, addr; + Elf_Addr shpp, addr, align; int i, j, loaded; size_t size, shdrsz; Elf_Addr maxp, elfp = 0; @@ -383,11 +383,22 @@ ELFNAMEEND(loadfile_dynamic)(int fd, Elf maxp += roundup(shdrsz, ELFROUND); /* - * Load the KERNEL SECTIONS. + * Load the KERNEL SECTIONS, and group them into segments. First text, + * then rodata, then data. Between sections, we align to the requested + * section alignment. Between segments, we align to KERNALIGN. */ + + /* text */ maxp = roundup(maxp, KERNALIGN); for (i = 0; i < elf->e_shnum; i++) { - addr = maxp; + if (!(shdr[i].sh_flags & SHF_EXECINSTR)) { + continue; + } + align = shdr[i].sh_addralign; + if (align == 0) { + align = ELFROUND; + } + addr = roundup(maxp, align); size = (size_t)shdr[i].sh_size; loaded = 0; @@ -411,15 +422,94 @@ ELFNAMEEND(loadfile_dynamic)(int fd, Elf } if (loaded) { - shdr[i].sh_offset = maxp - elfp; - maxp = roundup(maxp + size, KERNALIGN); + shdr[i].sh_offset = addr - elfp; + maxp = addr + size; + } + } + + /* rodata */ + maxp = roundup(maxp, KERNALIGN); + for (i = 0; i < elf->e_shnum; i++) { + if ((shdr[i].sh_flags & (SHF_EXECINSTR|SHF_WRITE))) { + continue; + } + align = shdr[i].sh_addralign; + if (align == 0) { + align = ELFROUND; + } + addr = roundup(maxp, align); + size = (size_t)shdr[i].sh_size; + + loaded = 0; + switch (shdr[i].sh_type) { + case SHT_NOBITS: + /* Zero out bss. */ + BZERO(addr, size); + loaded = 1; + break; + case SHT_PROGBITS: + ret = ELFNAMEEND(readfile_global)(fd, offset, + shdr[i].sh_offset, addr, size); + if (ret == -1) { +goto out; + } + loaded = 1; + break; + default: + loaded = 0; + break; + } + + if (loaded) { + shdr[i].sh_offset = addr - elfp; + maxp = addr + size; + } + } + + /* data */ + maxp = roundup(maxp, KERNALIGN); + for (i = 0; i < elf->e_shnum; i++) { + if (!(shdr[i].sh_flags & SHF_WRITE) || + (shdr[i].sh_flags & SHF_EXECINSTR)) { + continue; + } + align = shdr[i].sh_addralign; + if (align == 0) { + align = ELFROUND; + } + addr = roundup(maxp, align); + size = (size_t)shdr[i].sh_size; + + loaded = 0; + switch (shdr[i].sh_type) { + case SHT_NOBITS: + /* Zero out bss. */ + BZERO(addr, size); + loaded = 1; + break; + case SHT_PROGBITS: + ret = ELFNAMEEND(readfile_global)(fd, offset, + shdr[i].sh_offset, addr, size); + if (ret == -1) { +goto out; + } + loaded = 1; + break; + default: + loaded = 0; + break; + } + + if (loaded) { + shdr[i].sh_offset = addr - elfp; + maxp = addr + size; } } /* * Load the SYM+REL SECTIONS. */ - maxp = roundup(maxp, ELFROUND); + maxp = roundup(maxp, KERNALIGN); for (i = 0; i < elf->e_shnum; i++) { addr = maxp; size = (size_t)shdr[i].sh_size;
CVS commit: src/sys/lib/libsa
Module Name:src Committed By: maxv Date: Wed Oct 18 16:29:56 UTC 2017 Modified Files: src/sys/lib/libsa: loadfile_elf32.c Log Message: Group the sections into segments, and align to KERNALIGN only between segments. Prerequisite for other changes. Unfortunately the code is not very compact, but whatever. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/lib/libsa/loadfile_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.