Changes in uspace/srv/fs/exfat/exfat_ops.c [09d6695:062d900] in mainline
- File:
-
- 1 edited
-
uspace/srv/fs/exfat/exfat_ops.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/exfat/exfat_ops.c
r09d6695 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 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);94 91 95 92 /* … … 915 912 } 916 913 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 }989 914 990 915 /** libfs operations */ … … 1005 930 .is_directory = exfat_is_directory, 1006 931 .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 1011 933 }; 1012 934
Note:
See TracChangeset
for help on using the changeset viewer.
