Changeset 9875711 in mainline


Ignore:
Timestamp:
2011-09-29T17:17:39Z (13 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6c501f8
Parents:
eb91db7
Message:

Superblock and inode structures definition

Location:
uspace/lib/ext4
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/libext4.h

    reb91db7 r9875711  
    3434#define LIBEXT4_LIBEXT4_H_
    3535
    36 #include "libext2_block_group.h"
    37 #include "libext2_directory.h"
    38 #include "libext2_inode.h"
    39 #include "libext2_superblock.h"
     36#include "libext4_block_group.h"
     37#include "libext4_directory.h"
     38#include "libext4_inode.h"
     39#include "libext4_superblock.h"
    4040
    4141#endif
  • uspace/lib/ext4/libext4_inode.c

    reb91db7 r9875711  
    3333/**
    3434 * @file        libext4_inode.c
    35  * @brief       TODO
     35 * @brief       Ext4 inode operations.
    3636 */
    3737
    38 
     38#include "libext4.h"
    3939
    4040/**
  • uspace/lib/ext4/libext4_inode.h

    reb91db7 r9875711  
    3434#define LIBEXT4_LIBEXT4_INODE_H_
    3535
     36#include <sys/types.h>
     37
     38// TODO better constant definition !!!
     39#define EXT4_N_BLOCKS   15
     40
     41/*
     42 * Structure of an inode on the disk
     43 */
     44typedef struct ext4_inode {
     45        uint16_t i_mode; // File mode
     46        uint16_t i_uid; // Low 16 bits of owner uid
     47        uint32_t i_size_lo; // Size in bytes
     48        uint32_t i_atime; // Access time
     49        uint32_t i_ctime; // Inode change time
     50        uint32_t i_mtime; // Modification time
     51        uint32_t i_dtime; // Deletion time
     52        uint16_t i_gid; // Low 16 bits of group id
     53        uint16_t i_links_count; // Links count
     54        uint32_t i_blocks_lo; // Blocks count
     55        uint32_t i_flags; // File flags
     56
     57        /*
     58        union {
     59                struct {
     60                        __le32  l_i_version;
     61                } linux1;
     62                struct {
     63                        __u32  h_i_translator;
     64                } hurd1;
     65                struct {
     66                        __u32  m_i_reserved1;
     67                } masix1;
     68        } osd1;
     69        */
     70        uint32_t unused_osd1; // OS dependent - not used in HelenOS
     71
     72    uint32_t i_block[EXT4_N_BLOCKS]; // Pointers to blocks
     73    uint32_t i_generation; // File version (for NFS)
     74    uint32_t i_file_acl_lo; // File ACL
     75    uint32_t i_size_high;
     76    uint32_t i_obso_faddr; // Obsoleted fragment address
     77
     78    /*
     79        union {
     80                struct {
     81                        __le16  l_i_blocks_high;
     82                        __le16  l_i_file_acl_high;
     83                        __le16  l_i_uid_high;
     84                        __le16  l_i_gid_high;
     85                        __u32   l_i_reserved2;
     86                } linux2;
     87                struct {
     88                        __le16  h_i_reserved1;
     89                        __u16   h_i_mode_high;
     90                        __u16   h_i_uid_high;
     91                        __u16   h_i_gid_high;
     92                        __u32   h_i_author;
     93                } hurd2;
     94                struct {
     95                        __le16  h_i_reserved1;
     96                        __le16  m_i_file_acl_high;
     97                        __u32   m_i_reserved2[2];
     98                } masix2;
     99        } osd2;
     100        */
     101
     102        uint32_t unused_osd2[3]; // OS dependent - not used in HelenOS
     103        uint16_t i_extra_isize;
     104        uint16_t i_pad1;
     105        uint32_t  i_ctime_extra; // Extra change time (nsec << 2 | epoch)
     106        uint32_t i_mtime_extra; // Extra Modification time (nsec << 2 | epoch)
     107        uint32_t i_atime_extra; // Extra Access time (nsec << 2 | epoch)
     108        uint32_t i_crtime; // File creation time
     109        uint32_t i_crtime_extra; // Extra file creation time (nsec << 2 | epoch)
     110        uint32_t i_version_hi;   // High 32 bits for 64-bit version
     111} __attribute__ ((packed)) ext4_inode_t;
     112
     113
    36114
    37115#endif
  • uspace/lib/ext4/libext4_superblock.c

    reb91db7 r9875711  
    3333/**
    3434 * @file        libext4_superblock.c
    35  * @brief       TODO
     35 * @brief       Ext4 superblock operations.
    3636 */
    3737
     38#include "libext4.h"
    3839
    3940
  • uspace/lib/ext4/libext4_superblock.h

    reb91db7 r9875711  
    2929/** @addtogroup libext4
    3030 * @{
    31  */ 
     31 */
    3232
    3333#ifndef LIBEXT4_LIBEXT4_SUPERBLOCK_H_
    3434#define LIBEXT4_LIBEXT4_SUPERBLOCK_H_
     35
     36#include <sys/types.h>
     37
     38/*
     39 * Structure of the super block
     40 */
     41typedef struct ext4_superblock {
     42        uint32_t s_inodes_count; // Inodes count
     43        uint32_t s_blocks_count_lo; // Blocks count
     44        uint32_t s_r_blocks_count_lo; // Reserved blocks count
     45        uint32_t s_free_blocks_count_lo; // Free blocks count
     46        uint32_t s_free_inodes_count; // Free inodes count
     47        uint32_t s_first_data_block; // First Data Block
     48        uint32_t s_log_block_size; // Block size
     49        uint32_t s_obso_log_frag_size; // Obsoleted fragment size
     50        uint32_t s_blocks_per_group; // Number of blocks per group
     51        uint32_t s_obso_frags_per_group; // Obsoleted fragments per group
     52        uint32_t s_inodes_per_group; // Number of inodes per group
     53        uint32_t s_mtime; // Mount time
     54        uint32_t s_wtime; // Write time
     55        uint16_t s_mnt_count; // Mount count
     56        uint16_t s_max_mnt_count; // Maximal mount count
     57        uint16_t s_magic; // Magic signature
     58        uint16_t s_state; // File system state
     59        uint16_t s_errors; // Behaviour when detecting errors
     60        uint16_t s_minor_rev_level; // Minor revision level
     61        uint32_t s_lastcheck; // Time of last check
     62        uint32_t s_checkinterval; // Maximum time between checks
     63        uint32_t s_creator_os; // Creator OS
     64        uint32_t s_rev_level; // Revision level
     65        uint16_t s_def_resuid; // Default uid for reserved blocks
     66        uint16_t s_def_resgid; // Default gid for reserved blocks
     67
     68        // Fields for EXT4_DYNAMIC_REV superblocks only.
     69        uint32_t s_first_ino; // First non-reserved inode
     70        uint16_t s_inode_size; // Size of inode structure
     71        uint16_t s_block_group_nr; // Block group number of this superblock
     72        uint32_t s_feature_compat; // Compatible feature set
     73        uint32_t s_feature_incompat; // Incompatible feature set
     74        uint32_t s_feature_ro_compat; // Readonly-compatible feature set
     75        uint8_t s_uuid[16]; // 128-bit uuid for volume
     76        char s_volume_name[16]; // Volume name
     77        char s_last_mounted[64]; // Directory where last mounted
     78        uint32_t s_algorithm_usage_bitmap; // For compression
     79
     80        /*
     81         * Performance hints. Directory preallocation should only
     82         * happen if the EXT4_FEATURE_COMPAT_DIR_PREALLOC flag is on.
     83         */
     84        uint8_t s_prealloc_blocks; // Number of blocks to try to preallocate
     85        uint8_t s_prealloc_dir_blocks; // Number to preallocate for dirs
     86        uint16_t s_reserved_gdt_blocks; // Per group desc for online growth
     87
     88        /*
     89         * Journaling support valid if EXT4_FEATURE_COMPAT_HAS_JOURNAL set.
     90         */
     91        uint8_t s_journal_uuid[16]; // UUID of journal superblock
     92        uint32_t s_journal_inum; // Inode number of journal file
     93        uint32_t s_journal_dev; // Device number of journal file
     94        uint32_t s_last_orphan; // Head of list of inodes to delete
     95        uint32_t s_hash_seed[4]; // HTREE hash seed
     96        uint8_t s_def_hash_version; // Default hash version to use
     97        uint8_t s_jnl_backup_type;
     98        uint16_t s_desc_size; // Size of group descriptor
     99        uint32_t s_default_mount_opts; // Default mount options
     100        uint32_t s_first_meta_bg; // First metablock block group
     101        uint32_t s_mkfs_time; // When the filesystem was created
     102        uint32_t s_jnl_blocks[17]; // Backup of the journal inode
     103
     104        /* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
     105        uint32_t s_blocks_count_hi; // Blocks count
     106        uint32_t s_r_blocks_count_hi; // Reserved blocks count
     107        uint32_t s_free_blocks_count_hi; // Free blocks count
     108        uint16_t s_min_extra_isize; // All inodes have at least # bytes
     109        uint16_t s_want_extra_isize; // New inodes should reserve # bytes
     110        uint32_t s_flags; // Miscellaneous flags
     111        uint16_t s_raid_stride; // RAID stride
     112        uint16_t s_mmp_interval; // # seconds to wait in MMP checking
     113        uint64_t s_mmp_block; // Block for multi-mount protection
     114        uint32_t s_raid_stripe_width; // blocks on all data disks (N*stride)
     115        uint8_t s_log_groups_per_flex; // FLEX_BG group size
     116        uint8_t s_reserved_char_pad;
     117        uint16_t s_reserved_pad;
     118        uint64_t s_kbytes_written; // Number of lifetime kilobytes written
     119        uint32_t s_snapshot_inum; // Inode number of active snapshot
     120        uint32_t s_snapshot_id; // Sequential ID of active snapshot
     121        uint64_t s_snapshot_r_blocks_count; /* reserved blocks for active snapshot's future use */
     122        uint32_t s_snapshot_list; // inode number of the head of the on-disk snapshot list
     123
     124        //#define EXT4_S_ERR_START offsetof(struct ext4_super_block, s_error_count)
     125        uint32_t s_error_count; // number of fs errors
     126        uint32_t s_first_error_time; // First time an error happened
     127        uint32_t s_first_error_ino; // Inode involved in first error
     128        uint64_t s_first_error_block; // block involved of first error
     129        uint8_t s_first_error_func[32]; // Function where the error happened
     130        uint32_t s_first_error_line; // Line number where error happened
     131        uint32_t s_last_error_time; // Most recent time of an error
     132        uint32_t s_last_error_ino; // Inode involved in last error
     133        uint32_t s_last_error_line; // Line number where error happened
     134        uint64_t s_last_error_block;     /* block involved of last error */
     135        uint8_t s_last_error_func[32];  /* function where the error happened */
     136        //#define EXT4_S_ERR_END offsetof(struct ext4_super_block, s_mount_opts)
     137        uint8_t s_mount_opts[64];
     138        uint32_t s_reserved[112]; // Padding to the end of the block
     139
     140} __attribute__((packed)) ext4_superblock_t;
    35141
    36142
Note: See TracChangeset for help on using the changeset viewer.