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

Changeset 64cbf94 in mainline


Ignore:
Timestamp:
2009-08-12T21:02:09Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
2e151ab0, 8a8c311, fd210de
Parents:
8b58fc1 (diff), d44aabd (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge FAT server fixes.

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

Legend:

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

    r8b58fc1 r64cbf94  
    451451}
    452452
     453void
     454fat_zero_cluster(struct fat_bs *bs, dev_handle_t dev_handle, fat_cluster_t c)
     455{
     456        int i;
     457        block_t *b;
     458        unsigned bps;
     459
     460        bps = uint16_t_le2host(bs->bps);
     461       
     462        for (i = 0; i < bs->spc; i++) {
     463                b = _fat_block_get(bs, dev_handle, c, i, BLOCK_FLAGS_NOREAD);
     464                memset(b->data, 0, bps);
     465                b->dirty = true;
     466                block_put(b);
     467        }
     468}
     469
    453470/**
    454471 * @}
  • uspace/srv/fs/fat/fat_fat.h

    r8b58fc1 r64cbf94  
    8484extern void fat_fill_gap(struct fat_bs *, struct fat_node *, fat_cluster_t,
    8585    off_t);
     86extern void fat_zero_cluster(struct fat_bs *, dev_handle_t, fat_cluster_t);
    8687
    8788#endif
  • uspace/srv/fs/fat/fat_ops.c

    r8b58fc1 r64cbf94  
    332332        /* idxp->lock held */
    333333        if (flags & L_DIRECTORY) {
    334                 int i;
    335                 block_t *b;
    336 
    337                 /*
    338                  * Populate the new cluster with unused dentries.
    339                  */
    340                 for (i = 0; i < bs->spc; i++) {
    341                         b = _fat_block_get(bs, dev_handle, mcl, i,
    342                             BLOCK_FLAGS_NOREAD);
    343                         /* mark all dentries as never-used */
    344                         memset(b->data, 0, bps);
    345                         b->dirty = false;
    346                         block_put(b);
    347                 }
     334                /* Populate the new cluster with unused dentries. */
     335                fat_zero_cluster(bs, dev_handle, mcl);
    348336                nodep->type = FAT_DIRECTORY;
    349337                nodep->firstc = mcl;
     
    462450         * We need to grow the parent in order to create a new unused dentry.
    463451         */
    464         if (parentp->idx->pfc == FAT_CLST_ROOT) {
     452        if (parentp->firstc == FAT_CLST_ROOT) {
    465453                /* Can't grow the root directory. */
    466454                fibril_mutex_unlock(&parentp->idx->lock);
     
    472460                return rc;
    473461        }
     462        fat_zero_cluster(bs, parentp->idx->dev_handle, mcl);
    474463        fat_append_clusters(bs, parentp, mcl);
    475         b = fat_block_get(bs, parentp, i, BLOCK_FLAGS_NOREAD);
     464        parentp->size += bps * bs->spc;
     465        parentp->dirty = true;          /* need to sync node */
     466        b = fat_block_get(bs, parentp, i, BLOCK_FLAGS_NONE);
    476467        d = (fat_dentry_t *)b->data;
    477         /*
    478          * Clear all dentries in the block except for the first one (the first
    479          * dentry will be cleared in the next step).
    480          */
    481         memset(d + 1, 0, bps - sizeof(fat_dentry_t));
    482468
    483469hit:
Note: See TracChangeset for help on using the changeset viewer.