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

Changeset b5db2ae in mainline


Ignore:
Timestamp:
2011-05-01T09:15:06Z (11 years ago)
Author:
Oleg Romanenko <romanenko.oleg@…>
Branches:
lfn, master
Children:
979c313a
Parents:
0a51029f
Message:
  1. Add macros for determining first cluster of root directory (FAT_ROOT_CLST)
  2. Root directory (FAT32) can consist of many clusters rather than of only one.
  3. Using FAT_CLST_ROOT value to determining root directory first cluster

is applicable only to FAT12/16 filesystem.

Location:
uspace/srv/fs/fat
Files:
3 edited

Legend:

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

    r0a51029f rb5db2ae  
    139139                return ELIMIT;
    140140
    141         if (nodep->firstc == FAT_CLST_ROOT)
     141        if (!FAT_IS_FAT32(bs) && nodep->firstc == FAT_CLST_ROOT)
    142142                goto fall_through;
    143143
     
    207207                return ELIMIT;
    208208
    209         if (fcl == FAT_CLST_ROOT) {
     209        if (!FAT_IS_FAT32(bs) && fcl == FAT_CLST_ROOT) {
    210210                /* root directory special case */
    211211                assert(bn < RDS(bs));
  • uspace/srv/fs/fat/fat_fat.h

    r0a51029f rb5db2ae  
    103103    (FAT_IS_FAT32(bs) ? FAT32_MASK : FAT16_MASK))
    104104
     105#define FAT_ROOT_CLST(bs) \
     106    (FAT_IS_FAT32(bs) ? uint32_t_le2host(bs->fat32.root_cluster) : \
     107    FAT_CLST_ROOT)
     108
    105109/* forward declarations */
    106110struct block;
  • uspace/srv/fs/fat/fat_ops.c

    r0a51029f rb5db2ae  
    657657         * We need to grow the parent in order to create a new unused dentry.
    658658         */
    659         if (parentp->firstc == FAT_CLST_ROOT) {
     659        if (!FAT_IS_FAT32(bs) && parentp->firstc == FAT_CLST_ROOT) {
    660660                /* Can't grow the root directory. */
    661661                fibril_mutex_unlock(&parentp->idx->lock);
     
    738738                        memcpy(d->ext, FAT_EXT_PAD, FAT_EXT_LEN);
    739739                        d->attr = FAT_ATTR_SUBDIR;
    740                         d->firstc = (parentp->firstc == FAT_CLST_ROOT) ?
    741                             host2uint16_t_le(FAT_CLST_RES0) :
     740                        d->firstc = (parentp->firstc == FAT_ROOT_CLST(bs)) ?
     741                            host2uint16_t_le(FAT_CLST_ROOTPAR) :
    742742                            host2uint16_t_le(parentp->firstc);
    743743                        /* TODO: initialize also the date/time members. */
     
    10551055
    10561056        rootp->type = FAT_DIRECTORY;
    1057         rootp->firstc = (FAT_IS_FAT32(bs) ? bs->fat32.root_cluster : FAT_CLST_ROOT);
     1057        rootp->firstc = FAT_ROOT_CLST(bs);
    10581058        rootp->refcnt = 1;
    10591059        rootp->lnkcnt = 0;      /* FS root is not linked */
    1060         rootp->size = (FAT_IS_FAT32(bs) ? SPC(bs)*BPS(bs) :
    1061             RDE(bs) * sizeof(fat_dentry_t));
     1060
     1061        if (FAT_IS_FAT32(bs)) {
     1062                uint16_t clusters;
     1063                rc = fat_clusters_get(&clusters, bs, devmap_handle, rootp->firstc);
     1064                if (rc != EOK) {
     1065                        free(rfn);
     1066                        free(rootp);
     1067                        free(ridxp); /* TODO: Is it right way to free ridxp? */
     1068                        (void) block_cache_fini(devmap_handle);
     1069                        block_fini(devmap_handle);
     1070                        fat_idx_fini_by_devmap_handle(devmap_handle);
     1071                        async_answer_0(rid, ENOTSUP);
     1072                        return;
     1073                }
     1074                rootp->size = BPS(bs) * SPC(bs) * clusters;
     1075        } else
     1076                rootp->size = RDE(bs) * sizeof(fat_dentry_t);
     1077
    10621078        rootp->idx = ridxp;
    10631079        ridxp->nodep = rootp;
Note: See TracChangeset for help on using the changeset viewer.