Ignore:
File:
1 edited

Legend:

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

    r44ecf89 r5cd6c84  
    9191static bool fat_is_file(fs_node_t *node);
    9292static service_id_t fat_service_get(fs_node_t *node);
     93static uint32_t fat_size_block(service_id_t);
     94static uint64_t fat_total_block_count(service_id_t);
     95static uint64_t fat_free_block_count(service_id_t);
    9396
    9497/*
     
    843846}
    844847
     848uint32_t fat_size_block(service_id_t service_id)
     849{
     850        fat_bs_t *bs;
     851        bs = block_bb_get(service_id);
     852
     853        return BPC(bs);
     854}
     855
     856uint64_t fat_total_block_count(service_id_t service_id)
     857{
     858        fat_bs_t *bs;
     859        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
     866uint64_t fat_free_block_count(service_id_t service_id)
     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       
     877        clusters = (SPC(bs)) ? TS(bs) / SPC(bs) : 0;
     878       
     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
     888        return block_count;
     889}
     890
    845891/** libfs operations */
    846892libfs_ops_t fat_libfs_ops = {
     
    860906        .is_directory = fat_is_directory,
    861907        .is_file = fat_is_file,
    862         .service_get = fat_service_get
     908        .service_get = fat_service_get,
     909        .size_block = fat_size_block,
     910        .total_block_count = fat_total_block_count,
     911        .free_block_count = fat_free_block_count
    863912};
    864913
Note: See TracChangeset for help on using the changeset viewer.