Changeset dc87ad11 in mainline


Ignore:
Timestamp:
2009-09-03T13:36:31Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cca29e3c
Parents:
e402382
Message:

Make fat_get_cluster() return an error code.

Location:
uspace/srv/fs/fat
Files:
2 edited

Legend:

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

    re402382 rdc87ad11  
    234234 * @param dev_handle    Device handle for the file system.
    235235 * @param clst          Cluster which to get.
    236  *
    237  * @return              Value found in the cluster.
    238  */
    239 fat_cluster_t
    240 fat_get_cluster(fat_bs_t *bs, dev_handle_t dev_handle, fat_cluster_t clst)
     236 * @param value         Output argument holding the value of the cluster.
     237 *
     238 * @return              EOK or a negative error code.
     239 */
     240int
     241fat_get_cluster(fat_bs_t *bs, dev_handle_t dev_handle, fat_cluster_t clst,
     242    fat_cluster_t *value)
    241243{
    242244        block_t *b;
    243245        uint16_t bps;
    244246        uint16_t rscnt;
    245         fat_cluster_t *cp, value;
     247        fat_cluster_t *cp;
    246248        int rc;
    247249
     
    251253        rc = block_get(&b, dev_handle, rscnt +
    252254            (clst * sizeof(fat_cluster_t)) / bps, BLOCK_FLAGS_NONE);
    253         assert(rc == EOK);
     255        if (rc != EOK)
     256                return rc;
    254257        cp = (fat_cluster_t *)b->data + clst % (bps / sizeof(fat_cluster_t));
    255         value = uint16_t_le2host(*cp);
     258        *value = uint16_t_le2host(*cp);
    256259        rc = block_put(b);
    257         assert(rc == EOK);
    258        
    259         return value;
     260       
     261        return rc;
    260262}
    261263
     
    415417        unsigned fatno;
    416418        fat_cluster_t nextc;
     419        int rc;
    417420
    418421        /* Mark all clusters in the chain as free in all copies of FAT. */
    419422        while (firstc < FAT_CLST_LAST1) {
    420423                assert(firstc >= FAT_CLST_FIRST && firstc < FAT_CLST_BAD);
    421                 nextc = fat_get_cluster(bs, dev_handle, firstc);
     424                rc = fat_get_cluster(bs, dev_handle, firstc, &nextc);
     425                assert(rc == EOK);
    422426                for (fatno = FAT1; fatno < bs->fatcnt; fatno++)
    423427                        fat_set_cluster(bs, dev_handle, fatno, firstc,
     
    466470void fat_chop_clusters(fat_bs_t *bs, fat_node_t *nodep, fat_cluster_t lastc)
    467471{
     472        int rc;
     473
    468474        dev_handle_t dev_handle = nodep->idx->dev_handle;
    469475        if (lastc == FAT_CLST_RES0) {
     
    476482                unsigned fatno;
    477483
    478                 nextc = fat_get_cluster(bs, dev_handle, lastc);
     484                rc = fat_get_cluster(bs, dev_handle, lastc, &nextc);
     485                assert(rc == EOK);
    479486
    480487                /* Terminate the cluster chain in all copies of FAT. */
  • uspace/srv/fs/fat/fat_fat.h

    re402382 rdc87ad11  
    8080extern void fat_alloc_shadow_clusters(struct fat_bs *, dev_handle_t,
    8181    fat_cluster_t *, unsigned);
    82 extern fat_cluster_t fat_get_cluster(struct fat_bs *, dev_handle_t, fat_cluster_t);
     82extern int fat_get_cluster(struct fat_bs *, dev_handle_t, fat_cluster_t,
     83    fat_cluster_t *);
    8384extern void fat_set_cluster(struct fat_bs *, dev_handle_t, unsigned,
    8485    fat_cluster_t, fat_cluster_t);
Note: See TracChangeset for help on using the changeset viewer.