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
fs
defined in line
46; used 88 times
- in line 132-133(4)
- in /usr/src/bin/df.c line
219(2)
- in /usr/src/old/dump/dumptraverse.c line
4(2)
- in /usr/src/sbin/dcheck/dcheck.c line
30(2)
- in /usr/src/sbin/dump/dumptraverse.c line
7(2)
- in /usr/src/sbin/icheck/icheck.c line
23(2)
- in /usr/src/sbin/mkfs/mkfs.c line
59(2)
- in /usr/src/sbin/ncheck/ncheck.c line
28(2)
- in /usr/src/sbin/quotacheck/quotacheck.c line
69(2)
- in /usr/src/sbin/restor/restor.c line
44(2)
- in /usr/src/sbin/savecore/savecore.c line
263(2)
- in /usr/src/sys/h/mount.h line
54(2)
- in /usr/src/sys/pdp/machdep2.c line
381(2)
- in /usr/src/sys/sys/init_main.c line
61(2)
- in /usr/src/sys/sys/quota_subr.c line
84(2)
- in /usr/src/sys/sys/ufs_alloc.c line
38(2),
81-83(4),
136(2),
245(2),
289(2),
311(2)
- in /usr/src/sys/sys/ufs_inode.c line
102(2)
- in /usr/src/sys/sys/ufs_mount.c line
37(2),
139(2),
158(2),
166(2),
220(2)
- in /usr/src/sys/sys/ufs_namei.c line
119(2),
1072(2)
- in /usr/src/sys/sys/ufs_subr.c line
29(2),
107(2),
128-133(4),
146(2)
- in /usr/src/sys/sys/ufs_syscalls2.c line
66(2),
129(2),
155(2),
170(2)
- in /usr/src/usr.sbin/lpr/recvjob.c line
257(2)
- in /usr/src/usr.sbin/mkproto/mkproto.c line
29-33(4)
- in /usr/src/usr.sbin/quot/quot.c line
24(2)
Defined macros
BBSIZE
defined in line
22; used 10 times
INOPB
defined in line
111; used 40 times
- in line 87-88(4)
- in /usr/src/bin/df.c line
257
- in /usr/src/old/dump/dumptraverse.c line
5,
18,
24
- in /usr/src/sbin/dcheck/dcheck.c line
41,
114,
130,
142
- in /usr/src/sbin/dump/dumptraverse.c line
8,
21,
27
- in /usr/src/sbin/fsck/setup.c line
78-83(2)
- in /usr/src/sbin/icheck/icheck.c line
24,
147,
173
- in /usr/src/sbin/mkfs/mkfs.c line
233-239(4),
254,
443
- in /usr/src/sbin/ncheck/ncheck.c line
29,
126-131(2),
144,
156
- in /usr/src/sbin/quotacheck/quotacheck.c line
224
- in /usr/src/sbin/restor/restor.c line
346,
1206-1209(2),
1221-1223(2)
- in /usr/src/sys/sys/ufs_alloc.c line
201-205(2)
- in /usr/src/sys/sys/ufs_syscalls2.c line
75
NICFREE
defined in line
32; used 21 times
- in line 51,
72
- in /usr/src/sbin/fsck/pass5.c line
43,
108,
172,
183
- in /usr/src/sbin/icheck/icheck.c line
356,
367,
373,
389-392(2)
- in /usr/src/sbin/mkfs/mkfs.c line
355,
396-398(2)
- in /usr/src/sbin/restor/restor.c line
810-812(2),
845
- in /usr/src/sys/sys/ufs_alloc.c line
51,
260
- in /usr/src/sys/sys/ufs_subr.c line
139
- in /usr/src/usr.sbin/mkproto/mkproto.c line
378
NINDIR
defined in line
116; used 40 times
- in /usr/src/old/dump/dumptraverse.c line
68-74(3),
81
- in /usr/src/sbin/dcheck/dcheck.c line
249
- in /usr/src/sbin/dump/dumptraverse.c line
69-75(3),
82
- in /usr/src/sbin/fsck/inode.c line
82-87(5)
- in /usr/src/sbin/fsck/pass1.c line
98
- in /usr/src/sbin/icheck/icheck.c line
229-231(3),
272,
284,
296
- in /usr/src/sbin/ncheck/ncheck.c line
366-371(2)
- in /usr/src/sbin/restor/restor.c line
785-789(2),
867
- in /usr/src/sys/sys/ufs_bmap.c line
133
- in /usr/src/sys/sys/ufs_inode.c line
488-489(3),
616-619(3),
643,
667,
706-710(3)
- in /usr/src/usr.sbin/mkproto/mkproto.c line
306,
335
ROOTINO
defined in line
28; used 76 times
- in line 29
- in /usr/src/sbin/dcheck/dcheck.c line
166
- in /usr/src/sbin/dump/dumpdir.c line
94
- in /usr/src/sbin/fsck/dir.c line
202,
306-323(6),
342,
348-351(2),
411(2),
510
- in /usr/src/sbin/fsck/inode.c line
121,
179,
195,
251
- in /usr/src/sbin/fsck/main.c line
234
- in /usr/src/sbin/fsck/pass1.c line
39
- in /usr/src/sbin/fsck/pass1b.c line
28-29(2)
- in /usr/src/sbin/fsck/pass2.c line
28-30(2),
36-38(4),
44-53(7),
60-80(9)
- in /usr/src/sbin/fsck/pass3.c line
26,
36
- in /usr/src/sbin/fsck/pass4.c line
27
- in /usr/src/sbin/fsck/utilities.c line
270,
291
- in /usr/src/sbin/mkfs/mkfs.c line
272-278(3),
308
- in /usr/src/sbin/ncheck/ncheck.c line
312
- in /usr/src/sbin/quotacheck/quotacheck.c line
226,
503
- in /usr/src/sbin/restor/restor.c line
637
- in /usr/src/sys/pdpstand/sys.c line
105
- in /usr/src/sys/sys/init_main.c line
206-208(2)
- in /usr/src/sys/sys/ufs_alloc.c line
161
- in /usr/src/sys/sys/ufs_inode.c line
139
- in /usr/src/sys/sys/ufs_mount.c line
66,
117
- in /usr/src/sys/sys/ufs_namei.c line
643-644(2),
1166,
1189
- in /usr/src/usr.sbin/mkproto/mkproto.c line
103-106(3),
153,
167,
274
SBLOCK
defined in line
25; used 18 times
SBSIZE
defined in line
23; used 10 times
dbtofsb
defined in line
80; used 46 times
- in /usr/src/sbin/mkfs/mkfs.c line
185-189(2),
204
- in /usr/src/sys/pdpstand/sys.c line
314,
342
- in /usr/src/sys/pdpuba/ht.c line
178,
223-225(2),
237-238(2),
259-265(3),
313,
364-372(3)
- in /usr/src/sys/pdpuba/tm.c line
276,
358,
366,
378-383(2),
405-410(3),
550,
593
- in /usr/src/sys/pdpuba/ts.c line
262,
329,
337,
349-354(2),
375-381(3),
554,
585-587(2),
593,
599
- in /usr/src/sys/sys/kern_exec.c line
246,
285,
324
- in /usr/src/sys/sys/ufs_bmap.c line
58,
104,
141
itod
defined in line
88; used 11 times
itoo
defined in line
87; used 9 times
lblkno
defined in line
97; used 12 times
Usage of this include