UNIX 16-Bit Filesystem Structure ================================ http://mdfs.net/Docs/Comp/Disk/Format/Unix/16bit The Unix 16-bit filesystem uses 512-byte disk blocks. Blocks are counted with 16-bit numbers from &0000 at the start of the filesystem. The Unix filesystem is also known as UFS and S5FS (System 5 filesystem). Block &0000 ----------- 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 &0001 ----------- Disk superblock. This contains information about the whole disk. 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 &0002 ----------- Block &0002 onwards holds the inode table. Each inode entry is 32 bytes long. An inode is a 16-bit number. inode entries in the inode table are numbered from &0001 upwards. inode 1 is the root directory. If inode 1 have 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 : i_nlink - number of directory entries for this object if zero, this inode if free 003 : i_uid - object owner user id 004 : i_gid - object owner groups id 005 : i_size0 - b16-b23 of object size 006-007 : i_size1 - b0-b15 of object size, low byte first 008-017 : i_addr[8] - object allocation vector of eight 16-bit block numbers. If i_mode bit 12 is zero, then the eight blocks pointed to by the allocation vector contain the object's data. The first pointer points to the object's first 512 bytes, the second pointer to the second 512 bytes, etc, up to 8K in total. If i_mode bit 12 is one, then the eight blocks pointed to by the allocation vector each point to a block containing up to 256 block pointers that actually point to the object's contents. The first pointer points to a block that points to the data for the first 128K, the second pointer points to a block that points to the data for the second 128K, etc, up to 1M in total. If i_mode bit 12 is one and the file is larger than 1M, then the eight blocks pointed to by the allocation vector are a double indirected allocation vector. [needs details] A block number of zero indicaties that that part of the object has not been allocated any disk space. 018-01B : i_atime[2] - object last access time, seconds since 1970 01C-01F : i_mtime[2] - object last modified 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.