Changeset 979c313a in mainline


Ignore:
Timestamp:
2011-05-02T07:35:20Z (14 years ago)
Author:
Oleg Romanenko <romanenko.oleg@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a8c14aa
Parents:
b5db2ae
Message:

Fix bug with cluster at sector boundary (FAT12 only).

File:
1 edited

Legend:

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

    rb5db2ae r979c313a  
    5757        (SSA((bs)) + ((cl) - FAT_CLST_FIRST) * SPC((bs)) + (bn) % SPC((bs)))
    5858
     59#define IS_ODD(number)  (number & 0x1)
     60
    5961/**
    6062 * The fat_alloc_lock mutex protects all copies of the File Allocation Table
     
    302304        assert(fatno < FATCNT(bs));
    303305       
    304         *value = 0;
    305 
    306306        if (FAT_IS_FAT12(bs))
    307307                offset = (clst + clst/2);
     
    314314                return rc;
    315315
    316         /* This cluster access spans a sector boundary. Check only for FAT12 */
    317316        if (FAT_IS_FAT12(bs)) {
     317                /* This cluster access spans a sector boundary. Check only for FAT12 */
    318318                if ((offset % BPS(bs) + 1 == BPS(bs))) {
    319319                        /* Is it last sector of FAT? */
     
    331331                                */
    332332                                *value  = *(uint8_t *)(b->data + BPS(bs) - 1);
    333                                 *value |= *(uint8_t *)(b1->data);
     333                                *value |= *(uint8_t *)(b1->data) << 8;
    334334
    335335                                rc = block_put(b1);
     
    345345                        }
    346346                }
    347 
    348                 if (clst & 0x0001)
     347                else
     348                        *value = *(uint16_t *)(b->data + offset % BPS(bs));
     349
     350                if (IS_ODD(clst))
    349351                        *value = (*value) >> 4;
    350352                else
     
    358360        }
    359361
    360         *value = uint16_t_le2host(*value);
     362        *value = uint32_t_le2host(*value);
    361363        rc = block_put(b);
    362364
Note: See TracChangeset for help on using the changeset viewer.