Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/src/superblock.c

    r5a6cc679 ra35b458  
    241241        uint32_t log = 0;
    242242        uint32_t tmp = size / EXT4_MIN_BLOCK_SIZE;
    243        
     243
    244244        tmp >>= 1;
    245245        while (tmp) {
     
    247247                tmp >>= 1;
    248248        }
    249        
     249
    250250        ext4_superblock_set_log_block_size(sb, log);
    251251}
     
    297297        uint32_t log = 0;
    298298        uint32_t tmp = size / EXT4_MIN_BLOCK_SIZE;
    299        
     299
    300300        tmp >>= 1;
    301301        while (tmp) {
     
    303303                tmp >>= 1;
    304304        }
    305        
     305
    306306        ext4_superblock_set_log_frag_size(sb, log);
    307307}
     
    736736        if (ext4_superblock_get_rev_level(sb) == 0)
    737737                return EXT4_REV0_INODE_SIZE;
    738        
     738
    739739        return uint16_t_le2host(sb->inode_size);
    740740}
     
    10011001{
    10021002        uint16_t size = uint16_t_le2host(sb->desc_size);
    1003        
     1003
    10041004        if (size < EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
    10051005                size = EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE;
    1006        
     1006
    10071007        return size;
    10081008}
     
    10211021                sb->desc_size =
    10221022                    host2uint16_t_le(EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE);
    1023        
     1023
    10241024        sb->desc_size = host2uint16_t_le(size);
    10251025}
     
    10641064        if (ext4_superblock_get_flags(sb) & flag)
    10651065                return true;
    1066        
     1066
    10671067        return false;
    10681068}
     
    10811081        if (ext4_superblock_get_features_compatible(sb) & feature)
    10821082                return true;
    1083        
     1083
    10841084        return false;
    10851085}
     
    10981098        if (ext4_superblock_get_features_incompatible(sb) & feature)
    10991099                return true;
    1100        
     1100
    11011101        return false;
    11021102}
     
    11151115        if (ext4_superblock_get_features_read_only(sb) & feature)
    11161116                return true;
    1117        
     1117
    11181118        return false;
    11191119}
     
    11331133        if (data == NULL)
    11341134                return ENOMEM;
    1135        
     1135
    11361136        /* Read data from block device */
    11371137        errno_t rc = block_read_bytes_direct(service_id, EXT4_SUPERBLOCK_OFFSET,
    11381138            EXT4_SUPERBLOCK_SIZE, data);
    1139        
     1139
    11401140        if (rc != EOK) {
    11411141                free(data);
    11421142                return rc;
    11431143        }
    1144        
     1144
    11451145        /* Set output value */
    11461146        (*sb) = data;
    1147        
     1147
    11481148        return EOK;
    11491149}
     
    11641164        if (rc != EOK)
    11651165                return rc;
    1166        
     1166
    11671167        /* Compute address of the first block */
    11681168        uint64_t first_block = EXT4_SUPERBLOCK_OFFSET / phys_block_size;
    1169        
     1169
    11701170        /* Compute number of block to write */
    11711171        size_t block_count = EXT4_SUPERBLOCK_SIZE / phys_block_size;
    1172        
     1172
    11731173        /* Check alignment */
    11741174        if (EXT4_SUPERBLOCK_SIZE % phys_block_size)
    11751175                block_count++;
    1176        
     1176
    11771177        /* Write data */
    11781178        return block_write_direct(service_id, first_block, block_count, sb);
     
    12031203        if (ext4_superblock_get_magic(sb) != EXT4_SUPERBLOCK_MAGIC)
    12041204                return ENOTSUP;
    1205        
     1205
    12061206        if (ext4_superblock_get_inodes_count(sb) == 0)
    12071207                return ENOTSUP;
    1208        
     1208
    12091209        if (ext4_superblock_get_blocks_count(sb) == 0)
    12101210                return ENOTSUP;
    1211        
     1211
    12121212        if (ext4_superblock_get_blocks_per_group(sb) == 0)
    12131213                return ENOTSUP;
    1214        
     1214
    12151215        if (ext4_superblock_get_inodes_per_group(sb) == 0)
    12161216                return ENOTSUP;
    1217        
     1217
    12181218        if (ext4_superblock_get_inode_size(sb) < 128)
    12191219                return ENOTSUP;
    1220        
     1220
    12211221        if (ext4_superblock_get_first_inode(sb) < 11)
    12221222                return ENOTSUP;
    1223        
     1223
    12241224        if (ext4_superblock_get_desc_size(sb) <
    12251225            EXT4_MIN_BLOCK_GROUP_DESCRIPTOR_SIZE)
    12261226                return ENOTSUP;
    1227        
     1227
    12281228        if (ext4_superblock_get_desc_size(sb) >
    12291229            EXT4_MAX_BLOCK_GROUP_DESCRIPTOR_SIZE)
    12301230                return ENOTSUP;
    1231        
     1231
    12321232        return EOK;
    12331233}
     
    12441244        uint64_t blocks_count = ext4_superblock_get_blocks_count(sb);
    12451245        uint32_t blocks_per_group = ext4_superblock_get_blocks_per_group(sb);
    1246        
     1246
    12471247        uint32_t block_groups_count = blocks_count / blocks_per_group;
    1248        
     1248
    12491249        if (blocks_count % blocks_per_group)
    12501250                block_groups_count++;
    1251        
     1251
    12521252        return block_groups_count;
    12531253}
     
    12691269        uint64_t total_blocks =
    12701270            ext4_superblock_get_blocks_count(sb);
    1271        
     1271
    12721272        if (bgid < block_group_count - 1)
    12731273                return blocks_per_group;
     
    12921292        uint32_t total_inodes =
    12931293            ext4_superblock_get_inodes_count(sb);
    1294        
     1294
    12951295        if (bgid < block_group_count - 1)
    12961296                return inodes_per_group;
Note: See TracChangeset for help on using the changeset viewer.