Changeset dfddfcd in mainline
- Timestamp:
- 2009-11-03T22:48:16Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9131690, bccec98
- Parents:
- 453f2e75
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_ops.c
r453f2e75 rdfddfcd 1172 1172 fat_node_t *nodep; 1173 1173 fat_bs_t *bs; 1174 size_t bytes ;1174 size_t bytes, size; 1175 1175 block_t *b; 1176 1176 uint16_t bps; … … 1195 1195 size_t len; 1196 1196 if (!async_data_write_receive(&callid, &len)) { 1197 fat_node_put(fn);1197 (void) fat_node_put(fn); 1198 1198 ipc_answer_0(callid, EINVAL); 1199 1199 ipc_answer_0(rid, EINVAL); … … 1226 1226 */ 1227 1227 rc = fat_fill_gap(bs, nodep, FAT_CLST_RES0, pos); 1228 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 } 1229 1234 rc = fat_block_get(&b, bs, nodep, pos / bps, flags); 1230 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 } 1231 1241 (void) async_data_write_finalize(callid, b->data + pos % bps, 1232 1242 bytes); 1233 1243 b->dirty = true; /* need to sync block */ 1234 1244 rc = block_put(b); 1235 assert(rc == EOK); 1245 if (rc != EOK) { 1246 (void) fat_node_put(fn); 1247 ipc_answer_0(rid, rc); 1248 return; 1249 } 1236 1250 if (pos + bytes > nodep->size) { 1237 1251 nodep->size = pos + bytes; 1238 1252 nodep->dirty = true; /* need to sync node */ 1239 1253 } 1240 ipc_answer_2(rid, EOK, bytes, nodep->size); 1241 fat_node_put(fn); 1254 size = nodep->size; 1255 rc = fat_node_put(fn); 1256 ipc_answer_2(rid, rc, bytes, nodep->size); 1242 1257 return; 1243 1258 } else { … … 1246 1261 * clusters for the node and zero them out. 1247 1262 */ 1248 int status;1249 1263 unsigned nclsts; 1250 1264 fat_cluster_t mcl, lcl; … … 1252 1266 nclsts = (ROUND_UP(pos + bytes, bpc) - boundary) / bpc; 1253 1267 /* create an independent chain of nclsts clusters in all FATs */ 1254 status= fat_alloc_clusters(bs, dev_handle, nclsts, &mcl, &lcl);1255 if ( status!= EOK) {1268 rc = fat_alloc_clusters(bs, dev_handle, nclsts, &mcl, &lcl); 1269 if (rc != EOK) { 1256 1270 /* could not allocate a chain of nclsts clusters */ 1257 fat_node_put(fn);1258 ipc_answer_0(callid, status);1259 ipc_answer_0(rid, status);1271 (void) fat_node_put(fn); 1272 ipc_answer_0(callid, rc); 1273 ipc_answer_0(rid, rc); 1260 1274 return; 1261 1275 } 1262 1276 /* zero fill any gaps */ 1263 1277 rc = fat_fill_gap(bs, nodep, mcl, pos); 1264 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 } 1265 1285 rc = _fat_block_get(&b, bs, dev_handle, lcl, (pos / bps) % spc, 1266 1286 flags); 1267 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 } 1268 1294 (void) async_data_write_finalize(callid, b->data + pos % bps, 1269 1295 bytes); 1270 1296 b->dirty = true; /* need to sync block */ 1271 1297 rc = block_put(b); 1272 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 } 1273 1304 /* 1274 1305 * Append the cluster chain starting in mcl to the end of the … … 1276 1307 */ 1277 1308 rc = fat_append_clusters(bs, nodep, mcl); 1278 assert(rc == EOK); 1279 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; 1280 1316 nodep->dirty = true; /* need to sync node */ 1281 ipc_answer_2(rid, EOK, bytes, nodep->size);1282 fat_node_put(fn);1317 rc = fat_node_put(fn); 1318 ipc_answer_2(rid, rc, bytes, size); 1283 1319 return; 1284 1320 }
Note:
See TracChangeset
for help on using the changeset viewer.