Changeset 0e976d9b in mainline for uspace/srv/fs/exfat/exfat_ops.c
- Timestamp:
- 2013-07-24T12:13:41Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a39aac7
- Parents:
- 5cd6c84
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/exfat/exfat_ops.c
r5cd6c84 r0e976d9b 935 935 uint64_t exfat_free_block_count(service_id_t service_id) 936 936 { 937 fs_node_t *node; 938 exfat_node_t *bmap_node; 937 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 938 947 bs = block_bb_get(service_id); 939 940 uint64_t block_count = (DATA_CNT(bs) / 100) * 941 bs->allocated_percent; 942 943 return block_count; 948 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; 944 988 } 945 989
Note:
See TracChangeset
for help on using the changeset viewer.