Changes in uspace/srv/fs/fat/fat_ops.c [44ecf89:1558d85] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_ops.c
r44ecf89 r1558d85 55 55 #include <assert.h> 56 56 #include <fibril_synch.h> 57 #include <sys/mman.h>58 57 #include <align.h> 59 58 #include <malloc.h> 60 #include <str.h>61 59 62 60 #define FAT_NODE(node) ((node) ? (fat_node_t *) (node)->data : NULL) … … 91 89 static bool fat_is_file(fs_node_t *node); 92 90 static service_id_t fat_service_get(fs_node_t *node); 91 static int fat_size_block(service_id_t, uint32_t *); 92 static int fat_total_block_count(service_id_t, uint64_t *); 93 static int fat_free_block_count(service_id_t, uint64_t *); 93 94 94 95 /* … … 149 150 static int fat_node_fini_by_service_id(service_id_t service_id) 150 151 { 151 fat_node_t *nodep;152 152 int rc; 153 153 … … 160 160 restart: 161 161 fibril_mutex_lock(&ffn_mutex); 162 list_foreach(ffn_list, lnk) { 163 nodep = list_get_instance(lnk, fat_node_t, ffn_link); 162 list_foreach(ffn_list, ffn_link, fat_node_t, nodep) { 164 163 if (!fibril_mutex_trylock(&nodep->lock)) { 165 164 fibril_mutex_unlock(&ffn_mutex); … … 843 842 } 844 843 844 int fat_size_block(service_id_t service_id, uint32_t *size) 845 { 846 fat_bs_t *bs; 847 848 bs = block_bb_get(service_id); 849 *size = BPC(bs); 850 851 return EOK; 852 } 853 854 int fat_total_block_count(service_id_t service_id, uint64_t *count) 855 { 856 fat_bs_t *bs; 857 858 bs = block_bb_get(service_id); 859 *count = (SPC(bs)) ? TS(bs) / SPC(bs) : 0; 860 861 return EOK; 862 } 863 864 int fat_free_block_count(service_id_t service_id, uint64_t *count) 865 { 866 fat_bs_t *bs; 867 fat_cluster_t e0; 868 uint64_t block_count; 869 int rc; 870 uint32_t cluster_no, clusters; 871 872 block_count = 0; 873 bs = block_bb_get(service_id); 874 clusters = (SPC(bs)) ? TS(bs) / SPC(bs) : 0; 875 for (cluster_no = 0; cluster_no < clusters; cluster_no++) { 876 rc = fat_get_cluster(bs, service_id, FAT1, cluster_no, &e0); 877 if (rc != EOK) 878 return EIO; 879 880 if (e0 == FAT_CLST_RES0) 881 block_count++; 882 } 883 *count = block_count; 884 885 return EOK; 886 } 887 845 888 /** libfs operations */ 846 889 libfs_ops_t fat_libfs_ops = { … … 860 903 .is_directory = fat_is_directory, 861 904 .is_file = fat_is_file, 862 .service_get = fat_service_get 905 .service_get = fat_service_get, 906 .size_block = fat_size_block, 907 .total_block_count = fat_total_block_count, 908 .free_block_count = fat_free_block_count 863 909 }; 864 910 … … 883 929 /* Parse mount options. */ 884 930 char *mntopts = (char *) opts; 885 char *saveptr;886 931 char *opt; 887 while ((opt = str tok_r(mntopts, " ,", &saveptr)) != NULL) {932 while ((opt = str_tok(mntopts, " ,", &mntopts)) != NULL) { 888 933 if (str_cmp(opt, "wtcache") == 0) 889 934 cmode = CACHE_MODE_WT; 890 935 else if (str_cmp(opt, "nolfn") == 0) 891 936 instance->lfn_enabled = false; 892 mntopts = NULL;893 937 } 894 938 895 939 /* initialize libblock */ 896 rc = block_init( EXCHANGE_SERIALIZE,service_id, BS_SIZE);940 rc = block_init(service_id, BS_SIZE); 897 941 if (rc != EOK) { 898 942 free(instance);
Note:
See TracChangeset
for help on using the changeset viewer.