Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/exfat/exfat_ops.c

    r09d6695 r062d900  
    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);
    9491
    9592/*
     
    915912}
    916913
    917 uint32_t exfat_size_block(service_id_t service_id)
    918 {
    919         exfat_bs_t *bs;
    920         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)
    926 {
    927         exfat_bs_t *bs;
    928         bs = block_bb_get(service_id);
    929        
    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)
    936 {
    937         fs_node_t *node;
    938         exfat_node_t *bmap_node;
    939         exfat_bs_t *bs;
    940         uint64_t free_block_count = 0;
    941         uint64_t block_count;
    942         unsigned sector;
    943         int rc;
    944 
    945         block_count = exfat_total_block_count(service_id);
    946 
    947         bs = block_bb_get(service_id);
    948         node = NULL;
    949         rc = exfat_bitmap_get(&node, service_id);
    950         if (rc != EOK)
    951                 goto exit;
    952 
    953         bmap_node = (exfat_node_t *) node->data;
    954 
    955         for (sector = 0; sector < bmap_node->size / BPS(bs); ++sector) {
    956 
    957                 block_t *block;
    958                 uint8_t *bitmap;
    959                 unsigned bit;
    960 
    961                 rc = exfat_block_get_by_clst(&block, bs, service_id,
    962                     bmap_node->fragmented, bmap_node->firstc, NULL, sector,
    963                     BLOCK_FLAGS_NONE);
    964                 if (rc != EOK) {
    965                         free_block_count = 0;
    966                         goto exit;
    967                 }
    968 
    969                 bitmap = (uint8_t *) block->data;
    970 
    971                 for (bit = 0; bit < BPS(bs) * 8 && block_count > 0;
    972                     ++bit, --block_count) {
    973                         if (!(bitmap[bit / 8] & (1 << (bit % 8))))
    974                                 ++free_block_count;
    975                 }
    976 
    977                 block_put(block);
    978 
    979                 if (block_count == 0) {
    980                         /* Reached the end of the bitmap */
    981                         goto exit;
    982                 }
    983         }
    984 
    985 exit:
    986         exfat_node_put(node);
    987         return free_block_count;
    988 }
    989914
    990915/** libfs operations */
     
    1005930        .is_directory = exfat_is_directory,
    1006931        .is_file = exfat_is_file,
    1007         .service_get = exfat_service_get,
    1008         .size_block = exfat_size_block,
    1009         .total_block_count = exfat_total_block_count,
    1010         .free_block_count = exfat_free_block_count
     932        .service_get = exfat_service_get
    1011933};
    1012934
Note: See TracChangeset for help on using the changeset viewer.