Changeset 0c2d9bb in mainline for uspace/srv/fs/exfat/exfat_ops.c
- Timestamp:
- 2013-12-25T22:54:29Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b51cf2c
- Parents:
- f7a33de (diff), ac36aed (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/exfat/exfat_ops.c
rf7a33de r0c2d9bb 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 *); 91 94 92 95 /* … … 155 158 static int exfat_node_fini_by_service_id(service_id_t service_id) 156 159 { 157 exfat_node_t *nodep;158 160 int rc; 159 161 … … 166 168 restart: 167 169 fibril_mutex_lock(&ffn_mutex); 168 list_foreach(ffn_list, lnk) { 169 nodep = list_get_instance(lnk, exfat_node_t, ffn_link); 170 list_foreach(ffn_list, ffn_link, exfat_node_t, nodep) { 170 171 if (!fibril_mutex_trylock(&nodep->lock)) { 171 172 fibril_mutex_unlock(&ffn_mutex); … … 912 913 } 913 914 915 int exfat_size_block(service_id_t service_id, uint32_t *size) 916 { 917 exfat_bs_t *bs; 918 bs = block_bb_get(service_id); 919 *size = BPC(bs); 920 921 return EOK; 922 } 923 924 int exfat_total_block_count(service_id_t service_id, uint64_t *count) 925 { 926 exfat_bs_t *bs; 927 bs = block_bb_get(service_id); 928 *count = DATA_CNT(bs); 929 930 return EOK; 931 } 932 933 int exfat_free_block_count(service_id_t service_id, uint64_t *count) 934 { 935 fs_node_t *node; 936 exfat_node_t *bmap_node; 937 exfat_bs_t *bs; 938 uint64_t free_block_count = 0; 939 uint64_t block_count; 940 unsigned sector; 941 int rc; 942 943 rc = exfat_total_block_count(service_id, &block_count); 944 if (rc != EOK) 945 goto exit; 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 unsigned const bmap_sectors = ROUND_UP(bmap_node->size, BPS(bs)) / 956 BPS(bs); 957 958 for (sector = 0; sector < bmap_sectors; ++sector) { 959 960 block_t *block; 961 uint8_t *bitmap; 962 unsigned bit; 963 964 rc = exfat_block_get(&block, bs, bmap_node, sector, 965 BLOCK_FLAGS_NONE); 966 if (rc != EOK) { 967 free_block_count = 0; 968 goto exit; 969 } 970 971 bitmap = (uint8_t *) block->data; 972 973 for (bit = 0; bit < BPS(bs) * 8 && block_count > 0; 974 ++bit, --block_count) { 975 if (!(bitmap[bit / 8] & (1 << (bit % 8)))) 976 ++free_block_count; 977 } 978 979 block_put(block); 980 981 if (block_count == 0) { 982 /* Reached the end of the bitmap */ 983 goto exit; 984 } 985 } 986 987 exit: 988 exfat_node_put(node); 989 *count = free_block_count; 990 return rc; 991 } 914 992 915 993 /** libfs operations */ … … 930 1008 .is_directory = exfat_is_directory, 931 1009 .is_file = exfat_is_file, 932 .service_get = exfat_service_get 1010 .service_get = exfat_service_get, 1011 .size_block = exfat_size_block, 1012 .total_block_count = exfat_total_block_count, 1013 .free_block_count = exfat_free_block_count 933 1014 }; 934 1015
Note:
See TracChangeset
for help on using the changeset viewer.