Changes in / [3766467:f60a0e4] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_ops.c
r3766467 rf60a0e4 363 363 } 364 364 rc = fat_node_get_core(&nodep, idx); 365 assert(rc == EOK); 365 366 fibril_mutex_unlock(&idx->lock); 366 if (rc != EOK) { 367 (void) block_put(b); 368 return rc; 369 } 367 (void) block_put(b); 370 368 *rfn = FS_NODE(nodep); 371 rc = block_put(b); 372 if (rc != EOK) 373 (void) fat_node_put(*rfn); 374 return rc; 369 return EOK; 375 370 } 376 371 } … … 1077 1072 rc = fat_block_get(&b, bs, nodep, pos / bps, 1078 1073 BLOCK_FLAGS_NONE); 1079 if (rc != EOK) { 1080 fat_node_put(fn); 1081 ipc_answer_0(callid, rc); 1082 ipc_answer_0(rid, rc); 1083 return; 1084 } 1074 assert(rc == EOK); 1085 1075 (void) async_data_read_finalize(callid, b->data + pos % bps, 1086 1076 bytes); 1087 1077 rc = block_put(b); 1088 if (rc != EOK) { 1089 fat_node_put(fn); 1090 ipc_answer_0(rid, rc); 1091 return; 1092 } 1078 assert(rc == EOK); 1093 1079 } 1094 1080 } else { … … 1114 1100 rc = fat_block_get(&b, bs, nodep, bnum, 1115 1101 BLOCK_FLAGS_NONE); 1116 if (rc != EOK) 1117 goto err; 1102 assert(rc == EOK); 1118 1103 for (o = pos % (bps / sizeof(fat_dentry_t)); 1119 1104 o < bps / sizeof(fat_dentry_t); … … 1126 1111 case FAT_DENTRY_LAST: 1127 1112 rc = block_put(b); 1128 if (rc != EOK) 1129 goto err; 1113 assert(rc == EOK); 1130 1114 goto miss; 1131 1115 default: … … 1133 1117 fat_dentry_name_get(d, name); 1134 1118 rc = block_put(b); 1135 if (rc != EOK) 1136 goto err; 1119 assert(rc == EOK); 1137 1120 goto hit; 1138 1121 } 1139 1122 } 1140 1123 rc = block_put(b); 1141 if (rc != EOK) 1142 goto err; 1124 assert(rc == EOK); 1143 1125 bnum++; 1144 1126 } 1145 1127 miss: 1146 rc = fat_node_put(fn); 1147 ipc_answer_0(callid, rc != EOK ? rc : ENOENT); 1148 ipc_answer_1(rid, rc != EOK ? rc : ENOENT, 0); 1149 return; 1150 1151 err: 1152 (void) fat_node_put(fn); 1153 ipc_answer_0(callid, rc); 1154 ipc_answer_0(rid, rc); 1155 return; 1156 1128 fat_node_put(fn); 1129 ipc_answer_0(callid, ENOENT); 1130 ipc_answer_1(rid, ENOENT, 0); 1131 return; 1157 1132 hit: 1158 1133 (void) async_data_read_finalize(callid, name, str_size(name) + 1); … … 1160 1135 } 1161 1136 1162 rc =fat_node_put(fn);1163 ipc_answer_1(rid, rc, (ipcarg_t)bytes);1137 fat_node_put(fn); 1138 ipc_answer_1(rid, EOK, (ipcarg_t)bytes); 1164 1139 } 1165 1140 … … 1172 1147 fat_node_t *nodep; 1173 1148 fat_bs_t *bs; 1174 size_t bytes , size;1149 size_t bytes; 1175 1150 block_t *b; 1176 1151 uint16_t bps; … … 1195 1170 size_t len; 1196 1171 if (!async_data_write_receive(&callid, &len)) { 1197 (void)fat_node_put(fn);1172 fat_node_put(fn); 1198 1173 ipc_answer_0(callid, EINVAL); 1199 1174 ipc_answer_0(rid, EINVAL); … … 1226 1201 */ 1227 1202 rc = fat_fill_gap(bs, nodep, FAT_CLST_RES0, pos); 1228 if (rc != EOK) { 1229 (void) fat_node_put(fn); 1230 ipc_answer_0(callid, rc); 1231 ipc_answer_0(rid, rc); 1232 return; 1233 } 1203 assert(rc == EOK); 1234 1204 rc = fat_block_get(&b, bs, nodep, pos / bps, flags); 1235 if (rc != EOK) { 1236 (void) fat_node_put(fn); 1237 ipc_answer_0(callid, rc); 1238 ipc_answer_0(rid, rc); 1239 return; 1240 } 1205 assert(rc == EOK); 1241 1206 (void) async_data_write_finalize(callid, b->data + pos % bps, 1242 1207 bytes); 1243 1208 b->dirty = true; /* need to sync block */ 1244 1209 rc = block_put(b); 1245 if (rc != EOK) { 1246 (void) fat_node_put(fn); 1247 ipc_answer_0(rid, rc); 1248 return; 1249 } 1210 assert(rc == EOK); 1250 1211 if (pos + bytes > nodep->size) { 1251 1212 nodep->size = pos + bytes; 1252 1213 nodep->dirty = true; /* need to sync node */ 1253 1214 } 1254 size = nodep->size; 1255 rc = fat_node_put(fn); 1256 ipc_answer_2(rid, rc, bytes, nodep->size); 1215 ipc_answer_2(rid, EOK, bytes, nodep->size); 1216 fat_node_put(fn); 1257 1217 return; 1258 1218 } else { … … 1261 1221 * clusters for the node and zero them out. 1262 1222 */ 1223 int status; 1263 1224 unsigned nclsts; 1264 1225 fat_cluster_t mcl, lcl; … … 1266 1227 nclsts = (ROUND_UP(pos + bytes, bpc) - boundary) / bpc; 1267 1228 /* create an independent chain of nclsts clusters in all FATs */ 1268 rc= fat_alloc_clusters(bs, dev_handle, nclsts, &mcl, &lcl);1269 if ( rc!= EOK) {1229 status = fat_alloc_clusters(bs, dev_handle, nclsts, &mcl, &lcl); 1230 if (status != EOK) { 1270 1231 /* could not allocate a chain of nclsts clusters */ 1271 (void)fat_node_put(fn);1272 ipc_answer_0(callid, rc);1273 ipc_answer_0(rid, rc);1232 fat_node_put(fn); 1233 ipc_answer_0(callid, status); 1234 ipc_answer_0(rid, status); 1274 1235 return; 1275 1236 } 1276 1237 /* zero fill any gaps */ 1277 1238 rc = fat_fill_gap(bs, nodep, mcl, pos); 1278 if (rc != EOK) { 1279 (void) fat_free_clusters(bs, dev_handle, mcl); 1280 (void) fat_node_put(fn); 1281 ipc_answer_0(callid, rc); 1282 ipc_answer_0(rid, rc); 1283 return; 1284 } 1239 assert(rc == EOK); 1285 1240 rc = _fat_block_get(&b, bs, dev_handle, lcl, (pos / bps) % spc, 1286 1241 flags); 1287 if (rc != EOK) { 1288 (void) fat_free_clusters(bs, dev_handle, mcl); 1289 (void) fat_node_put(fn); 1290 ipc_answer_0(callid, rc); 1291 ipc_answer_0(rid, rc); 1292 return; 1293 } 1242 assert(rc == EOK); 1294 1243 (void) async_data_write_finalize(callid, b->data + pos % bps, 1295 1244 bytes); 1296 1245 b->dirty = true; /* need to sync block */ 1297 1246 rc = block_put(b); 1298 if (rc != EOK) { 1299 (void) fat_free_clusters(bs, dev_handle, mcl); 1300 (void) fat_node_put(fn); 1301 ipc_answer_0(rid, rc); 1302 return; 1303 } 1247 assert(rc == EOK); 1304 1248 /* 1305 1249 * Append the cluster chain starting in mcl to the end of the … … 1307 1251 */ 1308 1252 rc = fat_append_clusters(bs, nodep, mcl); 1309 if (rc != EOK) { 1310 (void) fat_free_clusters(bs, dev_handle, mcl); 1311 (void) fat_node_put(fn); 1312 ipc_answer_0(rid, rc); 1313 return; 1314 } 1315 nodep->size = size = pos + bytes; 1253 assert(rc == EOK); 1254 nodep->size = pos + bytes; 1316 1255 nodep->dirty = true; /* need to sync node */ 1317 rc = fat_node_put(fn);1318 ipc_answer_2(rid, rc, bytes, size);1256 ipc_answer_2(rid, EOK, bytes, nodep->size); 1257 fat_node_put(fn); 1319 1258 return; 1320 1259 }
Note:
See TracChangeset
for help on using the changeset viewer.