The structure of the Reiser file system
Other operating systems might have additional file types. Only regular files and directories have other items associated with the stat item. In all the other cases the stat item makes up the entire file.
The "rdev" field applies to special files that are not regular files (S_IFREG), directories (S_IFDIR), or links (S_IFLNK). In those cases, the field holds the device number (or socket number) belonging to the file. The "generation" field applies to the other cases and denotes the inode generation number for the file/directory/link (see above for superblock inode generation field' description). The "first" field doesn't seem to be used in version 2 anymore.
Example:
The following example shows the stat item denoted by key {2, 14, 0, 0} from the item header example above: 00000000 ff 43 05 00 03 00 00 00 50 00 00 00 00 00 00 00 ÿC......P.......
00000010 00 00 00 00 00 00 00 00 2d 1c 17 3f 34 94 ff 3e ........-..?4.ÿ>
00000020 34 94 ff 3e 01 00 00 00 00 00 00 00 4.ÿ>........
Mode: 0x43ff -- type: directory, sticky bit set, 777 permissions Reserved: 5 Num. links: 3 Size: 80 bytes UID: 0 GID: 0 Atime: Thu Jul 17 16:59:09 2003 Mtime: Sun Jun 29 20:36:52 2003 Ctime: Sun Jun 29 20:36:52 2003 Blocks: 1 First: 0
Directory Items Directory items describe a directory. If there are too many entries in a directory to be contained in one directory item, it will span across several directory items, using the offset value of the key. Directory items are made up of directory headers and file names. Just like leaf nodes, the free space (if there is any) is located in the middle of the item. The structure of a directory item is as follows:
Directory headers contain an offset, the first two parts of the referenced item's key (directory id and object id), the location of the name within the block, and a status field.
Name |
Size |
Description |
Offset |
4 |
Hash value and generation number |
Dir ID |
4 |
object id of the referenced item's parent directory |
Object ID |
4 |
object id of the referenced item |
Location |
2 |
offset of name within the item |
State |
2 |
bit 0 indicates that item contains stat data (not used) bit 2 whether entry is visible (bit set) or hidden |
The file names are simple zero-terminated ASCII strings. File name entries seem to be 8-byte aligned, but the information in the directory headers should be the authorative source for the start of the name (and implicitly the end by looking at the previous header entry). The "offset" field is aptly misnamed as it contains a hash value of the file name. Bits 7 through 30 of the field contains the actual hash value and bits 0 through 6 a generation number in case two file names within a directory hash to the same value. Bit 31 seems to be unused. The hash value is used to actually search for file and directory names in reiserfs, and the directory items are sorted by the offset value. Three different hash functions are possible: keyed tea hash, rupasov hash, and r5 hash. The purpose of the hash function is to create different values for different strings with as little collisions as possible. In the Linux implementation of reiserfs, the r5 hash seems to be the default.
|