Ignore:
File:
1 edited

Legend:

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

    r6b6f394d rfeeac0d  
    8989static bool exfat_is_file(fs_node_t *node);
    9090static service_id_t exfat_service_get(fs_node_t *node);
    91 static int exfat_size_block(service_id_t, uint32_t *);
    92 static int exfat_total_block_count(service_id_t, uint64_t *);
    93 static int exfat_free_block_count(service_id_t, uint64_t *);
    9491
    9592/*
     
    158155static int exfat_node_fini_by_service_id(service_id_t service_id)
    159156{
    160         exfat_node_t *nodep;
    161157        int rc;
    162158
     
    169165restart:
    170166        fibril_mutex_lock(&ffn_mutex);
    171         list_foreach(ffn_list, lnk) {
    172                 nodep = list_get_instance(lnk, exfat_node_t, ffn_link);
     167        list_foreach(ffn_list, ffn_link, exfat_node_t, nodep) {
    173168                if (!fibril_mutex_trylock(&nodep->lock)) {
    174169                        fibril_mutex_unlock(&ffn_mutex);
     
    915910}
    916911
    917 int exfat_size_block(service_id_t service_id, uint32_t *size)
    918 {
    919         exfat_bs_t *bs;
    920         bs = block_bb_get(service_id);
    921         *size = BPC(bs);
    922 
    923         return EOK;
    924 }
    925 
    926 int exfat_total_block_count(service_id_t service_id, uint64_t *count)
    927 {
    928         exfat_bs_t *bs;
    929         bs = block_bb_get(service_id);
    930         *count = DATA_CNT(bs);
    931        
    932         return EOK;
    933 }
    934 
    935 int exfat_free_block_count(service_id_t service_id, uint64_t *count)
    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         rc = exfat_total_block_count(service_id, &block_count);
    946         if (rc != EOK)
    947                 goto exit;
    948 
    949         bs = block_bb_get(service_id);
    950         node = NULL;
    951         rc = exfat_bitmap_get(&node, service_id);
    952         if (rc != EOK)
    953                 goto exit;
    954 
    955         bmap_node = (exfat_node_t *) node->data;
    956 
    957         unsigned const bmap_sectors = ROUND_UP(bmap_node->size, BPS(bs)) /
    958             BPS(bs);
    959 
    960         for (sector = 0; sector < bmap_sectors; ++sector) {
    961 
    962                 block_t *block;
    963                 uint8_t *bitmap;
    964                 unsigned bit;
    965 
    966                 rc = exfat_block_get(&block, bs, bmap_node, sector,
    967                     BLOCK_FLAGS_NONE);
    968                 if (rc != EOK) {
    969                         free_block_count = 0;
    970                         goto exit;
    971                 }
    972 
    973                 bitmap = (uint8_t *) block->data;
    974 
    975                 for (bit = 0; bit < BPS(bs) * 8 && block_count > 0;
    976                     ++bit, --block_count) {
    977                         if (!(bitmap[bit / 8] & (1 << (bit % 8))))
    978                                 ++free_block_count;
    979                 }
    980 
    981                 block_put(block);
    982 
    983                 if (block_count == 0) {
    984                         /* Reached the end of the bitmap */
    985                         goto exit;
    986                 }
    987         }
    988 
    989 exit:
    990         exfat_node_put(node);
    991         *count = free_block_count;
    992         return rc;
    993 }
    994912
    995913/** libfs operations */
     
    1010928        .is_directory = exfat_is_directory,
    1011929        .is_file = exfat_is_file,
    1012         .service_get = exfat_service_get,
    1013         .size_block = exfat_size_block,
    1014         .total_block_count = exfat_total_block_count,
    1015         .free_block_count = exfat_free_block_count
     930        .service_get = exfat_service_get
    1016931};
    1017932
Note: See TracChangeset for help on using the changeset viewer.