4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / sys / ufs / ffs / fs.h
index 3c82561..39ff1e6 100644 (file)
@@ -1,10 +1,10 @@
 /*
 /*
- * Copyright (c) 1982, 1986 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1982, 1986, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)fs.h        7.11 (Berkeley) %G%
+ *     @(#)fs.h        8.1 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
  *
  * The file system records space availability at the fragment level;
  * to determine block availability, aligned fragments are examined.
  *
  * The file system records space availability at the fragment level;
  * to determine block availability, aligned fragments are examined.
- *
- * 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        ROOTINO         ((ino_t)2)      /* i number of all roots */
 
 /*
  * MINBSIZE is the smallest allowable block size.
 
 /*
  * MINBSIZE is the smallest allowable block size.
@@ -111,10 +103,7 @@ struct csum {
 /*
  * Super block for a file system.
  */
 /*
  * Super block for a file system.
  */
-#define        FS_MAGIC        0x011954
-#define        FSOKAY          0x7c269d38
-struct fs
-{
+struct fs {
        struct  fs *fs_link;            /* linked list of file systems */
        struct  fs *fs_rlink;           /*     used for incore super blocks */
        daddr_t fs_sblkno;              /* addr of super-block in filesys */
        struct  fs *fs_link;            /* linked list of file systems */
        struct  fs *fs_rlink;           /*     used for incore super blocks */
        daddr_t fs_sblkno;              /* addr of super-block in filesys */
@@ -188,10 +177,13 @@ struct    fs
        struct  csum *fs_csp[MAXCSBUFS];/* list of fs_cs info buffers */
        long    fs_cpc;                 /* cyl per cycle in postbl */
        short   fs_opostbl[16][8];      /* old rotation block list head */
        struct  csum *fs_csp[MAXCSBUFS];/* list of fs_cs info buffers */
        long    fs_cpc;                 /* cyl per cycle in postbl */
        short   fs_opostbl[16][8];      /* old rotation block list head */
-       long    fs_sparecon[55];        /* reserved for future constants */
+       long    fs_sparecon[51];        /* reserved for future constants */
+       long    fs_maxsymlinklen;       /* max length of an internal symlink */
+       long    fs_inodefmt;            /* format of on-disk inodes */
+       u_quad_t fs_maxfilesize;        /* maximum representable file size */
+       quad_t  fs_qbmask;              /* ~fs_bmask - for use with quad size */
+       quad_t  fs_qfmask;              /* ~fs_fmask - for use with quad size */
        long    fs_state;               /* validate fs_clean field */
        long    fs_state;               /* validate fs_clean field */
-       quad    fs_qbmask;              /* ~fs_bmask - for use with quad size */
-       quad    fs_qfmask;              /* ~fs_fmask - for use with quad size */
        long    fs_postblformat;        /* format of positional layout tables */
        long    fs_nrpos;               /* number of rotaional positions */
        long    fs_postbloff;           /* (short) rotation block list head */
        long    fs_postblformat;        /* format of positional layout tables */
        long    fs_nrpos;               /* number of rotaional positions */
        long    fs_postbloff;           /* (short) rotation block list head */
@@ -200,6 +192,13 @@ struct     fs
        u_char  fs_space[1];            /* list of blocks for each rotation */
 /* actually longer */
 };
        u_char  fs_space[1];            /* list of blocks for each rotation */
 /* actually longer */
 };
+/*
+ * Filesystem idetification
+ */
+#define        FS_MAGIC        0x011954        /* the fast filesystem magic number */
+#define        FS_OKAY         0x7c269d38      /* superblock checksum */
+#define FS_42INODEFMT  -1              /* 4.2BSD inode format */
+#define FS_44INODEFMT  2               /* 4.4BSD inode format */
 /*
  * Preference for optimization.
  */
 /*
  * Preference for optimization.
  */
@@ -361,9 +360,9 @@ struct      ocg {
  * modulos and multiplications.
  */
 #define blkoff(fs, loc)                /* calculates (loc % fs->fs_bsize) */ \
  * modulos and multiplications.
  */
 #define blkoff(fs, loc)                /* calculates (loc % fs->fs_bsize) */ \
-       ((loc) & ~(fs)->fs_bmask)
+       ((loc) & (fs)->fs_qbmask)
 #define fragoff(fs, loc)       /* calculates (loc % fs->fs_fsize) */ \
 #define fragoff(fs, loc)       /* calculates (loc % fs->fs_fsize) */ \
-       ((loc) & ~(fs)->fs_fmask)
+       ((loc) & (fs)->fs_qfmask)
 #define lblktosize(fs, blk)    /* calculates (blk * fs->fs_bsize) */ \
        ((blk) << (fs)->fs_bshift)
 #define lblkno(fs, loc)                /* calculates (loc / fs->fs_bsize) */ \
 #define lblktosize(fs, blk)    /* calculates (blk * fs->fs_bsize) */ \
        ((blk) << (fs)->fs_bshift)
 #define lblkno(fs, loc)                /* calculates (loc / fs->fs_bsize) */ \
@@ -371,9 +370,9 @@ struct      ocg {
 #define numfrags(fs, loc)      /* calculates (loc / fs->fs_fsize) */ \
        ((loc) >> (fs)->fs_fshift)
 #define blkroundup(fs, size)   /* calculates roundup(size, fs->fs_bsize) */ \
 #define numfrags(fs, loc)      /* calculates (loc / fs->fs_fsize) */ \
        ((loc) >> (fs)->fs_fshift)
 #define blkroundup(fs, size)   /* calculates roundup(size, fs->fs_bsize) */ \
-       (((size) + (fs)->fs_bsize - 1) & (fs)->fs_bmask)
+       (((size) + (fs)->fs_qbmask) & (fs)->fs_bmask)
 #define fragroundup(fs, size)  /* calculates roundup(size, fs->fs_fsize) */ \
 #define fragroundup(fs, size)  /* calculates roundup(size, fs->fs_fsize) */ \
-       (((size) + (fs)->fs_fsize - 1) & (fs)->fs_fmask)
+       (((size) + (fs)->fs_qfmask) & (fs)->fs_fmask)
 #define fragstoblks(fs, frags) /* calculates (frags / fs->fs_frag) */ \
        ((frags) >> (fs)->fs_fragshift)
 #define blkstofrags(fs, blks)  /* calculates (blks * fs->fs_frag) */ \
 #define fragstoblks(fs, frags) /* calculates (frags / fs->fs_frag) */ \
        ((frags) >> (fs)->fs_fragshift)
 #define blkstofrags(fs, blks)  /* calculates (blks * fs->fs_frag) */ \
@@ -419,3 +418,6 @@ struct      ocg {
  * NINDIR is the number of indirects in a file system block.
  */
 #define        NINDIR(fs)      ((fs)->fs_nindir)
  * NINDIR is the number of indirects in a file system block.
  */
 #define        NINDIR(fs)      ((fs)->fs_nindir)
+
+extern int inside[], around[];
+extern u_char *fragtbl[];