Changeset 48eb7a14 in mainline


Ignore:
Timestamp:
2008-11-22T12:00:05Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2eb893b
Parents:
7e6c9eb
Message:

Add implementation of fat_idx_destroy().

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

Legend:

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

    r7e6c9eb r48eb7a14  
    208208extern fat_idx_t *fat_idx_get_by_pos(dev_handle_t, fat_cluster_t, unsigned);
    209209extern fat_idx_t *fat_idx_get_by_index(dev_handle_t, fs_index_t);
     210extern void fat_idx_destroy(fat_idx_t *);
    210211
    211212extern int fat_idx_init(void);
  • uspace/srv/fs/fat/fat_idx.c

    r7e6c9eb r48eb7a14  
    215215
    216216/** Allocate a VFS index which is not currently in use. */
    217 static bool fat_idx_alloc(dev_handle_t dev_handle, fs_index_t *index)
     217static bool fat_index_alloc(dev_handle_t dev_handle, fs_index_t *index)
    218218{
    219219        unused_t *u;
     
    277277
    278278/** Free a VFS index, which is no longer in use. */
    279 static void fat_idx_free(dev_handle_t dev_handle, fs_index_t index)
     279static void fat_index_free(dev_handle_t dev_handle, fs_index_t index)
    280280{
    281281        unused_t *u;
     
    339339}
    340340
    341 static fat_idx_t *fat_idx_get_new_core(dev_handle_t dev_handle)
     341static fat_idx_t *fat_idx_create(dev_handle_t dev_handle)
    342342{
    343343        fat_idx_t *fidx;
     
    346346        if (!fidx)
    347347                return NULL;
    348         if (!fat_idx_alloc(dev_handle, &fidx->index)) {
     348        if (!fat_index_alloc(dev_handle, &fidx->index)) {
    349349                free(fidx);
    350350                return NULL;
     
    367367
    368368        futex_down(&used_futex);
    369         fidx = fat_idx_get_new_core(dev_handle);
     369        fidx = fat_idx_create(dev_handle);
    370370        if (!fidx) {
    371371                futex_up(&used_futex);
     
    401401                fidx = hash_table_get_instance(l, fat_idx_t, uph_link);
    402402        } else {
    403                 fidx = fat_idx_get_new_core(dev_handle);
     403                fidx = fat_idx_create(dev_handle);
    404404                if (!fidx) {
    405405                        futex_up(&used_futex);
     
    445445}
    446446
     447/** Destroy the index structure.
     448 *
     449 * @param idx           The index structure to be destroyed.
     450 */
     451void fat_idx_destroy(fat_idx_t *idx)
     452{
     453        unsigned long ikey[] = {
     454                [UIH_DH_KEY] = idx->dev_handle,
     455                [UIH_INDEX_KEY] = idx->index,
     456        };
     457
     458        assert(idx->pfc == FAT_CLST_RES0);
     459
     460        futex_down(&used_futex);
     461        /*
     462         * Since we can only free unlinked nodes, the index structure is not
     463         * present in the position hash (uph). We therefore hash it out from
     464         * the index hash only.
     465         */
     466        hash_table_remove(&ui_hash, ikey, 2);
     467        futex_up(&used_futex);
     468        /* Release the VFS index. */
     469        fat_index_free(idx->dev_handle, idx->index);
     470        /* Deallocate the structure. */
     471        free(idx);
     472}
     473
    447474int fat_idx_init(void)
    448475{
Note: See TracChangeset for help on using the changeset viewer.