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


Ignore:
Timestamp:
2011-05-01T09:15:06Z (13 years ago)
Author:
Oleg Romanenko <romanenko.oleg@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.