1FILSYS(5)                     File Formats Manual                    FILSYS(5)
2
3
4

NAME

6       filsys, flblk, ino - format of file system volume
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <sys/flbk.h>
11       #include <sys/filsys.h>
12       #include <sys/ino.h>
13

DESCRIPTION

15       Every  file system storage volume (e.g. RF disk, RK disk, RP disk, DEC‐
16       tape reel) has a common format for certain  vital  information.   Every
17       such volume is divided into a certain number of 512-byte blocks.  Block
18       0 is unused and is available  to  contain  a  bootstrap  program,  pack
19       label, or other information.
20
21       Block  1  is the super block.  The layout of the super block as defined
22       by the include file <sys/filsys.h> is:
23
24       S_isize is the address of the  first  block  after  the  i-list,  which
25       starts  just  after  the  super-block,  in  block 2.  Thus is i-list is
26       s_isize-2 blocks long.  S_fsize is the address of the first  block  not
27       potentially available for allocation to a file.  These numbers are used
28       by the system to check for bad  block  addresses;  if  an  `impossible'
29       block address is allocated from the free list or is freed, a diagnostic
30       is written on  the  on-line  console.   Moreover,  the  free  array  is
31       cleared,  so  as  to  prevent further allocation from a presumably cor‐
32       rupted free list.
33
34       The free list for each volume is maintained  as  follows.   The  s_free
35       array  contains,  in  s_free[1], ... , s_free[s_nfree-1], up to NICFREE
36       free block numbers.  NICFREE is a configuration constant.  S_free[0] is
37       the  block  address  of  the head of a chain of blocks constituting the
38       free list.  The layout of each block of the free chain  as  defined  in
39       the include file <sys/fblk.h> is:
40
41       The  fields  df_nfree and df_free in a free block are used exactly like
42       s_nfree and s_free in the super block.  To allocate a block:  decrement
43       s_nfree, and the new block number is s_free[s_nfree].  If the new block
44       address is 0, there are no blocks left, so give an error.   If  s_nfree
45       became 0, read the new block into s_nfree and s_free.  To free a block,
46       check if s_nfree is NICFREE; if so, copy s_nfree and the  s_free  array
47       into  it,  write  it  out,  and  set  s_nfree  to  0.  In any event set
48       s_free[s_nfree] to the freed block's address and increment s_nfree.
49
50       S_ninode is the number of free i-numbers  in  the  s_inode  array.   To
51       allocate  an  i-node:  if  s_ninode is greater than 0, decrement it and
52       return s_inode[s_ninode].  If it was 0, read the i-list and  place  the
53       numbers of all free inodes (up to NICINOD) into the s_inode array, then
54       try again.  To free an i-node, provided s_ninode is less than NICINODE,
55       place  its  number  into  s_inode[s_ninode] and increment s_ninode.  If
56       s_ninode is already NICINODE, don't bother to enter  the  freed  i-node
57       into  any  table.  This list of i-nodes is only to speed up the alloca‐
58       tion process; the information as to whether the inode is really free or
59       not is maintained in the inode itself.
60
61       S_flock  and  s_ilock are flags maintained in the core copy of the file
62       system while it is mounted and their values  on  disk  are  immaterial.
63       The  value  of  s_fmod  on disk is likewise immaterial; it is used as a
64       flag to indicate that the super-block has changed and should be  copied
65       to the disk during the next periodic update of file system information.
66       S_ronly is a write-protection indicator; its disk value is also immate‐
67       rial.
68
69       S_time is the last time the super-block of the file system was changed.
70       During a reboot, s_time of the super-block for the root file system  is
71       used to set the system's idea of the time.
72
73       The  fields  s_tfree,  s_tinode,  s_fname and s_fpack are not currently
74       maintained.
75
76       I-numbers begin at 1, and the storage for i-nodes begins  in  block  2.
77       I-nodes  are 64 bytes long, so 8 of them fit into a block.  I-node 2 is
78       reserved for the root directory of the file system, but no other i-num‐
79       ber has a built-in meaning.  Each i-node represents one file.  The for‐
80       mat of an i-node as given in the include file <sys/ino.h> is:
81
82       Di_mode tells the kind of  file;  it  is  encoded  identically  to  the
83       st_mode  field of stat(2).  Di_nlink is the number of directory entries
84       (links) that refer to this i-node.  Di_uid and di_gid are  the  owner's
85       user and group IDs.  Size is the number of bytes in the file.  Di_atime
86       and di_mtime are the times of last access and modification of the  file
87       contents  (read,  write or create) (see times(2)); Di_ctime records the
88       time of last modification to the inode or to the file, and is  used  to
89       determine whether it should be dumped.
90
91       Special  files  are  recognized  by their modes and not by i-number.  A
92       block-type special file is one which can potentially be  mounted  as  a
93       file  system;  a  character-type  special file cannot, though it is not
94       necessarily character-oriented.  For special files, the  di_addr  field
95       is  occupied  by  the  device code (see types(5)).  The device codes of
96       block and character special files overlap.
97
98       Disk addresses of plain files and directories are  kept  in  the  array
99       di_addr  packed  into  3  bytes  each.   The first 10 addresses specify
100       device blocks directly.  The last 3 addresses are singly,  doubly,  and
101       triply indirect and point to blocks of 128 block pointers.  Pointers in
102       indirect blocks have the type daddr_t (see types(5)).
103
104       For block b in a file to exist, it is not  necessary  that  all  blocks
105       less  than b exist.  A zero block number either in the address words of
106       the i-node or in an indirect block  indicates  that  the  corresponding
107       block  has  never  been allocated.  Such a missing block reads as if it
108       contained all zero words.
109

SEE ALSO

111       icheck(1), dcheck(1), dir(5), mount(1), stat(2), types(5)
112
113
114
115                                                                     FILSYS(5)
Impressum