Changeset a31c1ccf in mainline


Ignore:
Timestamp:
2008-11-25T22:45:38Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e5557131
Parents:
d1b625b
Message:

Implement fat_unlink().

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

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/fat/fat.h

    rd1b625b ra31c1ccf  
    211211extern void fat_idx_destroy(fat_idx_t *);
    212212extern void fat_idx_hashin(fat_idx_t *);
     213extern void fat_idx_hashout(fat_idx_t *);
    213214
    214215extern int fat_idx_init(void);
  • uspace/srv/fs/fat/fat_dentry.c

    rd1b625b ra31c1ccf  
    4040#include <string.h>
    4141
    42 #define FAT_PAD                 ' '
    43 
    44 #define FAT_DENTRY_UNUSED       0x00
    45 #define FAT_DENTRY_E5_ESC       0x05
    46 #define FAT_DENTRY_DOT          0x2e
    47 #define FAT_DENTRY_ERASED       0xe5
    48 
    4942static bool is_d_char(const char ch)
    5043{
  • uspace/srv/fs/fat/fat_dentry.h

    rd1b625b ra31c1ccf  
    4444#define FAT_ATTR_SUBDIR         (1 << 4)
    4545
     46#define FAT_PAD                 ' '
     47
     48#define FAT_DENTRY_UNUSED       0x00
     49#define FAT_DENTRY_E5_ESC       0x05
     50#define FAT_DENTRY_DOT          0x2e
     51#define FAT_DENTRY_ERASED       0xe5
     52
    4653typedef enum {
    4754        FAT_DENTRY_SKIP,
  • uspace/srv/fs/fat/fat_idx.c

    rd1b625b ra31c1ccf  
    437437}
    438438
     439void fat_idx_hashout(fat_idx_t *idx)
     440{
     441        unsigned long pkey[] = {
     442                [UPH_DH_KEY] = idx->dev_handle,
     443                [UPH_PFC_KEY] = idx->pfc,
     444                [UPH_PDI_KEY] = idx->pdi,
     445        };
     446
     447        futex_down(&used_futex);
     448        hash_table_remove(&up_hash, pkey, 3);
     449        futex_up(&used_futex);
     450}
     451
    439452fat_idx_t *
    440453fat_idx_get_by_index(dev_handle_t dev_handle, fs_index_t index)
  • uspace/srv/fs/fat/fat_ops.c

    rd1b625b ra31c1ccf  
    480480int fat_unlink(void *prnt, void *chld)
    481481{
    482         return ENOTSUP; /* not supported at the moment */
     482        fat_node_t *parentp = (fat_node_t *)prnt;
     483        fat_node_t *childp = (fat_node_t *)chld;
     484        fat_bs_t *bs;
     485        fat_dentry_t *d;
     486        uint16_t bps;
     487        block_t *b;
     488
     489        futex_down(&parentp->lock);
     490        futex_down(&childp->lock);
     491        assert(childp->lnkcnt == 1);
     492        futex_down(&childp->idx->lock);
     493        bs = block_bb_get(childp->idx->dev_handle);
     494        bps = uint16_t_le2host(bs->bps);
     495
     496        b = _fat_block_get(bs, childp->idx->dev_handle, childp->idx->pfc,
     497            (childp->idx->pdi * sizeof(fat_dentry_t)) / bps,
     498            BLOCK_FLAGS_NONE);
     499        d = (fat_dentry_t *)b->data +
     500            (childp->idx->pdi % (bps / sizeof(fat_dentry_t)));
     501        /* mark the dentry as not-currently-used */
     502        d->name[0] = FAT_DENTRY_ERASED;
     503        b->dirty = true;                /* need to sync block */
     504        block_put(b);
     505
     506        /* remove the index structure from the position hash */
     507        fat_idx_hashout(childp->idx);
     508        /* clear position information */
     509        childp->idx->pfc = FAT_CLST_RES0;
     510        childp->idx->pdi = 0;
     511        futex_up(&childp->idx->lock);
     512        childp->lnkcnt = 0;
     513        childp->dirty = true;
     514        futex_up(&childp->lock);
     515        futex_up(&parentp->lock);
     516
     517        return EOK;
    483518}
    484519
Note: See TracChangeset for help on using the changeset viewer.