Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0 |
| 2 | |
| 3 | ================== |
| 4 | SystemV Filesystem |
| 5 | ================== |
| 6 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | It implements all of |
| 8 | - Xenix FS, |
| 9 | - SystemV/386 FS, |
| 10 | - Coherent FS. |
| 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | To install: |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | * Answer the 'System V and Coherent filesystem support' question with 'y' |
| 15 | when configuring the kernel. |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 16 | * To mount a disk or a partition, use:: |
| 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | mount [-r] -t sysv device mountpoint |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 19 | |
| 20 | The file system type names:: |
| 21 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | -t sysv |
| 23 | -t xenix |
| 24 | -t coherent |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | may be used interchangeably, but the last two will eventually disappear. |
| 27 | |
| 28 | Bugs in the present implementation: |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 29 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | - Coherent FS: |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 31 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | - 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 Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 34 | (See Coherent "man mkfs" for a description of these features.) |
| 35 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | - SystemV Release 2 FS: |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 37 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | 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 Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 43 | These filesystems are rather similar. Here is a comparison with Minix FS: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 45 | * Linux fdisk reports on partitions |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 46 | |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 47 | - Minix FS 0x81 Linux/Minix |
| 48 | - Xenix FS ?? |
| 49 | - SystemV FS ?? |
| 50 | - Coherent FS 0x08 AIX bootable |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 52 | * Size of a block or zone (data allocation unit on disk) |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 53 | |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 54 | - 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 Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 65 | |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 66 | - 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 Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 70 | |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 71 | 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 Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 74 | |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 75 | - 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 Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 79 | |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 80 | 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 Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 83 | |
| 84 | ================================= == |
| 85 | Minix FS 1 |
| 86 | Xenix FS, SystemV FS, Coherent FS 2 |
| 87 | ================================= == |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 88 | |
| 89 | * Maximum number of hard links to a file: |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 90 | |
| 91 | =========== ========= |
| 92 | Minix FS 250 |
| 93 | Xenix FS ?? |
| 94 | SystemV FS ?? |
| 95 | Coherent FS >=10000 |
| 96 | =========== ========= |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 97 | |
| 98 | * Free inode management: |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 99 | |
| 100 | - Minix FS |
| 101 | a bitmap |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 102 | - 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 Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 107 | |
| 108 | - Minix FS |
| 109 | a bitmap |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 110 | - 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 Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 120 | |
| 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 Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 127 | |
| 128 | * Super-block layout: |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 129 | |
| 130 | - Minix FS:: |
| 131 | |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 132 | 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 Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 140 | |
| 141 | - Xenix FS, SystemV FS, Coherent FS:: |
| 142 | |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 143 | 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 Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 161 | |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 162 | then they differ considerably: |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 163 | |
| 164 | Xenix FS:: |
| 165 | |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 166 | char s_clean; |
| 167 | char s_fill[371]; |
| 168 | long s_magic; |
| 169 | long s_type; |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 170 | |
| 171 | SystemV FS:: |
| 172 | |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 173 | long s_fill[12 or 14]; |
| 174 | long s_state; |
| 175 | long s_magic; |
| 176 | long s_type; |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 177 | |
| 178 | Coherent FS:: |
| 179 | |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 180 | unsigned long s_unique; |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 181 | |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 182 | Note that Coherent FS has no magic. |
| 183 | |
| 184 | * Inode layout: |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 185 | |
| 186 | - Minix FS:: |
| 187 | |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 188 | 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 Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 195 | |
| 196 | - Xenix FS, SystemV FS, Coherent FS:: |
| 197 | |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 198 | 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 Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 208 | |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 209 | * 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 Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 233 | |
| 234 | * Directory entry on disk |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 235 | |
| 236 | - Minix FS:: |
| 237 | |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 238 | unsigned short inode; |
| 239 | char name[14/30]; |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 240 | |
| 241 | - Xenix FS, SystemV FS, Coherent FS:: |
| 242 | |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 243 | unsigned short inode; |
| 244 | char name[14]; |
| 245 | |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 246 | =========== ============== ===================== |
| 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 Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 254 | |
| 255 | * How to implement symbolic links such that the host fsck doesn't scream: |
Mauro Carvalho Chehab | 826a613 | 2020-02-17 17:12:25 +0100 | [diff] [blame] | 256 | |
Adrian Bunk | 3982cd9 | 2006-12-06 20:40:01 -0800 | [diff] [blame] | 257 | - 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 | |
| 263 | Notation: We often speak of a "block" but mean a zone (the allocation unit) |
| 264 | and not the disk driver's notion of "block". |