Ext2
include/fs/ext2.h View source View on GitHubStructs
Section titled “Structs”ext2_sblock
Section titled “ext2_sblock” struct ext2_sblock (39 fields) source
uint32_t inodes_count uint32_t blocks_count uint32_t r_blocks_count uint32_t free_blocks_count uint32_t free_inodes_count uint32_t first_data_block uint32_t log_block_size uint32_t log_frag_size uint32_t blocks_per_group uint32_t frags_per_group uint32_t inodes_per_group uint32_t mtime uint32_t wtime uint16_t mnt_count uint16_t max_mnt_count uint16_t magic uint16_t state uint16_t errors uint16_t minor_rev_level uint32_t lastcheck uint32_t checkinterval uint32_t creator_os uint32_t rev_level uint16_t def_resuid uint16_t def_resgid uint32_t first_ino uint16_t inode_size uint16_t block_group_nr uint32_t feature_compat uint32_t feature_incompat uint32_t feature_ro_compat uint8_t uuid[16] char volume_name[16] char last_mounted[64] uint32_t algorithm_usage_bitmap uint8_t prealloc_blocks uint8_t prealloc_dir_blocks uint16_t padding union struct uint32_t journal_uuid[4] uint32_t journal_inum uint32_t journal_dev uint32_t last_orphan uint32_t hash_seed[4] uint8_t def_hash_version uint8_t journal_backup_type uint16_t desc_size uint32_t default_mount_opts uint32_t first_meta_bg uint32_t mkfs_time uint32_t journal_blocks[17] uint32_t quota_group_inode [4] → offset 0x258
uint32_t quota_project_inode [5] → offset 0x25C
uint32_t reserved[204] ext2_group_desc
Section titled “ext2_group_desc” struct ext2_group_desc (8 fields) source
ext2_inode
Section titled “ext2_inode” struct ext2_inode (19 fields) source
uint16_t uid uint32_t size uint32_t atime uint32_t ctime uint32_t mtime uint32_t dtime uint16_t gid uint16_t links_count uint32_t blocks uint32_t flags uint32_t osd1 uint32_t block[EXT2_NBLOCKS] uint32_t generation uint32_t file_acl uint32_t dir_acl uint32_t faddr uint8_t frag[16] uint8_t osd2[12] ext2_full_inode
Section titled “ext2_full_inode” struct ext2_full_inode (3 fields) source
ext2_dir_entry
Section titled “ext2_dir_entry” struct ext2_dir_entry (5 fields) source
ext2_fs
Section titled “ext2_fs” struct ext2_fs (14 fields) source
struct block_device *drive struct ext2_sblock *sblock struct ext2_group_desc *group_desc struct bcache_entry *sbcache_ent struct bcache_entry *gdesc_cache_ent uint32_t num_groups uint32_t inodes_count uint32_t inodes_per_group uint32_t blocks_per_group uint32_t block_size uint32_t sectors_per_block uint16_t inode_size ext2_errno
Section titled “ext2_errno” enum ext2_errno (2 variants) source
EXT2_ERR_FS_INVALID = ERR_DELTA_START EXT2_ERR_NO_INODE Type Aliases
Section titled “Type Aliases”dir_entry_callback
Section titled “dir_entry_callback”typedef bool (*dir_entry_callback)(
struct ext2_fs * fs,
struct ext2_dir_entry * entry,
void * ctx,
uint32_t block_num,
uint32_t entry_num,
uint32_t entry_offset
) source ext2_block_visitor
Section titled “ext2_block_visitor”typedef void (*ext2_block_visitor)(
struct ext2_fs * fs,
struct ext2_inode * inode,
uint32_t depth,
uint32_t * block_ptr,
void * user_data
) source Functions
Section titled “Functions”ext2_block_read
Section titled “ext2_block_read”uint8_t * ext2_block_read(
struct ext2_fs *fs,
uint32_t block_num,
struct bcache_entry **out
) source ext2_block_write
Section titled “ext2_block_write”bool ext2_block_write(
struct ext2_fs *fs,
struct bcache_entry *ent,
enum bio_request_priority prio
) source ext2_read_superblock
Section titled “ext2_read_superblock”bool ext2_read_superblock(
struct partition * *,
struct ext2_sblock *sblock
) source ext2_write_superblock
Section titled “ext2_write_superblock”ext2_write_group_desc
Section titled “ext2_write_group_desc”ext2_mount
Section titled “ext2_mount”ext2_g_mount
Section titled “ext2_g_mount”ext2_inode_read
Section titled “ext2_inode_read”struct ext2_inode * ext2_inode_read(
struct ext2_fs *fs,
inode_t inode_idx,
struct bcache_entry **out_ent
) source ext2_inode_write
Section titled “ext2_inode_write”bool ext2_inode_write(
struct ext2_fs *fs,
inode_t inode_num,
const struct ext2_inode *inode
) source ext2_get_or_set_block
Section titled “ext2_get_or_set_block”uint32_t ext2_get_or_set_block(
struct ext2_fs *fs,
struct ext2_inode *inode,
uint32_t block_index,
uint32_t new_block_num,
bool allocate,
bool *was_allocated
) source ext2_block_to_lba
Section titled “ext2_block_to_lba”ext2_dirent_valid
Section titled “ext2_dirent_valid”bool ext2_dirent_valid(struct ext2_dir_entry *entry) source ext2_init_inode
Section titled “ext2_init_inode”void ext2_init_inode(struct ext2_inode *new_inode, mode_t mode) source ext2_init_dirent
Section titled “ext2_init_dirent”void ext2_init_dirent(
struct ext2_fs *fs,
struct ext2_dir_entry *new_entry,
inode_t inode_num,
const char *name,
uint8_t type
) source ext2_extract_ftype
Section titled “ext2_extract_ftype”ext2_walk_dir
Section titled “ext2_walk_dir”bool ext2_walk_dir(
struct ext2_fs *fs,
struct ext2_full_inode *dir,
dir_entry_callback cb,
void *ctx
) source ext2_dealloc_inode
Section titled “ext2_dealloc_inode”void ext2_dealloc_inode(struct ext2_full_inode *ino) source ext2_get_block_group
Section titled “ext2_get_block_group”ext2_get_inode_group
Section titled “ext2_get_inode_group”ext2_fs_lock
Section titled “ext2_fs_lock”ext2_fs_unlock
Section titled “ext2_fs_unlock”ext2_prefetch_block
Section titled “ext2_prefetch_block”ext2_inode_lock
Section titled “ext2_inode_lock”void ext2_inode_lock(struct ext2_full_inode *ino) source ext2_inode_unlock
Section titled “ext2_inode_unlock”void ext2_inode_unlock(struct ext2_full_inode *ino) source ext2_create_bcache_ent
Section titled “ext2_create_bcache_ent”uint8_t * ext2_create_bcache_ent(
struct ext2_fs *fs,
uint32_t block,
struct bcache_entry **out
) source ext2_link_file
Section titled “ext2_link_file”enum err ext2_link_file(
struct ext2_fs *fs,
struct ext2_full_inode *dir_inode,
struct ext2_full_inode *inode,
const char *name,
uint8_t type,
bool increment_links
) source ext2_unlink_file
Section titled “ext2_unlink_file”enum err ext2_unlink_file(
struct ext2_fs *fs,
struct ext2_full_inode *dir_inode,
const char *name,
bool free_blocks,
bool decrement_links
) source ext2_create_file
Section titled “ext2_create_file”enum err ext2_create_file(
struct ext2_fs *fs,
struct ext2_full_inode *parent_dir,
const char *name,
mode_t mode,
bool increment_links
) source ext2_symlink_file
Section titled “ext2_symlink_file”enum err ext2_symlink_file(
struct ext2_fs *fs,
struct ext2_full_inode *dir_inode,
const char *name,
const char *target
) source ext2_write_file
Section titled “ext2_write_file”enum err ext2_write_file(
struct ext2_fs *fs,
struct ext2_full_inode *inode,
uint32_t offset,
const uint8_t *src,
uint32_t size
) source ext2_read_file
Section titled “ext2_read_file”enum err ext2_read_file(
struct ext2_fs *fs,
struct ext2_full_inode *inode,
uint32_t offset,
uint8_t *buffer,
uint64_t length
) source ext2_truncate_file
Section titled “ext2_truncate_file”enum err ext2_truncate_file(
struct ext2_fs *fs,
struct ext2_full_inode *inode,
uint32_t new_size
) source ext2_chmod
Section titled “ext2_chmod”enum err ext2_chmod(
struct ext2_fs *fs,
struct ext2_full_inode *node,
mode_t new_mode
) source ext2_chown
Section titled “ext2_chown”ext2_readlink
Section titled “ext2_readlink”enum err ext2_readlink(
struct ext2_fs *fs,
struct ext2_full_inode *node,
char *buf,
uint64_t size
) source ext2_find_file_in_dir
Section titled “ext2_find_file_in_dir”struct ext2_full_inode * ext2_find_file_in_dir(
struct ext2_fs *fs,
struct ext2_full_inode *dir_inode,
const char *fname,
uint8_t *type_out
) source ext2_dir_contains_file
Section titled “ext2_dir_contains_file”bool ext2_dir_contains_file(
struct ext2_fs *fs,
struct ext2_full_inode *dir_inode,
const char *fname
) source ext2_mkdir
Section titled “ext2_mkdir”enum err ext2_mkdir(
struct ext2_fs *fs,
struct ext2_full_inode *parent_dir,
const char *name,
mode_t mode
) source ext2_rmdir
Section titled “ext2_rmdir”enum err ext2_rmdir(
struct ext2_fs *fs,
struct ext2_full_inode *parent_dir,
const char *name
) source ext2_readdir
Section titled “ext2_readdir”enum err ext2_readdir(
struct ext2_fs *fs,
struct ext2_full_inode *dir_inode,
struct ext2_dir_entry *out,
uint32_t entry_offset
) source ext2_alloc_block
Section titled “ext2_alloc_block”ext2_free_block
Section titled “ext2_free_block”ext2_alloc_inode
Section titled “ext2_alloc_inode”ext2_free_inode
Section titled “ext2_free_inode”ext2_find_first_available
Section titled “ext2_find_first_available”bool ext2_find_first_available(
struct ext2_fs *fs,
struct ext2_full_inode *dir,
uint32_t *new_block
) source ext2_traverse_inode_blocks
Section titled “ext2_traverse_inode_blocks”void ext2_traverse_inode_blocks(
struct ext2_fs *fs,
struct ext2_inode *inode,
ext2_block_visitor visitor,
void *user_data,
bool readahead
) source ext2_g_print
Section titled “ext2_g_print”ext2_dump_file_data
Section titled “ext2_dump_file_data”void ext2_dump_file_data(
struct ext2_fs *fs,
const struct ext2_inode *inode,
uint32_t start_block_index,
uint32_t length
) source Variables
Section titled “Variables”PTRS_PER_BLOCK
Section titled “PTRS_PER_BLOCK”extern uint64_t PTRS_PER_BLOCK source move this flaming disaster into internal.h, and also, this file is going to all get modified BIG TIME when we get actual page cache stuff.
If you are reading this for the sake of education, DON’T!
Macros
Section titled “Macros”EXT2_PRIO_DIRENT
Section titled “EXT2_PRIO_DIRENT”#define EXT2_PRIO_DIRENT BIO_RQ_MEDIUM source EXT2_PRIO_INODE
Section titled “EXT2_PRIO_INODE”#define EXT2_PRIO_INODE BIO_RQ_MEDIUM source EXT2_PRIO_DATA
Section titled “EXT2_PRIO_DATA”#define EXT2_PRIO_DATA BIO_RQ_HIGH source EXT2_PRIO_BITMAPS
Section titled “EXT2_PRIO_BITMAPS”#define EXT2_PRIO_BITMAPS BIO_RQ_BACKGROUND source EXT2_PRIO_SBLOCK
Section titled “EXT2_PRIO_SBLOCK”#define EXT2_PRIO_SBLOCK BIO_RQ_LOW source EXT2_NBLOCKS
Section titled “EXT2_NBLOCKS”#define EXT2_NBLOCKS 15 source EXT2_SUPERBLOCK_OFFSET
Section titled “EXT2_SUPERBLOCK_OFFSET”#define EXT2_SUPERBLOCK_OFFSET 1024 source EXT2_SIGNATURE_OFFSET
Section titled “EXT2_SIGNATURE_OFFSET”#define EXT2_SIGNATURE_OFFSET 0x38 source EXT2_SIGNATURE
Section titled “EXT2_SIGNATURE”#define EXT2_SIGNATURE 0xEF53 source EXT2_NAME_LEN
Section titled “EXT2_NAME_LEN”#define EXT2_NAME_LEN 255 source EXT2_ROOT_INODE
Section titled “EXT2_ROOT_INODE”#define EXT2_ROOT_INODE 2 source EXT2_S_IFSOCK
Section titled “EXT2_S_IFSOCK”#define EXT2_S_IFSOCK 0xC000 source socket
EXT2_S_IFLNK
Section titled “EXT2_S_IFLNK”#define EXT2_S_IFLNK 0xA000 source symbolic link
EXT2_S_IFREG
Section titled “EXT2_S_IFREG”#define EXT2_S_IFREG 0x8000 source regular file
EXT2_S_IFBLK
Section titled “EXT2_S_IFBLK”#define EXT2_S_IFBLK 0x6000 source block device
EXT2_S_IFDIR
Section titled “EXT2_S_IFDIR”#define EXT2_S_IFDIR 0x4000 source directory
EXT2_S_IFCHR
Section titled “EXT2_S_IFCHR”#define EXT2_S_IFCHR 0x2000 source character device
EXT2_S_IFIFO
Section titled “EXT2_S_IFIFO”#define EXT2_S_IFIFO 0x1000 source FIFO
EXT2_S_IFMT
Section titled “EXT2_S_IFMT”#define EXT2_S_IFMT 0xF000 source mask to extract file type from i_mode
EXT2_S_PERMS
Section titled “EXT2_S_PERMS”#define EXT2_S_PERMS 0x0FFF source lower 12 bits: special + rwx bits
EXT2_S_IRWXU
Section titled “EXT2_S_IRWXU”#define EXT2_S_IRWXU 0x01C0 source owner permissions - ALL
EXT2_S_IRWXG
Section titled “EXT2_S_IRWXG”#define EXT2_S_IRWXG 0x0038 source group permissions - ALL
EXT2_S_IRWXO
Section titled “EXT2_S_IRWXO”#define EXT2_S_IRWXO 0x0007 source others permissions - ALL
EXT2_S_PERMS_ONLY
Section titled “EXT2_S_PERMS_ONLY”#define EXT2_S_PERMS_ONLY 0x01FF source rwx bits only
EXT2_S_IRUSR
Section titled “EXT2_S_IRUSR”#define EXT2_S_IRUSR 0x0100 source Owner can read
EXT2_S_IWUSR
Section titled “EXT2_S_IWUSR”#define EXT2_S_IWUSR 0x0080 source Owner can write
EXT2_S_IXUSR
Section titled “EXT2_S_IXUSR”#define EXT2_S_IXUSR 0x0040 source Owner can execute
EXT2_S_IRGRP
Section titled “EXT2_S_IRGRP”#define EXT2_S_IRGRP 0x0020 source Group can read
EXT2_S_IWGRP
Section titled “EXT2_S_IWGRP”#define EXT2_S_IWGRP 0x0010 source Group can write
EXT2_S_IXGRP
Section titled “EXT2_S_IXGRP”#define EXT2_S_IXGRP 0x0008 source Group can execute
EXT2_S_IROTH
Section titled “EXT2_S_IROTH”#define EXT2_S_IROTH 0x0004 source Others can read
EXT2_S_IWOTH
Section titled “EXT2_S_IWOTH”#define EXT2_S_IWOTH 0x0002 source Others can write
EXT2_S_IXOTH
Section titled “EXT2_S_IXOTH”#define EXT2_S_IXOTH 0x0001 source Others can execute
EXT2_FT_UNKNOWN
Section titled “EXT2_FT_UNKNOWN”#define EXT2_FT_UNKNOWN 0 source Unknown file type
EXT2_FT_REG_FILE
Section titled “EXT2_FT_REG_FILE”#define EXT2_FT_REG_FILE 1 source Regular file
EXT2_FT_DIR
Section titled “EXT2_FT_DIR”#define EXT2_FT_DIR 2 source Directory
EXT2_FT_CHRDEV
Section titled “EXT2_FT_CHRDEV”#define EXT2_FT_CHRDEV 3 source Character device
EXT2_FT_BLKDEV
Section titled “EXT2_FT_BLKDEV”#define EXT2_FT_BLKDEV 4 source Block device
EXT2_FT_FIFO
Section titled “EXT2_FT_FIFO”#define EXT2_FT_FIFO 5 source FIFO (named pipe)EXT2_FT_SOCK
Section titled “EXT2_FT_SOCK”#define EXT2_FT_SOCK 6 source Unix domain socket
EXT2_FT_SYMLINK
Section titled “EXT2_FT_SYMLINK”#define EXT2_FT_SYMLINK 7 source Symbolic link
EXT2_FT_MAX
Section titled “EXT2_FT_MAX”#define EXT2_FT_MAX 8 source Number of defined file types
EXT2_SECRM_FL
Section titled “EXT2_SECRM_FL”#define EXT2_SECRM_FL 0x00000001 source ext2 inode flags
Secure deletion
EXT2_UNRM_FL
Section titled “EXT2_UNRM_FL”#define EXT2_UNRM_FL 0x00000002 source Undelete
EXT2_COMPR_FL
Section titled “EXT2_COMPR_FL”#define EXT2_COMPR_FL 0x00000004 source Compress file
EXT2_SYNC_FL
Section titled “EXT2_SYNC_FL”#define EXT2_SYNC_FL 0x00000008 source Synchronous updates
EXT2_IMMUTABLE_FL
Section titled “EXT2_IMMUTABLE_FL”#define EXT2_IMMUTABLE_FL 0x00000010 source Immutable file
EXT2_APPEND_FL
Section titled “EXT2_APPEND_FL”#define EXT2_APPEND_FL 0x00000020 source Writes only append
EXT2_NODUMP_FL
Section titled “EXT2_NODUMP_FL”#define EXT2_NODUMP_FL 0x00000040 source Don’t include in backups
EXT2_NOATIME_FL
Section titled “EXT2_NOATIME_FL”#define EXT2_NOATIME_FL 0x00000080 source Don’t update access time
EXT2_DIRTY_FL
Section titled “EXT2_DIRTY_FL”#define EXT2_DIRTY_FL 0x00000100 source Dirty (compress support)EXT2_COMPRBLK_FL
Section titled “EXT2_COMPRBLK_FL”#define EXT2_COMPRBLK_FL 0x00000200 source One or more compressed clusters
EXT2_NOCOMPR_FL
Section titled “EXT2_NOCOMPR_FL”#define EXT2_NOCOMPR_FL 0x00000400 source Don’t compress
EXT2_ECOMPR_FL
Section titled “EXT2_ECOMPR_FL”#define EXT2_ECOMPR_FL 0x00000800 source Compression error
EXT2_IMAGIC_FL
Section titled “EXT2_IMAGIC_FL”#define EXT2_IMAGIC_FL 0x00002000 source AFS directory
EXT2_JOURNAL_DATA_FL
Section titled “EXT2_JOURNAL_DATA_FL”#define EXT2_JOURNAL_DATA_FL 0x00004000 source Write data to journal (data=journal)
EXT2_NOTAIL_FL
Section titled “EXT2_NOTAIL_FL”#define EXT2_NOTAIL_FL 0x00008000 source File tail not merged (reiserfs)
EXT2_DIRSYNC_FL
Section titled “EXT2_DIRSYNC_FL”#define EXT2_DIRSYNC_FL 0x00010000 source Directory sync updates
EXT2_TOPDIR_FL
Section titled “EXT2_TOPDIR_FL”#define EXT2_TOPDIR_FL 0x00020000 source Top of directory hierarchy
EXT2_HUGE_FILE_FL
Section titled “EXT2_HUGE_FILE_FL”#define EXT2_HUGE_FILE_FL 0x00040000 source Set to each huge file
EXT2_EXTENTS_FL
Section titled “EXT2_EXTENTS_FL”#define EXT2_EXTENTS_FL 0x00080000 source Inode uses extents
EXT2_EA_INODE_FL
Section titled “EXT2_EA_INODE_FL”#define EXT2_EA_INODE_FL 0x00200000 source Inode stores extended attributes
EXT2_INLINE_DATA_FL
Section titled “EXT2_INLINE_DATA_FL”#define EXT2_INLINE_DATA_FL 0x10000000 source Data is stored inline in inode
EXT2_PROJINHERIT_FL
Section titled “EXT2_PROJINHERIT_FL”#define EXT2_PROJINHERIT_FL 0x20000000 source Project ID inheritance
EXT2_RESERVED_FL
Section titled “EXT2_RESERVED_FL”#define EXT2_RESERVED_FL 0x80000000 source Reserved for ext3/4
Useful masks
EXT2_FL_USER_VISIBLE
Section titled “EXT2_FL_USER_VISIBLE”#define EXT2_FL_USER_VISIBLE 0x000BDFFF source User-visible flags
EXT2_FL_USER_MODIFIABLE
Section titled “EXT2_FL_USER_MODIFIABLE”#define EXT2_FL_USER_MODIFIABLE source Expansion
#define EXT2_FL_USER_MODIFIABLE \
(EXT2_FL_USER_VISIBLE & ~(EXT2_SECRM_FL | EXT2_UNRM_FL)) MAKE_NOP_CALLBACK
Section titled “MAKE_NOP_CALLBACK”#define MAKE_NOP_CALLBACK source Expansion
#define MAKE_NOP_CALLBACK \
static cc_unused bool nop_callback( \
struct ext2_fs *fs, struct ext2_dir_entry *entry, void *ctx_ptr, \
uint32_t block_num, uint32_t entry_num, uint32_t entry_offset) { \
cc_ignore(fs, entry_offset, entry, ctx_ptr, block_num, entry_num); \
return false; \
}