Changeset 3949e8a0 in mainline


Ignore:
Timestamp:
2011-02-14T21:35:32Z (14 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1d6f507
Parents:
f6fa2c2
Message:

Split libext2 header

Location:
uspace/lib/ext2
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext2/libext2.h

    rf6fa2c2 r3949e8a0  
    3737#define LIBEXT2_LIBEXT2_H_
    3838
    39 #include <byteorder.h>
    40 #include <libblock.h>
    41 
    42 typedef struct ext2_superblock {
    43         uint32_t        total_inode_count; // Total number of inodes
    44         uint32_t        total_block_count; // Total number of blocks
    45         uint32_t        reserved_block_count; // Total number of reserved blocks
    46         uint32_t        free_block_count; // Total number of free blocks
    47         uint32_t        free_inode_count; // Total number of free inodes
    48         uint32_t        first_block; // Block containing the superblock (either 0 or 1)
    49         uint32_t        block_size_log2; // log_2(block_size)
    50         int32_t         fragment_size_log2; // log_2(fragment size)
    51         uint32_t        blocks_per_group; // Number of blocks in one block group
    52         uint32_t        fragments_per_group; // Number of fragments per block group
    53         uint32_t        inodes_per_group; // Number of inodes per block group
    54         uint8_t         unused2[12];
    55         uint16_t        magic; // Magic value
    56         uint16_t        state; // State (mounted/unmounted)
    57         uint16_t        error_behavior; // What to do when errors are encountered
    58         uint16_t        rev_minor; // Minor revision level
    59         uint8_t         unused3[8];
    60         uint32_t        os; // OS that created the filesystem
    61         uint32_t        rev_major; // Major revision level
    62         uint8_t         unused4[4];
    63        
    64         // Following is for ext2 revision 1 only
    65         uint32_t        first_inode;
    66         uint16_t        inode_size;
    67         uint8_t         unused5[14];
    68         uint8_t         uuid[16]; // UUID TODO: Create a library for UUIDs
    69         uint8_t         volume_name[16];
    70 
    71 // TODO: add __attribute__((aligned(...)) for better performance?
    72 //       (it is necessary to ensure the superblock is correctly aligned then
    73 //        though)
    74 } __attribute__ ((packed)) ext2_superblock_t;
    75 
    76 
    77 typedef struct ext2_filesystem {
    78         devmap_handle_t         device;
    79         ext2_superblock_t *     superblock;
    80 } ext2_filesystem_t;
    81 
    82 #define EXT2_SUPERBLOCK_MAGIC           0xEF53
    83 #define EXT2_SUPERBLOCK_SIZE            1024
    84 #define EXT2_SUPERBLOCK_OFFSET          1024
    85 #define EXT2_SUPERBLOCK_LAST_BYTE       (EXT2_SUPERBLOCK_OFFSET + \
    86                                                                          EXT2_SUPERBLOCK_SIZE -1)
    87 // allow maximum this block size
    88 #define EXT2_MAX_BLOCK_SIZE                     8096
    89 #define EXT2_REV0_FIRST_INODE           11
    90 #define EXT2_REV0_INODE_SIZE            128
    91 
    92 inline uint16_t ext2_superblock_get_magic(ext2_superblock_t *);
    93 inline uint32_t ext2_superblock_get_first_block(ext2_superblock_t *);
    94 inline uint32_t ext2_superblock_get_block_size_log2(ext2_superblock_t *);
    95 inline uint32_t ext2_superblock_get_block_size(ext2_superblock_t *);
    96 inline int32_t  ext2_superblock_get_fragment_size_log2(ext2_superblock_t *);
    97 inline uint32_t ext2_superblock_get_fragment_size(ext2_superblock_t *);
    98 inline uint32_t ext2_superblock_get_blocks_per_group(ext2_superblock_t *);
    99 inline uint32_t ext2_superblock_get_fragments_per_group(ext2_superblock_t *);
    100 inline uint16_t ext2_superblock_get_state(ext2_superblock_t *);
    101 inline uint16_t ext2_superblock_get_rev_minor(ext2_superblock_t *);
    102 inline uint32_t ext2_superblock_get_rev_major(ext2_superblock_t *);
    103 inline uint32_t ext2_superblock_get_os(ext2_superblock_t *);
    104 inline uint32_t ext2_superblock_get_first_inode(ext2_superblock_t *);
    105 inline uint16_t ext2_superblock_get_inode_size(ext2_superblock_t *);
    106 inline uint32_t ext2_superblock_get_total_inode_count(ext2_superblock_t *);
    107 inline uint32_t ext2_superblock_get_total_block_count(ext2_superblock_t *);
    108 inline uint32_t ext2_superblock_get_reserved_block_count(ext2_superblock_t *);
    109 inline uint32_t ext2_superblock_get_free_block_count(ext2_superblock_t *);
    110 inline uint32_t ext2_superblock_get_free_inode_count(ext2_superblock_t *);
    111 
    112 extern int ext2_superblock_read_direct(devmap_handle_t, ext2_superblock_t **);
    113 
    114 extern int ext2_filesystem_init(ext2_filesystem_t *, devmap_handle_t);
    115 extern void ext2_filesystem_fini(ext2_filesystem_t *);
     39#include "libext2_superblock.h"
     40#include "libext2_filesystem.h"
    11641
    11742#endif
  • uspace/lib/ext2/libext2_superblock.c

    rf6fa2c2 r3949e8a0  
    3838#include <malloc.h>
    3939#include <libblock.h>
     40#include <byteorder.h>
    4041
    4142/**
Note: See TracChangeset for help on using the changeset viewer.