Changeset 566c401 in mainline


Ignore:
Timestamp:
2011-02-13T20:37:31Z (13 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8bd5dad
Parents:
e272949
Message:

Cleanup

Location:
uspace/lib/ext2
Files:
3 edited

Legend:

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

    re272949 r566c401  
    11/*
    2  * Copyright (c) 2010 Martin Sucha
     2 * Copyright (c) 2011 Martin Sucha
    33 * All rights reserved.
    44 *
     
    5050        uint8_t         unused2[12];
    5151        uint16_t        magic; // Magic value
    52 } __attribute__ ((packed)) ext2_superblock_t;
     52
    5353// TODO: add __attribute__((aligned(...)) for better performance?
    5454//       (it is necessary to ensure the superblock is correctly aligned then
    5555//        though)
     56} __attribute__ ((packed)) ext2_superblock_t;
     57
    5658
    5759typedef struct ext2_filesystem {
     
    6668                                                                         EXT2_SUPERBLOCK_SIZE -1)
    6769
    68 inline uint16_t ext2_superblock_get_magic(ext2_superblock_t *sb);
    69 inline uint32_t ext2_superblock_get_first_block(ext2_superblock_t *sb);
    70 inline uint32_t ext2_superblock_get_block_size_log2(ext2_superblock_t *sb);
    71 inline uint32_t ext2_superblock_get_block_size(ext2_superblock_t *sb);
    72 inline int32_t  ext2_superblock_get_fragment_size_log2(ext2_superblock_t *sb);
    73 inline uint32_t ext2_superblock_get_fragment_size(ext2_superblock_t *sb);
    74 inline uint32_t ext2_superblock_get_blocks_per_group(ext2_superblock_t *sb);
    75 inline uint32_t ext2_superblock_get_fragments_per_group(ext2_superblock_t *sb);
     70inline uint16_t ext2_superblock_get_magic(ext2_superblock_t *);
     71inline uint32_t ext2_superblock_get_first_block(ext2_superblock_t *);
     72inline uint32_t ext2_superblock_get_block_size_log2(ext2_superblock_t *);
     73inline uint32_t ext2_superblock_get_block_size(ext2_superblock_t *);
     74inline int32_t  ext2_superblock_get_fragment_size_log2(ext2_superblock_t *);
     75inline uint32_t ext2_superblock_get_fragment_size(ext2_superblock_t *);
     76inline uint32_t ext2_superblock_get_blocks_per_group(ext2_superblock_t *);
     77inline uint32_t ext2_superblock_get_fragments_per_group(ext2_superblock_t *);
    7678
    77 int ext2_superblock_read_direct(devmap_handle_t, ext2_superblock_t **);
     79extern int ext2_superblock_read_direct(devmap_handle_t, ext2_superblock_t **);
    7880
    79 int ext2_filesystem_init(ext2_filesystem_t *fs, devmap_handle_t dev);
    80 void ext2_filesystem_fini(ext2_filesystem_t *fs);
     81extern int ext2_filesystem_init(ext2_filesystem_t *, devmap_handle_t);
     82extern void ext2_filesystem_fini(ext2_filesystem_t *);
    8183
    8284#endif
  • uspace/lib/ext2/libext2_filesystem.c

    re272949 r566c401  
    4343 * This function reads superblock from the device and
    4444 * initializes libblock cache with appropriate logical block size.
     45 *
     46 * @param fs Pointer to ext2_filesystem_t to initialize
     47 * @param devmap_handle Device handle of the block device
    4548 */
    46 int ext2_filesystem_init(ext2_filesystem_t *fs, devmap_handle_t dev) {
     49int ext2_filesystem_init(ext2_filesystem_t *fs, devmap_handle_t devmap_handle)
     50{
    4751        int rc;
    4852        ext2_superblock_t *temp_superblock;
    4953       
    50         fs->device = dev;
     54        fs->device = devmap_handle;
    5155       
    5256        rc = block_init(fs->device, 2048);
     
    5559        }
    5660       
    57         rc = ext2_superblock_read_direct(dev, &temp_superblock);
     61        rc = ext2_superblock_read_direct(fs->device, &temp_superblock);
    5862        if (rc != EOK) {
    59                 block_fini(dev);
     63                block_fini(fs->device);
    6064                return rc;
    6165        }
     
    6872/**
    6973 * Finalize an instance of filesystem
     74 *
     75 * @param fs Pointer to ext2_filesystem_t to finalize
    7076 */
    71 void ext2_filesystem_fini(ext2_filesystem_t *fs) {
     77void ext2_filesystem_fini(ext2_filesystem_t *fs)
     78{
    7279        block_fini(fs->device);
    7380}
  • uspace/lib/ext2/libext2_superblock.c

    re272949 r566c401  
    4242 * Return a magic number from ext2 superblock, this should be equal to
    4343 * EXT_SUPERBLOCK_MAGIC for valid ext2 superblock
     44 *
     45 * @param sb pointer to superblock
    4446 */
    45 inline uint16_t ext2_superblock_get_magic(ext2_superblock_t *sb) {
     47inline uint16_t ext2_superblock_get_magic(ext2_superblock_t *sb)
     48{
    4649        return uint16_t_le2host(sb->magic);
    4750}
     
    5053 * Get the position of first ext2 data block (i.e. the block number
    5154 * containing main superblock)
     55 *
     56 * @param sb pointer to superblock
    5257 */
    53 inline uint32_t ext2_superblock_get_first_block(ext2_superblock_t *sb) {
     58inline uint32_t ext2_superblock_get_first_block(ext2_superblock_t *sb)
     59{
    5460        return uint32_t_le2host(sb->first_block);
    5561}
     
    5864 * Get the number of bits to shift a value of 1024 to the left necessary
    5965 * to get the size of a block
     66 *
     67 * @param sb pointer to superblock
    6068 */
    61 inline uint32_t ext2_superblock_get_block_size_log2(ext2_superblock_t *sb) {
     69inline uint32_t ext2_superblock_get_block_size_log2(ext2_superblock_t *sb)
     70{
    6271        return uint32_t_le2host(sb->block_size_log2);
    6372}
     
    6574/**
    6675 * Get the size of a block, in bytes
     76 *
     77 * @param sb pointer to superblock
    6778 */
    68 inline uint32_t ext2_superblock_get_block_size(ext2_superblock_t *sb) {
     79inline uint32_t ext2_superblock_get_block_size(ext2_superblock_t *sb)
     80{
    6981        return 1024 << ext2_superblock_get_block_size(sb);
    7082}
     
    7486 * to get the size of a fragment (note that this is a signed integer and
    7587 * if negative, the value should be shifted to the right instead)
     88 *
     89 * @param sb pointer to superblock
    7690 */
    77 inline int32_t ext2_superblock_get_fragment_size_log2(ext2_superblock_t *sb) {
     91inline int32_t ext2_superblock_get_fragment_size_log2(ext2_superblock_t *sb)
     92{
    7893        return uint32_t_le2host(sb->fragment_size_log2);
    7994}
     
    8196/**
    8297 * Get the size of a fragment, in bytes
     98 *
     99 * @param sb pointer to superblock
    83100 */
    84 inline uint32_t ext2_superblock_get_fragment_size(ext2_superblock_t *sb) {
     101inline uint32_t ext2_superblock_get_fragment_size(ext2_superblock_t *sb)
     102{
    85103        int32_t log = ext2_superblock_get_fragment_size_log2(sb);
    86104        if (log >= 0) {
     
    94112/**
    95113 * Get number of blocks per block group
     114 *
     115 * @param sb pointer to superblock
    96116 */
    97 inline uint32_t ext2_superblock_get_blocks_per_group(ext2_superblock_t *sb) {
     117inline uint32_t ext2_superblock_get_blocks_per_group(ext2_superblock_t *sb)
     118{
    98119        return uint32_t_le2host(sb->blocks_per_group);
    99120}
     
    101122/**
    102123 * Get number of fragments per block group
     124 *
     125 * @param sb pointer to superblock
    103126 */
    104 inline uint32_t ext2_superblock_get_fragments_per_group(ext2_superblock_t *sb) {
     127inline uint32_t ext2_superblock_get_fragments_per_group(ext2_superblock_t *sb)
     128{
    105129        return uint32_t_le2host(sb->fragments_per_group);
    106130}
Note: See TracChangeset for help on using the changeset viewer.