Changes in / [7431b665:3249673] in mainline


Ignore:
File:
1 edited

Legend:

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

    r7431b665 r3249673  
    545545        dev_handle_t dev_handle = nodep->idx->dev_handle;
    546546        fat_cluster_t lastc;
     547        uint16_t numc;
    547548        uint8_t fatno;
    548549        int rc;
    549550
    550         if (nodep->firstc == FAT_CLST_RES0) {
    551                 /* No clusters allocated to the node yet. */
    552                 nodep->firstc = mcl;
    553                 nodep->dirty = true;    /* need to sync node */
     551        if (nodep->lastc_cached_valid) {
     552                lastc = nodep->lastc_cached_value;
     553                nodep->lastc_cached_valid = false;
    554554        } else {
    555                 if (nodep->lastc_cached_valid) {
    556                         lastc = nodep->lastc_cached_value;
    557                         nodep->lastc_cached_valid = false;
    558                 } else {
    559                         rc = fat_cluster_walk(bs, dev_handle, nodep->firstc,
    560                             &lastc, NULL, (uint16_t) -1);
    561                         if (rc != EOK)
    562                                 return rc;
     555                rc = fat_cluster_walk(bs, dev_handle, nodep->firstc, &lastc,
     556                    &numc, (uint16_t) -1);
     557                if (rc != EOK)
     558                        return rc;
     559
     560                if (numc == 0) {
     561                        /* No clusters allocated to the node yet. */
     562                        nodep->firstc = mcl;
     563                        nodep->dirty = true;    /* need to sync node */
     564                        return EOK;
    563565                }
    564 
    565                 for (fatno = FAT1; fatno < bs->fatcnt; fatno++) {
    566                         rc = fat_set_cluster(bs, nodep->idx->dev_handle, fatno,
    567                             lastc, mcl);
    568                         if (rc != EOK)
    569                                 return rc;
    570                 }
     566        }
     567
     568        for (fatno = FAT1; fatno < bs->fatcnt; fatno++) {
     569                rc = fat_set_cluster(bs, nodep->idx->dev_handle, fatno, lastc,
     570                    mcl);
     571                if (rc != EOK)
     572                        return rc;
    571573        }
    572574
Note: See TracChangeset for help on using the changeset viewer.