Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Move the dinode (on-disk inode) structures to lfs.h, since t...



details:   https://anonhg.NetBSD.org/src/rev/6851d567f0c3
branches:  trunk
changeset: 787239:6851d567f0c3
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sat Jun 08 02:09:35 2013 +0000

description:
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.

diffstat:

 libexec/lfs_cleanerd/lfs_cleanerd.c |   4 +-
 sbin/fsck_lfs/inode.c               |   8 +-
 sbin/fsck_lfs/pass6.c               |  18 ++++----
 sbin/fsck_lfs/segwrite.c            |   6 +-
 sbin/fsck_lfs/setup.c               |   4 +-
 sbin/newfs_lfs/make_lfs.c           |   6 +-
 sys/ufs/lfs/lfs.h                   |  82 ++++++++++++++++++++++++++++++++++++-
 sys/ufs/lfs/ulfs_dinode.h           |  74 +--------------------------------
 8 files changed, 105 insertions(+), 97 deletions(-)

diffs (truncated from 370 to 300 lines):

diff -r f8d5490274fd -r 6851d567f0c3 libexec/lfs_cleanerd/lfs_cleanerd.c
--- a/libexec/lfs_cleanerd/lfs_cleanerd.c       Sat Jun 08 02:06:17 2013 +0000
+++ b/libexec/lfs_cleanerd/lfs_cleanerd.c       Sat Jun 08 02:09:35 2013 +0000
@@ -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 @@
                                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);
diff -r f8d5490274fd -r 6851d567f0c3 sbin/fsck_lfs/inode.c
--- a/sbin/fsck_lfs/inode.c     Sat Jun 08 02:06:17 2013 +0000
+++ b/sbin/fsck_lfs/inode.c     Sat Jun 08 02:09:35 2013 +0000
@@ -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 @@
        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 @@
                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 */
        }
 }
diff -r f8d5490274fd -r 6851d567f0c3 sbin/fsck_lfs/pass6.c
--- a/sbin/fsck_lfs/pass6.c     Sat Jun 08 02:06:17 2013 +0000
+++ b/sbin/fsck_lfs/pass6.c     Sat Jun 08 02:09:35 2013 +0000
@@ -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 @@
                        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 @@
        /* 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 @@
        
        /* 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;
 }
 
 /*
diff -r f8d5490274fd -r 6851d567f0c3 sbin/fsck_lfs/segwrite.c
--- a/sbin/fsck_lfs/segwrite.c  Sat Jun 08 02:06:17 2013 +0000
+++ b/sbin/fsck_lfs/segwrite.c  Sat Jun 08 02:09:35 2013 +0000
@@ -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 @@
        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 @@
        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;
diff -r f8d5490274fd -r 6851d567f0c3 sbin/fsck_lfs/setup.c
--- a/sbin/fsck_lfs/setup.c     Sat Jun 08 02:06:17 2013 +0000
+++ b/sbin/fsck_lfs/setup.c     Sat Jun 08 02:09:35 2013 +0000
@@ -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 @@
 
        /* 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));
diff -r f8d5490274fd -r 6851d567f0c3 sbin/newfs_lfs/make_lfs.c
--- a/sbin/newfs_lfs/make_lfs.c Sat Jun 08 02:06:17 2013 +0000
+++ b/sbin/newfs_lfs/make_lfs.c Sat Jun 08 02:09:35 2013 +0000
@@ -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 @@
        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();
diff -r f8d5490274fd -r 6851d567f0c3 sys/ufs/lfs/lfs.h
--- a/sys/ufs/lfs/lfs.h Sat Jun 08 02:06:17 2013 +0000
+++ b/sys/ufs/lfs/lfs.h Sat Jun 08 02:09:35 2013 +0000
@@ -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 @@
 #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
  */
 
diff -r f8d5490274fd -r 6851d567f0c3 sys/ufs/lfs/ulfs_dinode.h
--- a/sys/ufs/lfs/ulfs_dinode.h Sat Jun 08 02:06:17 2013 +0000
+++ b/sys/ufs/lfs/ulfs_dinode.h Sat Jun 08 02:09:35 2013 +0000
@@ -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 {



Home | Main Index | Thread Index | Old Index