Changes in uspace/srv/fs/exfat/exfat_ops.c [2463df9:062d900] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/exfat/exfat_ops.c
r2463df9 r062d900 58 58 #include <assert.h> 59 59 #include <fibril_synch.h> 60 #include <sys/mman.h> 60 61 #include <align.h> 61 62 #include <malloc.h> … … 88 89 static bool exfat_is_file(fs_node_t *node); 89 90 static service_id_t exfat_service_get(fs_node_t *node); 90 static int exfat_size_block(service_id_t, uint32_t *);91 static int exfat_total_block_count(service_id_t, uint64_t *);92 static int exfat_free_block_count(service_id_t, uint64_t *);93 91 94 92 /* … … 157 155 static int exfat_node_fini_by_service_id(service_id_t service_id) 158 156 { 157 exfat_node_t *nodep; 159 158 int rc; 160 159 … … 167 166 restart: 168 167 fibril_mutex_lock(&ffn_mutex); 169 list_foreach(ffn_list, ffn_link, exfat_node_t, nodep) { 168 list_foreach(ffn_list, lnk) { 169 nodep = list_get_instance(lnk, exfat_node_t, ffn_link); 170 170 if (!fibril_mutex_trylock(&nodep->lock)) { 171 171 fibril_mutex_unlock(&ffn_mutex); … … 912 912 } 913 913 914 int exfat_size_block(service_id_t service_id, uint32_t *size)915 {916 exfat_bs_t *bs;917 bs = block_bb_get(service_id);918 *size = BPC(bs);919 920 return EOK;921 }922 923 int exfat_total_block_count(service_id_t service_id, uint64_t *count)924 {925 exfat_bs_t *bs;926 bs = block_bb_get(service_id);927 *count = DATA_CNT(bs);928 929 return EOK;930 }931 932 int exfat_free_block_count(service_id_t service_id, uint64_t *count)933 {934 fs_node_t *node;935 exfat_node_t *bmap_node;936 exfat_bs_t *bs;937 uint64_t free_block_count = 0;938 uint64_t block_count;939 unsigned sector;940 int rc;941 942 rc = exfat_total_block_count(service_id, &block_count);943 if (rc != EOK)944 goto exit;945 946 bs = block_bb_get(service_id);947 node = NULL;948 rc = exfat_bitmap_get(&node, service_id);949 if (rc != EOK)950 goto exit;951 952 bmap_node = (exfat_node_t *) node->data;953 954 unsigned const bmap_sectors = ROUND_UP(bmap_node->size, BPS(bs)) /955 BPS(bs);956 957 for (sector = 0; sector < bmap_sectors; ++sector) {958 959 block_t *block;960 uint8_t *bitmap;961 unsigned bit;962 963 rc = exfat_block_get(&block, bs, bmap_node, sector,964 BLOCK_FLAGS_NONE);965 if (rc != EOK) {966 free_block_count = 0;967 goto exit;968 }969 970 bitmap = (uint8_t *) block->data;971 972 for (bit = 0; bit < BPS(bs) * 8 && block_count > 0;973 ++bit, --block_count) {974 if (!(bitmap[bit / 8] & (1 << (bit % 8))))975 ++free_block_count;976 }977 978 block_put(block);979 980 if (block_count == 0) {981 /* Reached the end of the bitmap */982 goto exit;983 }984 }985 986 exit:987 exfat_node_put(node);988 *count = free_block_count;989 return rc;990 }991 914 992 915 /** libfs operations */ … … 1007 930 .is_directory = exfat_is_directory, 1008 931 .is_file = exfat_is_file, 1009 .service_get = exfat_service_get, 1010 .size_block = exfat_size_block, 1011 .total_block_count = exfat_total_block_count, 1012 .free_block_count = exfat_free_block_count 932 .service_get = exfat_service_get 1013 933 }; 1014 934
Note:
See TracChangeset
for help on using the changeset viewer.