Changeset a9b756e in mainline for uspace/srv/fs/exfat/exfat_fat.c


Ignore:
Timestamp:
2011-08-16T16:30:27Z (13 years ago)
Author:
Oleg Romanenko <romanenko.oleg@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ae560da
Parents:
93e12f3
Message:

exFAT: fix exfat_alloc_clusters. Bitmap should have higher priority than FAT

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/exfat/exfat_fat.c

    r93e12f3 ra9b756e  
    3838
    3939#include "exfat_fat.h"
     40#include "exfat_bitmap.h"
    4041#include "exfat.h"
    4142#include "../../vfs/vfs.h"
     
    301302        exfat_cluster_t *lifo;    /* stack for storing free cluster numbers */
    302303        unsigned found = 0;     /* top of the free cluster number stack */
    303         exfat_cluster_t clst, value;
     304        exfat_cluster_t clst;
    304305        int rc = EOK;
    305306
     
    310311        fibril_mutex_lock(&exfat_alloc_lock);
    311312        for (clst=EXFAT_CLST_FIRST; clst < DATA_CNT(bs)+2 && found < nclsts; clst++) {
    312                 rc = exfat_get_cluster(bs, devmap_handle, clst, &value);
    313                 if (rc != EOK)
    314                         break;
    315 
    316                 if (value == 0) {
     313                /* Need to rewrite because of multiple exfat_bitmap_get calls */
     314                if (bitmap_is_free(bs, devmap_handle, clst)==EOK) {
    317315                   /*
    318316                        * The cluster is free. Put it into our stack
     
    324322                        if (rc != EOK)
    325323                                break;
    326 
    327324                        found++;
     325                        rc = bitmap_set_cluster(bs, devmap_handle, clst);
     326                        if (rc != EOK)
     327                                break;
     328
    328329                }
    329330        }
     
    339340        /* If something wrong - free the clusters */
    340341        if (found > 0) {
    341                 while (found--)
    342                         rc = exfat_set_cluster(bs, devmap_handle, lifo[found], 0);
     342                while (found--) {
     343                        (void) bitmap_clear_cluster(bs, devmap_handle, lifo[found]);
     344                        (void) exfat_set_cluster(bs, devmap_handle, lifo[found], 0);
     345                }
    343346        }
    344347
Note: See TracChangeset for help on using the changeset viewer.