Changeset 0773396 in mainline for uspace/srv/fs/fat/fat_ops.c


Ignore:
Timestamp:
2013-12-25T13:05:25Z (10 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bc54126c
Parents:
f4a47e52 (diff), 6946f23 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge mainline changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/fat/fat_ops.c

    rf4a47e52 r0773396  
    9191static bool fat_is_file(fs_node_t *node);
    9292static service_id_t fat_service_get(fs_node_t *node);
     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 *);
    9396
    9497/*
     
    149152static int fat_node_fini_by_service_id(service_id_t service_id)
    150153{
    151         fat_node_t *nodep;
    152154        int rc;
    153155
     
    160162restart:
    161163        fibril_mutex_lock(&ffn_mutex);
    162         list_foreach(ffn_list, lnk) {
    163                 nodep = list_get_instance(lnk, fat_node_t, ffn_link);
     164        list_foreach(ffn_list, ffn_link, fat_node_t, nodep) {
    164165                if (!fibril_mutex_trylock(&nodep->lock)) {
    165166                        fibril_mutex_unlock(&ffn_mutex);
     
    843844}
    844845
     846int fat_size_block(service_id_t service_id, uint32_t *size)
     847{
     848        fat_bs_t *bs;
     849
     850        bs = block_bb_get(service_id);
     851        *size = BPC(bs);
     852
     853        return EOK;
     854}
     855
     856int fat_total_block_count(service_id_t service_id, uint64_t *count)
     857{
     858        fat_bs_t *bs;
     859       
     860        bs = block_bb_get(service_id);
     861        *count = (SPC(bs)) ? TS(bs) / SPC(bs) : 0;
     862
     863        return EOK;
     864}
     865
     866int fat_free_block_count(service_id_t service_id, uint64_t *count)
     867{
     868        fat_bs_t *bs;
     869        fat_cluster_t e0;
     870        uint64_t block_count;
     871        int rc;
     872        uint32_t cluster_no, clusters;
     873
     874        block_count = 0;
     875        bs = block_bb_get(service_id);
     876        clusters = (SPC(bs)) ? TS(bs) / SPC(bs) : 0;
     877        for (cluster_no = 0; cluster_no < clusters; cluster_no++) {
     878                rc = fat_get_cluster(bs, service_id, FAT1, cluster_no, &e0);
     879                if (rc != EOK)
     880                        return EIO;
     881
     882                if (e0 == FAT_CLST_RES0)
     883                        block_count++;
     884        }
     885        *count = block_count;
     886       
     887        return EOK;
     888}
     889
    845890/** libfs operations */
    846891libfs_ops_t fat_libfs_ops = {
     
    860905        .is_directory = fat_is_directory,
    861906        .is_file = fat_is_file,
    862         .service_get = fat_service_get
     907        .service_get = fat_service_get,
     908        .size_block = fat_size_block,
     909        .total_block_count = fat_total_block_count,
     910        .free_block_count = fat_free_block_count
    863911};
    864912
Note: See TracChangeset for help on using the changeset viewer.