Changeset ff62c6d in mainline for uspace/srv/fs/fat/fat_fat.c


Ignore:
Timestamp:
2009-08-27T20:00:17Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1ee00b7, b7b3fda, cfa8738
Parents:
f2f89315 (diff), 402a18f (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.
Message:

Merge libblock improvements.

File:
1 edited

Legend:

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

    rf2f89315 rff62c6d  
    7575        uint16_t clusters = 0;
    7676        fat_cluster_t clst = firstc;
     77        int rc;
    7778
    7879        bps = uint16_t_le2host(bs->bps);
     
    9697                fidx = clst % (bps / sizeof(fat_cluster_t));
    9798                /* read FAT1 */
    98                 b = block_get(dev_handle, rscnt + fsec, BLOCK_FLAGS_NONE);
     99                rc = block_get(&b, dev_handle, rscnt + fsec, BLOCK_FLAGS_NONE);
     100                assert(rc == EOK);
    99101                clst = uint16_t_le2host(((fat_cluster_t *)b->data)[fidx]);
    100102                assert(clst != FAT_CLST_BAD);
    101                 block_put(b);
     103                rc = block_put(b);
     104                assert(rc == EOK);
    102105                clusters++;
    103106        }
     
    133136        unsigned clusters, max_clusters;
    134137        fat_cluster_t lastc;
     138        int rc;
    135139
    136140        bps = uint16_t_le2host(bs->bps);
     
    146150                /* root directory special case */
    147151                assert(bn < rds);
    148                 b = block_get(dev_handle, rscnt + bs->fatcnt * sf + bn, flags);
     152                rc = block_get(&b, dev_handle, rscnt + bs->fatcnt * sf + bn,
     153                    flags);
     154                assert(rc == EOK);
    149155                return b;
    150156        }
     
    155161        assert(clusters == max_clusters);
    156162
    157         b = block_get(dev_handle, ssa + (lastc - FAT_CLST_FIRST) * bs->spc +
    158             bn % bs->spc, flags);
     163        rc = block_get(&b, dev_handle, ssa +
     164            (lastc - FAT_CLST_FIRST) * bs->spc + bn % bs->spc, flags);
     165        assert(rc == EOK);
    159166
    160167        return b;
     
    177184        block_t *b;
    178185        off_t o, boundary;
     186        int rc;
    179187
    180188        bps = uint16_t_le2host(bs->bps);
     
    191199                memset(b->data + o % bps, 0, bps - o % bps);
    192200                b->dirty = true;                /* need to sync node */
    193                 block_put(b);
     201                rc = block_put(b);
     202                assert(rc == EOK);
    194203        }
    195204       
     
    203212                memset(b->data, 0, min(bps, pos - o));
    204213                b->dirty = true;                /* need to sync node */
    205                 block_put(b);
     214                rc = block_put(b);
     215                assert(rc == EOK);
    206216        }
    207217}
     
    222232        uint16_t rscnt;
    223233        fat_cluster_t *cp, value;
     234        int rc;
    224235
    225236        bps = uint16_t_le2host(bs->bps);
    226237        rscnt = uint16_t_le2host(bs->rscnt);
    227238
    228         b = block_get(dev_handle, rscnt + (clst * sizeof(fat_cluster_t)) / bps,
    229             BLOCK_FLAGS_NONE);
     239        rc = block_get(&b, dev_handle, rscnt +
     240            (clst * sizeof(fat_cluster_t)) / bps, BLOCK_FLAGS_NONE);
     241        assert(rc == EOK);
    230242        cp = (fat_cluster_t *)b->data + clst % (bps / sizeof(fat_cluster_t));
    231243        value = uint16_t_le2host(*cp);
    232         block_put(b);
     244        rc = block_put(b);
     245        assert(rc == EOK);
    233246       
    234247        return value;
     
    252265        uint16_t sf;
    253266        fat_cluster_t *cp;
     267        int rc;
    254268
    255269        bps = uint16_t_le2host(bs->bps);
     
    258272
    259273        assert(fatno < bs->fatcnt);
    260         b = block_get(dev_handle, rscnt + sf * fatno +
     274        rc = block_get(&b, dev_handle, rscnt + sf * fatno +
    261275            (clst * sizeof(fat_cluster_t)) / bps, BLOCK_FLAGS_NONE);
     276        assert(rc == EOK);
    262277        cp = (fat_cluster_t *)b->data + clst % (bps / sizeof(fat_cluster_t));
    263278        *cp = host2uint16_t_le(value);
    264279        b->dirty = true;                /* need to sync block */
    265         block_put(b);
     280        rc = block_put(b);
     281        assert(rc == EOK);
    266282}
    267283
     
    315331        unsigned found = 0;     /* top of the free cluster number stack */
    316332        unsigned b, c, cl;
     333        int rc;
    317334
    318335        lifo = (fat_cluster_t *) malloc(nclsts * sizeof(fat_cluster_t));
     
    329346        fibril_mutex_lock(&fat_alloc_lock);
    330347        for (b = 0, cl = 0; b < sf; b++) {
    331                 blk = block_get(dev_handle, rscnt + b, BLOCK_FLAGS_NONE);
     348                rc = block_get(&blk, dev_handle, rscnt + b, BLOCK_FLAGS_NONE);
    332349                for (c = 0; c < bps / sizeof(fat_cluster_t); c++, cl++) {
    333350                        fat_cluster_t *clst = (fat_cluster_t *)blk->data + c;
     
    344361                                if (++found == nclsts) {
    345362                                        /* we are almost done */
    346                                         block_put(blk);
     363                                        rc = block_put(blk);
     364                                        assert(rc == EOK);
    347365                                        /* update the shadow copies of FAT */
    348366                                        fat_alloc_shadow_clusters(bs,
     
    356374                        }
    357375                }
    358                 block_put(blk);
     376                rc = block_put(blk);
     377                assert(rc == EOK);
    359378        }
    360379        fibril_mutex_unlock(&fat_alloc_lock);
     
    457476        block_t *b;
    458477        unsigned bps;
     478        int rc;
    459479
    460480        bps = uint16_t_le2host(bs->bps);
     
    464484                memset(b->data, 0, bps);
    465485                b->dirty = true;
    466                 block_put(b);
     486                rc = block_put(b);
     487                assert(rc == EOK);
    467488        }
    468489}
Note: See TracChangeset for help on using the changeset viewer.