Module Name:    src
Committed By:   dholland
Date:           Sat Jun  8 02:09:36 UTC 2013

Modified Files:
        src/libexec/lfs_cleanerd: lfs_cleanerd.c
        src/sbin/fsck_lfs: inode.c pass6.c segwrite.c setup.c
        src/sbin/newfs_lfs: make_lfs.c
        src/sys/ufs/lfs: lfs.h ulfs_dinode.h

Log Message:
Move the dinode (on-disk inode) structures to lfs.h, since they are
and will be obviously required by userland tools that need to read
the on-disk structures.

Also, DINODE{1,2}_SIZE -> LFS_DINODE{1,2}_SIZE.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/libexec/lfs_cleanerd/lfs_cleanerd.c
cvs rdiff -u -r1.45 -r1.46 src/sbin/fsck_lfs/inode.c
cvs rdiff -u -r1.27 -r1.28 src/sbin/fsck_lfs/pass6.c
cvs rdiff -u -r1.23 -r1.24 src/sbin/fsck_lfs/segwrite.c
cvs rdiff -u -r1.41 -r1.42 src/sbin/fsck_lfs/setup.c
cvs rdiff -u -r1.22 -r1.23 src/sbin/newfs_lfs/make_lfs.c
cvs rdiff -u -r1.142 -r1.143 src/sys/ufs/lfs/lfs.h
cvs rdiff -u -r1.4 -r1.5 src/sys/ufs/lfs/ulfs_dinode.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/libexec/lfs_cleanerd/lfs_cleanerd.c
diff -u src/libexec/lfs_cleanerd/lfs_cleanerd.c:1.33 src/libexec/lfs_cleanerd/lfs_cleanerd.c:1.34
--- src/libexec/lfs_cleanerd/lfs_cleanerd.c:1.33	Thu Jun  6 00:53:35 2013
+++ src/libexec/lfs_cleanerd/lfs_cleanerd.c	Sat Jun  8 02:09:35 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_cleanerd.c,v 1.33 2013/06/06 00:53:35 dholland Exp $	 */
+/* $NetBSD: lfs_cleanerd.c,v 1.34 2013/06/08 02:09:35 dholland Exp $	 */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -485,7 +485,7 @@ parse_pseg(struct clfs *fs, daddr_t dadd
 				bip[*bic - 1].bi_segcreate = ssp->ss_create;
 				bip[*bic - 1].bi_version = dip[i].di_gen;
 				bip[*bic - 1].bi_bp = &(dip[i]);
-				bip[*bic - 1].bi_size = DINODE1_SIZE;
+				bip[*bic - 1].bi_size = LFS_DINODE1_SIZE;
 			}
 			inoc += i;
 			daddr += btofsb(fs, fs->lfs_ibsize);

Index: src/sbin/fsck_lfs/inode.c
diff -u src/sbin/fsck_lfs/inode.c:1.45 src/sbin/fsck_lfs/inode.c:1.46
--- src/sbin/fsck_lfs/inode.c:1.45	Thu Jun  6 00:54:49 2013
+++ src/sbin/fsck_lfs/inode.c	Sat Jun  8 02:09:35 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: inode.c,v 1.45 2013/06/06 00:54:49 dholland Exp $	 */
+/* $NetBSD: inode.c,v 1.46 2013/06/08 02:09:35 dholland Exp $	 */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -113,7 +113,7 @@ ginode(ino_t ino)
 	if (din_table[ino] == 0x0) {
 		LFS_IENTRY(ifp, fs, ino, bp);
 		din_table[ino] = ifp->if_daddr;
-		seg_table[dtosn(fs, ifp->if_daddr)].su_nbytes += DINODE1_SIZE;
+		seg_table[dtosn(fs, ifp->if_daddr)].su_nbytes += LFS_DINODE1_SIZE;
 		brelse(bp, 0);
 	}
 	return (VTOI(vp)->i_din.ffs1_din);
@@ -476,9 +476,9 @@ clearinode(ino_t inumber)
 		SEGUSE *sup;
 		u_int32_t oldsn = dtosn(fs, daddr);
 
-		seg_table[oldsn].su_nbytes -= DINODE1_SIZE;
+		seg_table[oldsn].su_nbytes -= LFS_DINODE1_SIZE;
 		LFS_SEGENTRY(sup, fs, oldsn, bp);
-		sup->su_nbytes -= DINODE1_SIZE;
+		sup->su_nbytes -= LFS_DINODE1_SIZE;
 		LFS_WRITESEGENTRY(sup, fs, oldsn, bp);	/* Ifile */
 	}
 }

Index: src/sbin/fsck_lfs/pass6.c
diff -u src/sbin/fsck_lfs/pass6.c:1.27 src/sbin/fsck_lfs/pass6.c:1.28
--- src/sbin/fsck_lfs/pass6.c:1.27	Thu Jun  6 00:54:49 2013
+++ src/sbin/fsck_lfs/pass6.c	Sat Jun  8 02:09:35 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: pass6.c,v 1.27 2013/06/06 00:54:49 dholland Exp $	 */
+/* $NetBSD: pass6.c,v 1.28 2013/06/08 02:09:35 dholland Exp $	 */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -237,9 +237,9 @@ remove_ino(struct uvnode *vp, ino_t ino)
 			vp = lfs_raw_vget(fs, ino, fs->lfs_ivnode->v_fd, daddr);
 
 		LFS_SEGENTRY(sup, fs, dtosn(fs, daddr), sbp);
-		sup->su_nbytes -= DINODE1_SIZE;
+		sup->su_nbytes -= LFS_DINODE1_SIZE;
 		VOP_BWRITE(sbp);
-		seg_table[dtosn(fs, daddr)].su_nbytes -= DINODE1_SIZE;
+		seg_table[dtosn(fs, daddr)].su_nbytes -= LFS_DINODE1_SIZE;
 	} else
 		brelse(bp, 0);
 
@@ -454,15 +454,15 @@ readdress_inode(struct ulfs1_dinode *dp,
 	/* Finally account the inode itself */
 	sn = dtosn(fs, odaddr);
 	LFS_SEGENTRY(sup, fs, sn, bp);
-	sup->su_nbytes -= DINODE1_SIZE;
+	sup->su_nbytes -= LFS_DINODE1_SIZE;
 	VOP_BWRITE(bp);
-	seg_table[sn].su_nbytes -= DINODE1_SIZE;
+	seg_table[sn].su_nbytes -= LFS_DINODE1_SIZE;
 
 	sn = dtosn(fs, daddr);
 	LFS_SEGENTRY(sup, fs, sn, bp);
-	sup->su_nbytes += DINODE1_SIZE;
+	sup->su_nbytes += LFS_DINODE1_SIZE;
 	VOP_BWRITE(bp);
-	seg_table[sn].su_nbytes += DINODE1_SIZE;
+	seg_table[sn].su_nbytes += LFS_DINODE1_SIZE;
 }
 
 /*
@@ -521,9 +521,9 @@ alloc_inode(ino_t thisino, ulfs_daddr_t 
 	
 	/* Account for new location */
 	LFS_SEGENTRY(sup, fs, dtosn(fs, daddr), bp);
-	sup->su_nbytes += DINODE1_SIZE;
+	sup->su_nbytes += LFS_DINODE1_SIZE;
 	VOP_BWRITE(bp);
-	seg_table[dtosn(fs, daddr)].su_nbytes += DINODE1_SIZE;
+	seg_table[dtosn(fs, daddr)].su_nbytes += LFS_DINODE1_SIZE;
 }
 
 /*

Index: src/sbin/fsck_lfs/segwrite.c
diff -u src/sbin/fsck_lfs/segwrite.c:1.23 src/sbin/fsck_lfs/segwrite.c:1.24
--- src/sbin/fsck_lfs/segwrite.c:1.23	Thu Jun  6 00:54:49 2013
+++ src/sbin/fsck_lfs/segwrite.c	Sat Jun  8 02:09:35 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: segwrite.c,v 1.23 2013/06/06 00:54:49 dholland Exp $ */
+/* $NetBSD: segwrite.c,v 1.24 2013/06/08 02:09:35 dholland Exp $ */
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -346,7 +346,7 @@ lfs_writeinode(struct lfs * fs, struct s
 	if (daddr != LFS_UNUSED_DADDR) {
 		u_int32_t oldsn = dtosn(fs, daddr);
 		LFS_SEGENTRY(sup, fs, oldsn, bp);
-		sup->su_nbytes -= DINODE1_SIZE;
+		sup->su_nbytes -= LFS_DINODE1_SIZE;
 		redo_ifile =
 		    (ino == LFS_IFILE_INUM && !(bp->b_flags & B_GATHERED));
 		if (redo_ifile)
@@ -769,7 +769,7 @@ lfs_writeseg(struct lfs * fs, struct seg
 	ssp->ss_flags |= SS_RFW;
 
 	ninos = (ssp->ss_ninos + INOPB(fs) - 1) / INOPB(fs);
-	sup->su_nbytes += ssp->ss_ninos * DINODE1_SIZE;
+	sup->su_nbytes += ssp->ss_ninos * LFS_DINODE1_SIZE;
 
 	if (fs->lfs_version == 1)
 		sup->su_olastmod = write_time;

Index: src/sbin/fsck_lfs/setup.c
diff -u src/sbin/fsck_lfs/setup.c:1.41 src/sbin/fsck_lfs/setup.c:1.42
--- src/sbin/fsck_lfs/setup.c:1.41	Thu Jun  6 00:54:49 2013
+++ src/sbin/fsck_lfs/setup.c	Sat Jun  8 02:09:35 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: setup.c,v 1.41 2013/06/06 00:54:49 dholland Exp $ */
+/* $NetBSD: setup.c,v 1.42 2013/06/08 02:09:35 dholland Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -434,7 +434,7 @@ setup(const char *dev)
 
 	/* Initialize Ifile entry */
 	din_table[fs->lfs_ifile] = fs->lfs_idaddr;
-	seg_table[dtosn(fs, fs->lfs_idaddr)].su_nbytes += DINODE1_SIZE;
+	seg_table[dtosn(fs, fs->lfs_idaddr)].su_nbytes += LFS_DINODE1_SIZE;
 
 #ifndef VERBOSE_BLOCKMAP
 	bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(int16_t));

Index: src/sbin/newfs_lfs/make_lfs.c
diff -u src/sbin/newfs_lfs/make_lfs.c:1.22 src/sbin/newfs_lfs/make_lfs.c:1.23
--- src/sbin/newfs_lfs/make_lfs.c:1.22	Thu Jun  6 00:54:49 2013
+++ src/sbin/newfs_lfs/make_lfs.c	Sat Jun  8 02:09:35 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: make_lfs.c,v 1.22 2013/06/06 00:54:49 dholland Exp $	*/
+/*	$NetBSD: make_lfs.c,v 1.23 2013/06/08 02:09:35 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.22 2013/06/06 00:54:49 dholland Exp $");
+__RCSID("$NetBSD: make_lfs.c,v 1.23 2013/06/08 02:09:35 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -452,7 +452,7 @@ make_lfs(int devfd, uint secsize, struct
 	fs->lfs_minfree = minfree;
 
 	if (version > 1) {
-		fs->lfs_inopf = secsize/DINODE1_SIZE;
+		fs->lfs_inopf = secsize/LFS_DINODE1_SIZE;
 		fs->lfs_interleave = interleave;
 		if (roll_id == 0)
 			roll_id = arc4random();

Index: src/sys/ufs/lfs/lfs.h
diff -u src/sys/ufs/lfs/lfs.h:1.142 src/sys/ufs/lfs/lfs.h:1.143
--- src/sys/ufs/lfs/lfs.h:1.142	Sat Jun  8 02:04:31 2013
+++ src/sys/ufs/lfs/lfs.h	Sat Jun  8 02:09:35 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: lfs.h,v 1.142 2013/06/08 02:04:31 dholland Exp $	*/
+/*	$NetBSD: lfs.h,v 1.143 2013/06/08 02:09:35 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -124,7 +124,7 @@
 #define LFS_INVERSE_MAX_BYTES(n) LFS_INVERSE_MAX_RESOURCE(n, PAGE_SIZE)
 #define LFS_WAIT_BYTES	    LFS_WAIT_RESOURCE(bufmem_lowater, PAGE_SIZE)
 #define LFS_MAX_DIROP	    ((desiredvnodes >> 2) + (desiredvnodes >> 3))
-#define SIZEOF_DIROP(fs)	(2 * ((fs)->lfs_bsize + DINODE1_SIZE))
+#define SIZEOF_DIROP(fs)	(2 * ((fs)->lfs_bsize + LFS_DINODE1_SIZE))
 #define LFS_MAX_FSDIROP(fs)						\
 	((fs)->lfs_nclean <= (fs)->lfs_resvseg ? 0 :			\
 	 (((fs)->lfs_nclean - (fs)->lfs_resvseg) * (fs)->lfs_ssize) /	\
@@ -194,6 +194,84 @@ typedef struct lfs_res_blk {
 #define	MAXDIRSIZE	(0x7fffffff)
 
 /*
+ * Inodes
+ */
+
+/*
+ * A dinode contains all the meta-data associated with a ULFS file.
+ * This structure defines the on-disk format of a dinode. Since
+ * this structure describes an on-disk structure, all its fields
+ * are defined by types with precise widths.
+ */
+
+struct ulfs1_dinode {
+	u_int16_t	di_mode;	/*   0: IFMT, permissions; see below. */
+	int16_t		di_nlink;	/*   2: File link count. */
+	union {
+		u_int16_t oldids[2];	/*   4: Ffs: old user and group ids. */
+		u_int32_t inumber;	/*   4: Lfs: inode number. */
+	} di_u;
+	u_int64_t	di_size;	/*   8: File byte count. */
+	int32_t		di_atime;	/*  16: Last access time. */
+	int32_t		di_atimensec;	/*  20: Last access time. */
+	int32_t		di_mtime;	/*  24: Last modified time. */
+	int32_t		di_mtimensec;	/*  28: Last modified time. */
+	int32_t		di_ctime;	/*  32: Last inode change time. */
+	int32_t		di_ctimensec;	/*  36: Last inode change time. */
+	int32_t		di_db[ULFS_NDADDR]; /*  40: Direct disk blocks. */
+	int32_t		di_ib[ULFS_NIADDR]; /*  88: Indirect disk blocks. */
+	u_int32_t	di_flags;	/* 100: Status flags (chflags). */
+	u_int32_t	di_blocks;	/* 104: Blocks actually held. */
+	int32_t		di_gen;		/* 108: Generation number. */
+	u_int32_t	di_uid;		/* 112: File owner. */
+	u_int32_t	di_gid;		/* 116: File group. */
+	u_int64_t	di_modrev;	/* 120: i_modrev for NFSv4 */
+};
+
+struct ulfs2_dinode {
+	u_int16_t	di_mode;	/*   0: IFMT, permissions; see below. */
+	int16_t		di_nlink;	/*   2: File link count. */
+	u_int32_t	di_uid;		/*   4: File owner. */
+	u_int32_t	di_gid;		/*   8: File group. */
+	u_int32_t	di_blksize;	/*  12: Inode blocksize. */
+	u_int64_t	di_size;	/*  16: File byte count. */
+	u_int64_t	di_blocks;	/*  24: Bytes actually held. */
+	int64_t		di_atime;	/*  32: Last access time. */
+	int64_t		di_mtime;	/*  40: Last modified time. */
+	int64_t		di_ctime;	/*  48: Last inode change time. */
+	int64_t		di_birthtime;	/*  56: Inode creation time. */
+	int32_t		di_mtimensec;	/*  64: Last modified time. */
+	int32_t		di_atimensec;	/*  68: Last access time. */
+	int32_t		di_ctimensec;	/*  72: Last inode change time. */
+	int32_t		di_birthnsec;	/*  76: Inode creation time. */
+	int32_t		di_gen;		/*  80: Generation number. */
+	u_int32_t	di_kernflags;	/*  84: Kernel flags. */
+	u_int32_t	di_flags;	/*  88: Status flags (chflags). */
+	int32_t		di_extsize;	/*  92: External attributes block. */
+	int64_t		di_extb[ULFS_NXADDR];/* 96: External attributes block. */
+	int64_t		di_db[ULFS_NDADDR]; /* 112: Direct disk blocks. */
+	int64_t		di_ib[ULFS_NIADDR]; /* 208: Indirect disk blocks. */
+	u_int64_t	di_modrev;	/* 232: i_modrev for NFSv4 */
+	int64_t		di_spare[2];	/* 240: Reserved; currently unused */
+};
+
+/*
+ * The di_db fields may be overlaid with other information for
+ * file types that do not have associated disk storage. Block
+ * and character devices overlay the first data block with their
+ * dev_t value. Short symbolic links place their path in the
+ * di_db area.
+ */
+#define	di_inumber	di_u.inumber
+#define	di_ogid		di_u.oldids[1]
+#define	di_ouid		di_u.oldids[0]
+#define	di_rdev		di_db[0]
+
+/* Size of the on-disk inode. */
+#define	LFS_DINODE1_SIZE	(sizeof(struct ulfs1_dinode))	/* 128 */
+#define	LFS_DINODE2_SIZE	(sizeof(struct ulfs2_dinode))
+
+/*
  * "struct buf" associated definitions
  */
 

Index: src/sys/ufs/lfs/ulfs_dinode.h
diff -u src/sys/ufs/lfs/ulfs_dinode.h:1.4 src/sys/ufs/lfs/ulfs_dinode.h:1.5
--- src/sys/ufs/lfs/ulfs_dinode.h:1.4	Thu Jun  6 01:25:25 2013
+++ src/sys/ufs/lfs/ulfs_dinode.h	Sat Jun  8 02:09:35 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ulfs_dinode.h,v 1.4 2013/06/06 01:25:25 dholland Exp $	*/
+/*	$NetBSD: ulfs_dinode.h,v 1.5 2013/06/08 02:09:35 dholland Exp $	*/
 /*  from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp  */
 
 /*
@@ -72,74 +72,8 @@
 #define	ULFS_WINO	((ino_t)1)
 
 /*
- * A dinode contains all the meta-data associated with a ULFS file.
- * This structure defines the on-disk format of a dinode. Since
- * this structure describes an on-disk structure, all its fields
- * are defined by types with precise widths.
+ * Maximum length of a symlink that can be stored within the inode.
  */
-
-struct ulfs1_dinode {
-	u_int16_t	di_mode;	/*   0: IFMT, permissions; see below. */
-	int16_t		di_nlink;	/*   2: File link count. */
-	union {
-		u_int16_t oldids[2];	/*   4: Ffs: old user and group ids. */
-		u_int32_t inumber;	/*   4: Lfs: inode number. */
-	} di_u;
-	u_int64_t	di_size;	/*   8: File byte count. */
-	int32_t		di_atime;	/*  16: Last access time. */
-	int32_t		di_atimensec;	/*  20: Last access time. */
-	int32_t		di_mtime;	/*  24: Last modified time. */
-	int32_t		di_mtimensec;	/*  28: Last modified time. */
-	int32_t		di_ctime;	/*  32: Last inode change time. */
-	int32_t		di_ctimensec;	/*  36: Last inode change time. */
-	int32_t		di_db[ULFS_NDADDR]; /*  40: Direct disk blocks. */
-	int32_t		di_ib[ULFS_NIADDR]; /*  88: Indirect disk blocks. */
-	u_int32_t	di_flags;	/* 100: Status flags (chflags). */
-	u_int32_t	di_blocks;	/* 104: Blocks actually held. */
-	int32_t		di_gen;		/* 108: Generation number. */
-	u_int32_t	di_uid;		/* 112: File owner. */
-	u_int32_t	di_gid;		/* 116: File group. */
-	u_int64_t	di_modrev;	/* 120: i_modrev for NFSv4 */
-};
-
-struct ulfs2_dinode {
-	u_int16_t	di_mode;	/*   0: IFMT, permissions; see below. */
-	int16_t		di_nlink;	/*   2: File link count. */
-	u_int32_t	di_uid;		/*   4: File owner. */
-	u_int32_t	di_gid;		/*   8: File group. */
-	u_int32_t	di_blksize;	/*  12: Inode blocksize. */
-	u_int64_t	di_size;	/*  16: File byte count. */
-	u_int64_t	di_blocks;	/*  24: Bytes actually held. */
-	int64_t		di_atime;	/*  32: Last access time. */
-	int64_t		di_mtime;	/*  40: Last modified time. */
-	int64_t		di_ctime;	/*  48: Last inode change time. */
-	int64_t		di_birthtime;	/*  56: Inode creation time. */
-	int32_t		di_mtimensec;	/*  64: Last modified time. */
-	int32_t		di_atimensec;	/*  68: Last access time. */
-	int32_t		di_ctimensec;	/*  72: Last inode change time. */
-	int32_t		di_birthnsec;	/*  76: Inode creation time. */
-	int32_t		di_gen;		/*  80: Generation number. */
-	u_int32_t	di_kernflags;	/*  84: Kernel flags. */
-	u_int32_t	di_flags;	/*  88: Status flags (chflags). */
-	int32_t		di_extsize;	/*  92: External attributes block. */
-	int64_t		di_extb[ULFS_NXADDR];/* 96: External attributes block. */
-	int64_t		di_db[ULFS_NDADDR]; /* 112: Direct disk blocks. */
-	int64_t		di_ib[ULFS_NIADDR]; /* 208: Indirect disk blocks. */
-	u_int64_t	di_modrev;	/* 232: i_modrev for NFSv4 */
-	int64_t		di_spare[2];	/* 240: Reserved; currently unused */
-};
-
-/*
- * The di_db fields may be overlaid with other information for
- * file types that do not have associated disk storage. Block
- * and character devices overlay the first data block with their
- * dev_t value. Short symbolic links place their path in the
- * di_db area.
- */
-#define	di_inumber	di_u.inumber
-#define	di_ogid		di_u.oldids[1]
-#define	di_ouid		di_u.oldids[0]
-#define	di_rdev		di_db[0]
 #define ULFS1_MAXSYMLINKLEN	((ULFS_NDADDR + ULFS_NIADDR) * sizeof(int32_t))
 #define ULFS2_MAXSYMLINKLEN	((ULFS_NDADDR + ULFS_NIADDR) * sizeof(int64_t))
 
@@ -166,8 +100,4 @@ struct ulfs2_dinode {
 #define	IFSOCK		0140000		/* UNIX domain socket. */
 #define	IFWHT		0160000		/* Whiteout. */
 
-/* Size of the on-disk inode. */
-#define	DINODE1_SIZE	(sizeof(struct ulfs1_dinode))		/* 128 */
-#define	DINODE2_SIZE	(sizeof(struct ulfs2_dinode))
-
 #endif /* !_UFS_LFS_ULFS_DINODE_H_ */

Reply via email to