omfs.txt 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. Optimized MPEG Filesystem (OMFS)
  2. Overview
  3. ========
  4. OMFS is a filesystem created by SonicBlue for use in the ReplayTV DVR
  5. and Rio Karma MP3 player. The filesystem is extent-based, utilizing
  6. block sizes from 2k to 8k, with hash-based directories. This
  7. filesystem driver may be used to read and write disks from these
  8. devices.
  9. Note, it is not recommended that this FS be used in place of a general
  10. filesystem for your own streaming media device. Native Linux filesystems
  11. will likely perform better.
  12. More information is available at:
  13. http://linux-karma.sf.net/
  14. Various utilities, including mkomfs and omfsck, are included with
  15. omfsprogs, available at:
  16. http://bobcopeland.com/karma/
  17. Instructions are included in its README.
  18. Options
  19. =======
  20. OMFS supports the following mount-time options:
  21. uid=n - make all files owned by specified user
  22. gid=n - make all files owned by specified group
  23. umask=xxx - set permission umask to xxx
  24. fmask=xxx - set umask to xxx for files
  25. dmask=xxx - set umask to xxx for directories
  26. Disk format
  27. ===========
  28. OMFS discriminates between "sysblocks" and normal data blocks. The sysblock
  29. group consists of super block information, file metadata, directory structures,
  30. and extents. Each sysblock has a header containing CRCs of the entire
  31. sysblock, and may be mirrored in successive blocks on the disk. A sysblock may
  32. have a smaller size than a data block, but since they are both addressed by the
  33. same 64-bit block number, any remaining space in the smaller sysblock is
  34. unused.
  35. Sysblock header information:
  36. struct omfs_header {
  37. __be64 h_self; /* FS block where this is located */
  38. __be32 h_body_size; /* size of useful data after header */
  39. __be16 h_crc; /* crc-ccitt of body_size bytes */
  40. char h_fill1[2];
  41. u8 h_version; /* version, always 1 */
  42. char h_type; /* OMFS_INODE_X */
  43. u8 h_magic; /* OMFS_IMAGIC */
  44. u8 h_check_xor; /* XOR of header bytes before this */
  45. __be32 h_fill2;
  46. };
  47. Files and directories are both represented by omfs_inode:
  48. struct omfs_inode {
  49. struct omfs_header i_head; /* header */
  50. __be64 i_parent; /* parent containing this inode */
  51. __be64 i_sibling; /* next inode in hash bucket */
  52. __be64 i_ctime; /* ctime, in milliseconds */
  53. char i_fill1[35];
  54. char i_type; /* OMFS_[DIR,FILE] */
  55. __be32 i_fill2;
  56. char i_fill3[64];
  57. char i_name[OMFS_NAMELEN]; /* filename */
  58. __be64 i_size; /* size of file, in bytes */
  59. };
  60. Directories in OMFS are implemented as a large hash table. Filenames are
  61. hashed then prepended into the bucket list beginning at OMFS_DIR_START.
  62. Lookup requires hashing the filename, then seeking across i_sibling pointers
  63. until a match is found on i_name. Empty buckets are represented by block
  64. pointers with all-1s (~0).
  65. A file is an omfs_inode structure followed by an extent table beginning at
  66. OMFS_EXTENT_START:
  67. struct omfs_extent_entry {
  68. __be64 e_cluster; /* start location of a set of blocks */
  69. __be64 e_blocks; /* number of blocks after e_cluster */
  70. };
  71. struct omfs_extent {
  72. __be64 e_next; /* next extent table location */
  73. __be32 e_extent_count; /* total # extents in this table */
  74. __be32 e_fill;
  75. struct omfs_extent_entry e_entry; /* start of extent entries */
  76. };
  77. Each extent holds the block offset followed by number of blocks allocated to
  78. the extent. The final extent in each table is a terminator with e_cluster
  79. being ~0 and e_blocks being ones'-complement of the total number of blocks
  80. in the table.
  81. If this table overflows, a continuation inode is written and pointed to by
  82. e_next. These have a header but lack the rest of the inode structure.