Ignore:
File:
1 edited

Legend:

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

    rfeeac0d r3dd148d  
    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{
     154        fat_node_t *nodep;
    151155        int rc;
    152156
     
    159163restart:
    160164        fibril_mutex_lock(&ffn_mutex);
    161         list_foreach(ffn_list, ffn_link, fat_node_t, nodep) {
     165        list_foreach(ffn_list, lnk) {
     166                nodep = list_get_instance(lnk, fat_node_t, ffn_link);
    162167                if (!fibril_mutex_trylock(&nodep->lock)) {
    163168                        fibril_mutex_unlock(&ffn_mutex);
     
    841846}
    842847
     848int fat_size_block(service_id_t service_id, uint32_t *size)
     849{
     850        fat_bs_t *bs;
     851
     852        bs = block_bb_get(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)
     859{
     860        fat_bs_t *bs;
     861       
     862        bs = block_bb_get(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)
     869{
     870        fat_bs_t *bs;
     871        fat_cluster_t e0;
     872        uint64_t block_count;
     873        int rc;
     874        uint32_t cluster_no, clusters;
     875
     876        block_count = 0;
     877        bs = block_bb_get(service_id);
     878        clusters = (SPC(bs)) ? TS(bs) / SPC(bs) : 0;
     879        for (cluster_no = 0; cluster_no < clusters; cluster_no++) {
     880                rc = fat_get_cluster(bs, service_id, FAT1, cluster_no, &e0);
     881                if (rc != EOK)
     882                        return EIO;
     883
     884                if (e0 == FAT_CLST_RES0)
     885                        block_count++;
     886        }
     887        *count = block_count;
     888       
     889        return EOK;
     890}
     891
    843892/** libfs operations */
    844893libfs_ops_t fat_libfs_ops = {
     
    858907        .is_directory = fat_is_directory,
    859908        .is_file = fat_is_file,
    860         .service_get = fat_service_get
     909        .service_get = fat_service_get,
     910        .size_block = fat_size_block,
     911        .total_block_count = fat_total_block_count,
     912        .free_block_count = fat_free_block_count
    861913};
    862914
Note: See TracChangeset for help on using the changeset viewer.