Module Name: src Committed By: dholland Date: Sat Jun 8 02:13:33 UTC 2013
Modified Files: src/sys/ufs/lfs: lfs.h ulfs_dinode.h ulfs_dir.h ulfs_dirhash.h ulfs_lookup.c ulfsmount.h Log Message: Move stuff to lfs.h that's needed by userland: LFS_DT_* ULFS_ROOTINO ULFS_WINO struct lfs_direct struct lfs_dirtemplate struct lfs_odirtemplate struct ulfs_args Also fix FFS_MAXNAMLEN -> LFS_MAXNAMLEN in several places. To generate a diff of this commit: cvs rdiff -u -r1.144 -r1.145 src/sys/ufs/lfs/lfs.h cvs rdiff -u -r1.8 -r1.9 src/sys/ufs/lfs/ulfs_dinode.h cvs rdiff -u -r1.5 -r1.6 src/sys/ufs/lfs/ulfs_dir.h cvs rdiff -u -r1.3 -r1.4 src/sys/ufs/lfs/ulfs_dirhash.h cvs rdiff -u -r1.7 -r1.8 src/sys/ufs/lfs/ulfs_lookup.c cvs rdiff -u -r1.6 -r1.7 src/sys/ufs/lfs/ulfsmount.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.144 src/sys/ufs/lfs/lfs.h:1.145 --- src/sys/ufs/lfs/lfs.h:1.144 Sat Jun 8 02:11:49 2013 +++ src/sys/ufs/lfs/lfs.h Sat Jun 8 02:13:33 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: lfs.h,v 1.144 2013/06/08 02:11:49 dholland Exp $ */ +/* $NetBSD: lfs.h,v 1.145 2013/06/08 02:13:33 dholland Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -88,6 +88,23 @@ #define LFS_LOSTFOUNDINO 3 /* 3: lost+found inode number */ #define LFS_FIRST_INUM 4 /* 4: first free inode number */ +/* + * The root inode is the root of the file system. Inode 0 can't be used for + * normal purposes and historically bad blocks were linked to inode 1, thus + * the root inode is 2. (Inode 1 is no longer used for this purpose, however + * numerous dump tapes make this assumption, so we are stuck with it). + */ +#define ULFS_ROOTINO ((ino_t)2) + +/* + * The Whiteout inode# is a dummy non-zero inode number which will + * never be allocated to a real file. It is used as a place holder + * in the directory entry which has been tagged as a LFS_DT_WHT entry. + * See the comments about ULFS_ROOTINO above. + */ +#define ULFS_WINO ((ino_t)1) + + #define LFS_V1_SUMMARY_SIZE 512 /* V1 fixed summary size */ #define LFS_DFL_SUMMARY_SIZE 512 /* Default summary size */ @@ -193,6 +210,64 @@ typedef struct lfs_res_blk { #define lfs_doff_t int32_t #define MAXDIRSIZE (0x7fffffff) +#define LFS_MAXNAMLEN 255 + +/* + * File types for d_type + */ +#define LFS_DT_UNKNOWN 0 +#define LFS_DT_FIFO 1 +#define LFS_DT_CHR 2 +#define LFS_DT_DIR 4 +#define LFS_DT_BLK 6 +#define LFS_DT_REG 8 +#define LFS_DT_LNK 10 +#define LFS_DT_SOCK 12 +#define LFS_DT_WHT 14 + +/* + * (See notes in ulfs_dir.h) + */ +#define d_ino d_fileno +struct lfs_direct { + u_int32_t d_fileno; /* inode number of entry */ + u_int16_t d_reclen; /* length of this record */ + u_int8_t d_type; /* file type, see below */ + u_int8_t d_namlen; /* length of string in d_name */ + char d_name[LFS_MAXNAMLEN + 1];/* name with length <= LFS_MAXNAMLEN */ +}; + +/* + * Template for manipulating directories. Should use struct lfs_direct's, + * but the name field is LFS_MAXNAMLEN - 1, and this just won't do. + */ +struct lfs_dirtemplate { + u_int32_t dot_ino; + int16_t dot_reclen; + u_int8_t dot_type; + u_int8_t dot_namlen; + char dot_name[4]; /* must be multiple of 4 */ + u_int32_t dotdot_ino; + int16_t dotdot_reclen; + u_int8_t dotdot_type; + u_int8_t dotdot_namlen; + char dotdot_name[4]; /* ditto */ +}; + +/* + * This is the old format of directories, sans type element. + */ +struct lfs_odirtemplate { + u_int32_t dot_ino; + int16_t dot_reclen; + u_int16_t dot_namlen; + char dot_name[4]; /* must be multiple of 4 */ + u_int32_t dotdot_ino; + int16_t dotdot_reclen; + u_int16_t dotdot_namlen; + char dotdot_name[4]; /* ditto */ +}; + /* * Inodes */ @@ -1288,6 +1363,13 @@ struct lfs_fhandle { # define ASSERT_MAYBE_SEGLOCK(x) #endif /* !notyet */ +/* + * Arguments to mount LFS filesystems + */ +struct ulfs_args { + char *fspec; /* block special device to mount */ +}; + __BEGIN_DECLS void lfs_itimes(struct inode *, const struct timespec *, const struct timespec *, const struct timespec *); Index: src/sys/ufs/lfs/ulfs_dinode.h diff -u src/sys/ufs/lfs/ulfs_dinode.h:1.8 src/sys/ufs/lfs/ulfs_dinode.h:1.9 --- src/sys/ufs/lfs/ulfs_dinode.h:1.8 Sat Jun 8 02:12:56 2013 +++ src/sys/ufs/lfs/ulfs_dinode.h Sat Jun 8 02:13:33 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ulfs_dinode.h,v 1.8 2013/06/08 02:12:56 dholland Exp $ */ +/* $NetBSD: ulfs_dinode.h,v 1.9 2013/06/08 02:13:33 dholland Exp $ */ /* from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp */ /* @@ -56,22 +56,6 @@ #include <ufs/lfs/lfs.h> /* - * The root inode is the root of the file system. Inode 0 can't be used for - * normal purposes and historically bad blocks were linked to inode 1, thus - * the root inode is 2. (Inode 1 is no longer used for this purpose, however - * numerous dump tapes make this assumption, so we are stuck with it). - */ -#define ULFS_ROOTINO ((ino_t)2) - -/* - * The Whiteout inode# is a dummy non-zero inode number which will - * never be allocated to a real file. It is used as a place holder - * in the directory entry which has been tagged as a LFS_DT_WHT entry. - * See the comments about ULFS_ROOTINO above. - */ -#define ULFS_WINO ((ino_t)1) - -/* * Maximum length of a symlink that can be stored within the inode. */ #define ULFS1_MAXSYMLINKLEN ((ULFS_NDADDR + ULFS_NIADDR) * sizeof(int32_t)) Index: src/sys/ufs/lfs/ulfs_dir.h diff -u src/sys/ufs/lfs/ulfs_dir.h:1.5 src/sys/ufs/lfs/ulfs_dir.h:1.6 --- src/sys/ufs/lfs/ulfs_dir.h:1.5 Sat Jun 8 02:12:56 2013 +++ src/sys/ufs/lfs/ulfs_dir.h Sat Jun 8 02:13:33 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ulfs_dir.h,v 1.5 2013/06/08 02:12:56 dholland Exp $ */ +/* $NetBSD: ulfs_dir.h,v 1.6 2013/06/08 02:13:33 dholland Exp $ */ /* from NetBSD: dir.h,v 1.21 2009/07/22 04:49:19 dholland Exp */ /* @@ -51,7 +51,7 @@ * the length of the entry, and the length of the name contained in * the entry. These are followed by the name padded to a 4 byte boundary. * All names are guaranteed null terminated. - * The maximum length of a name in a directory is FFS_MAXNAMLEN. + * The maximum length of a name in a directory is LFS_MAXNAMLEN. * * The macro DIRSIZ(fmt, dp) gives the amount of space required to represent * a directory entry. Free space in a directory is represented by @@ -67,29 +67,6 @@ */ #undef DIRBLKSIZ #define DIRBLKSIZ DEV_BSIZE -#define FFS_MAXNAMLEN 255 - -#define d_ino d_fileno -struct lfs_direct { - u_int32_t d_fileno; /* inode number of entry */ - u_int16_t d_reclen; /* length of this record */ - u_int8_t d_type; /* file type, see below */ - u_int8_t d_namlen; /* length of string in d_name */ - char d_name[FFS_MAXNAMLEN + 1];/* name with length <= FFS_MAXNAMLEN */ -}; - -/* - * File types - */ -#define LFS_DT_UNKNOWN 0 -#define LFS_DT_FIFO 1 -#define LFS_DT_CHR 2 -#define LFS_DT_DIR 4 -#define LFS_DT_BLK 6 -#define LFS_DT_REG 8 -#define LFS_DT_LNK 10 -#define LFS_DT_SOCK 12 -#define LFS_DT_WHT 14 /* * Convert between stat structure types and directory types. @@ -104,7 +81,7 @@ struct lfs_direct { * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary. */ #define DIRECTSIZ(namlen) \ - ((sizeof(struct lfs_direct) - (FFS_MAXNAMLEN+1)) + (((namlen)+1 + 3) &~ 3)) + ((sizeof(struct lfs_direct) - (LFS_MAXNAMLEN+1)) + (((namlen)+1 + 3) &~ 3)) #if (BYTE_ORDER == LITTLE_ENDIAN) #define DIRSIZ(oldfmt, dp, needswap) \ @@ -119,34 +96,4 @@ struct lfs_direct { #define OLDDIRFMT 1 #define NEWDIRFMT 0 -/* - * Template for manipulating directories. Should use struct direct's, - * but the name field is FFS_MAXNAMLEN - 1, and this just won't do. - */ -struct lfs_dirtemplate { - u_int32_t dot_ino; - int16_t dot_reclen; - u_int8_t dot_type; - u_int8_t dot_namlen; - char dot_name[4]; /* must be multiple of 4 */ - u_int32_t dotdot_ino; - int16_t dotdot_reclen; - u_int8_t dotdot_type; - u_int8_t dotdot_namlen; - char dotdot_name[4]; /* ditto */ -}; - -/* - * This is the old format of directories, sanz type element. - */ -struct lfs_odirtemplate { - u_int32_t dot_ino; - int16_t dot_reclen; - u_int16_t dot_namlen; - char dot_name[4]; /* must be multiple of 4 */ - u_int32_t dotdot_ino; - int16_t dotdot_reclen; - u_int16_t dotdot_namlen; - char dotdot_name[4]; /* ditto */ -}; #endif /* !_UFS_LFS_ULFS_DIR_H_ */ Index: src/sys/ufs/lfs/ulfs_dirhash.h diff -u src/sys/ufs/lfs/ulfs_dirhash.h:1.3 src/sys/ufs/lfs/ulfs_dirhash.h:1.4 --- src/sys/ufs/lfs/ulfs_dirhash.h:1.3 Sat Jun 8 02:12:56 2013 +++ src/sys/ufs/lfs/ulfs_dirhash.h Sat Jun 8 02:13:33 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ulfs_dirhash.h,v 1.3 2013/06/08 02:12:56 dholland Exp $ */ +/* $NetBSD: ulfs_dirhash.h,v 1.4 2013/06/08 02:13:33 dholland Exp $ */ /* from NetBSD: dirhash.h,v 1.6 2008/06/04 11:33:19 ad Exp */ /* @@ -48,7 +48,7 @@ #define DIRHASH_DEL (-2) /* deleted entry; may be part of chain */ #define DIRALIGN 4 -#define DH_NFSTATS (DIRECTSIZ(FFS_MAXNAMLEN + 1) / DIRALIGN) +#define DH_NFSTATS (DIRECTSIZ(LFS_MAXNAMLEN + 1) / DIRALIGN) /* max DIRALIGN words in a directory entry */ /* Index: src/sys/ufs/lfs/ulfs_lookup.c diff -u src/sys/ufs/lfs/ulfs_lookup.c:1.7 src/sys/ufs/lfs/ulfs_lookup.c:1.8 --- src/sys/ufs/lfs/ulfs_lookup.c:1.7 Sat Jun 8 02:12:56 2013 +++ src/sys/ufs/lfs/ulfs_lookup.c Sat Jun 8 02:13:33 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ulfs_lookup.c,v 1.7 2013/06/08 02:12:56 dholland Exp $ */ +/* $NetBSD: ulfs_lookup.c,v 1.8 2013/06/08 02:13:33 dholland Exp $ */ /* from NetBSD: ufs_lookup.c,v 1.122 2013/01/22 09:39:18 dholland Exp */ /* @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ulfs_lookup.c,v 1.7 2013/06/08 02:12:56 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ulfs_lookup.c,v 1.8 2013/06/08 02:13:33 dholland Exp $"); #ifdef _KERNEL_OPT #include "opt_lfs.h" @@ -707,7 +707,7 @@ ulfs_dirbad(struct inode *ip, doff_t off * record length must be multiple of 4 * entry must fit in rest of its DIRBLKSIZ block * record must be large enough to contain entry - * name is not longer than FFS_MAXNAMLEN + * name is not longer than LFS_MAXNAMLEN * name must be as long as advertised, and null terminated */ int @@ -735,7 +735,7 @@ ulfs_dirbadentry(struct vnode *dp, struc dirblksiz - (entryoffsetinblock & (dirblksiz - 1)) || ulfs_rw16(ep->d_reclen, needswap) < DIRSIZ(FSFMT(dp), ep, needswap) || - namlen > FFS_MAXNAMLEN) { + namlen > LFS_MAXNAMLEN) { /*return (1); */ printf("First bad, reclen=%#x, DIRSIZ=%lu, namlen=%d, " "flags=%#x, entryoffsetinblock=%d, dirblksiz = %d\n", Index: src/sys/ufs/lfs/ulfsmount.h diff -u src/sys/ufs/lfs/ulfsmount.h:1.6 src/sys/ufs/lfs/ulfsmount.h:1.7 --- src/sys/ufs/lfs/ulfsmount.h:1.6 Thu Jun 6 01:25:25 2013 +++ src/sys/ufs/lfs/ulfsmount.h Sat Jun 8 02:13:33 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ulfsmount.h,v 1.6 2013/06/06 01:25:25 dholland Exp $ */ +/* $NetBSD: ulfsmount.h,v 1.7 2013/06/08 02:13:33 dholland Exp $ */ /* from NetBSD: ufsmount.h,v 1.39 2012/10/19 17:09:08 drochner Exp */ /* @@ -37,13 +37,6 @@ #include <sys/mount.h> /* struct export_args30 */ -/* - * Arguments to mount ULFS-based filesystems - */ -struct ulfs_args { - char *fspec; /* block special device to mount */ -}; - #ifdef _KERNEL #if defined(_KERNEL_OPT)