1: /*
   2:  * Copyright (c) 1986 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  *
   6:  *	@(#)fs.h	1.3 (2.11BSD GTE) 1995/12/24
   7:  */
   8: 
   9: #ifndef _SYS_FS_H_
  10: #define _SYS_FS_H_
  11: 
  12: /*
  13:  * The root inode is the root of the file system.
  14:  * Inode 0 can't be used for normal purposes and
  15:  * historically bad blocks were linked to inode 1,
  16:  * thus the root inode is 2. (inode 1 is no longer used for
  17:  * this purpose, however numerous dump tapes make this
  18:  * assumption, so we are stuck with it)
  19:  * The lost+found directory is given the next available
  20:  * inode when it is created by ``mkfs''.
  21:  */
  22: #define BBSIZE      DEV_BSIZE
  23: #define SBSIZE      DEV_BSIZE
  24: #define BBLOCK      ((daddr_t)(0))
  25: #define SBLOCK      ((daddr_t)(BBLOCK + BBSIZE / DEV_BSIZE))
  26: 
  27: #define SUPERB      ((daddr_t)1)    /* block number of the super block */
  28: #define ROOTINO     ((ino_t)2)  /* i number of all roots */
  29: #define LOSTFOUNDINO    (ROOTINO + 1)
  30: 
  31: #define NICINOD     100     /* number of superblock inodes */
  32: #define NICFREE     50      /* number of superblock free blocks */
  33: 
  34: /*
  35:  * The path name on which the file system is mounted is maintained
  36:  * in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in
  37:  * the super block for this name.
  38:  */
  39: #define MAXMNTLEN 12
  40: 
  41: /*
  42:  * Super block for a file system.  NOTE:  The 'fs_flock' and 'fs_ilock'
  43:  * fields MUST be on an even byte boundary because they are used as sleep()
  44:  * channels and odd values specify a network sleep().
  45:  */
  46: struct  fs
  47: {
  48:     u_short fs_isize;       /* first block after i-list */
  49:     daddr_t fs_fsize;       /* size in blocks of entire volume */
  50:     short   fs_nfree;       /* number of addresses in fs_free */
  51:     daddr_t fs_free[NICFREE];   /* free block list */
  52:     short   fs_ninode;      /* number of inodes in fs_inode */
  53:     ino_t   fs_inode[NICINOD];  /* free inode list */
  54:     char    fs_flock;       /* lock during free list manipulation */
  55:     char    fs_fmod;        /* super block modified flag */
  56:     char    fs_ilock;       /* lock during i-list manipulation */
  57:     char    fs_ronly;       /* mounted read-only flag */
  58:     time_t  fs_time;        /* last super block update */
  59:     daddr_t fs_tfree;       /* total free blocks */
  60:     ino_t   fs_tinode;      /* total free inodes */
  61:     short   fs_step;        /* optimal step in free list pattern */
  62:     short   fs_cyl;         /* number of blocks per pattern */
  63:     char    fs_fsmnt[MAXMNTLEN];    /* ordinary file mounted on */
  64:     ino_t   fs_lasti;       /* start place for circular search */
  65:     ino_t   fs_nbehind;     /* est # free inodes before s_lasti */
  66:     u_short fs_flags;       /* mount time flags */
  67: /* actually longer */
  68: };
  69: 
  70: struct  fblk {
  71:     short   df_nfree;       /* number of addresses in df_free */
  72:     daddr_t df_free[NICFREE];   /* free block list */
  73: };
  74: 
  75: /*
  76:  * Turn file system block numbers into disk block addresses.
  77:  * This maps file system blocks to device size blocks.
  78:  */
  79: #define fsbtodb(b)  ((daddr_t)((daddr_t)(b)<<1))
  80: #define dbtofsb(b)  ((daddr_t)((daddr_t)(b)>>1))
  81: 
  82: /*
  83:  * Macros for handling inode numbers:
  84:  *     inode number to file system block offset.
  85:  *     inode number to file system block address.
  86:  */
  87: #define itoo(x)     ((int)(((x) + 2 * INOPB - 1) % INOPB))
  88: #define itod(x)     ((daddr_t)((((u_int)(x) + 2 * INOPB - 1) / INOPB)))
  89: 
  90: /*
  91:  * The following macros optimize certain frequently calculated
  92:  * quantities by using shifts and masks in place of divisions
  93:  * modulos and multiplications.
  94:  */
  95: #define blkoff(loc)     /* calculates (loc % fs->fs_bsize) */ \
  96:     ((loc) & DEV_BMASK)
  97: #define lblkno(loc)     /* calculates (loc / fs->fs_bsize) */ \
  98:     ((loc) >> DEV_BSHIFT)
  99: 
 100: /*
 101:  * Determine the number of available blocks given a
 102:  * percentage to hold in reserve
 103:  */
 104: #define freespace(fs, percentreserved) \
 105:     ((fs)->fs_tfree - ((fs)->fs_fsize - \
 106:     (fs)->fs_isize) * (percentreserved) / 100)
 107: 
 108: /*
 109:  * INOPB is the number of inodes in a secondary storage block.
 110:  */
 111: #define INOPB   16          /* MAXBSIZE / sizeof(dinode) */
 112: 
 113: /*
 114:  * NINDIR is the number of indirects in a file system block.
 115:  */
 116: #define NINDIR      (DEV_BSIZE / sizeof(daddr_t))
 117: #define NSHIFT      8       /* log2(NINDIR) */
 118: #define NMASK       0377L       /* NINDIR - 1 */
 119: 
 120: /*
 121:  * We continue to implement pipes within the file system because it would
 122:  * be pretty tough for us to handle 10 4K blocked pipes on a 1M machine.
 123:  *
 124:  * 4K is the allowable buffering per write on a pipe.  This is also roughly
 125:  * the max size of the file created to implement the pipe.  If this size is
 126:  * bigger than 4096, pipes will be implemented with large files, which is
 127:  * probably not good.
 128:  */
 129: #define MAXPIPSIZ   (NDADDR * MAXBSIZE)
 130: 
 131: #if defined(KERNEL) && !defined(SUPERVISOR)
 132: struct  fs *getfs();
 133: struct  fs *mountfs();
 134: #endif
 135: #endif /* _SYS_FS_H_ */

Defined struct's

fblk defined in line 70; used 18 times

Defined macros

BBLOCK defined in line 24; used 1 times
  • in line 25
BBSIZE defined in line 22; used 10 times
LOSTFOUNDINO defined in line 29; used 3 times
MAXMNTLEN defined in line 39; used 1 times
  • in line 63
MAXPIPSIZ defined in line 129; used 5 times
NICINOD defined in line 31; used 7 times
NSHIFT defined in line 117; used 9 times
_SYS_FS_H_ defined in line 10; used 1 times
  • in line 9
freespace defined in line 104; never used
fsbtodb defined in line 79; used 10 times

Usage of this include

fs.h used 60 times
Last modified: 1995-12-27
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3962
Valid CSS Valid XHTML 1.0 Strict