CVS commit: src/tests/net/if
Module Name:src Committed By: ozaki-r Date: Tue Sep 15 09:51:01 UTC 2015 Modified Files: src/tests/net/if: t_ifconfig.sh Log Message: Improve test stability ifconfig -a -v after ifconfig -a -z is expected to show '0 packets' for all interface. However, shmif0 can receive packets between the two operations. So we have to keep shmif0 down during such tests. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/net/if/t_ifconfig.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/net/if/t_ifconfig.sh diff -u src/tests/net/if/t_ifconfig.sh:1.2 src/tests/net/if/t_ifconfig.sh:1.3 --- src/tests/net/if/t_ifconfig.sh:1.2 Thu Sep 3 10:22:52 2015 +++ src/tests/net/if/t_ifconfig.sh Tue Sep 15 09:51:01 2015 @@ -1,4 +1,4 @@ -# $NetBSD: t_ifconfig.sh,v 1.2 2015/09/03 10:22:52 ozaki-r Exp $ +# $NetBSD: t_ifconfig.sh,v 1.3 2015/09/15 09:51:01 ozaki-r Exp $ # # Copyright (c) 2015 The NetBSD Foundation, Inc. # All rights reserved. @@ -149,8 +149,11 @@ options_body() atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up atf_check -s exit:0 -o match:'0 packets' rump.ifconfig -a -v atf_check -s exit:0 -o ignore rump.ping -c 1 localhost + atf_check -s exit:0 -o ignore rump.ifconfig shmif0 down atf_check -s exit:0 -o match:'2 packets' rump.ifconfig -a -z atf_check -s exit:0 -o not-match:'2 packets' rump.ifconfig -a -v + atf_check -s exit:0 -o match:'0 packets' rump.ifconfig -a -v + atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up # ifconfig -l [-bdsu] # -l shows only inteface names
CVS commit: src/sys/rump/include/rump
Module Name:src Committed By: pooka Date: Tue Sep 15 14:55:12 UTC 2015 Modified Files: src/sys/rump/include/rump: makerumpdefs.sh Log Message: Generate rump_errno2host(): translates rump kernel errnos to host errnos. Essentially, it's a partial I-know-what-I'm-doing syscall compat. Functionality requested by Robert Millan. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/rump/include/rump/makerumpdefs.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/include/rump/makerumpdefs.sh diff -u src/sys/rump/include/rump/makerumpdefs.sh:1.27 src/sys/rump/include/rump/makerumpdefs.sh:1.28 --- src/sys/rump/include/rump/makerumpdefs.sh:1.27 Thu Sep 10 16:21:32 2015 +++ src/sys/rump/include/rump/makerumpdefs.sh Tue Sep 15 14:55:12 2015 @@ -8,7 +8,7 @@ echo Generating rumpdefs.h rm -f rumpdefs.h exec 3>&1 > rumpdefs.h -printf '/* $NetBSD: makerumpdefs.sh,v 1.27 2015/09/10 16:21:32 pooka Exp $ */\n\n' +printf '/* $NetBSD: makerumpdefs.sh,v 1.28 2015/09/15 14:55:12 pooka Exp $ */\n\n' printf '/*\n *\tAUTOMATICALLY GENERATED. DO NOT EDIT.\n */\n\n' printf '#ifndef _RUMP_RUMPDEFS_H_\n' printf '#define _RUMP_RUMPDEFS_H_\n\n' @@ -126,11 +126,11 @@ getstruct ../../../sys/dirent.h dirent printf '\n#endif /* _RUMP_RUMPDEFS_H_ */\n' exec 1>&3 + echo Generating rumperr.h rm -f rumperr.h exec > rumperr.h - -printf '/* $NetBSD: makerumpdefs.sh,v 1.27 2015/09/10 16:21:32 pooka Exp $ */\n\n' +printf '/* $NetBSD: makerumpdefs.sh,v 1.28 2015/09/15 14:55:12 pooka Exp $ */\n\n' printf '/*\n *\tAUTOMATICALLY GENERATED. DO NOT EDIT.\n */\n' fromvers ../../../sys/errno.h @@ -168,4 +168,44 @@ if [ $? -ne 0 ]; then exit 1 fi +echo Generating rumperrno2host.h 1>&3 +rm -f rumperrno2host.h +exec > rumperrno2host.h +printf '/* $NetBSD: makerumpdefs.sh,v 1.28 2015/09/15 14:55:12 pooka Exp $ */\n\n' +printf '/*\n *\tAUTOMATICALLY GENERATED. DO NOT EDIT.\n */\n' + +fromvers ../../../sys/errno.h + +printf "\n#ifndef ERANGE\n#error include ISO C style errno.h first\n#endif\n" +printf "\nstatic inline int \nrump_errno2host(int rumperrno)\n{\n\n" +printf "\tswitch (rumperrno) {\n\tcase 0:\n" +printf "\t\t return 0;\n" +awk '/^#define[ ]*E.*[0-9]/{ + ename = $2 + evalue = $3 + error = 1 + if (ename == "ELAST") { + printf "\tdefault:\n" + printf "#ifdef EINVAL\n\t\treturn EINVAL;\n" + printf "#else\n\t\treturn ERANGE;\n#endif\n" + printf "\t}\n}\n" + error = 0 + exit 0 + } + if (preverror + 1 != evalue) + exit 1 + preverror = evalue + printf "#ifdef %s\n", ename + printf "\tcase %d:\n\t\treturn %s;\n", evalue, ename + printf "#endif\n" +} +END { + exit error +}' < ../../../sys/errno.h +if [ $? -ne 0 ]; then + echo 'Parsing errno.h failed!' 1>&3 + rm -f rumpdefs.h rumperr.h rumperrno2host.h + exit 1 +fi + exit 0
CVS commit: src/sys/rump/include/rump
Module Name:src Committed By: pooka Date: Tue Sep 15 14:55:55 UTC 2015 Modified Files: src/sys/rump/include/rump: rumpdefs.h rumperr.h Added Files: src/sys/rump/include/rump: rumperrno2host.h Log Message: regen To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/rump/include/rump/rumpdefs.h cvs rdiff -u -r1.3 -r1.4 src/sys/rump/include/rump/rumperr.h cvs rdiff -u -r0 -r1.1 src/sys/rump/include/rump/rumperrno2host.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/rump/include/rump/rumpdefs.h diff -u src/sys/rump/include/rump/rumpdefs.h:1.32 src/sys/rump/include/rump/rumpdefs.h:1.33 --- src/sys/rump/include/rump/rumpdefs.h:1.32 Thu Sep 10 16:21:48 2015 +++ src/sys/rump/include/rump/rumpdefs.h Tue Sep 15 14:55:55 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: rumpdefs.h,v 1.32 2015/09/10 16:21:48 pooka Exp $ */ +/* $NetBSD: rumpdefs.h,v 1.33 2015/09/15 14:55:55 pooka Exp $ */ /* * AUTOMATICALLY GENERATED. DO NOT EDIT. Index: src/sys/rump/include/rump/rumperr.h diff -u src/sys/rump/include/rump/rumperr.h:1.3 src/sys/rump/include/rump/rumperr.h:1.4 --- src/sys/rump/include/rump/rumperr.h:1.3 Thu Sep 10 16:21:48 2015 +++ src/sys/rump/include/rump/rumperr.h Tue Sep 15 14:55:55 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: rumperr.h,v 1.3 2015/09/10 16:21:48 pooka Exp $ */ +/* $NetBSD: rumperr.h,v 1.4 2015/09/15 14:55:55 pooka Exp $ */ /* * AUTOMATICALLY GENERATED. DO NOT EDIT. Added files: Index: src/sys/rump/include/rump/rumperrno2host.h diff -u /dev/null src/sys/rump/include/rump/rumperrno2host.h:1.1 --- /dev/null Tue Sep 15 14:55:55 2015 +++ src/sys/rump/include/rump/rumperrno2host.h Tue Sep 15 14:55:55 2015 @@ -0,0 +1,411 @@ +/* $NetBSD: rumperrno2host.h,v 1.1 2015/09/15 14:55:55 pooka Exp $ */ + +/* + * AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* NetBSD: errno.h,v 1.40 2013/01/02 18:51:53 dsl Exp */ + +#ifndef ERANGE +#error include ISO C style errno.h first +#endif + +static inline int +rump_errno2host(int rumperrno) +{ + + switch (rumperrno) { + case 0: + return 0; +#ifdef EPERM + case 1: + return EPERM; +#endif +#ifdef ENOENT + case 2: + return ENOENT; +#endif +#ifdef ESRCH + case 3: + return ESRCH; +#endif +#ifdef EINTR + case 4: + return EINTR; +#endif +#ifdef EIO + case 5: + return EIO; +#endif +#ifdef ENXIO + case 6: + return ENXIO; +#endif +#ifdef E2BIG + case 7: + return E2BIG; +#endif +#ifdef ENOEXEC + case 8: + return ENOEXEC; +#endif +#ifdef EBADF + case 9: + return EBADF; +#endif +#ifdef ECHILD + case 10: + return ECHILD; +#endif +#ifdef EDEADLK + case 11: + return EDEADLK; +#endif +#ifdef ENOMEM + case 12: + return ENOMEM; +#endif +#ifdef EACCES + case 13: + return EACCES; +#endif +#ifdef EFAULT + case 14: + return EFAULT; +#endif +#ifdef ENOTBLK + case 15: + return ENOTBLK; +#endif +#ifdef EBUSY + case 16: + return EBUSY; +#endif +#ifdef EEXIST + case 17: + return EEXIST; +#endif +#ifdef EXDEV + case 18: + return EXDEV; +#endif +#ifdef ENODEV + case 19: + return ENODEV; +#endif +#ifdef ENOTDIR + case 20: + return ENOTDIR; +#endif +#ifdef EISDIR + case 21: + return EISDIR; +#endif +#ifdef EINVAL + case 22: + return EINVAL; +#endif +#ifdef ENFILE + case 23: + return ENFILE; +#endif +#ifdef EMFILE + case 24: + return EMFILE; +#endif +#ifdef ENOTTY + case 25: + return ENOTTY; +#endif +#ifdef ETXTBSY + case 26: + return ETXTBSY; +#endif +#ifdef EFBIG + case 27: + return EFBIG; +#endif +#ifdef ENOSPC + case 28: + return ENOSPC; +#endif +#ifdef ESPIPE + case 29: + return ESPIPE; +#endif +#ifdef EROFS + case 30: + return EROFS; +#endif +#ifdef EMLINK + case 31: + return EMLINK; +#endif +#ifdef EPIPE + case 32: + return EPIPE; +#endif +#ifdef EDOM + case 33: + return EDOM; +#endif +#ifdef ERANGE + case 34: + return ERANGE; +#endif +#ifdef EAGAIN + case 35: + return EAGAIN; +#endif +#ifdef EINPROGRESS + case 36: + return EINPROGRESS; +#endif +#ifdef EALREADY + case 37: + return EALREADY; +#endif +#ifdef ENOTSOCK + case 38: + return ENOTSOCK; +#endif +#ifdef EDESTADDRREQ + case 39: + return EDESTADDRREQ; +#endif +#ifdef EMSGSIZE + case 40: + return EMSGSIZE; +#endif +#ifdef EPROTOTYPE + case 41: + return EPROTOTYPE; +#endif +#ifdef ENOPROTOOPT + case 42: + return ENOPROTOOPT; +#endif +#ifdef EPROTONOSUPPORT + case 43: + return EPROTONOSUPPORT; +#endif +#ifdef ESOCKTNOSUPPORT + case 44: + return ESOCKTNOSUPPORT; +#endif +#ifdef EOPNOTSUPP + case 45: + return EOPNOTSUPP; +#endif +#ifdef EPFNOSUPPORT + case 46: + return EPFNOSUPPORT; +#endif +#ifdef EAFNOSUPPORT + case 47: + return EAFNOSUPPORT; +#endif +#ifdef EADDRINUSE + case 48: + return EADDRINUSE; +#endif +#ifdef EADDRNOTAVAIL + case 49: + return EADDRNOTAVAIL; +#endif +#ifdef ENETDOWN + case 50: + return ENETDOWN; +#endif +#ifdef ENETUNREACH + case 51: + return ENETUNREACH; +#endif +#ifdef ENETRESET + case 52: + return ENETRESET; +#endif +#ifdef ECONN
CVS commit: src
Module Name:src Committed By: dholland Date: Tue Sep 15 14:58:06 UTC 2015 Modified Files: src/sbin/fsck_lfs: dir.c inode.c pass2.c src/sbin/newfs_lfs: make_lfs.c src/sys/ufs/lfs: lfs.h lfs_accessors.h lfs_rename.c ulfs_dirhash.c ulfs_lookup.c ulfs_vnops.c Log Message: Add and use accessor functions for more of the directory entry fields. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sbin/fsck_lfs/dir.c cvs rdiff -u -r1.63 -r1.64 src/sbin/fsck_lfs/inode.c cvs rdiff -u -r1.27 -r1.28 src/sbin/fsck_lfs/pass2.c cvs rdiff -u -r1.49 -r1.50 src/sbin/newfs_lfs/make_lfs.c cvs rdiff -u -r1.185 -r1.186 src/sys/ufs/lfs/lfs.h cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/lfs/lfs_accessors.h cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/lfs/lfs_rename.c \ src/sys/ufs/lfs/ulfs_dirhash.c cvs rdiff -u -r1.26 -r1.27 src/sys/ufs/lfs/ulfs_lookup.c cvs rdiff -u -r1.28 -r1.29 src/sys/ufs/lfs/ulfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/fsck_lfs/dir.c diff -u src/sbin/fsck_lfs/dir.c:1.38 src/sbin/fsck_lfs/dir.c:1.39 --- src/sbin/fsck_lfs/dir.c:1.38 Tue Sep 1 06:16:58 2015 +++ src/sbin/fsck_lfs/dir.c Tue Sep 15 14:58:05 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.38 2015/09/01 06:16:58 dholland Exp $ */ +/* $NetBSD: dir.c,v 1.39 2015/09/15 14:58:05 dholland Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -154,7 +154,7 @@ dirscan(struct inodesc *idesc) vp = vget(fs, idesc->id_number); for (dp = fsck_readdir(vp, idesc); dp != NULL; dp = fsck_readdir(vp, idesc)) { - dsize = dp->d_reclen; + dsize = lfs_dir_getreclen(fs, dp); memcpy(dbuf, dp, (size_t) dsize); idesc->id_dirp = (struct lfs_direct *) dbuf; if ((n = (*idesc->id_func) (idesc)) & ALTERED) { @@ -193,8 +193,8 @@ fsck_readdir(struct uvnode *vp, struct i fix = dofix(idesc, "DIRECTORY CORRUPTED"); bread(vp, idesc->id_lblkno, blksiz, 0, &bp); dp = (struct lfs_direct *) (bp->b_data + idesc->id_loc); - dp->d_reclen = LFS_DIRBLKSIZ; - dp->d_ino = 0; + lfs_dir_setreclen(fs, dp, LFS_DIRBLKSIZ); + lfs_dir_setino(fs, dp, 0); lfs_dir_settype(fs, dp, LFS_DT_UNKNOWN); lfs_dir_setnamlen(fs, dp, 0); dp->d_name[0] = '\0'; @@ -213,8 +213,8 @@ dpok: } dploc = idesc->id_loc; dp = (struct lfs_direct *) (bp->b_data + dploc); - idesc->id_loc += dp->d_reclen; - idesc->id_filesize -= dp->d_reclen; + idesc->id_loc += lfs_dir_getreclen(fs, dp); + idesc->id_filesize -= lfs_dir_getreclen(fs, dp); if ((idesc->id_loc % LFS_DIRBLKSIZ) == 0) { brelse(bp, 0); return dp; @@ -231,7 +231,7 @@ dpok: fix = dofix(idesc, "DIRECTORY CORRUPTED"); bread(vp, idesc->id_lblkno, blksiz, 0, &bp); dp = (struct lfs_direct *) (bp->b_data + dploc); - dp->d_reclen += size; + lfs_dir_setreclen(fs, dp, lfs_dir_getreclen(fs, dp) + size); if (fix) VOP_BWRITE(bp); else @@ -255,23 +255,24 @@ dircheck(struct inodesc *idesc, struct l int spaceleft; spaceleft = LFS_DIRBLKSIZ - (idesc->id_loc % LFS_DIRBLKSIZ); - if (dp->d_ino >= maxino || - dp->d_reclen == 0 || - dp->d_reclen > spaceleft || - (dp->d_reclen & 0x3) != 0) { + if (lfs_dir_getino(fs, dp) >= maxino || + lfs_dir_getreclen(fs, dp) == 0 || + lfs_dir_getreclen(fs, dp) > spaceleft || + (lfs_dir_getreclen(fs, dp) & 0x3) != 0) { pwarn("ino too large, reclen=0, reclen>space, or reclen&3!=0\n"); - pwarn("dp->d_ino = 0x%x\tdp->d_reclen = 0x%x\n", - dp->d_ino, dp->d_reclen); - pwarn("maxino = %llu\tspaceleft = 0x%x\n", - (unsigned long long)maxino, spaceleft); + pwarn("dp->d_ino = 0x%jx\tdp->d_reclen = 0x%x\n", + (uintmax_t)lfs_dir_getino(fs, dp), + lfs_dir_getreclen(fs, dp)); + pwarn("maxino = %ju\tspaceleft = 0x%x\n", + (uintmax_t)maxino, spaceleft); return (0); } - if (dp->d_ino == 0) + if (lfs_dir_getino(fs, dp) == 0) return (1); size = LFS_DIRSIZ(fs, dp); namlen = lfs_dir_getnamlen(fs, dp); type = lfs_dir_gettype(fs, dp); - if (dp->d_reclen < size || + if (lfs_dir_getreclen(fs, dp) < size || idesc->id_filesize < size || /* namlen > MAXNAMLEN || */ type > 15) { @@ -374,17 +375,18 @@ mkentry(struct inodesc *idesc) namlen = strlen(idesc->id_name); lfs_dir_setnamlen(fs, &newent, namlen); newlen = LFS_DIRSIZ(fs, &newent); - if (dirp->d_ino != 0) + if (lfs_dir_getino(fs, dirp) != 0) oldlen = LFS_DIRSIZ(fs, dirp); else oldlen = 0; - if (dirp->d_reclen - oldlen < newlen) + if (lfs_dir_getreclen(fs, dirp) - oldlen < newlen) return (KEEPON); - newent.d_reclen = dirp->d_reclen - oldlen; - dirp->d_reclen = oldlen; + lfs_dir_setreclen(fs, &newent, lfs_dir_getreclen(fs, dirp) - oldlen); + lfs_dir_setreclen(fs, dirp, oldlen); dirp = (struct lfs_direct *) (((char *) dirp) + oldlen); - dirp->d_ino = idesc->id_parent; /* ino to be entered is in id_parent */ - dirp->d_reclen = newent.d_reclen; + /* ino to be entered is in id_parent */ +
CVS commit: src
Module Name:src Committed By: pooka Date: Tue Sep 15 14:57:35 UTC 2015 Modified Files: src/distrib/sets/lists/comp: mi src/sys/rump/include/rump: Makefile Log Message: install To generate a diff of this commit: cvs rdiff -u -r1.1987 -r1.1988 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.7 -r1.8 src/sys/rump/include/rump/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/comp/mi diff -u src/distrib/sets/lists/comp/mi:1.1987 src/distrib/sets/lists/comp/mi:1.1988 --- src/distrib/sets/lists/comp/mi:1.1987 Sun Sep 13 10:58:30 2015 +++ src/distrib/sets/lists/comp/mi Tue Sep 15 14:57:34 2015 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1987 2015/09/13 10:58:30 he Exp $ +# $NetBSD: mi,v 1.1988 2015/09/15 14:57:34 pooka Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -2658,6 +2658,7 @@ ./usr/include/rump/rumpclient.h comp-c-include rump ./usr/include/rump/rumpdefs.h comp-c-include rump ./usr/include/rump/rumperr.h comp-c-include rump +./usr/include/rump/rumperrno2host.h comp-c-include rump ./usr/include/rump/rumpkern_if_pub.h comp-c-include rump ./usr/include/rump/rumpnet_if_pub.h comp-c-include rump ./usr/include/rump/rumpuser.h comp-c-include rump Index: src/sys/rump/include/rump/Makefile diff -u src/sys/rump/include/rump/Makefile:1.7 src/sys/rump/include/rump/Makefile:1.8 --- src/sys/rump/include/rump/Makefile:1.7 Fri Apr 25 00:24:39 2014 +++ src/sys/rump/include/rump/Makefile Tue Sep 15 14:57:34 2015 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.7 2014/04/25 00:24:39 pooka Exp $ +# $NetBSD: Makefile,v 1.8 2015/09/15 14:57:34 pooka Exp $ .include @@ -6,7 +6,7 @@ INCSDIR= /usr/include/rump .if (${MKRUMP} != "no") INCS= rump.h rump_namei.h rump_syscalls.h rump_syscalls_compat.h -INCS+= rumpdefs.h rumperr.h rumpuser.h rumpvnode_if.h +INCS+= rumpdefs.h rumperr.h rumperrno2host.h rumpuser.h rumpvnode_if.h INCS+= rumpkern_if_pub.h rumpvfs_if_pub.h rumpnet_if_pub.h .endif
CVS commit: src/sys/ufs/lfs
Module Name:src Committed By: dholland Date: Tue Sep 15 15:00:32 UTC 2015 Modified Files: src/sys/ufs/lfs: lfs_rename.c lfs_vnops.c ulfs_extern.h ulfs_lookup.c ulfs_vnops.c Log Message: Kill off ulfs_makedirentry; just pass the data to ulfs_direnter instead. For now, move one copy of the code that allocates and fills in a temporary struct lfs_direct to the top of ulfs_direnter; but it should go away shortly. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/lfs/lfs_rename.c cvs rdiff -u -r1.289 -r1.290 src/sys/ufs/lfs/lfs_vnops.c cvs rdiff -u -r1.16 -r1.17 src/sys/ufs/lfs/ulfs_extern.h cvs rdiff -u -r1.27 -r1.28 src/sys/ufs/lfs/ulfs_lookup.c cvs rdiff -u -r1.29 -r1.30 src/sys/ufs/lfs/ulfs_vnops.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/ufs/lfs/lfs_rename.c diff -u src/sys/ufs/lfs/lfs_rename.c:1.10 src/sys/ufs/lfs/lfs_rename.c:1.11 --- src/sys/ufs/lfs/lfs_rename.c:1.10 Tue Sep 15 14:58:06 2015 +++ src/sys/ufs/lfs/lfs_rename.c Tue Sep 15 15:00:32 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_rename.c,v 1.10 2015/09/15 14:58:06 dholland Exp $ */ +/* $NetBSD: lfs_rename.c,v 1.11 2015/09/15 15:00:32 dholland Exp $ */ /* from NetBSD: ufs_rename.c,v 1.6 2013/01/22 09:39:18 dholland Exp */ /*- @@ -89,7 +89,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.10 2015/09/15 14:58:06 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.11 2015/09/15 15:00:32 dholland Exp $"); #include #include @@ -770,7 +770,6 @@ ulfs_gro_rename(struct mount *mp, kauth_ struct ulfs_lookup_results *fulr = fde; struct ulfs_lookup_results *tulr = tde; bool directory_p, reparent_p; - struct lfs_direct *newdir; int error; KASSERT(mp != NULL); @@ -871,10 +870,9 @@ ulfs_gro_rename(struct mount *mp, kauth_ } } - newdir = pool_cache_get(ulfs_direct_cache, PR_WAITOK); - ulfs_makedirentry(VTOI(fvp), tcnp, newdir); - error = ulfs_direnter(tdvp, tulr, NULL, newdir, tcnp, NULL); - pool_cache_put(ulfs_direct_cache, newdir); + error = ulfs_direnter(tdvp, tulr, + NULL, tcnp, VTOI(fvp)->i_number, LFS_IFTODT(VTOI(fvp)->i_mode), + NULL); if (error) { if (directory_p && reparent_p) { /* Index: src/sys/ufs/lfs/lfs_vnops.c diff -u src/sys/ufs/lfs/lfs_vnops.c:1.289 src/sys/ufs/lfs/lfs_vnops.c:1.290 --- src/sys/ufs/lfs/lfs_vnops.c:1.289 Tue Sep 1 06:16:59 2015 +++ src/sys/ufs/lfs/lfs_vnops.c Tue Sep 15 15:00:32 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_vnops.c,v 1.289 2015/09/01 06:16:59 dholland Exp $ */ +/* $NetBSD: lfs_vnops.c,v 1.290 2015/09/15 15:00:32 dholland Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -125,7 +125,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.289 2015/09/01 06:16:59 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.290 2015/09/15 15:00:32 dholland Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -858,7 +858,6 @@ lfs_mkdir(void *v) struct ulfs_lookup_results *ulr; struct buf *bp; struct lfs_dirtemplate dirtemplate; - struct lfs_direct *newdir; int dirblksiz; int error; @@ -963,10 +962,8 @@ lfs_mkdir(void *v) if ((error = lfs_update(tvp, NULL, NULL, UPDATE_DIROP)) != 0) { goto bad; } - newdir = pool_cache_get(ulfs_direct_cache, PR_WAITOK); - ulfs_makedirentry(ip, cnp, newdir); - error = ulfs_direnter(dvp, ulr, tvp, newdir, cnp, bp); - pool_cache_put(ulfs_direct_cache, newdir); + error = ulfs_direnter(dvp, ulr, tvp, + cnp, ip->i_number, LFS_IFTODT(ip->i_mode), bp); bad: if (error == 0) { VN_KNOTE(dvp, NOTE_WRITE | NOTE_LINK); Index: src/sys/ufs/lfs/ulfs_extern.h diff -u src/sys/ufs/lfs/ulfs_extern.h:1.16 src/sys/ufs/lfs/ulfs_extern.h:1.17 --- src/sys/ufs/lfs/ulfs_extern.h:1.16 Tue Sep 1 06:16:59 2015 +++ src/sys/ufs/lfs/ulfs_extern.h Tue Sep 15 15:00:32 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ulfs_extern.h,v 1.16 2015/09/01 06:16:59 dholland Exp $ */ +/* $NetBSD: ulfs_extern.h,v 1.17 2015/09/15 15:00:32 dholland Exp $ */ /* from NetBSD: ufs_extern.h,v 1.72 2012/05/09 00:21:18 riastradh Exp */ /*- @@ -112,13 +112,10 @@ int ulfs_balloc_range(struct vnode *, of /* ulfs_lookup.c */ void ulfs_dirbad(struct inode *, doff_t, const char *); int ulfs_dirbadentry(struct vnode *, struct lfs_direct *, int); -void ulfs_makedirentry(struct inode *, struct componentname *, - struct lfs_direct *); -void ulfs_makedirentry_bytype(struct lfs *, struct componentname *, - ino_t, unsigned /*dtype*/, struct lfs_direct *); int ulfs_direnter(struct vnode *, const struct ulfs_lookup_results *, - struct vnode *, struct lfs_direct *, - struct componentname *, struct buf *); + struct vnode *, + struct componentname *, ino_t, unsigned, + struct buf *); int ulfs_dirremove(struct vnode *, const struct ulfs_lookup_results *, struct inode *, int,
CVS commit: src
Module Name:src Committed By: dholland Date: Tue Sep 15 14:59:58 UTC 2015 Modified Files: src/sbin/newfs_lfs: make_lfs.c src/sys/ufs/lfs: lfs.h lfs_accessors.h Log Message: Move the header part of struct lfs_direct to its own structure. (lfs_dirheader) Take the opportunity to improve the directory generation code in make_lfs.c. (Everything else was unaffected by virtue of using accessor functions.) To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sbin/newfs_lfs/make_lfs.c cvs rdiff -u -r1.186 -r1.187 src/sys/ufs/lfs/lfs.h cvs rdiff -u -r1.23 -r1.24 src/sys/ufs/lfs/lfs_accessors.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/newfs_lfs/make_lfs.c diff -u src/sbin/newfs_lfs/make_lfs.c:1.50 src/sbin/newfs_lfs/make_lfs.c:1.51 --- src/sbin/newfs_lfs/make_lfs.c:1.50 Tue Sep 15 14:58:05 2015 +++ src/sbin/newfs_lfs/make_lfs.c Tue Sep 15 14:59:58 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: make_lfs.c,v 1.50 2015/09/15 14:58:05 dholland Exp $ */ +/* $NetBSD: make_lfs.c,v 1.51 2015/09/15 14:59:58 dholland Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ #if 0 static char sccsid[] = "@(#)lfs.c 8.5 (Berkeley) 5/24/95"; #else -__RCSID("$NetBSD: make_lfs.c,v 1.50 2015/09/15 14:58:05 dholland Exp $"); +__RCSID("$NetBSD: make_lfs.c,v 1.51 2015/09/15 14:59:58 dholland Exp $"); #endif #endif /* not lint */ @@ -242,63 +242,32 @@ static const struct lfs lfs_default; #define UMASK 0755 -struct lfs_direct lfs_root_dir[] = { - { - .d_ino = ULFS_ROOTINO, - .d_reclen = sizeof(struct lfs_direct), - .d_type = LFS_DT_DIR, - .d_namlen = 1, - .d_name = "." - }, - { - .d_ino = ULFS_ROOTINO, - .d_reclen = sizeof(struct lfs_direct), - .d_type = LFS_DT_DIR, - .d_namlen = 2, - .d_name = ".." - }, -/* - { - .d_ino = LFS_IFILE_INUM, - .d_reclen = sizeof(struct lfs_direct), - .d_type = LFS_DT_REG, - .d_namlen = 5, - .d_name = "ifile" - }, -*/ +struct dirproto { + ino_t dp_ino; + const char *dp_name; + unsigned dp_type; +}; + +static const struct dirproto lfs_root_dir[] = { + { ULFS_ROOTINO, ".", LFS_DT_DIR }, + { ULFS_ROOTINO, "..", LFS_DT_DIR }, + /*{ LFS_IFILE_INUM, "ifile", LFS_DT_REG },*/ #ifdef MAKE_LF_DIR - { - .d_ino = LOSTFOUNDINO, - .d_reclen = sizeof(struct lfs_direct), - .d_type = LFS_DT_DIR, - .d_namlen = 10, - .d_name = "lost+found" - }, + { LOSTFOUNDINO, "lost+found", LFS_DT_DIR }, #endif }; #ifdef MAKE_LF_DIR -struct lfs_direct lfs_lf_dir[] = { -{ - .d_ino = LOSTFOUNDINO, - .d_reclen = sizeof(struct lfs_direct), - .d_type = LFS_DT_DIR, - .d_reclen = 1, - .d_name = "." - }, -{ - .d_ino = ULFS_ROOTINO, - .d_reclen = sizeof(struct lfs_direct), - .d_type = LFS_DT_DIR, - .d_reclen = 2, - .d_name = ".." - }, +static const struct dirproto lfs_lf_dir[] = { +{ LOSTFOUNDINO, ".", LFS_DT_DIR }, + { ULFS_ROOTINO, "..", LFS_DT_DIR }, }; #endif void pwarn(const char *, ...); static void make_dinode(ino_t, union lfs_dinode *, int, struct lfs *); -static void make_dir(struct lfs *, void *, struct lfs_direct *, int); +static void make_dir(struct lfs *, void *, + const struct dirproto *, unsigned); static uint64_t maxfilesize(int); /* @@ -385,23 +354,42 @@ make_dinode(ino_t ino, union lfs_dinode * entries in protodir fit in the first DIRBLKSIZ. */ static void -make_dir(struct lfs *fs, void *bufp, struct lfs_direct *protodir, int entries) +make_dir(struct lfs *fs, void *bufp, +const struct dirproto *protodir, unsigned numentries) { - char *cp; - int i, spcleft; - unsigned reclen; - - spcleft = LFS_DIRBLKSIZ; - for (cp = bufp, i = 0; i < entries - 1; i++) { - reclen = LFS_DIRSIZ(fs, &protodir[i]); - lfs_dir_setreclen(fs, &protodir[i], reclen); - memmove(cp, &protodir[i], lfs_dir_getreclen(fs, &protodir[i])); - cp += reclen; - if ((spcleft -= reclen) < 0) + struct lfs_direct *ep; + unsigned spaceleft; + unsigned namlen, reclen; + unsigned i; + char *pad; + + spaceleft = LFS_DIRBLKSIZ; + ep = bufp; + for (i = 0; i < numentries; i++) { + namlen = strlen(protodir[i].dp_name); + reclen = LFS_DIRECTSIZ(namlen); + if (spaceleft < reclen) fatal("%s: %s", special, "directory too big"); + + /* Last entry includes all the free space. */ + if (i + 1 == numentries) { + reclen = spaceleft; + } + spaceleft -= reclen; + + lfs_dir_setino(fs, ep, protodir[i].dp_ino); + lfs_dir_setreclen(fs, ep, reclen); + lfs_dir_settype(fs, ep, protodir[i].dp_type); + lfs_dir_setnamlen(fs, ep, namlen); + memcpy(ep->d_name, protodir[i].dp_name, namlen); + pad = ep->d_name + namlen; + ep = LFS_NEXTDIR(fs, ep); + + while (pad < (char *)ep) { + *pad++ = '\0'; + } } - lfs_dir_setreclen(fs, &protodir[i], spcleft); - memmove(cp, &protodir[i], LFS_DIRSIZ(fs, &protodir[i])); + assert(spaceleft == 0); } int @@ -838,8 +826,7 @@ make_lfs(int devfd, uint secsize, struct VTOI(vp)->i_lfs_f
CVS commit: src/sys/ufs/lfs
Module Name:src Committed By: dholland Date: Tue Sep 15 15:00:49 UTC 2015 Modified Files: src/sys/ufs/lfs: ulfs_lookup.c Log Message: Tidy up ulfs_direnter: don't malloc a temporary struct lfs_direct and double-copy it. Just write to the destination buffer. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/ufs/lfs/ulfs_lookup.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/ufs/lfs/ulfs_lookup.c diff -u src/sys/ufs/lfs/ulfs_lookup.c:1.28 src/sys/ufs/lfs/ulfs_lookup.c:1.29 --- src/sys/ufs/lfs/ulfs_lookup.c:1.28 Tue Sep 15 15:00:32 2015 +++ src/sys/ufs/lfs/ulfs_lookup.c Tue Sep 15 15:00:49 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ulfs_lookup.c,v 1.28 2015/09/15 15:00:32 dholland Exp $ */ +/* $NetBSD: ulfs_lookup.c,v 1.29 2015/09/15 15:00:49 dholland Exp $ */ /* from NetBSD: ufs_lookup.c,v 1.122 2013/01/22 09:39:18 dholland Exp */ /* @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ulfs_lookup.c,v 1.28 2015/09/15 15:00:32 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ulfs_lookup.c,v 1.29 2015/09/15 15:00:49 dholland Exp $"); #ifdef _KERNEL_OPT #include "opt_lfs.h" @@ -696,26 +696,29 @@ bad: } /* - * Construct a new directory entry after a call to namei, using the - * name in the componentname argument cnp. The new directory entry - * will refer to inode INUM which has type (directory-level type) - * DTYPE. If adding a reference to an already-created or - * already-extant inode, these values are retrieved with: - * ip->i_number - * LFS_IFTODT(ip->i_mode) - * (The latter should be tidier. XXX) + * Assign the contents of directory entry DIRP, on volume FS. + * + * NAME/NAMLEN is the name, which is not necessarily null terminated. + * INUM is the inode number, and DTYPE is the type code (LFS_DT_*). + * + * Note that these values typically come from: + *cnp->cn_nameptr + *cnp->cn_namelen + *ip->i_number + *LFS_IFTODT(ip->i_mode) * * Does not set d_reclen. */ static void -ulfs_makedirentry_tmp(struct lfs *fs, struct componentname *cnp, -ino_t inum, unsigned dtype, struct lfs_direct *newdirp) +ulfs_direntry_assign(struct lfs *fs, struct lfs_direct *dirp, + const char *name, size_t namlen, + ino_t inum, unsigned dtype) { - lfs_dir_setino(fs, newdirp, inum); - memcpy(newdirp->d_name, cnp->cn_nameptr, (size_t)cnp->cn_namelen); - newdirp->d_name[cnp->cn_namelen] = '\0'; - lfs_dir_setnamlen(fs, newdirp, cnp->cn_namelen); - lfs_dir_settype(fs, newdirp, dtype); + lfs_dir_setino(fs, dirp, inum); + lfs_dir_setnamlen(fs, dirp, namlen); + lfs_dir_settype(fs, dirp, dtype); + memcpy(dirp->d_name, name, namlen); + dirp->d_name[namlen] = '\0'; } /* @@ -766,16 +769,19 @@ ulfs_direnter(struct vnode *dvp, const s struct ulfsmount *ump = VFSTOULFS(dvp->v_mount); struct lfs *fs = ump->um_lfs; int dirblksiz = fs->um_dirblksiz; - struct lfs_direct *dirp; - - dirp = pool_cache_get(ulfs_direct_cache, PR_WAITOK); - ulfs_makedirentry_tmp(fs, cnp, inum, dtype, dirp); + const char *name; + unsigned namlen, reclen; +#ifdef LFS_DIRHASH + int dohashadd; +#endif error = 0; + name = cnp->cn_nameptr; /* note: not null-terminated */ + namlen = cnp->cn_namelen; cr = cnp->cn_cred; dp = VTOI(dvp); - newentrysize = LFS_DIRSIZ(fs, dirp); + newentrysize = LFS_DIRECTSIZ(namlen); if (ulr->ulr_count == 0) { /* @@ -788,7 +794,6 @@ ulfs_direnter(struct vnode *dvp, const s panic("ulfs_direnter: newblk"); if ((error = lfs_balloc(dvp, (off_t)ulr->ulr_offset, dirblksiz, cr, B_CLRBUF | B_SYNC, &bp)) != 0) { - pool_cache_put(ulfs_direct_cache, dirp); return (error); } dp->i_size = ulr->ulr_offset + dirblksiz; @@ -796,11 +801,13 @@ ulfs_direnter(struct vnode *dvp, const s dp->i_flag |= IN_CHANGE | IN_UPDATE; uvm_vnp_setsize(dvp, dp->i_size); lfs_blkoff = ulr->ulr_offset & (ump->um_mountp->mnt_stat.f_iosize - 1); - memcpy((char *)bp->b_data + lfs_blkoff, dirp, newentrysize); + ep = (struct lfs_direct *)((char *)bp->b_data + lfs_blkoff); + ulfs_direntry_assign(fs, ep, name, namlen, inum, dtype); + lfs_dir_setreclen(fs, ep, dirblksiz); #ifdef LFS_DIRHASH if (dp->i_dirhash != NULL) { ulfsdirhash_newblk(dp, ulr->ulr_offset); - ulfsdirhash_add(dp, dirp, ulr->ulr_offset); + ulfsdirhash_add(dp, ep, ulr->ulr_offset); ulfsdirhash_checkblock(dp, (char *)bp->b_data + lfs_blkoff, ulr->ulr_offset); } @@ -808,7 +815,6 @@ ulfs_direnter(struct vnode *dvp, const s error = VOP_BWRITE(bp->b_vp, bp); vfs_timestamp(&ts); ret = lfs_update(dvp, &ts, &ts, UPDATE_DIROP); - pool_cache_put(ulfs_direct_cache, dirp); if (error == 0) return (ret); return (error); @@ -844,7 +850,6 @@ ulfs_direnter(struct vnode *dvp, const s */ error = ulfs_blkatoff(dvp, (off_t)ulr->ulr_offset, &dirbuf, &bp, true); if (error) { - pool_cache_put(ulfs_direct_cache, dirp); return (error);
CVS commit: src/sys/ufs/lfs
Module Name:src Committed By: dholland Date: Tue Sep 15 15:01:03 UTC 2015 Modified Files: src/sys/ufs/lfs: ulfs_extern.h ulfs_vfsops.c Log Message: Kill off the ulfs_direct_cache pool. We no longer allocate temporary struct directs, so we don't need a pool for them. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/ufs/lfs/ulfs_extern.h cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/lfs/ulfs_vfsops.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/ufs/lfs/ulfs_extern.h diff -u src/sys/ufs/lfs/ulfs_extern.h:1.17 src/sys/ufs/lfs/ulfs_extern.h:1.18 --- src/sys/ufs/lfs/ulfs_extern.h:1.17 Tue Sep 15 15:00:32 2015 +++ src/sys/ufs/lfs/ulfs_extern.h Tue Sep 15 15:01:03 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ulfs_extern.h,v 1.17 2015/09/15 15:00:32 dholland Exp $ */ +/* $NetBSD: ulfs_extern.h,v 1.18 2015/09/15 15:01:03 dholland Exp $ */ /* from NetBSD: ufs_extern.h,v 1.72 2012/05/09 00:21:18 riastradh Exp */ /*- @@ -58,8 +58,6 @@ struct uio; struct vattr; struct vnode; -extern pool_cache_t ulfs_direct_cache; /* memory pool for lfs_directs */ - __BEGIN_DECLS #define ulfs_abortop genfs_abortop int ulfs_access(void *); Index: src/sys/ufs/lfs/ulfs_vfsops.c diff -u src/sys/ufs/lfs/ulfs_vfsops.c:1.10 src/sys/ufs/lfs/ulfs_vfsops.c:1.11 --- src/sys/ufs/lfs/ulfs_vfsops.c:1.10 Tue Sep 1 06:16:59 2015 +++ src/sys/ufs/lfs/ulfs_vfsops.c Tue Sep 15 15:01:03 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ulfs_vfsops.c,v 1.10 2015/09/01 06:16:59 dholland Exp $ */ +/* $NetBSD: ulfs_vfsops.c,v 1.11 2015/09/15 15:01:03 dholland Exp $ */ /* from NetBSD: ufs_vfsops.c,v 1.52 2013/01/22 09:39:18 dholland Exp */ /* @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ulfs_vfsops.c,v 1.10 2015/09/01 06:16:59 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ulfs_vfsops.c,v 1.11 2015/09/15 15:01:03 dholland Exp $"); #if defined(_KERNEL_OPT) #include "opt_lfs.h" @@ -70,8 +70,6 @@ __KERNEL_RCSID(0, "$NetBSD: ulfs_vfsops. /* how many times ulfs_init() was called */ static int ulfs_initcount = 0; -pool_cache_t ulfs_direct_cache; - /* * Make a filesystem operational. * Nothing to do at the moment. @@ -247,9 +245,6 @@ ulfs_init(void) if (ulfs_initcount++ > 0) return; - ulfs_direct_cache = pool_cache_init(sizeof(struct lfs_direct), 0, 0, 0, - "ulfsdir", NULL, IPL_NONE, NULL, NULL, NULL); - #if defined(LFS_QUOTA) || defined(LFS_QUOTA2) lfs_dqinit(); #endif @@ -282,7 +277,6 @@ ulfs_done(void) #if defined(LFS_QUOTA) || defined(LFS_QUOTA2) lfs_dqdone(); #endif - pool_cache_destroy(ulfs_direct_cache); #ifdef LFS_DIRHASH ulfsdirhash_done(); #endif
CVS commit: src
Module Name:src Committed By: dholland Date: Tue Sep 15 15:01:38 UTC 2015 Modified Files: src/sbin/fsck_lfs: dir.c pass2.c src/sbin/newfs_lfs: make_lfs.c src/sys/ufs/lfs: lfs_accessors.h Log Message: Add a function lfs_copydirname() to copy directory names in place; use it in place of (variously) memcpy and strlcpy. (The latter isn't even correct; was probably changed blindly from strncpy at some point.) The new function zeroes the padding in the directory entry instead of leaving trash behind. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sbin/fsck_lfs/dir.c cvs rdiff -u -r1.29 -r1.30 src/sbin/fsck_lfs/pass2.c cvs rdiff -u -r1.51 -r1.52 src/sbin/newfs_lfs/make_lfs.c cvs rdiff -u -r1.24 -r1.25 src/sys/ufs/lfs/lfs_accessors.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/fsck_lfs/dir.c diff -u src/sbin/fsck_lfs/dir.c:1.40 src/sbin/fsck_lfs/dir.c:1.41 --- src/sbin/fsck_lfs/dir.c:1.40 Tue Sep 15 15:01:22 2015 +++ src/sbin/fsck_lfs/dir.c Tue Sep 15 15:01:38 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.40 2015/09/15 15:01:22 dholland Exp $ */ +/* $NetBSD: dir.c,v 1.41 2015/09/15 15:01:38 dholland Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -198,6 +198,7 @@ fsck_readdir(struct uvnode *vp, struct i lfs_dir_setnamlen(fs, dp, 0); lfs_dir_setreclen(fs, dp, LFS_DIRBLKSIZ); /* for now at least, don't zero the old contents */ + /*lfs_copydirname(fs, dp->d_name, "", 0, LFS_DIRBLKSIZ);*/ dp->d_name[0] = '\0'; if (fix) VOP_BWRITE(bp); @@ -399,7 +400,9 @@ mkentry(struct inodesc *idesc) lfs_dir_setreclen(fs, dirp, newreclen); lfs_dir_settype(fs, dirp, typemap[idesc->id_parent]); lfs_dir_setnamlen(fs, dirp, namlen); - memcpy(dirp->d_name, idesc->id_name, (size_t)namlen + 1); + lfs_copydirname(fs, dirp->d_name, idesc->id_name, + namlen, newreclen); + return (ALTERED | STOP); } Index: src/sbin/fsck_lfs/pass2.c diff -u src/sbin/fsck_lfs/pass2.c:1.29 src/sbin/fsck_lfs/pass2.c:1.30 --- src/sbin/fsck_lfs/pass2.c:1.29 Tue Sep 15 15:01:22 2015 +++ src/sbin/fsck_lfs/pass2.c Tue Sep 15 15:01:38 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: pass2.c,v 1.29 2015/09/15 15:01:22 dholland Exp $ */ +/* $NetBSD: pass2.c,v 1.30 2015/09/15 15:01:38 dholland Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -258,16 +258,16 @@ pass2check(struct inodesc * idesc) /* convert this entry to a . entry */ lfs_dir_setreclen(fs, &proto, lfs_dir_getreclen(fs, dirp)); memcpy(dirp, &proto, sizeof(proto)); - /* 4 is entrysize - headersize (XXX: clean up) */ - (void) strlcpy(dirp->d_name, ".", 4); + lfs_copydirname(fs, dirp->d_name, ".", 1, +lfs_dir_getreclen(fs, dirp)); if (reply("FIX") == 1) ret |= ALTERED; } else { /* split this entry and use the beginning for the . entry */ n = lfs_dir_getreclen(fs, dirp) - entrysize; memcpy(dirp, &proto, sizeof(proto)); - /* XXX see case above */ - (void) strlcpy(dirp->d_name, ".", 4); + lfs_copydirname(fs, dirp->d_name, ".", 1, +lfs_dir_getreclen(fs, dirp)); idesc->id_entryno++; lncntp[lfs_dir_getino(fs, dirp)]--; dirp = LFS_NEXTDIR(fs, dirp); @@ -324,8 +324,8 @@ chk1: fileerror(inp->i_parent, idesc->id_number, "MISSING '..'"); lfs_dir_setreclen(fs, &proto, lfs_dir_getreclen(fs, dirp)); memcpy(dirp, &proto, (size_t) entrysize); - /* 4 is entrysize - headersize (XXX: clean up) */ - (void) strlcpy(proto.d_name, "..", 4); + lfs_copydirname(fs, dirp->d_name, "..", 2, +lfs_dir_getreclen(fs, dirp)); if (reply("FIX") == 1) ret |= ALTERED; } Index: src/sbin/newfs_lfs/make_lfs.c diff -u src/sbin/newfs_lfs/make_lfs.c:1.51 src/sbin/newfs_lfs/make_lfs.c:1.52 --- src/sbin/newfs_lfs/make_lfs.c:1.51 Tue Sep 15 14:59:58 2015 +++ src/sbin/newfs_lfs/make_lfs.c Tue Sep 15 15:01:38 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: make_lfs.c,v 1.51 2015/09/15 14:59:58 dholland Exp $ */ +/* $NetBSD: make_lfs.c,v 1.52 2015/09/15 15:01:38 dholland Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ #if 0 static char sccsid[] = "@(#)lfs.c 8.5 (Berkeley) 5/24/95"; #else -__RCSID("$NetBSD: make_lfs.c,v 1.51 2015/09/15 14:59:58 dholland Exp $"); +__RCSID("$NetBSD: make_lfs.c,v 1.52 2015/09/15 15:01:38 dholland Exp $"); #endif #endif /* not lint */ @@ -361,7 +361,6 @@ make_dir(struct lfs *fs, void *bufp, unsigned spaceleft; unsigned namlen, reclen; unsigned i; - char *pad; spaceleft = LFS_DIRBLKSIZ; ep = bufp; @@ -381,13 +380,9 @@ make_dir(struct lfs *fs, void *bufp, lfs_dir_setreclen(fs, ep, reclen); lfs_dir_settype(fs, ep, protodir[i].dp_type); lfs_dir_setnamlen(fs, ep, namlen); - memcpy(ep->d_name, protodir[i].dp_name, namlen); - pad = ep->d_name + namlen; + lfs_copydirname(fs, ep->d_name, protodir[i].dp_name, +namlen, reclen); ep = LFS_NEXTDIR(fs, ep); - - while (pad < (char *)ep) { - *pad++ = '\0'; - } } asse
CVS commit: src
Module Name:src Committed By: dholland Date: Tue Sep 15 15:01:22 UTC 2015 Modified Files: src/sbin/fsck_lfs: dir.c inode.c pass2.c src/sys/ufs/lfs: ulfs_lookup.c Log Message: Tidyups/fixes preparatory to making d_name[] in struct lfs_direct size 0 instead of size LFS_MAXNAMLEN+1, and preparatory to having accessor functions for d_name. In particular, don't create prototype entries and copy them, and access the name field only for directory structures that are in buffers with space for the name to exist. To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sbin/fsck_lfs/dir.c cvs rdiff -u -r1.64 -r1.65 src/sbin/fsck_lfs/inode.c cvs rdiff -u -r1.28 -r1.29 src/sbin/fsck_lfs/pass2.c cvs rdiff -u -r1.29 -r1.30 src/sys/ufs/lfs/ulfs_lookup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/fsck_lfs/dir.c diff -u src/sbin/fsck_lfs/dir.c:1.39 src/sbin/fsck_lfs/dir.c:1.40 --- src/sbin/fsck_lfs/dir.c:1.39 Tue Sep 15 14:58:05 2015 +++ src/sbin/fsck_lfs/dir.c Tue Sep 15 15:01:22 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.39 2015/09/15 14:58:05 dholland Exp $ */ +/* $NetBSD: dir.c,v 1.40 2015/09/15 15:01:22 dholland Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -193,10 +193,11 @@ fsck_readdir(struct uvnode *vp, struct i fix = dofix(idesc, "DIRECTORY CORRUPTED"); bread(vp, idesc->id_lblkno, blksiz, 0, &bp); dp = (struct lfs_direct *) (bp->b_data + idesc->id_loc); - lfs_dir_setreclen(fs, dp, LFS_DIRBLKSIZ); lfs_dir_setino(fs, dp, 0); lfs_dir_settype(fs, dp, LFS_DT_UNKNOWN); lfs_dir_setnamlen(fs, dp, 0); + lfs_dir_setreclen(fs, dp, LFS_DIRBLKSIZ); + /* for now at least, don't zero the old contents */ dp->d_name[0] = '\0'; if (fix) VOP_BWRITE(bp); @@ -250,7 +251,7 @@ int dircheck(struct inodesc *idesc, struct lfs_direct *dp) { int size; - char *cp; + const char *cp; u_char namlen, type; int spaceleft; @@ -279,7 +280,8 @@ dircheck(struct inodesc *idesc, struct l printf("reclen15\n"); return (0); } - for (cp = dp->d_name, size = 0; size < namlen; size++) + cp = dp->d_name; + for (size = 0; size < namlen; size++) if (*cp == '\0' || (*cp++ == '/')) { printf("name contains NUL or /\n"); return (0); @@ -368,25 +370,33 @@ static int mkentry(struct inodesc *idesc) { struct lfs_direct *dirp = idesc->id_dirp; - struct lfs_direct newent; unsigned namlen; - int newlen, oldlen; + unsigned newreclen, oldreclen; + /* figure the length needed for id_name */ namlen = strlen(idesc->id_name); - lfs_dir_setnamlen(fs, &newent, namlen); - newlen = LFS_DIRSIZ(fs, &newent); + newreclen = LFS_DIRECTSIZ(namlen); + + /* find the minimum record length for the existing name */ if (lfs_dir_getino(fs, dirp) != 0) - oldlen = LFS_DIRSIZ(fs, dirp); + oldreclen = LFS_DIRSIZ(fs, dirp); else - oldlen = 0; - if (lfs_dir_getreclen(fs, dirp) - oldlen < newlen) + oldreclen = 0; + + /* Can we insert here? */ + if (lfs_dir_getreclen(fs, dirp) - oldreclen < newreclen) return (KEEPON); - lfs_dir_setreclen(fs, &newent, lfs_dir_getreclen(fs, dirp) - oldlen); - lfs_dir_setreclen(fs, dirp, oldlen); - dirp = (struct lfs_direct *) (((char *) dirp) + oldlen); - /* ino to be entered is in id_parent */ + + /* Divide the record; all but oldreclen goes to the new record */ + newreclen = lfs_dir_getreclen(fs, dirp) - oldreclen; + lfs_dir_setreclen(fs, dirp, oldreclen); + + /* advance the pointer to the new record */ + dirp = LFS_NEXTDIR(fs, dirp); + + /* write record; ino to be entered is in id_parent */ lfs_dir_setino(fs, dirp, idesc->id_parent); - lfs_dir_setreclen(fs, dirp, lfs_dir_getreclen(fs, &newent)); + lfs_dir_setreclen(fs, dirp, newreclen); lfs_dir_settype(fs, dirp, typemap[idesc->id_parent]); lfs_dir_setnamlen(fs, dirp, namlen); memcpy(dirp->d_name, idesc->id_name, (size_t)namlen + 1); Index: src/sbin/fsck_lfs/inode.c diff -u src/sbin/fsck_lfs/inode.c:1.64 src/sbin/fsck_lfs/inode.c:1.65 --- src/sbin/fsck_lfs/inode.c:1.64 Tue Sep 15 14:58:05 2015 +++ src/sbin/fsck_lfs/inode.c Tue Sep 15 15:01:22 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: inode.c,v 1.64 2015/09/15 14:58:05 dholland Exp $ */ +/* $NetBSD: inode.c,v 1.65 2015/09/15 15:01:22 dholland Exp $ */ /*- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -508,7 +508,6 @@ findname(struct inodesc * idesc) if (lfs_dir_getino(fs, dirp) != idesc->id_parent) return (KEEPON); len = lfs_dir_getnamlen(fs, dirp) + 1; - /* XXX this is wrong: namlen+1 can be up to MAXPATHLEN+1 */ if (len > MAXPATHLEN) { /* Truncate it but don't overflow the buffer */ /* XXX: this case doesn't null-terminate the result */ Index: src/sbin/fsck_lfs/pass2.c diff -u src/sbin/fsck_lfs/pass2.c:1.28 src/sbin/fsck_lfs/pass2.c:1.29 --- src/sbin/fsck_lfs/pass2.c:1.28 Tue Sep 15 14:58:05 2015 +++ src/sbin/fsck_lfs/pass2.c Tue Sep 15 15:01:22 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: pass2.c,v 1.28 2015
CVS commit: src
Module Name:src Committed By: dholland Date: Tue Sep 15 15:02:01 UTC 2015 Modified Files: src/sbin/fsck_lfs: dir.c inode.c pass2.c src/sbin/newfs_lfs: make_lfs.c src/sys/ufs/lfs: lfs.h lfs_accessors.h lfs_rename.c ulfs_dirhash.c ulfs_lookup.c ulfs_vnops.c Log Message: Add an accessor function for directory names. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sbin/fsck_lfs/dir.c cvs rdiff -u -r1.65 -r1.66 src/sbin/fsck_lfs/inode.c cvs rdiff -u -r1.30 -r1.31 src/sbin/fsck_lfs/pass2.c cvs rdiff -u -r1.52 -r1.53 src/sbin/newfs_lfs/make_lfs.c cvs rdiff -u -r1.187 -r1.188 src/sys/ufs/lfs/lfs.h cvs rdiff -u -r1.25 -r1.26 src/sys/ufs/lfs/lfs_accessors.h cvs rdiff -u -r1.11 -r1.12 src/sys/ufs/lfs/lfs_rename.c cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/lfs/ulfs_dirhash.c cvs rdiff -u -r1.30 -r1.31 src/sys/ufs/lfs/ulfs_lookup.c \ src/sys/ufs/lfs/ulfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/fsck_lfs/dir.c diff -u src/sbin/fsck_lfs/dir.c:1.41 src/sbin/fsck_lfs/dir.c:1.42 --- src/sbin/fsck_lfs/dir.c:1.41 Tue Sep 15 15:01:38 2015 +++ src/sbin/fsck_lfs/dir.c Tue Sep 15 15:02:01 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.41 2015/09/15 15:01:38 dholland Exp $ */ +/* $NetBSD: dir.c,v 1.42 2015/09/15 15:02:01 dholland Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -198,8 +198,8 @@ fsck_readdir(struct uvnode *vp, struct i lfs_dir_setnamlen(fs, dp, 0); lfs_dir_setreclen(fs, dp, LFS_DIRBLKSIZ); /* for now at least, don't zero the old contents */ - /*lfs_copydirname(fs, dp->d_name, "", 0, LFS_DIRBLKSIZ);*/ - dp->d_name[0] = '\0'; + /*lfs_copydirname(fs, lfs_dir_nameptr(fs, dp), "", 0, LFS_DIRBLKSIZ);*/ + lfs_dir_nameptr(fs, dp)[0] = '\0'; if (fix) VOP_BWRITE(bp); else @@ -281,7 +281,7 @@ dircheck(struct inodesc *idesc, struct l printf("reclen15\n"); return (0); } - cp = dp->d_name; + cp = lfs_dir_nameptr(fs, dp); for (size = 0; size < namlen; size++) if (*cp == '\0' || (*cp++ == '/')) { printf("name contains NUL or /\n"); @@ -400,7 +400,7 @@ mkentry(struct inodesc *idesc) lfs_dir_setreclen(fs, dirp, newreclen); lfs_dir_settype(fs, dirp, typemap[idesc->id_parent]); lfs_dir_setnamlen(fs, dirp, namlen); - lfs_copydirname(fs, dirp->d_name, idesc->id_name, + lfs_copydirname(fs, lfs_dir_nameptr(fs, dirp), idesc->id_name, namlen, newreclen); return (ALTERED | STOP); @@ -413,7 +413,7 @@ chgino(struct inodesc *idesc) int namlen; namlen = lfs_dir_getnamlen(fs, dirp); - if (memcmp(dirp->d_name, idesc->id_name, namlen + 1)) + if (memcmp(lfs_dir_nameptr(fs, dirp), idesc->id_name, namlen + 1)) return (KEEPON); lfs_dir_setino(fs, dirp, idesc->id_parent); lfs_dir_settype(fs, dirp, typemap[idesc->id_parent]); Index: src/sbin/fsck_lfs/inode.c diff -u src/sbin/fsck_lfs/inode.c:1.65 src/sbin/fsck_lfs/inode.c:1.66 --- src/sbin/fsck_lfs/inode.c:1.65 Tue Sep 15 15:01:22 2015 +++ src/sbin/fsck_lfs/inode.c Tue Sep 15 15:02:01 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: inode.c,v 1.65 2015/09/15 15:01:22 dholland Exp $ */ +/* $NetBSD: inode.c,v 1.66 2015/09/15 15:02:01 dholland Exp $ */ /*- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -515,7 +515,7 @@ findname(struct inodesc * idesc) } /* this is namebuf with utils.h */ buf = __UNCONST(idesc->id_name); - (void)memcpy(buf, dirp->d_name, len); + (void)memcpy(buf, lfs_dir_nameptr(fs, dirp), len); return (STOP | FOUND); } @@ -528,7 +528,7 @@ findino(struct inodesc * idesc) ino = lfs_dir_getino(fs, dirp); if (ino == 0) return (KEEPON); - if (strcmp(dirp->d_name, idesc->id_name) == 0 && + if (strcmp(lfs_dir_nameptr(fs, dirp), idesc->id_name) == 0 && ino >= ULFS_ROOTINO && ino < maxino) { idesc->id_parent = ino; return (STOP | FOUND); Index: src/sbin/fsck_lfs/pass2.c diff -u src/sbin/fsck_lfs/pass2.c:1.30 src/sbin/fsck_lfs/pass2.c:1.31 --- src/sbin/fsck_lfs/pass2.c:1.30 Tue Sep 15 15:01:38 2015 +++ src/sbin/fsck_lfs/pass2.c Tue Sep 15 15:02:01 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: pass2.c,v 1.30 2015/09/15 15:01:38 dholland Exp $ */ +/* $NetBSD: pass2.c,v 1.31 2015/09/15 15:02:01 dholland Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -226,7 +226,7 @@ pass2check(struct inodesc * idesc) */ if (idesc->id_entryno != 0) goto chk1; - if (lfs_dir_getino(fs, dirp) != 0 && strcmp(dirp->d_name, ".") == 0) { + if (lfs_dir_getino(fs, dirp) != 0 && strcmp(lfs_dir_nameptr(fs, dirp), ".") == 0) { if (lfs_dir_getino(fs, dirp) != idesc->id_number) { direrror(idesc->id_number, "BAD INODE NUMBER FOR '.'"); if (reply("FIX") == 1) { @@ -249,16 +249,16 @@ pass2check(struct inodesc * idesc) lfs_dir_setnamlen(fs, &proto, 1); entrysize = LFS_DIRECTSIZ(1); lfs_dir_setreclen(fs, &proto, entrysize); - if (lfs_dir_getino(fs, dirp) != 0 && strcmp(dirp->d_name, "..") != 0) { + if (lfs_dir_getino(fs, dirp) != 0
CVS commit: src
Module Name:src Committed By: dholland Date: Tue Sep 15 15:02:26 UTC 2015 Modified Files: src/sbin/fsck_lfs: dir.c extern.h fsck.h inode.c pass2.c src/sbin/newfs_lfs: make_lfs.c src/sys/ufs/lfs: lfs_accessors.h lfs_rename.c ulfs_dirhash.c ulfs_dirhash.h ulfs_extern.h ulfs_lookup.c ulfs_vnops.c Log Message: Pass around struct lfs_dirheader instead of struct lfs_direct. To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sbin/fsck_lfs/dir.c cvs rdiff -u -r1.12 -r1.13 src/sbin/fsck_lfs/extern.h cvs rdiff -u -r1.21 -r1.22 src/sbin/fsck_lfs/fsck.h cvs rdiff -u -r1.66 -r1.67 src/sbin/fsck_lfs/inode.c cvs rdiff -u -r1.31 -r1.32 src/sbin/fsck_lfs/pass2.c cvs rdiff -u -r1.53 -r1.54 src/sbin/newfs_lfs/make_lfs.c cvs rdiff -u -r1.26 -r1.27 src/sys/ufs/lfs/lfs_accessors.h cvs rdiff -u -r1.12 -r1.13 src/sys/ufs/lfs/lfs_rename.c cvs rdiff -u -r1.11 -r1.12 src/sys/ufs/lfs/ulfs_dirhash.c cvs rdiff -u -r1.5 -r1.6 src/sys/ufs/lfs/ulfs_dirhash.h cvs rdiff -u -r1.18 -r1.19 src/sys/ufs/lfs/ulfs_extern.h cvs rdiff -u -r1.31 -r1.32 src/sys/ufs/lfs/ulfs_lookup.c \ src/sys/ufs/lfs/ulfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/fsck_lfs/dir.c diff -u src/sbin/fsck_lfs/dir.c:1.42 src/sbin/fsck_lfs/dir.c:1.43 --- src/sbin/fsck_lfs/dir.c:1.42 Tue Sep 15 15:02:01 2015 +++ src/sbin/fsck_lfs/dir.c Tue Sep 15 15:02:25 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.42 2015/09/15 15:02:01 dholland Exp $ */ +/* $NetBSD: dir.c,v 1.43 2015/09/15 15:02:25 dholland Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -85,7 +85,7 @@ struct lfs_odirtemplate odirhead = { static int expanddir(struct uvnode *, union lfs_dinode *, char *); static void freedir(ino_t, ino_t); -static struct lfs_direct *fsck_readdir(struct uvnode *, struct inodesc *); +static struct lfs_dirheader *fsck_readdir(struct uvnode *, struct inodesc *); static int lftempname(char *, ino_t); static int mkentry(struct inodesc *); static int chgino(struct inodesc *); @@ -132,7 +132,7 @@ propagate(void) int dirscan(struct inodesc *idesc) { - struct lfs_direct *dp; + struct lfs_dirheader *dp; struct ubuf *bp; int dsize, n; long blksiz; @@ -156,7 +156,7 @@ dirscan(struct inodesc *idesc) dp = fsck_readdir(vp, idesc)) { dsize = lfs_dir_getreclen(fs, dp); memcpy(dbuf, dp, (size_t) dsize); - idesc->id_dirp = (struct lfs_direct *) dbuf; + idesc->id_dirp = (struct lfs_dirheader *) dbuf; if ((n = (*idesc->id_func) (idesc)) & ALTERED) { bread(vp, idesc->id_lblkno, blksiz, 0, &bp); memcpy(bp->b_data + idesc->id_loc - dsize, dbuf, @@ -173,10 +173,10 @@ dirscan(struct inodesc *idesc) /* * get next entry in a directory. */ -static struct lfs_direct * +static struct lfs_dirheader * fsck_readdir(struct uvnode *vp, struct inodesc *idesc) { - struct lfs_direct *dp, *ndp; + struct lfs_dirheader *dp, *ndp; struct ubuf *bp; long size, blksiz, fix, dploc; @@ -184,7 +184,7 @@ fsck_readdir(struct uvnode *vp, struct i bread(vp, idesc->id_lblkno, blksiz, 0, &bp); if (idesc->id_loc % LFS_DIRBLKSIZ == 0 && idesc->id_filesize > 0 && idesc->id_loc < blksiz) { - dp = (struct lfs_direct *) (bp->b_data + idesc->id_loc); + dp = (struct lfs_dirheader *) (bp->b_data + idesc->id_loc); if (dircheck(idesc, dp)) goto dpok; brelse(bp, 0); @@ -192,7 +192,7 @@ fsck_readdir(struct uvnode *vp, struct i return (0); fix = dofix(idesc, "DIRECTORY CORRUPTED"); bread(vp, idesc->id_lblkno, blksiz, 0, &bp); - dp = (struct lfs_direct *) (bp->b_data + idesc->id_loc); + dp = (struct lfs_dirheader *) (bp->b_data + idesc->id_loc); lfs_dir_setino(fs, dp, 0); lfs_dir_settype(fs, dp, LFS_DT_UNKNOWN); lfs_dir_setnamlen(fs, dp, 0); @@ -214,14 +214,14 @@ dpok: return NULL; } dploc = idesc->id_loc; - dp = (struct lfs_direct *) (bp->b_data + dploc); + dp = (struct lfs_dirheader *) (bp->b_data + dploc); idesc->id_loc += lfs_dir_getreclen(fs, dp); idesc->id_filesize -= lfs_dir_getreclen(fs, dp); if ((idesc->id_loc % LFS_DIRBLKSIZ) == 0) { brelse(bp, 0); return dp; } - ndp = (struct lfs_direct *) (bp->b_data + idesc->id_loc); + ndp = (struct lfs_dirheader *) (bp->b_data + idesc->id_loc); if (idesc->id_loc < blksiz && idesc->id_filesize > 0 && dircheck(idesc, ndp) == 0) { brelse(bp, 0); @@ -232,7 +232,7 @@ dpok: return 0; fix = dofix(idesc, "DIRECTORY CORRUPTED"); bread(vp, idesc->id_lblkno, blksiz, 0, &bp); - dp = (struct lfs_direct *) (bp->b_data + dploc); + dp = (struct lfs_dirheader *) (bp->b_data + dploc); lfs_dir_setreclen(fs, dp, lfs_dir_getreclen(fs, dp) + size); if (fix) VOP_BWRITE(bp); @@ -249,7 +249,7 @@ dpok: * This is a superset of the checks made in the kernel. */ int -dircheck(struct inodesc *idesc, struct lfs_direct *dp) +dircheck(struct inodesc *idesc, struct lfs_dirheader *dp) { int size; cons
CVS commit: src/sys/ufs/lfs
Module Name:src Committed By: dholland Date: Tue Sep 15 15:02:40 UTC 2015 Modified Files: src/sys/ufs/lfs: lfs.h Log Message: Remove struct lfs_direct (no longer used) and update the big block comment about directories. To generate a diff of this commit: cvs rdiff -u -r1.188 -r1.189 src/sys/ufs/lfs/lfs.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/ufs/lfs/lfs.h diff -u src/sys/ufs/lfs/lfs.h:1.188 src/sys/ufs/lfs/lfs.h:1.189 --- src/sys/ufs/lfs/lfs.h:1.188 Tue Sep 15 15:02:01 2015 +++ src/sys/ufs/lfs/lfs.h Tue Sep 15 15:02:40 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: lfs.h,v 1.188 2015/09/15 15:02:01 dholland Exp $ */ +/* $NetBSD: lfs.h,v 1.189 2015/09/15 15:02:40 dholland Exp $ */ /* from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp */ /* from NetBSD: dir.h,v 1.21 2009/07/22 04:49:19 dholland Exp */ @@ -228,15 +228,15 @@ * All strings include a null terminator; the maximum string length * is LFS_MAXNAMLEN, which is 255. * - * The directory entry structure (struct lfs_direct) includes both the - * header and a maximal string. A real entry is potentially smaller; - * this causes assorted complications and hazards. For example, if - * pointing at the last entry in a directory block, in most cases the - * end of the struct lfs_direct will be off the end of the block - * buffer and pointing into some other memory (or into the void); thus - * one must never e.g. assign structures directly or do anything that - * accesses the name field beyond the real length stored in the - * header. + * The directory entry header structure (struct lfs_dirheader) is just + * the header information. A complete entry is this plus a null- + * terminated name following it, plus some amount of padding. The + * length of the name (not including the null terminator) is given by + * the namlen field of the header; the complete record length, + * including the null terminator and padding, is given by the reclen + * field of the header. The record length is always 4-byte aligned. + * (Even on 64-bit volumes, the record length is only 4-byte aligned, + * not 8-byte.) * * Historically, FFS directories were/are organized into blocks of * size DIRBLKSIZE that can be written atomically to disk at the @@ -263,6 +263,8 @@ *- any particular entry may be arbitrarily larger (which is why the * header stores both the entry size and the name size) to pad out * unused space. + *- historically the padding in an entry is not necessarily zeroed + * but may contain trash. *- dp->d_reclen is the size of the entry. This is always 4-byte * aligned. *- dp->d_namlen is the length of the string, and should always be @@ -276,56 +278,37 @@ * removed their space is merged into the entry ahead of them. *- an empty/unused entry has d_ino set to 0. This normally only * appears in the first entry in a block, as elsewhere the unused - * entry should have been merged into the one before it. + * entry should have been merged into the one before it. However, + * fsck leaves such entries behind so they must be tolerated + * elsewhere. *- a completely empty directory block has one entry whose * d_reclen is DIRBLKSIZ and whose d_ino is 0. * - * LFS_OLDDIRFMT and LFS_NEWDIRFMT are code numbers for a directory - * format change that happened in ffs a long time ago. This was in the - * 80s, if I'm not mistaken, and well before LFS was first written, so - * there should be no LFS volumes (and certainly no LFS v2-format - * volumes, or LFS64 volumes) where LFS_OLDDIRFMT pertains. All the - * same, we get to carry the logic around until we can conclusively - * demonstrate that it's never needed. - * - * Note that these code numbers do not appear on disk. They're - * generated from runtime logic that is cued by other things, which is - * why LFS_OLDDIRFMT is confusingly 1 and LFS_NEWDIRFMT is confusingly - * 0. - * - * Relatedly, the byte swapping logic for directories we have, which - * is derived from the FFS_EI code, is a horrible mess. For example, - * to access the namlen field, one does the following: - * - * #if (BYTE_ORDER == LITTLE_ENDIAN) - * swap = (ULFS_IPNEEDSWAP(VTOI(vp)) == 0); - * #else - * swap = (ULFS_IPNEEDSWAP(VTOI(vp)) != 0); - * #endif - * return ((FSFMT(vp) && swap)? ep->d_type : ep->d_namlen); - * - * ULFS_IPNEEDSWAP() is the same as fetching fs->lfs_dobyteswap. This - * horrible "swap" logic is cutpasted all over everywhere but amounts - * to the following: - * - *running code volume lfs_dobyteswap "swap" - *-- - *LITTLE_ENDIAN LITTLE_ENDIAN false true - *LITTLE_ENDIAN BIG_ENDIAN truefalse - *BIG_ENDIANLITTLE_ENDIAN truetrue - *BIG
CVS commit: src/sys/rump/librump/rumpkern
Module Name:src Committed By: pooka Date: Tue Sep 15 15:09:11 UTC 2015 Modified Files: src/sys/rump/librump/rumpkern: Makefile.rumpkern Log Message: Use the more widely accepted version of alphabetical order. To generate a diff of this commit: cvs rdiff -u -r1.163 -r1.164 src/sys/rump/librump/rumpkern/Makefile.rumpkern Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/librump/rumpkern/Makefile.rumpkern diff -u src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.163 src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.164 --- src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.163 Mon Aug 31 07:38:48 2015 +++ src/sys/rump/librump/rumpkern/Makefile.rumpkern Tue Sep 15 15:09:10 2015 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.rumpkern,v 1.163 2015/08/31 07:38:48 ozaki-r Exp $ +# $NetBSD: Makefile.rumpkern,v 1.164 2015/09/15 15:09:10 pooka Exp $ # .include "${RUMPTOP}/Makefile.rump" @@ -83,6 +83,7 @@ SRCS+= init_sysctl_base.c \ kern_rndpool.c \ kern_rndq.c \ kern_rndsink.c \ + kern_rwlock_obj.c \ kern_stub.c \ kern_syscall.c \ kern_sysctl.c \ @@ -92,11 +93,11 @@ SRCS+= init_sysctl_base.c \ kern_uidinfo.c \ kern_xxx.c \ param.c \ - subr_devsw.c \ subr_callback.c \ subr_copy.c \ subr_cprng.c \ subr_device.c \ + subr_devsw.c \ subr_evcnt.c \ subr_extent.c \ subr_hash.c \ @@ -113,7 +114,6 @@ SRCS+= init_sysctl_base.c \ subr_pool.c \ subr_prf.c \ subr_pserialize.c \ - kern_rwlock_obj.c \ subr_specificdata.c \ subr_time.c \ subr_vmem.c \
CVS commit: src/sys/arch
Module Name:src Committed By: christos Date: Tue Sep 15 15:49:03 UTC 2015 Modified Files: src/sys/arch/aarch64/include: ptrace.h src/sys/arch/alpha/include: ptrace.h src/sys/arch/amd64/include: ptrace.h src/sys/arch/arm/include: ptrace.h src/sys/arch/hppa/include: ptrace.h src/sys/arch/i386/include: ptrace.h src/sys/arch/ia64/include: ptrace.h src/sys/arch/m68k/include: ptrace.h src/sys/arch/mips/include: ptrace.h src/sys/arch/or1k/include: ptrace.h src/sys/arch/powerpc/include: ptrace.h src/sys/arch/riscv/include: ptrace.h src/sys/arch/sh3/include: ptrace.h src/sys/arch/sparc/include: ptrace.h src/sys/arch/vax/include: ptrace.h Log Message: Provide access to pc/sp/syscall-return registers like we have for mcontext To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/aarch64/include/ptrace.h cvs rdiff -u -r1.6 -r1.7 src/sys/arch/alpha/include/ptrace.h cvs rdiff -u -r1.3 -r1.4 src/sys/arch/amd64/include/ptrace.h cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/include/ptrace.h cvs rdiff -u -r1.3 -r1.4 src/sys/arch/hppa/include/ptrace.h cvs rdiff -u -r1.13 -r1.14 src/sys/arch/i386/include/ptrace.h cvs rdiff -u -r1.2 -r1.3 src/sys/arch/ia64/include/ptrace.h cvs rdiff -u -r1.8 -r1.9 src/sys/arch/m68k/include/ptrace.h cvs rdiff -u -r1.12 -r1.13 src/sys/arch/mips/include/ptrace.h cvs rdiff -u -r1.1 -r1.2 src/sys/arch/or1k/include/ptrace.h cvs rdiff -u -r1.11 -r1.12 src/sys/arch/powerpc/include/ptrace.h cvs rdiff -u -r1.1 -r1.2 src/sys/arch/riscv/include/ptrace.h cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sh3/include/ptrace.h cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sparc/include/ptrace.h cvs rdiff -u -r1.4 -r1.5 src/sys/arch/vax/include/ptrace.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/arch/aarch64/include/ptrace.h diff -u src/sys/arch/aarch64/include/ptrace.h:1.2 src/sys/arch/aarch64/include/ptrace.h:1.3 --- src/sys/arch/aarch64/include/ptrace.h:1.2 Mon Aug 11 18:09:08 2014 +++ src/sys/arch/aarch64/include/ptrace.h Tue Sep 15 11:49:02 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ptrace.h,v 1.2 2014/08/11 22:09:08 matt Exp $ */ +/* $NetBSD: ptrace.h,v 1.3 2015/09/15 15:49:02 christos Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -49,6 +49,13 @@ "PT_GETFPREGS", \ "PT_SETFPREGS", + +#include +#define PTRACE_REG_PC(r) (r)->r_pc +#define PTRACE_REG_SET_PC(r, v) (r)->r_pc = (v) +#define PTRACE_REG_SP(r) (r)->r_sp +#define PTRACE_REG_INTRV(r) (r)->r_reg[0] + #elif defined(__arm__) #include Index: src/sys/arch/alpha/include/ptrace.h diff -u src/sys/arch/alpha/include/ptrace.h:1.6 src/sys/arch/alpha/include/ptrace.h:1.7 --- src/sys/arch/alpha/include/ptrace.h:1.6 Fri Jan 25 07:03:36 2008 +++ src/sys/arch/alpha/include/ptrace.h Tue Sep 15 11:49:02 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ptrace.h,v 1.6 2008/01/25 12:03:36 skrll Exp $ */ +/* $NetBSD: ptrace.h,v 1.7 2015/09/15 15:49:02 christos Exp $ */ /* * Copyright (c) 1994 Christopher G. Demetriou @@ -44,3 +44,9 @@ "PT_SETREGS", \ "PT_GETFPREGS", \ "PT_SETFPREGS", + +#include +#define PTRACE_REG_PC(r) (r)->r_regs[R_ZERO] +#define PTRACE_REG_SET_PC(r, v) (r)->r_regs[R_ZERO] = (v) +#define PTRACE_REG_SP(r) (r)->r_regs[R_SP] +#define PTRACE_REG_INTRV(r) (r)->r_regs[R_V0] Index: src/sys/arch/amd64/include/ptrace.h diff -u src/sys/arch/amd64/include/ptrace.h:1.3 src/sys/arch/amd64/include/ptrace.h:1.4 --- src/sys/arch/amd64/include/ptrace.h:1.3 Mon Apr 16 08:22:26 2007 +++ src/sys/arch/amd64/include/ptrace.h Tue Sep 15 11:49:02 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ptrace.h,v 1.3 2007/04/16 12:22:26 njoly Exp $ */ +/* $NetBSD: ptrace.h,v 1.4 2015/09/15 15:49:02 christos Exp $ */ /* * Copyright (c) 1993 Christopher G. Demetriou @@ -46,6 +46,12 @@ "PT_GETFPREGS", \ "PT_SETFPREGS", +#include +#define PTRACE_REG_PC(r) (r)->regs[_REG_RIP] +#define PTRACE_REG_SET_PC(r, v) (r)->regs[_REG_RIP] = (v) +#define PTRACE_REG_SP(r) (r)->regs[_REG_RSP] +#define PTRACE_REG_INTRV(r) (r)->regs[_REG_RAX] + #ifdef _KERNEL_OPT #include "opt_compat_netbsd32.h" Index: src/sys/arch/arm/include/ptrace.h diff -u src/sys/arch/arm/include/ptrace.h:1.6 src/sys/arch/arm/include/ptrace.h:1.7 --- src/sys/arch/arm/include/ptrace.h:1.6 Wed Dec 5 14:05:46 2012 +++ src/sys/arch/arm/include/ptrace.h Tue Sep 15 11:49:02 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ptrace.h,v 1.6 2012/12/05 19:05:46 matt Exp $ */ +/* $NetBSD: ptrace.h,v 1.7 2015/09/15 15:49:02 christos Exp $ */ /* * Copyright (c) 1995 Frank Lancaster @@ -51,3 +51,9 @@ "old PT_SETFPREGS", \ "PT_GETFPREGS", \ "PT_SETFPREGS", + +#include +#define PTRACE_REG_PC(r) (r)->r_pc +#define PTRACE_REG_SET_PC(r, v) (r)->r_pc = (v) +#define PTRACE_REG_SP(r) (r)->r_sp +#define PTRACE_REG_INTRV(r) (r)->r[0] Index: src/sys/arch/hppa/include/ptrace.h diff -u src/sys/arch
CVS commit: src/external/cddl/osnet/lib/libctf
Module Name:src Committed By: christos Date: Tue Sep 15 18:38:41 UTC 2015 Modified Files: src/external/cddl/osnet/lib/libctf: Makefile Log Message: libctf depends on libz To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/lib/libctf/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/lib/libctf/Makefile diff -u src/external/cddl/osnet/lib/libctf/Makefile:1.4 src/external/cddl/osnet/lib/libctf/Makefile:1.5 --- src/external/cddl/osnet/lib/libctf/Makefile:1.4 Tue Sep 10 07:23:20 2013 +++ src/external/cddl/osnet/lib/libctf/Makefile Tue Sep 15 14:38:41 2015 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.4 2013/09/10 11:23:20 christos Exp $ +# $NetBSD: Makefile,v 1.5 2015/09/15 18:38:41 christos Exp $ # $FreeBSD: src/cddl/lib/libctf/Makefile,v 1.2.2.1 2009/08/03 08:13:06 kensmith Exp $ @@ -30,5 +30,7 @@ CPPFLAGS+= -I${OSNETDIR}/sys \ -I${OPENSOLARIS_USR_DISTDIR}/lib/libctf/common \ -I${OPENSOLARIS_SYS_DISTDIR}/uts/common +LIBDPLIBS+= z ${NETBSDSRCDIR}/lib/libz + .include
CVS commit: src/sys/arch/x68k/x68k
Module Name:src Committed By: isaki Date: Wed Sep 16 05:48:53 UTC 2015 Modified Files: src/sys/arch/x68k/x68k: machdep.c Log Message: To turn off the power, it's necessary to turn off the alarm signal of RTC before writing the system port. This is a fix for rev 1.191. Thanks to Y.Sugahara. Should be pulled up to netbsd-7. To generate a diff of this commit: cvs rdiff -u -r1.191 -r1.192 src/sys/arch/x68k/x68k/machdep.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/arch/x68k/x68k/machdep.c diff -u src/sys/arch/x68k/x68k/machdep.c:1.191 src/sys/arch/x68k/x68k/machdep.c:1.192 --- src/sys/arch/x68k/x68k/machdep.c:1.191 Wed Mar 26 16:21:39 2014 +++ src/sys/arch/x68k/x68k/machdep.c Wed Sep 16 05:48:52 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.191 2014/03/26 16:21:39 isaki Exp $ */ +/* $NetBSD: machdep.c,v 1.192 2015/09/16 05:48:52 isaki Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.191 2014/03/26 16:21:39 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.192 2015/09/16 05:48:52 isaki Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -106,6 +106,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v #include #include #include +#include extern void doboot(void) __attribute__((__noreturn__)); @@ -522,6 +523,10 @@ cpu_reboot(int howto, char *bootstr) if (((howto & RB_POWERDOWN) == RB_POWERDOWN) && power_switch_is_off) { printf("powering off...\n"); delay(100); + + /* Turn off the alarm signal of RTC */ + IODEVbase->io_rtc.bank0.reset = 0x0c; + intio_set_sysport_powoff(0x00); intio_set_sysport_powoff(0x0f); intio_set_sysport_powoff(0x0f);