Changeset 827d73f in mainline for uspace/srv/fs/fat/fat_idx.c


Ignore:
Timestamp:
2010-02-12T14:09:22Z (14 years ago)
Author:
Lukas Mejdrech <lukasmejdrech@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a70bda4
Parents:
918e9910 (diff), e70edd1 (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:

Merged the actual head

File:
1 edited

Legend:

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

    r918e9910 r827d73f  
    149149{
    150150        dev_handle_t dev_handle = (dev_handle_t)key[UPH_DH_KEY];
    151         fat_cluster_t pfc = (fat_cluster_t)key[UPH_PFC_KEY];
    152         unsigned pdi = (unsigned)key[UPH_PDI_KEY];
     151        fat_cluster_t pfc;
     152        unsigned pdi;
    153153        fat_idx_t *fidx = list_get_instance(item, fat_idx_t, uph_link);
    154154
    155         return (dev_handle == fidx->dev_handle) && (pfc == fidx->pfc) &&
    156             (pdi == fidx->pdi);
     155        switch (keys) {
     156        case 1:
     157                return (dev_handle == fidx->dev_handle);
     158        case 3:
     159                pfc = (fat_cluster_t) key[UPH_PFC_KEY];
     160                pdi = (unsigned) key[UPH_PDI_KEY];
     161                return (dev_handle == fidx->dev_handle) && (pfc == fidx->pfc) &&
     162                    (pdi == fidx->pdi);
     163        default:
     164                assert((keys == 1) || (keys == 3));
     165        }
     166
     167        return 0;
    157168}
    158169
     
    197208{
    198209        dev_handle_t dev_handle = (dev_handle_t)key[UIH_DH_KEY];
    199         fs_index_t index = (fs_index_t)key[UIH_INDEX_KEY];
     210        fs_index_t index;
    200211        fat_idx_t *fidx = list_get_instance(item, fat_idx_t, uih_link);
    201212
    202         return (dev_handle == fidx->dev_handle) && (index == fidx->index);
     213        switch (keys) {
     214        case 1:
     215                return (dev_handle == fidx->dev_handle);
     216        case 2:
     217                index = (fs_index_t) key[UIH_INDEX_KEY];
     218                return (dev_handle == fidx->dev_handle) &&
     219                    (index == fidx->index);
     220        default:
     221                assert((keys == 1) || (keys == 2));
     222        }
     223
     224        return 0;
    203225}
    204226
    205227static void idx_remove_callback(link_t *item)
    206228{
    207         /* nothing to do */
     229        fat_idx_t *fidx = list_get_instance(item, fat_idx_t, uih_link);
     230
     231        free(fidx);
    208232}
    209233
     
    486510                [UIH_INDEX_KEY] = idx->index,
    487511        };
     512        dev_handle_t dev_handle = idx->dev_handle;
     513        fs_index_t index = idx->index;
    488514
    489515        assert(idx->pfc == FAT_CLST_RES0);
     
    498524        fibril_mutex_unlock(&used_lock);
    499525        /* Release the VFS index. */
    500         fat_index_free(idx->dev_handle, idx->index);
    501         /* Deallocate the structure. */
    502         free(idx);
     526        fat_index_free(dev_handle, index);
     527        /* The index structure itself is freed in idx_remove_callback(). */
    503528}
    504529
     
    531556        unused_initialize(u, dev_handle);
    532557        fibril_mutex_lock(&unused_lock);
    533         if (!unused_find(dev_handle, false))
     558        if (!unused_find(dev_handle, false)) {
    534559                list_append(&u->link, &unused_head);
    535         else
     560        } else {
     561                free(u);
    536562                rc = EEXIST;
     563        }
    537564        fibril_mutex_unlock(&unused_lock);
    538565        return rc;
     
    541568void fat_idx_fini_by_dev_handle(dev_handle_t dev_handle)
    542569{
    543         unused_t *u;
    544 
    545         u = unused_find(dev_handle, true);
     570        unsigned long ikey[] = {
     571                [UIH_DH_KEY] = dev_handle
     572        };
     573        unsigned long pkey[] = {
     574                [UPH_DH_KEY] = dev_handle
     575        };
     576
     577        /*
     578         * Remove this instance's index structure from up_hash and ui_hash.
     579         * Process up_hash first and ui_hash second because the index structure
     580         * is actually removed in idx_remove_callback().
     581         */
     582        fibril_mutex_lock(&used_lock);
     583        hash_table_remove(&up_hash, pkey, 1);
     584        hash_table_remove(&ui_hash, ikey, 1);
     585        fibril_mutex_unlock(&used_lock);
     586
     587        /*
     588         * Free the unused and freed structures for this instance.
     589         */
     590        unused_t *u = unused_find(dev_handle, true);
    546591        assert(u);
    547592        list_remove(&u->link);
Note: See TracChangeset for help on using the changeset viewer.