Changeset b0247bac in mainline for uspace/srv/fs/fat/fat_ops.c


Ignore:
Timestamp:
2008-10-27T22:38:56Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5cf723b
Parents:
0951495
Message:

Directory size is always a multiple of BPS. Fix computation of number of
directory entries in the last block of the directory.

File:
1 edited

Legend:

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

    r0951495 rb0247bac  
    267267        bps = uint16_t_le2host(FAT_BS(bb)->bps);
    268268        dps = bps / sizeof(fat_dentry_t);
    269         blocks = parentp->size / bps + (parentp->size % bps != 0);
     269        blocks = parentp->size / bps;
    270270        for (i = 0; i < blocks; i++) {
    271                 unsigned dentries;
    272                
    273271                b = fat_block_get(bb->data, parentp, i);
    274                 dentries = (i == blocks - 1) ?
    275                     parentp->size % sizeof(fat_dentry_t) :
    276                     dps;
    277                 for (j = 0; j < dentries; j++) {
     272                for (j = 0; j < dps; j++) {
    278273                        d = ((fat_dentry_t *)b->data) + j;
    279274                        switch (fat_classify_dentry(d)) {
     
    356351        if (nodep->type != FAT_DIRECTORY)
    357352                return false;
    358 
     353       
    359354        futex_down(&nodep->idx->lock);
    360355        bb = block_get(nodep->idx->dev_handle, BS_BLOCK, BS_SIZE);
     
    362357        dps = bps / sizeof(fat_dentry_t);
    363358
    364         blocks = nodep->size / bps + (nodep->size % bps != 0);
     359        blocks = nodep->size / bps;
    365360
    366361        for (i = 0; i < blocks; i++) {
    367                 unsigned dentries;
    368362                fat_dentry_t *d;
    369363       
    370364                b = fat_block_get(bb->data, nodep, i);
    371                 dentries = (i == blocks - 1) ?
    372                     nodep->size % sizeof(fat_dentry_t) :
    373                     dps;
    374                 for (j = 0; j < dentries; j++) {
     365                for (j = 0; j < dps; j++) {
    375366                        d = ((fat_dentry_t *)b->data) + j;
    376367                        switch (fat_classify_dentry(d)) {
Note: See TracChangeset for help on using the changeset viewer.