Changeset 3dd148d in mainline


Ignore:
Timestamp:
2013-07-29T15:15:49Z (11 years ago)
Author:
Manuele Conti <conti.ma@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
736b07b
Parents:
a1c95da
Message:

Change stafs function operation to allow correct error handling.

Location:
uspace
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/fs/libfs.c

    ra1c95da r3dd148d  
    834834       
    835835        ops->node_put(fn);
    836        
     836
     837
    837838        async_data_read_finalize(callid, &stat, sizeof(struct stat));
    838839        async_answer_0(rid, EOK);
     
    862863        memset(&statfs, 0, sizeof(struct statfs));
    863864
    864         if (NULL != ops->size_block)   
    865                 statfs.f_bsize = ops->size_block(service_id);
    866         if (NULL != ops->total_block_count)
    867                 statfs.f_blocks = ops->total_block_count(service_id);
    868         if (NULL != ops->free_block_count)
    869                 statfs.f_bfree = ops->free_block_count(service_id);
    870        
     865        if (NULL != ops->size_block) { 
     866                rc = ops->size_block(service_id, &statfs.f_bsize);
     867                if (rc != EOK) goto error;
     868        }
     869
     870        if (NULL != ops->total_block_count) {
     871                rc = ops->total_block_count(service_id, &statfs.f_blocks);
     872                if (rc != EOK) goto error;
     873        }
     874
     875        if (NULL != ops->free_block_count) {
     876                rc = ops->free_block_count(service_id, &statfs.f_bfree);
     877                if (rc != EOK) goto error;
     878        }
     879
    871880        ops->node_put(fn);
    872        
    873881        async_data_read_finalize(callid, &statfs, sizeof(struct statfs));
    874882        async_answer_0(rid, EOK);
     883        return;
     884
     885error:
     886        ops->node_put(fn);
     887        async_answer_0(callid, EINVAL);
     888        async_answer_0(rid, EINVAL);
    875889}
    876890
  • uspace/lib/fs/libfs.h

    ra1c95da r3dd148d  
    9393        bool (* is_file)(fs_node_t *);
    9494        service_id_t (* service_get)(fs_node_t *);
    95         uint32_t (* size_block)(service_id_t);
    96         uint64_t (* total_block_count)(service_id_t);
    97         uint64_t (* free_block_count)(service_id_t);
     95        int (* size_block)(service_id_t, uint32_t *);
     96        int (* total_block_count)(service_id_t, uint64_t *);
     97        int (* free_block_count)(service_id_t, uint64_t *);
    9898} libfs_ops_t;
    9999
  • uspace/srv/fs/cdfs/cdfs_ops.c

    ra1c95da r3dd148d  
    625625}
    626626
    627 static uint32_t cdfs_size_block(service_id_t service_id)
    628 {
    629         uint32_t block_size = BLOCK_SIZE;
    630         return block_size;
     627static int cdfs_size_block(service_id_t service_id, uint32_t *size)
     628{
     629        *size = BLOCK_SIZE;
     630
     631        return EOK;
    631632}
    632633
  • uspace/srv/fs/exfat/exfat_ops.c

    ra1c95da r3dd148d  
    8989static bool exfat_is_file(fs_node_t *node);
    9090static service_id_t exfat_service_get(fs_node_t *node);
    91 static uint32_t exfat_size_block(service_id_t);
    92 static uint64_t exfat_total_block_count(service_id_t);
    93 static uint64_t exfat_free_block_count(service_id_t);
     91static int exfat_size_block(service_id_t, uint32_t *);
     92static int exfat_total_block_count(service_id_t, uint64_t *);
     93static int exfat_free_block_count(service_id_t, uint64_t *);
    9494
    9595/*
     
    915915}
    916916
    917 uint32_t exfat_size_block(service_id_t service_id)
     917int exfat_size_block(service_id_t service_id, uint32_t *size)
    918918{
    919919        exfat_bs_t *bs;
    920920        bs = block_bb_get(service_id);
    921        
    922         return BPC(bs);
    923 }
    924 
    925 uint64_t exfat_total_block_count(service_id_t service_id)
     921        *size = BPC(bs);
     922
     923        return EOK;
     924}
     925
     926int exfat_total_block_count(service_id_t service_id, uint64_t *count)
    926927{
    927928        exfat_bs_t *bs;
    928929        bs = block_bb_get(service_id);
     930        *count = DATA_CNT(bs);
    929931       
    930         uint64_t block_count = DATA_CNT(bs);
    931        
    932         return block_count;
    933 }
    934 
    935 uint64_t exfat_free_block_count(service_id_t service_id)
     932        return EOK;
     933}
     934
     935int exfat_free_block_count(service_id_t service_id, uint64_t *count)
    936936{
    937937        fs_node_t *node;
     
    943943        int rc;
    944944
    945         block_count = exfat_total_block_count(service_id);
     945        rc = exfat_total_block_count(service_id, &block_count);
     946        if (rc != EOK)
     947                goto exit;
    946948
    947949        bs = block_bb_get(service_id);
     
    985987exit:
    986988        exfat_node_put(node);
    987         return free_block_count;
     989        *count = free_block_count;
     990        return rc;
    988991}
    989992
  • uspace/srv/fs/ext4fs/ext4fs_ops.c

    ra1c95da r3dd148d  
    101101static bool ext4fs_is_file(fs_node_t *node);
    102102static service_id_t ext4fs_service_get(fs_node_t *node);
    103 static uint32_t ext4fs_size_block(service_id_t);
    104 static uint64_t ext4fs_total_block_count(service_id_t);
    105 static uint64_t ext4fs_free_block_count(service_id_t);
     103static int ext4fs_size_block(service_id_t, uint32_t *);
     104static int ext4fs_total_block_count(service_id_t, uint64_t *);
     105static int ext4fs_free_block_count(service_id_t, uint64_t *);
    106106
    107107/* Static variables */
     
    841841}
    842842
    843 uint32_t ext4fs_size_block(service_id_t service_id)
     843int ext4fs_size_block(service_id_t service_id, uint32_t *size)
    844844{
    845845        ext4fs_instance_t *inst;
     
    847847        if (rc != EOK)
    848848                return rc;
     849
    849850        if (NULL == inst)
    850851                return ENOENT;
    851852
    852853        ext4_superblock_t *sb = inst->filesystem->superblock;
    853         uint32_t block_size = ext4_superblock_get_block_size(sb);
    854 
    855         return block_size;
    856 }
    857 
    858 uint64_t ext4fs_total_block_count(service_id_t service_id)
     854        *size = ext4_superblock_get_block_size(sb);
     855
     856        return EOK;
     857}
     858
     859int ext4fs_total_block_count(service_id_t service_id, uint64_t *count)
    859860{
    860861        ext4fs_instance_t *inst;
     
    862863        if (rc != EOK)
    863864                return rc;
     865
    864866        if (NULL == inst)
    865867                return ENOENT;
    866868
    867869        ext4_superblock_t *sb = inst->filesystem->superblock;
    868         uint64_t block_count = ext4_superblock_get_blocks_count(sb);
    869 
    870         return block_count;
    871 }
    872 
    873 uint64_t ext4fs_free_block_count(service_id_t service_id)
     870        *count = ext4_superblock_get_blocks_count(sb);
     871
     872        return EOK;
     873}
     874
     875int ext4fs_free_block_count(service_id_t service_id, uint64_t *count)
    874876{
    875877        ext4fs_instance_t *inst;
     
    881883
    882884        ext4_superblock_t *sb = inst->filesystem->superblock;
    883         uint64_t block_count = ext4_superblock_get_free_blocks_count(sb);
    884 
    885         return block_count;
     885        *count = ext4_superblock_get_free_blocks_count(sb);
     886
     887        return EOK;
    886888}
    887889
  • uspace/srv/fs/fat/fat_ops.c

    ra1c95da r3dd148d  
    9191static bool fat_is_file(fs_node_t *node);
    9292static service_id_t fat_service_get(fs_node_t *node);
    93 static uint32_t fat_size_block(service_id_t);
    94 static uint64_t fat_total_block_count(service_id_t);
    95 static uint64_t fat_free_block_count(service_id_t);
     93static int fat_size_block(service_id_t, uint32_t *);
     94static int fat_total_block_count(service_id_t, uint64_t *);
     95static int fat_free_block_count(service_id_t, uint64_t *);
    9696
    9797/*
     
    846846}
    847847
    848 uint32_t fat_size_block(service_id_t service_id)
     848int fat_size_block(service_id_t service_id, uint32_t *size)
    849849{
    850850        fat_bs_t *bs;
     851
    851852        bs = block_bb_get(service_id);
    852 
    853         return BPC(bs);
    854 }
    855 
    856 uint64_t fat_total_block_count(service_id_t service_id)
     853        *size = BPC(bs);
     854
     855        return EOK;
     856}
     857
     858int fat_total_block_count(service_id_t service_id, uint64_t *count)
    857859{
    858860        fat_bs_t *bs;
     861       
    859862        bs = block_bb_get(service_id);
    860 
    861         uint64_t block_count = (SPC(bs)) ? TS(bs) / SPC(bs) : 0;
    862 
    863         return block_count;
    864 }
    865 
    866 uint64_t fat_free_block_count(service_id_t service_id)
     863        *count = (SPC(bs)) ? TS(bs) / SPC(bs) : 0;
     864
     865        return EOK;
     866}
     867
     868int fat_free_block_count(service_id_t service_id, uint64_t *count)
    867869{
    868870        fat_bs_t *bs;
     
    874876        block_count = 0;
    875877        bs = block_bb_get(service_id);
    876        
    877878        clusters = (SPC(bs)) ? TS(bs) / SPC(bs) : 0;
    878        
    879879        for (cluster_no = 0; cluster_no < clusters; cluster_no++) {
    880880                rc = fat_get_cluster(bs, service_id, FAT1, cluster_no, &e0);
     
    885885                        block_count++;
    886886        }
    887 
    888         return block_count;
     887        *count = block_count;
     888       
     889        return EOK;
    889890}
    890891
  • uspace/srv/fs/mfs/mfs_ops.c

    ra1c95da r3dd148d  
    6464static int mfs_check_sanity(struct mfs_sb_info *sbi);
    6565static bool is_power_of_two(uint32_t n);
    66 static uint32_t mfs_size_block(service_id_t service_id);
    67 static uint64_t mfs_total_block_count(service_id_t service_id);
    68 static uint64_t mfs_free_block_count(service_id_t service_id);
     66static int mfs_size_block(service_id_t service_id, uint32_t *size);
     67static int mfs_total_block_count(service_id_t service_id, uint64_t *count);
     68static int mfs_free_block_count(service_id_t service_id, uint64_t *count);
    6969
    7070static hash_table_t open_nodes;
     
    11351135}
    11361136
    1137 static uint32_t
    1138 mfs_size_block(service_id_t service_id)
    1139 {
    1140         uint32_t block_size;
    1141 
     1137static int
     1138mfs_size_block(service_id_t service_id, uint32_t *size)
     1139{
    11421140        struct mfs_instance *inst;
    1143         int rc = mfs_instance_get(service_id, &inst);
     1141        int rc;
     1142
     1143        rc = mfs_instance_get(service_id, &inst);
    11441144        if (rc != EOK)
    11451145                return rc;
     1146
    11461147        if (NULL == inst)
    11471148                return ENOENT;
    11481149       
    1149         block_size = inst->sbi->block_size;
    1150 
    1151         return block_size;
    1152 }
    1153 
    1154 static uint64_t
    1155 mfs_total_block_count(service_id_t service_id)
    1156 {
    1157         uint64_t block_total;
     1150        *size = inst->sbi->block_size;
     1151
     1152        return EOK;
     1153}
     1154
     1155static int
     1156mfs_total_block_count(service_id_t service_id, uint64_t *count)
     1157{
     1158        struct mfs_instance *inst;
     1159        int rc;
    11581160       
    1159         struct mfs_instance *inst;
    1160         int rc = mfs_instance_get(service_id, &inst);
     1161        rc = mfs_instance_get(service_id, &inst);
    11611162        if (rc != EOK)
    11621163                return rc;
     
    11651166                return ENOENT;
    11661167       
    1167         block_total = (uint64_t) MFS_BMAP_SIZE_BITS(inst->sbi, BMAP_ZONE);
    1168 
    1169         return block_total;
    1170 }
    1171 
    1172 static uint64_t
    1173 mfs_free_block_count(service_id_t service_id)
     1168        *count = (uint64_t) MFS_BMAP_SIZE_BITS(inst->sbi, BMAP_ZONE);
     1169
     1170        return EOK;
     1171}
     1172
     1173static int
     1174mfs_free_block_count(service_id_t service_id, uint64_t *count)
    11741175{
    11751176        uint32_t block_free;
     
    11841185
    11851186        mfs_count_free_zones(inst, &block_free);
    1186 
    1187         return (uint64_t)block_free;
     1187        *count = block_free;
     1188
     1189        return EOK;
    11881190}
    11891191
  • uspace/srv/fs/udf/udf_ops.c

    ra1c95da r3dd148d  
    249249}
    250250
    251 static uint32_t udf_size_block(service_id_t service_id)
     251static int udf_size_block(service_id_t service_id, uint32_t *size)
    252252{
    253253        udf_instance_t *instance;
     
    259259                return ENOENT;
    260260       
    261         return instance->volumes[DEFAULT_VOL].logical_block_size;
     261        *size = instance->volumes[DEFAULT_VOL].logical_block_size;
     262       
     263        return EOK;
    262264}
    263265
Note: See TracChangeset for help on using the changeset viewer.