Changeset dfddfcd in mainline


Ignore:
Timestamp:
2009-11-03T22:48:16Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9131690, bccec98
Parents:
453f2e75
Message:

Make fat_write() never assert on an I/O error.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/fat/fat_ops.c

    r453f2e75 rdfddfcd  
    11721172        fat_node_t *nodep;
    11731173        fat_bs_t *bs;
    1174         size_t bytes;
     1174        size_t bytes, size;
    11751175        block_t *b;
    11761176        uint16_t bps;
     
    11951195        size_t len;
    11961196        if (!async_data_write_receive(&callid, &len)) {
    1197                 fat_node_put(fn);
     1197                (void) fat_node_put(fn);
    11981198                ipc_answer_0(callid, EINVAL);
    11991199                ipc_answer_0(rid, EINVAL);
     
    12261226                 */
    12271227                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                }
    12291234                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                }
    12311241                (void) async_data_write_finalize(callid, b->data + pos % bps,
    12321242                    bytes);
    12331243                b->dirty = true;                /* need to sync block */
    12341244                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                }
    12361250                if (pos + bytes > nodep->size) {
    12371251                        nodep->size = pos + bytes;
    12381252                        nodep->dirty = true;    /* need to sync node */
    12391253                }
    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);
    12421257                return;
    12431258        } else {
     
    12461261                 * clusters for the node and zero them out.
    12471262                 */
    1248                 int status;
    12491263                unsigned nclsts;
    12501264                fat_cluster_t mcl, lcl;
     
    12521266                nclsts = (ROUND_UP(pos + bytes, bpc) - boundary) / bpc;
    12531267                /* 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) {
    12561270                        /* 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);
    12601274                        return;
    12611275                }
    12621276                /* zero fill any gaps */
    12631277                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                }
    12651285                rc = _fat_block_get(&b, bs, dev_handle, lcl, (pos / bps) % spc,
    12661286                    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                }
    12681294                (void) async_data_write_finalize(callid, b->data + pos % bps,
    12691295                    bytes);
    12701296                b->dirty = true;                /* need to sync block */
    12711297                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                }
    12731304                /*
    12741305                 * Append the cluster chain starting in mcl to the end of the
     
    12761307                 */
    12771308                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;
    12801316                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);
    12831319                return;
    12841320        }
Note: See TracChangeset for help on using the changeset viewer.