Changeset 9131690 in mainline for uspace/srv/fs/fat/fat_ops.c
- Timestamp:
- 2009-11-03T22:50:04Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3766467
- Parents:
- b1c21c2 (diff), dfddfcd (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/fat/fat_ops.c
rb1c21c2 r9131690 363 363 } 364 364 rc = fat_node_get_core(&nodep, idx); 365 assert(rc == EOK);366 365 fibril_mutex_unlock(&idx->lock); 367 (void) block_put(b); 366 if (rc != EOK) { 367 (void) block_put(b); 368 return rc; 369 } 368 370 *rfn = FS_NODE(nodep); 369 return EOK; 371 rc = block_put(b); 372 if (rc != EOK) 373 (void) fat_node_put(*rfn); 374 return rc; 370 375 } 371 376 } … … 1072 1077 rc = fat_block_get(&b, bs, nodep, pos / bps, 1073 1078 BLOCK_FLAGS_NONE); 1074 assert(rc == EOK); 1079 if (rc != EOK) { 1080 fat_node_put(fn); 1081 ipc_answer_0(callid, rc); 1082 ipc_answer_0(rid, rc); 1083 return; 1084 } 1075 1085 (void) async_data_read_finalize(callid, b->data + pos % bps, 1076 1086 bytes); 1077 1087 rc = block_put(b); 1078 assert(rc == EOK); 1088 if (rc != EOK) { 1089 fat_node_put(fn); 1090 ipc_answer_0(rid, rc); 1091 return; 1092 } 1079 1093 } 1080 1094 } else { … … 1100 1114 rc = fat_block_get(&b, bs, nodep, bnum, 1101 1115 BLOCK_FLAGS_NONE); 1102 assert(rc == EOK); 1116 if (rc != EOK) 1117 goto err; 1103 1118 for (o = pos % (bps / sizeof(fat_dentry_t)); 1104 1119 o < bps / sizeof(fat_dentry_t); … … 1111 1126 case FAT_DENTRY_LAST: 1112 1127 rc = block_put(b); 1113 assert(rc == EOK); 1128 if (rc != EOK) 1129 goto err; 1114 1130 goto miss; 1115 1131 default: … … 1117 1133 fat_dentry_name_get(d, name); 1118 1134 rc = block_put(b); 1119 assert(rc == EOK); 1135 if (rc != EOK) 1136 goto err; 1120 1137 goto hit; 1121 1138 } 1122 1139 } 1123 1140 rc = block_put(b); 1124 assert(rc == EOK); 1141 if (rc != EOK) 1142 goto err; 1125 1143 bnum++; 1126 1144 } 1127 1145 miss: 1128 fat_node_put(fn); 1129 ipc_answer_0(callid, ENOENT); 1130 ipc_answer_1(rid, ENOENT, 0); 1131 return; 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 1132 1157 hit: 1133 1158 (void) async_data_read_finalize(callid, name, str_size(name) + 1); … … 1135 1160 } 1136 1161 1137 fat_node_put(fn);1138 ipc_answer_1(rid, EOK, (ipcarg_t)bytes);1162 rc = fat_node_put(fn); 1163 ipc_answer_1(rid, rc, (ipcarg_t)bytes); 1139 1164 } 1140 1165 … … 1147 1172 fat_node_t *nodep; 1148 1173 fat_bs_t *bs; 1149 size_t bytes ;1174 size_t bytes, size; 1150 1175 block_t *b; 1151 1176 uint16_t bps; … … 1170 1195 size_t len; 1171 1196 if (!async_data_write_receive(&callid, &len)) { 1172 fat_node_put(fn);1197 (void) fat_node_put(fn); 1173 1198 ipc_answer_0(callid, EINVAL); 1174 1199 ipc_answer_0(rid, EINVAL); … … 1201 1226 */ 1202 1227 rc = fat_fill_gap(bs, nodep, FAT_CLST_RES0, pos); 1203 assert(rc == EOK); 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 } 1204 1234 rc = fat_block_get(&b, bs, nodep, pos / bps, flags); 1205 assert(rc == EOK); 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 } 1206 1241 (void) async_data_write_finalize(callid, b->data + pos % bps, 1207 1242 bytes); 1208 1243 b->dirty = true; /* need to sync block */ 1209 1244 rc = block_put(b); 1210 assert(rc == EOK); 1245 if (rc != EOK) { 1246 (void) fat_node_put(fn); 1247 ipc_answer_0(rid, rc); 1248 return; 1249 } 1211 1250 if (pos + bytes > nodep->size) { 1212 1251 nodep->size = pos + bytes; 1213 1252 nodep->dirty = true; /* need to sync node */ 1214 1253 } 1215 ipc_answer_2(rid, EOK, bytes, nodep->size); 1216 fat_node_put(fn); 1254 size = nodep->size; 1255 rc = fat_node_put(fn); 1256 ipc_answer_2(rid, rc, bytes, nodep->size); 1217 1257 return; 1218 1258 } else { … … 1221 1261 * clusters for the node and zero them out. 1222 1262 */ 1223 int status;1224 1263 unsigned nclsts; 1225 1264 fat_cluster_t mcl, lcl; … … 1227 1266 nclsts = (ROUND_UP(pos + bytes, bpc) - boundary) / bpc; 1228 1267 /* create an independent chain of nclsts clusters in all FATs */ 1229 status= fat_alloc_clusters(bs, dev_handle, nclsts, &mcl, &lcl);1230 if ( status!= EOK) {1268 rc = fat_alloc_clusters(bs, dev_handle, nclsts, &mcl, &lcl); 1269 if (rc != EOK) { 1231 1270 /* could not allocate a chain of nclsts clusters */ 1232 fat_node_put(fn);1233 ipc_answer_0(callid, status);1234 ipc_answer_0(rid, status);1271 (void) fat_node_put(fn); 1272 ipc_answer_0(callid, rc); 1273 ipc_answer_0(rid, rc); 1235 1274 return; 1236 1275 } 1237 1276 /* zero fill any gaps */ 1238 1277 rc = fat_fill_gap(bs, nodep, mcl, pos); 1239 assert(rc == EOK); 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 } 1240 1285 rc = _fat_block_get(&b, bs, dev_handle, lcl, (pos / bps) % spc, 1241 1286 flags); 1242 assert(rc == EOK); 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 } 1243 1294 (void) async_data_write_finalize(callid, b->data + pos % bps, 1244 1295 bytes); 1245 1296 b->dirty = true; /* need to sync block */ 1246 1297 rc = block_put(b); 1247 assert(rc == EOK); 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 } 1248 1304 /* 1249 1305 * Append the cluster chain starting in mcl to the end of the … … 1251 1307 */ 1252 1308 rc = fat_append_clusters(bs, nodep, mcl); 1253 assert(rc == EOK); 1254 nodep->size = pos + bytes; 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; 1255 1316 nodep->dirty = true; /* need to sync node */ 1256 ipc_answer_2(rid, EOK, bytes, nodep->size);1257 fat_node_put(fn);1317 rc = fat_node_put(fn); 1318 ipc_answer_2(rid, rc, bytes, size); 1258 1319 return; 1259 1320 }
Note:
See TracChangeset
for help on using the changeset viewer.