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