Ignore:
File:
1 edited

Legend:

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

    rb7fd2a0 r395df52  
    5454#include "ext4/superblock.h"
    5555
    56 static errno_t ext4_filesystem_check_features(ext4_filesystem_t *, bool *);
     56static int ext4_filesystem_check_features(ext4_filesystem_t *, bool *);
    5757
    5858/** Initialize filesystem for opening.
     
    6767 *
    6868 */
    69 static errno_t ext4_filesystem_init(ext4_filesystem_t *fs, service_id_t service_id,
     69static int ext4_filesystem_init(ext4_filesystem_t *fs, service_id_t service_id,
    7070    enum cache_mode cmode)
    7171{
    72         errno_t rc;
     72        int rc;
    7373        ext4_superblock_t *temp_superblock = NULL;
    7474
     
    161161 * @param service_id Block device to probe
    162162 *
    163  * @return EOK or an error code.
    164  *
    165  */
    166 errno_t ext4_filesystem_probe(service_id_t service_id)
     163 * @return EOK or negative error code.
     164 *
     165 */
     166int ext4_filesystem_probe(service_id_t service_id)
    167167{
    168168        ext4_filesystem_t *fs = NULL;
    169         errno_t rc;
     169        int rc;
    170170
    171171        fs = calloc(1, sizeof(ext4_filesystem_t));
     
    195195 *
    196196 */
    197 errno_t ext4_filesystem_open(ext4_instance_t *inst, service_id_t service_id,
     197int ext4_filesystem_open(ext4_instance_t *inst, service_id_t service_id,
    198198    enum cache_mode cmode, aoff64_t *size, ext4_filesystem_t **rfs)
    199199{
    200200        ext4_filesystem_t *fs = NULL;
    201201        fs_node_t *root_node = NULL;
    202         errno_t rc;
     202        int rc;
    203203
    204204        fs = calloc(1, sizeof(ext4_filesystem_t));
     
    252252 * @param fs Filesystem to be destroyed
    253253 *
    254  * @return EOK or an error code. On error the state of the file
     254 * @return EOK or negative error code. On error the state of the file
    255255 *         system is unchanged.
    256256 *
    257257 */
    258 errno_t ext4_filesystem_close(ext4_filesystem_t *fs)
     258int ext4_filesystem_close(ext4_filesystem_t *fs)
    259259{
    260260        /* Write the superblock to the device */
    261261        ext4_superblock_set_state(fs->superblock, EXT4_SUPERBLOCK_STATE_VALID_FS);
    262         errno_t rc = ext4_superblock_write_direct(fs->device, fs->superblock);
     262        int rc = ext4_superblock_write_direct(fs->device, fs->superblock);
    263263        if (rc != EOK)
    264264                return rc;
     
    281281 *
    282282 */
    283 static errno_t ext4_filesystem_check_features(ext4_filesystem_t *fs,
     283static int ext4_filesystem_check_features(ext4_filesystem_t *fs,
    284284    bool *read_only)
    285285{
     
    380380 *
    381381 */
    382 static errno_t ext4_filesystem_init_block_bitmap(ext4_block_group_ref_t *bg_ref)
     382static int ext4_filesystem_init_block_bitmap(ext4_block_group_ref_t *bg_ref)
    383383{
    384384        uint64_t itb;
     
    394394       
    395395        block_t *bitmap_block;
    396         errno_t rc = block_get(&bitmap_block, bg_ref->fs->device,
     396        int rc = block_get(&bitmap_block, bg_ref->fs->device,
    397397            bitmap_block_addr, BLOCK_FLAGS_NOREAD);
    398398        if (rc != EOK)
     
    451451 *
    452452 */
    453 static errno_t ext4_filesystem_init_inode_bitmap(ext4_block_group_ref_t *bg_ref)
     453static int ext4_filesystem_init_inode_bitmap(ext4_block_group_ref_t *bg_ref)
    454454{
    455455        /* Load bitmap */
     
    458458        block_t *bitmap_block;
    459459       
    460         errno_t rc = block_get(&bitmap_block, bg_ref->fs->device,
     460        int rc = block_get(&bitmap_block, bg_ref->fs->device,
    461461            bitmap_block_addr, BLOCK_FLAGS_NOREAD);
    462462        if (rc != EOK)
     
    494494 *
    495495 */
    496 static errno_t ext4_filesystem_init_inode_table(ext4_block_group_ref_t *bg_ref)
     496static int ext4_filesystem_init_inode_table(ext4_block_group_ref_t *bg_ref)
    497497{
    498498        ext4_superblock_t *sb = bg_ref->fs->superblock;
     
    519519        for (uint32_t fblock = first_block; fblock <= last_block; ++fblock) {
    520520                block_t *block;
    521                 errno_t rc = block_get(&block, bg_ref->fs->device, fblock,
     521                int rc = block_get(&block, bg_ref->fs->device, fblock,
    522522                    BLOCK_FLAGS_NOREAD);
    523523                if (rc != EOK)
     
    544544 *
    545545 */
    546 errno_t ext4_filesystem_get_block_group_ref(ext4_filesystem_t *fs, uint32_t bgid,
     546int ext4_filesystem_get_block_group_ref(ext4_filesystem_t *fs, uint32_t bgid,
    547547    ext4_block_group_ref_t **ref)
    548548{
     
    568568       
    569569        /* Load block with descriptors */
    570         errno_t rc = block_get(&newref->block, fs->device, block_id, 0);
     570        int rc = block_get(&newref->block, fs->device, block_id, 0);
    571571        if (rc != EOK) {
    572572                free(newref);
     
    804804 *
    805805 */
    806 errno_t ext4_filesystem_put_block_group_ref(ext4_block_group_ref_t *ref)
     806int ext4_filesystem_put_block_group_ref(ext4_block_group_ref_t *ref)
    807807{
    808808        /* Check if reference modified */
     
    819819       
    820820        /* Put back block, that contains block group descriptor */
    821         errno_t rc = block_put(ref->block);
     821        int rc = block_put(ref->block);
    822822        free(ref);
    823823       
     
    834834 *
    835835 */
    836 errno_t ext4_filesystem_get_inode_ref(ext4_filesystem_t *fs, uint32_t index,
     836int ext4_filesystem_get_inode_ref(ext4_filesystem_t *fs, uint32_t index,
    837837    ext4_inode_ref_t **ref)
    838838{
     
    857857        /* Load block group, where i-node is located */
    858858        ext4_block_group_ref_t *bg_ref;
    859         errno_t rc = ext4_filesystem_get_block_group_ref(fs, block_group, &bg_ref);
     859        int rc = ext4_filesystem_get_block_group_ref(fs, block_group, &bg_ref);
    860860        if (rc != EOK) {
    861861                free(newref);
     
    909909 *
    910910 */
    911 errno_t ext4_filesystem_put_inode_ref(ext4_inode_ref_t *ref)
     911int ext4_filesystem_put_inode_ref(ext4_inode_ref_t *ref)
    912912{
    913913        /* Check if reference modified */
     
    918918       
    919919        /* Put back block, that contains i-node */
    920         errno_t rc = block_put(ref->block);
     920        int rc = block_put(ref->block);
    921921        free(ref);
    922922       
     
    933933 *
    934934 */
    935 errno_t ext4_filesystem_alloc_inode(ext4_filesystem_t *fs,
     935int ext4_filesystem_alloc_inode(ext4_filesystem_t *fs,
    936936    ext4_inode_ref_t **inode_ref, int flags)
    937937{
     
    943943        /* Allocate inode by allocation algorithm */
    944944        uint32_t index;
    945         errno_t rc = ext4_ialloc_alloc_inode(fs, &index, is_dir);
     945        int rc = ext4_ialloc_alloc_inode(fs, &index, is_dir);
    946946        if (rc != EOK)
    947947                return rc;
     
    10251025 *
    10261026 */
    1027 errno_t ext4_filesystem_free_inode(ext4_inode_ref_t *inode_ref)
     1027int ext4_filesystem_free_inode(ext4_inode_ref_t *inode_ref)
    10281028{
    10291029        ext4_filesystem_t *fs = inode_ref->fs;
     
    10421042        uint32_t fblock = ext4_inode_get_indirect_block(inode_ref->inode, 0);
    10431043        if (fblock != 0) {
    1044                 errno_t rc = ext4_balloc_free_block(inode_ref, fblock);
     1044                int rc = ext4_balloc_free_block(inode_ref, fblock);
    10451045                if (rc != EOK)
    10461046                        return rc;
     
    10561056        fblock = ext4_inode_get_indirect_block(inode_ref->inode, 1);
    10571057        if (fblock != 0) {
    1058                 errno_t rc = block_get(&block, fs->device, fblock, BLOCK_FLAGS_NONE);
     1058                int rc = block_get(&block, fs->device, fblock, BLOCK_FLAGS_NONE);
    10591059                if (rc != EOK)
    10601060                        return rc;
     
    10881088        fblock = ext4_inode_get_indirect_block(inode_ref->inode, 2);
    10891089        if (fblock != 0) {
    1090                 errno_t rc = block_get(&block, fs->device, fblock, BLOCK_FLAGS_NONE);
     1090                int rc = block_get(&block, fs->device, fblock, BLOCK_FLAGS_NONE);
    10911091                if (rc != EOK)
    10921092                        return rc;
     
    11531153            inode_ref->inode, fs->superblock);
    11541154        if (xattr_block) {
    1155                 errno_t rc = ext4_balloc_free_block(inode_ref, xattr_block);
     1155                int rc = ext4_balloc_free_block(inode_ref, xattr_block);
    11561156                if (rc != EOK)
    11571157                        return rc;
     
    11611161       
    11621162        /* Free inode by allocator */
    1163         errno_t rc;
     1163        int rc;
    11641164        if (ext4_inode_is_type(fs->superblock, inode_ref->inode,
    11651165            EXT4_INODE_MODE_DIRECTORY))
     
    11791179 *
    11801180 */
    1181 errno_t ext4_filesystem_truncate_inode(ext4_inode_ref_t *inode_ref,
     1181int ext4_filesystem_truncate_inode(ext4_inode_ref_t *inode_ref,
    11821182    aoff64_t new_size)
    11831183{
     
    12121212            (ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_EXTENTS))) {
    12131213                /* Extents require special operation */
    1214                 errno_t rc = ext4_extent_release_blocks_from(inode_ref,
     1214                int rc = ext4_extent_release_blocks_from(inode_ref,
    12151215                    old_blocks_count - diff_blocks_count);
    12161216                if (rc != EOK)
     
    12211221                /* Starting from 1 because of logical blocks are numbered from 0 */
    12221222                for (uint32_t i = 1; i <= diff_blocks_count; ++i) {
    1223                         errno_t rc = ext4_filesystem_release_inode_block(inode_ref,
     1223                        int rc = ext4_filesystem_release_inode_block(inode_ref,
    12241224                            old_blocks_count - i);
    12251225                        if (rc != EOK)
     
    12441244 *
    12451245 */
    1246 errno_t ext4_filesystem_get_inode_data_block_index(ext4_inode_ref_t *inode_ref,
     1246int ext4_filesystem_get_inode_data_block_index(ext4_inode_ref_t *inode_ref,
    12471247    aoff64_t iblock, uint32_t *fblock)
    12481248{
     
    12611261            EXT4_FEATURE_INCOMPAT_EXTENTS)) &&
    12621262            (ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_EXTENTS))) {
    1263                 errno_t rc = ext4_extent_find_block(inode_ref, iblock, &current_block);
     1263                int rc = ext4_extent_find_block(inode_ref, iblock, &current_block);
    12641264                if (rc != EOK)
    12651265                        return rc;
     
    13111311        while (level > 0) {
    13121312                /* Load indirect block */
    1313                 errno_t rc = block_get(&block, fs->device, current_block, 0);
     1313                int rc = block_get(&block, fs->device, current_block, 0);
    13141314                if (rc != EOK)
    13151315                        return rc;
     
    13571357 *
    13581358 */
    1359 errno_t ext4_filesystem_set_inode_data_block_index(ext4_inode_ref_t *inode_ref,
     1359int ext4_filesystem_set_inode_data_block_index(ext4_inode_ref_t *inode_ref,
    13601360    aoff64_t iblock, uint32_t fblock)
    13611361{
     
    14071407        if (current_block == 0) {
    14081408                /* Allocate new indirect block */
    1409                 errno_t rc = ext4_balloc_alloc_block(inode_ref, &new_block_addr);
     1409                int rc = ext4_balloc_alloc_block(inode_ref, &new_block_addr);
    14101410                if (rc != EOK)
    14111411                        return rc;
     
    14411441         */
    14421442        while (level > 0) {
    1443                 errno_t rc = block_get(&block, fs->device, current_block, 0);
     1443                int rc = block_get(&block, fs->device, current_block, 0);
    14441444                if (rc != EOK)
    14451445                        return rc;
     
    15181518 *
    15191519 */
    1520 errno_t ext4_filesystem_release_inode_block(ext4_inode_ref_t *inode_ref,
     1520int ext4_filesystem_release_inode_block(ext4_inode_ref_t *inode_ref,
    15211521    uint32_t iblock)
    15221522{
     
    15751575                        return EOK;
    15761576               
    1577                 errno_t rc = block_get(&block, fs->device, current_block, 0);
     1577                int rc = block_get(&block, fs->device, current_block, 0);
    15781578                if (rc != EOK)
    15791579                        return rc;
     
    16251625 *
    16261626 */
    1627 errno_t ext4_filesystem_append_inode_block(ext4_inode_ref_t *inode_ref,
     1627int ext4_filesystem_append_inode_block(ext4_inode_ref_t *inode_ref,
    16281628    uint32_t *fblock, uint32_t *iblock)
    16291629{
     
    16491649        /* Allocate new physical block */
    16501650        uint32_t phys_block;
    1651         errno_t rc = ext4_balloc_alloc_block(inode_ref, &phys_block);
     1651        int rc = ext4_balloc_alloc_block(inode_ref, &phys_block);
    16521652        if (rc != EOK)
    16531653                return rc;
Note: See TracChangeset for help on using the changeset viewer.