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