Ignore:
File:
1 edited

Legend:

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

    r44ecf89 r2463df9  
    5555#include <assert.h>
    5656#include <fibril_synch.h>
    57 #include <sys/mman.h>
    5857#include <align.h>
    5958#include <malloc.h>
     
    9190static bool fat_is_file(fs_node_t *node);
    9291static service_id_t fat_service_get(fs_node_t *node);
     92static int fat_size_block(service_id_t, uint32_t *);
     93static int fat_total_block_count(service_id_t, uint64_t *);
     94static int fat_free_block_count(service_id_t, uint64_t *);
    9395
    9496/*
     
    149151static int fat_node_fini_by_service_id(service_id_t service_id)
    150152{
    151         fat_node_t *nodep;
    152153        int rc;
    153154
     
    160161restart:
    161162        fibril_mutex_lock(&ffn_mutex);
    162         list_foreach(ffn_list, lnk) {
    163                 nodep = list_get_instance(lnk, fat_node_t, ffn_link);
     163        list_foreach(ffn_list, ffn_link, fat_node_t, nodep) {
    164164                if (!fibril_mutex_trylock(&nodep->lock)) {
    165165                        fibril_mutex_unlock(&ffn_mutex);
     
    843843}
    844844
     845int fat_size_block(service_id_t service_id, uint32_t *size)
     846{
     847        fat_bs_t *bs;
     848
     849        bs = block_bb_get(service_id);
     850        *size = BPC(bs);
     851
     852        return EOK;
     853}
     854
     855int fat_total_block_count(service_id_t service_id, uint64_t *count)
     856{
     857        fat_bs_t *bs;
     858       
     859        bs = block_bb_get(service_id);
     860        *count = (SPC(bs)) ? TS(bs) / SPC(bs) : 0;
     861
     862        return EOK;
     863}
     864
     865int fat_free_block_count(service_id_t service_id, uint64_t *count)
     866{
     867        fat_bs_t *bs;
     868        fat_cluster_t e0;
     869        uint64_t block_count;
     870        int rc;
     871        uint32_t cluster_no, clusters;
     872
     873        block_count = 0;
     874        bs = block_bb_get(service_id);
     875        clusters = (SPC(bs)) ? TS(bs) / SPC(bs) : 0;
     876        for (cluster_no = 0; cluster_no < clusters; cluster_no++) {
     877                rc = fat_get_cluster(bs, service_id, FAT1, cluster_no, &e0);
     878                if (rc != EOK)
     879                        return EIO;
     880
     881                if (e0 == FAT_CLST_RES0)
     882                        block_count++;
     883        }
     884        *count = block_count;
     885       
     886        return EOK;
     887}
     888
    845889/** libfs operations */
    846890libfs_ops_t fat_libfs_ops = {
     
    860904        .is_directory = fat_is_directory,
    861905        .is_file = fat_is_file,
    862         .service_get = fat_service_get
     906        .service_get = fat_service_get,
     907        .size_block = fat_size_block,
     908        .total_block_count = fat_total_block_count,
     909        .free_block_count = fat_free_block_count
    863910};
    864911
Note: See TracChangeset for help on using the changeset viewer.