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


Ignore:
Timestamp:
2010-11-02T22:38:46Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
af894a21
Parents:
aab02fb (diff), e06ef614 (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 mainline changes

File:
1 edited

Legend:

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

    raab02fb refedee77  
    424424                for (c = 0; c < BPS(bs) / sizeof(fat_cluster_t); c++, cl++) {
    425425                        /*
    426                          * Check if the cluster is physically there. This check
    427                          * becomes necessary when the file system is created
    428                          * with fewer total sectors than how many is inferred
    429                          * from the size of the file allocation table.
     426                         * Check if the entire cluster is physically there.
     427                         * This check becomes necessary when the file system is
     428                         * created with fewer total sectors than how many is
     429                         * inferred from the size of the file allocation table
     430                         * or when the last cluster ends beyond the end of the
     431                         * device.
    430432                         */
    431                         if ((cl >= 2) &&
    432                             ((cl - 2) * SPC(bs) + SSA(bs) >= TS(bs))) {
     433                        if ((cl >= FAT_CLST_FIRST) &&
     434                            CLBN2PBN(bs, cl, SPC(bs) - 1) >= TS(bs)) {
    433435                                rc = block_put(blk);
    434436                                if (rc != EOK)
     
    543545        dev_handle_t dev_handle = nodep->idx->dev_handle;
    544546        fat_cluster_t lastc;
    545         uint16_t numc;
    546547        uint8_t fatno;
    547548        int rc;
    548549
    549         if (nodep->lastc_cached_valid) {
    550                 lastc = nodep->lastc_cached_value;
    551                 nodep->lastc_cached_valid = false;
     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 */
    552554        } else {
    553                 rc = fat_cluster_walk(bs, dev_handle, nodep->firstc, &lastc,
    554                     &numc, (uint16_t) -1);
    555                 if (rc != EOK)
    556                         return rc;
    557 
    558                 if (numc == 0) {
    559                         /* No clusters allocated to the node yet. */
    560                         nodep->firstc = mcl;
    561                         nodep->dirty = true;    /* need to sync node */
    562                         return EOK;
     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;
    563563                }
    564         }
    565 
    566         for (fatno = FAT1; fatno < bs->fatcnt; fatno++) {
    567                 rc = fat_set_cluster(bs, nodep->idx->dev_handle, fatno, lastc,
    568                     mcl);
    569                 if (rc != EOK)
    570                         return rc;
     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                }
    571571        }
    572572
Note: See TracChangeset for help on using the changeset viewer.