omfs.rst 4.1 KB

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