Changes in uspace/srv/fs/fat/fat_ops.c [b33870b:40cdbec] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_ops.c
rb33870b r40cdbec 871 871 aoff64_t *size, unsigned *linkcnt) 872 872 { 873 enum cache_mode cmode ;873 enum cache_mode cmode = CACHE_MODE_WB; 874 874 fat_bs_t *bs; 875 int rc; 876 877 /* Check for option enabling write through. */ 878 if (str_cmp(opts, "wtcache") == 0) 879 cmode = CACHE_MODE_WT; 880 else 881 cmode = CACHE_MODE_WB; 875 fat_instance_t *instance; 876 int rc; 877 878 instance = malloc(sizeof(fat_instance_t)); 879 if (!instance) 880 return ENOMEM; 881 instance->lfn_enabled = true; 882 883 /* Parse mount options. */ 884 char *mntopts = (char *) opts; 885 char *saveptr; 886 char *opt; 887 while ((opt = strtok_r(mntopts, " ,", &saveptr)) != NULL) { 888 if (str_cmp(opt, "wtcache") == 0) 889 cmode = CACHE_MODE_WT; 890 else if (str_cmp(opt, "nolfn") == 0) 891 instance->lfn_enabled = false; 892 mntopts = NULL; 893 } 882 894 883 895 /* initialize libblock */ 884 896 rc = block_init(EXCHANGE_SERIALIZE, service_id, BS_SIZE); 885 if (rc != EOK) 886 return rc; 897 if (rc != EOK) { 898 free(instance); 899 return rc; 900 } 887 901 888 902 /* prepare the boot block */ 889 903 rc = block_bb_read(service_id, BS_BLOCK); 890 904 if (rc != EOK) { 905 free(instance); 891 906 block_fini(service_id); 892 907 return rc; … … 897 912 898 913 if (BPS(bs) != BS_SIZE) { 914 free(instance); 899 915 block_fini(service_id); 900 916 return ENOTSUP; … … 904 920 rc = block_cache_init(service_id, BPS(bs), 0 /* XXX */, cmode); 905 921 if (rc != EOK) { 922 free(instance); 906 923 block_fini(service_id); 907 924 return rc; … … 911 928 rc = fat_sanity_check(bs, service_id); 912 929 if (rc != EOK) { 930 free(instance); 913 931 (void) block_cache_fini(service_id); 914 932 block_fini(service_id); … … 918 936 rc = fat_idx_init_by_service_id(service_id); 919 937 if (rc != EOK) { 938 free(instance); 920 939 (void) block_cache_fini(service_id); 921 940 block_fini(service_id); … … 926 945 fs_node_t *rfn = (fs_node_t *)malloc(sizeof(fs_node_t)); 927 946 if (!rfn) { 947 free(instance); 928 948 (void) block_cache_fini(service_id); 929 949 block_fini(service_id); … … 935 955 fat_node_t *rootp = (fat_node_t *)malloc(sizeof(fat_node_t)); 936 956 if (!rootp) { 957 free(instance); 937 958 free(rfn); 938 959 (void) block_cache_fini(service_id); … … 945 966 fat_idx_t *ridxp = fat_idx_get_by_pos(service_id, FAT_CLST_ROOTPAR, 0); 946 967 if (!ridxp) { 968 free(instance); 947 969 free(rfn); 948 970 free(rootp); … … 964 986 rc = fat_clusters_get(&clusters, bs, service_id, rootp->firstc); 965 987 if (rc != EOK) { 988 fibril_mutex_unlock(&ridxp->lock); 989 free(instance); 966 990 free(rfn); 967 991 free(rootp); … … 974 998 } else 975 999 rootp->size = RDE(bs) * sizeof(fat_dentry_t); 1000 1001 rc = fs_instance_create(service_id, instance); 1002 if (rc != EOK) { 1003 fibril_mutex_unlock(&ridxp->lock); 1004 free(instance); 1005 free(rfn); 1006 free(rootp); 1007 (void) block_cache_fini(service_id); 1008 block_fini(service_id); 1009 fat_idx_fini_by_service_id(service_id); 1010 return rc; 1011 } 976 1012 977 1013 rootp->idx = ridxp; … … 1024 1060 (void) block_cache_fini(service_id); 1025 1061 block_fini(service_id); 1062 1063 void *data; 1064 if (fs_instance_get(service_id, &data) == EOK) { 1065 fs_instance_destroy(service_id); 1066 free(data); 1067 } 1026 1068 1027 1069 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.