UNIX 24-Bit Filesystem Structure ================================ http://mdfs.net/Docs/Comp/Disk/Format/Unix/24bit The Unix 24-bit filesystem uses 512-byte disk blocks. Blocks are counted with 24-bit numbers from &000000 at the start of the filesystem. The Unix filesystem is also known as UFS and S5FS (System 5 filesystem). Large values are stored 'NUXI' format, that is b16-b23, b0-b7, b8-b15 for 24-bit values and b16-b23, b24-b31, b0-b7, b8-b15 for 32-bit values. Block &000000 ------------- The first block is not used by the Unix filesystem and can be used by the disk system itself to hold data about the disk. Block &000001 ------------- Disk superblock. This contains information about the whole disk. << details not checked>> 000-001 s_isize : size in blocks of inode table 002-003 s_fsize : size in blocks of entire volume 004-005 s_nfree : number of in-core free blocks (0-100) 006-0CD s_free[100] : in core free blocks 0CE-0CF s_ninode : number of in-core i-nodes (0-100) 0D0-197 s_inode[100] : in-core free i-nodes When the free space list in the superblock is exhausted, the inode table is scanned to find 100 more blocks. 198 s_flock : locked during free list manipulation 199 s_ilock : locked during i-list manipulation 19A s_fmod : super block modified flag 19B s_ronly : disk is read-only 19C-19F s_time[2] : date of last update, seconds since 1970 1A0-1FF s_pad[48] : padding (defined as s_pad[50] in source code) Block &000002 ------------- Block &000002 onwards holds the inode table. Each inode entry is 64 bytes long. An inode is a 16-bit number. inode entries in the inode table are numbered from &0001 upwards. inode 2 is the root directory. If inode 1 has a valid 16-bit allocation vector (inode entry 8-9 is nonzero), then the file system is a 16-bit Unix filesystem, and inode 1 is the root. If inode 1 does not have a valid 16-bit allocation vector (inode entry 8-9 is zero), then the file system is a 24-bit Unix filesystem, and inode 2 is the root. inode entry ----------- 000-001 : i_mode - object mode, "adclugsrwxrwxrwx" bit 0 : "x" - executable by world bit 1 : "w" - writable by world bit 2 : "r" - readable by world bit 3 : "x" - executable by group bit 4 : "w" - writable by group bit 5 : "r" - readable by group bit 6 : "x" - executable by owner bit 7 : "w" - writable by owner bit 8 : "r" - readable by owner bit 9 : "s" - save swapped text bit 10 : "g" - set group ID on execution bit 11 : "u" - set user ID on execution bit 12 : "l" - large object bit 13 : "c" - character device "c"+"d"="b" - block device bit 14 : "d" - directory bit 15 : "a" - space allocated on disk 002-003 : i_nlink - number of directory entries for this object if zero, this inode if free 004-005 : i_uid - object owner user id 006-007 : i_gid - object owner group id 008-009 : i_sizehi - b16-b23 of object size 00A-00B : i_sizelo - b0-b23 of object size 00C-029 : i_addr[10] - object allocation vector of ten 24-bit block numbers for the first 5K of the file. 02A-02C : indirected block, block number of a block containing the next 128 block numbers for the next 64K of the file. Each block contains: 000-001 : b16-b31 of first block number 002-003 : b0-b16 of first block number 004-005 : b16-b31 of second block number 006-007 : b0-b15 of second block number etc. 02D-02F : double indirected block, block number of a block containing a list of block numbers of blocks containing the next block numbers. 24-bit block numbers in the inode entry are stored as b16-b23 in the first byte, b0-b7 in the second byte and b8-b15 in the third byte. A block number of zero indicates that that part of the object has not been allocated any disk space. 030-033 : spare 034-035 : i_ctimehi - b16-b31 of object creation time, seconds since 1970 036-037 : i_ctimelo - b0-b15 of object creation time, seconds since 1970 038-039 : i_mtimehi - b16-b31 of object last modifcation time, seconds since 1970 03A-03B : i_mtimelo - b0-b15 of object last modified time, seconds since 1970 03C-03D : i_atimehi - b16-b31 of object last access time, seconds since 1970 03E-03F : i_atimelo - b0-b15 of object last access time, seconds since 1970 Directory entry --------------- 000-001 : i_node - inode of this object, if zero, this entry is free 002-00F : i_name[14] - object name, padded with NULs This first two entries of a directory are always '..' pointing to the parent, and '.' pointing to the same directory. The following directory entries are not stored in any particular order.