blob: 89e40911ad7cbc7efabae48b6d000042609fa0b0 [file] [log] [blame]
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +01001.. SPDX-License-Identifier: GPL-2.0
2
3==================
4SystemV Filesystem
5==================
6
Linus Torvalds1da177e2005-04-16 15:20:36 -07007It implements all of
8 - Xenix FS,
9 - SystemV/386 FS,
10 - Coherent FS.
11
Linus Torvalds1da177e2005-04-16 15:20:36 -070012To install:
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +010013
Linus Torvalds1da177e2005-04-16 15:20:36 -070014* Answer the 'System V and Coherent filesystem support' question with 'y'
15 when configuring the kernel.
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +010016* To mount a disk or a partition, use::
17
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 mount [-r] -t sysv device mountpoint
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +010019
20 The file system type names::
21
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 -t sysv
23 -t xenix
24 -t coherent
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +010025
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 may be used interchangeably, but the last two will eventually disappear.
27
28Bugs in the present implementation:
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +010029
Linus Torvalds1da177e2005-04-16 15:20:36 -070030- Coherent FS:
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +010031
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 - The "free list interleave" n:m is currently ignored.
33 - Only file systems with no filesystem name and no pack name are recognized.
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +010034 (See Coherent "man mkfs" for a description of these features.)
35
Linus Torvalds1da177e2005-04-16 15:20:36 -070036- SystemV Release 2 FS:
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +010037
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 The superblock is only searched in the blocks 9, 15, 18, which
39 corresponds to the beginning of track 1 on floppy disks. No support
40 for this FS on hard disk yet.
41
42
Adrian Bunk3982cd92006-12-06 20:40:01 -080043These filesystems are rather similar. Here is a comparison with Minix FS:
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
Adrian Bunk3982cd92006-12-06 20:40:01 -080045* Linux fdisk reports on partitions
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +010046
Adrian Bunk3982cd92006-12-06 20:40:01 -080047 - Minix FS 0x81 Linux/Minix
48 - Xenix FS ??
49 - SystemV FS ??
50 - Coherent FS 0x08 AIX bootable
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
Adrian Bunk3982cd92006-12-06 20:40:01 -080052* Size of a block or zone (data allocation unit on disk)
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +010053
Adrian Bunk3982cd92006-12-06 20:40:01 -080054 - Minix FS 1024
55 - Xenix FS 1024 (also 512 ??)
56 - SystemV FS 1024 (also 512 and 2048)
57 - Coherent FS 512
58
59* General layout: all have one boot block, one super block and
60 separate areas for inodes and for directories/data.
61 On SystemV Release 2 FS (e.g. Microport) the first track is reserved and
62 all the block numbers (including the super block) are offset by one track.
63
64* Byte ordering of "short" (16 bit entities) on disk:
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +010065
Adrian Bunk3982cd92006-12-06 20:40:01 -080066 - Minix FS little endian 0 1
67 - Xenix FS little endian 0 1
68 - SystemV FS little endian 0 1
69 - Coherent FS little endian 0 1
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +010070
Adrian Bunk3982cd92006-12-06 20:40:01 -080071 Of course, this affects only the file system, not the data of files on it!
72
73* Byte ordering of "long" (32 bit entities) on disk:
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +010074
Adrian Bunk3982cd92006-12-06 20:40:01 -080075 - Minix FS little endian 0 1 2 3
76 - Xenix FS little endian 0 1 2 3
77 - SystemV FS little endian 0 1 2 3
78 - Coherent FS PDP-11 2 3 0 1
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +010079
Adrian Bunk3982cd92006-12-06 20:40:01 -080080 Of course, this affects only the file system, not the data of files on it!
81
82* Inode on disk: "short", 0 means non-existent, the root dir ino is:
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +010083
84 ================================= ==
85 Minix FS 1
86 Xenix FS, SystemV FS, Coherent FS 2
87 ================================= ==
Adrian Bunk3982cd92006-12-06 20:40:01 -080088
89* Maximum number of hard links to a file:
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +010090
91 =========== =========
92 Minix FS 250
93 Xenix FS ??
94 SystemV FS ??
95 Coherent FS >=10000
96 =========== =========
Adrian Bunk3982cd92006-12-06 20:40:01 -080097
98* Free inode management:
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +010099
100 - Minix FS
101 a bitmap
Adrian Bunk3982cd92006-12-06 20:40:01 -0800102 - Xenix FS, SystemV FS, Coherent FS
103 There is a cache of a certain number of free inodes in the super-block.
104 When it is exhausted, new free inodes are found using a linear search.
105
106* Free block management:
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +0100107
108 - Minix FS
109 a bitmap
Adrian Bunk3982cd92006-12-06 20:40:01 -0800110 - Xenix FS, SystemV FS, Coherent FS
111 Free blocks are organized in a "free list". Maybe a misleading term,
112 since it is not true that every free block contains a pointer to
113 the next free block. Rather, the free blocks are organized in chunks
114 of limited size, and every now and then a free block contains pointers
115 to the free blocks pertaining to the next chunk; the first of these
116 contains pointers and so on. The list terminates with a "block number"
117 0 on Xenix FS and SystemV FS, with a block zeroed out on Coherent FS.
118
119* Super-block location:
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +0100120
121 =========== ==========================
122 Minix FS block 1 = bytes 1024..2047
123 Xenix FS block 1 = bytes 1024..2047
124 SystemV FS bytes 512..1023
125 Coherent FS block 1 = bytes 512..1023
126 =========== ==========================
Adrian Bunk3982cd92006-12-06 20:40:01 -0800127
128* Super-block layout:
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +0100129
130 - Minix FS::
131
Adrian Bunk3982cd92006-12-06 20:40:01 -0800132 unsigned short s_ninodes;
133 unsigned short s_nzones;
134 unsigned short s_imap_blocks;
135 unsigned short s_zmap_blocks;
136 unsigned short s_firstdatazone;
137 unsigned short s_log_zone_size;
138 unsigned long s_max_size;
139 unsigned short s_magic;
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +0100140
141 - Xenix FS, SystemV FS, Coherent FS::
142
Adrian Bunk3982cd92006-12-06 20:40:01 -0800143 unsigned short s_firstdatazone;
144 unsigned long s_nzones;
145 unsigned short s_fzone_count;
146 unsigned long s_fzones[NICFREE];
147 unsigned short s_finode_count;
148 unsigned short s_finodes[NICINOD];
149 char s_flock;
150 char s_ilock;
151 char s_modified;
152 char s_rdonly;
153 unsigned long s_time;
154 short s_dinfo[4]; -- SystemV FS only
155 unsigned long s_free_zones;
156 unsigned short s_free_inodes;
157 short s_dinfo[4]; -- Xenix FS only
158 unsigned short s_interleave_m,s_interleave_n; -- Coherent FS only
159 char s_fname[6];
160 char s_fpack[6];
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +0100161
Adrian Bunk3982cd92006-12-06 20:40:01 -0800162 then they differ considerably:
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +0100163
164 Xenix FS::
165
Adrian Bunk3982cd92006-12-06 20:40:01 -0800166 char s_clean;
167 char s_fill[371];
168 long s_magic;
169 long s_type;
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +0100170
171 SystemV FS::
172
Adrian Bunk3982cd92006-12-06 20:40:01 -0800173 long s_fill[12 or 14];
174 long s_state;
175 long s_magic;
176 long s_type;
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +0100177
178 Coherent FS::
179
Adrian Bunk3982cd92006-12-06 20:40:01 -0800180 unsigned long s_unique;
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +0100181
Adrian Bunk3982cd92006-12-06 20:40:01 -0800182 Note that Coherent FS has no magic.
183
184* Inode layout:
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +0100185
186 - Minix FS::
187
Adrian Bunk3982cd92006-12-06 20:40:01 -0800188 unsigned short i_mode;
189 unsigned short i_uid;
190 unsigned long i_size;
191 unsigned long i_time;
192 unsigned char i_gid;
193 unsigned char i_nlinks;
194 unsigned short i_zone[7+1+1];
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +0100195
196 - Xenix FS, SystemV FS, Coherent FS::
197
Adrian Bunk3982cd92006-12-06 20:40:01 -0800198 unsigned short i_mode;
199 unsigned short i_nlink;
200 unsigned short i_uid;
201 unsigned short i_gid;
202 unsigned long i_size;
203 unsigned char i_zone[3*(10+1+1+1)];
204 unsigned long i_atime;
205 unsigned long i_mtime;
206 unsigned long i_ctime;
207
Adrian Bunk3982cd92006-12-06 20:40:01 -0800208
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +0100209* Regular file data blocks are organized as
210
211 - Minix FS:
212
213 - 7 direct blocks
214 - 1 indirect block (pointers to blocks)
215 - 1 double-indirect block (pointer to pointers to blocks)
216
217 - Xenix FS, SystemV FS, Coherent FS:
218
219 - 10 direct blocks
220 - 1 indirect block (pointers to blocks)
221 - 1 double-indirect block (pointer to pointers to blocks)
222 - 1 triple-indirect block (pointer to pointers to pointers to blocks)
223
224
225 =========== ========== ================
226 Inode size inodes per block
227 =========== ========== ================
228 Minix FS 32 32
229 Xenix FS 64 16
230 SystemV FS 64 16
231 Coherent FS 64 8
232 =========== ========== ================
Adrian Bunk3982cd92006-12-06 20:40:01 -0800233
234* Directory entry on disk
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +0100235
236 - Minix FS::
237
Adrian Bunk3982cd92006-12-06 20:40:01 -0800238 unsigned short inode;
239 char name[14/30];
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +0100240
241 - Xenix FS, SystemV FS, Coherent FS::
242
Adrian Bunk3982cd92006-12-06 20:40:01 -0800243 unsigned short inode;
244 char name[14];
245
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +0100246 =========== ============== =====================
247 Dir entry size dir entries per block
248 =========== ============== =====================
249 Minix FS 16/32 64/32
250 Xenix FS 16 64
251 SystemV FS 16 64
252 Coherent FS 16 32
253 =========== ============== =====================
Adrian Bunk3982cd92006-12-06 20:40:01 -0800254
255* How to implement symbolic links such that the host fsck doesn't scream:
Mauro Carvalho Chehab826a6132020-02-17 17:12:25 +0100256
Adrian Bunk3982cd92006-12-06 20:40:01 -0800257 - Minix FS normal
258 - Xenix FS kludge: as regular files with chmod 1000
259 - SystemV FS ??
260 - Coherent FS kludge: as regular files with chmod 1000
261
262
263Notation: We often speak of a "block" but mean a zone (the allocation unit)
264and not the disk driver's notion of "block".