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


Ignore:
Timestamp:
2011-04-07T19:14:33Z (13 years ago)
Author:
Oleg Romanenko <romanenko.oleg@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
97bc3ee
Parents:
ccca251
Message:

Basic support for FAT12 file system. With many limitations of course.

File:
1 edited

Legend:

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

    rccca251 rfc35e98  
    104104        node->dirty = false;
    105105        node->lastc_cached_valid = false;
    106         node->lastc_cached_value = FAT_CLST_LAST1;
     106        node->lastc_cached_value = FAT16_CLST_LAST1;
    107107        node->currc_cached_valid = false;
    108108        node->currc_cached_bn = 0;
    109         node->currc_cached_value = FAT_CLST_LAST1;
     109        node->currc_cached_value = FAT16_CLST_LAST1;
    110110}
    111111
     
    945945 */
    946946
     947
     948#define RootDirSectors(bs)      (((RDE(bs)*32) + (BPS(bs)-1)) / BPS(bs))
     949#define FATSz(bs)               SF(bs) != 0 ? SF(bs) : uint32_t_le2host((bs)->fat32.sectors_per_fat)
     950#define DataSec(bs)             (TS(bs) - (RSCNT(bs) + (FATCNT(bs) * FATSz(bs)) + RootDirSectors(bs)))
     951#define CountOfClusters(bs)     (DataSec(bs) / SPC(bs))
     952
    947953void fat_mounted(ipc_callid_t rid, ipc_call_t *request)
    948954{
     
    10001006        }
    10011007
     1008        /* Storing FAT type (12, 16, 32) in reserved field (bs->reserved) */
     1009        if (CountOfClusters(bs) < 4085) {
     1010        /* Volume is FAT12 */
     1011            printf("Found FAT12 filesystem\n");
     1012            (bs)->reserved = 12;
     1013        } else if (CountOfClusters(bs) < 65525) {
     1014        /* Volume is FAT16 */
     1015            printf("Found FAT16 filesystem\n");
     1016            (bs)->reserved = 16;
     1017        } else {
     1018        /* Volume is FAT32 */
     1019            printf("FAT32 is not supported by FAT driver. Sorry\n");
     1020            block_fini(devmap_handle);
     1021            async_answer_0(rid, ENOTSUP);
     1022            return;
     1023
     1024        }
     1025
    10021026        /* Do some simple sanity checks on the file system. */
    10031027        rc = fat_sanity_check(bs, devmap_handle);
    10041028        if (rc != EOK) {
     1029                printf("Sanity check failed\n");
    10051030                (void) block_cache_fini(devmap_handle);
    10061031                block_fini(devmap_handle);
Note: See TracChangeset for help on using the changeset viewer.