Changes in uspace/srv/fs/exfat/exfat_ops.c [6b6f394d:062d900] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/exfat/exfat_ops.c
r6b6f394d r062d900 89 89 static bool exfat_is_file(fs_node_t *node); 90 90 static 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 *);94 91 95 92 /* … … 915 912 } 916 913 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 }994 914 995 915 /** libfs operations */ … … 1010 930 .is_directory = exfat_is_directory, 1011 931 .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 932 .service_get = exfat_service_get 1016 933 }; 1017 934
Note:
See TracChangeset
for help on using the changeset viewer.