Changes in uspace/srv/fs/exfat/exfat_ops.c [feeac0d:2463df9] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/exfat/exfat_ops.c
rfeeac0d r2463df9 58 58 #include <assert.h> 59 59 #include <fibril_synch.h> 60 #include <sys/mman.h>61 60 #include <align.h> 62 61 #include <malloc.h> … … 89 88 static bool exfat_is_file(fs_node_t *node); 90 89 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 *); 91 93 92 94 /* … … 910 912 } 911 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 } 912 991 913 992 /** libfs operations */ … … 928 1007 .is_directory = exfat_is_directory, 929 1008 .is_file = exfat_is_file, 930 .service_get = exfat_service_get 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 931 1013 }; 932 1014
Note:
See TracChangeset
for help on using the changeset viewer.