Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 3a8faba in mainline


Ignore:
Timestamp:
2009-09-26T12:12:41Z (11 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
master
Children:
bbf88db, e6bc3a5
Parents:
12bdc942
Message:

Be more robust towards a discrepancy between the FAT size and total sectors.

File:
1 edited

Legend:

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

    r12bdc942 r3a8faba  
    359359        uint16_t rscnt;
    360360        uint16_t sf;
     361        uint16_t ts;
     362        unsigned rde;
     363        unsigned rds;
     364        unsigned ssa;
    361365        block_t *blk;
    362366        fat_cluster_t *lifo;    /* stack for storing free cluster numbers */
     
    372376        rscnt = uint16_t_le2host(bs->rscnt);
    373377        sf = uint16_t_le2host(bs->sec_per_fat);
     378        rde = uint16_t_le2host(bs->root_ent_max);
     379        ts = uint16_t_le2host(bs->totsec16);
     380
     381        rds = (sizeof(fat_dentry_t) * rde) / bps;
     382        rds += ((sizeof(fat_dentry_t) * rde) % bps != 0);
     383        ssa = rscnt + bs->fatcnt * sf + rds;
    374384       
    375385        /*
     
    382392                        goto error;
    383393                for (c = 0; c < bps / sizeof(fat_cluster_t); c++, cl++) {
     394                        /*
     395                         * Check if the cluster is physically there. This check
     396                         * becomes necessary when the file system is created
     397                         * with fewer total sectors than how many is inferred
     398                         * from the size of the file allocation table.
     399                         */
     400                        if ((cl - 2) * bs->spc + ssa >= ts) {
     401                                rc = block_put(blk);
     402                                if (rc != EOK)
     403                                        goto error;
     404                                goto out;
     405                        }
     406
    384407                        fat_cluster_t *clst = (fat_cluster_t *)blk->data + c;
    385408                        if (uint16_t_le2host(*clst) == FAT_CLST_RES0) {
     
    419442                }
    420443        }
     444out:
    421445        fibril_mutex_unlock(&fat_alloc_lock);
    422446
Note: See TracChangeset for help on using the changeset viewer.