Changeset 50e5b25 in mainline


Ignore:
Timestamp:
2008-11-23T11:00:08Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f714576
Parents:
31696b4f
Message:

Add implementation of fat_destroy_node() and fat_destroy().

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

Legend:

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

    r31696b4f r50e5b25  
    204204extern void fat_write(ipc_callid_t, ipc_call_t *);
    205205extern void fat_truncate(ipc_callid_t, ipc_call_t *);
     206extern void fat_destroy(ipc_callid_t, ipc_call_t *);
    206207
    207208extern fat_idx_t *fat_idx_get_new(dev_handle_t);
  • uspace/srv/fs/fat/fat_ops.c

    r31696b4f r50e5b25  
    217217}
    218218
     219/*
     220 * Forward declarations of FAT libfs operations.
     221 */
     222static void *fat_node_get(dev_handle_t, fs_index_t);
     223static void fat_node_put(void *);
     224static void *fat_create_node(dev_handle_t, int);
     225static int fat_destroy_node(void *);
     226static bool fat_link(void *, void *, const char *);
     227static int fat_unlink(void *, void *);
     228static void *fat_match(void *, const char *);
     229static fs_index_t fat_index_get(void *);
     230static size_t fat_size_get(void *);
     231static unsigned fat_lnkcnt_get(void *);
     232static bool fat_has_children(void *);
     233static void *fat_root_get(dev_handle_t);
     234static char fat_plb_get_char(unsigned);
     235static bool fat_is_directory(void *);
     236static bool fat_is_file(void *node);
     237
     238/*
     239 * FAT libfs operations.
     240 */
     241
    219242/** Instantiate a FAT in-core node. */
    220 static void *fat_node_get(dev_handle_t dev_handle, fs_index_t index)
     243void *fat_node_get(dev_handle_t dev_handle, fs_index_t index)
    221244{
    222245        void *node;
     
    232255}
    233256
    234 static void fat_node_put(void *node)
     257void fat_node_put(void *node)
    235258{
    236259        fat_node_t *nodep = (fat_node_t *)node;
     
    258281}
    259282
    260 static void *fat_create_node(dev_handle_t dev_handle, int flags)
     283void *fat_create_node(dev_handle_t dev_handle, int flags)
    261284{
    262285        fat_idx_t *idxp;
     
    289312}
    290313
    291 static int fat_destroy_node(void *node)
     314int fat_destroy_node(void *node)
     315{
     316        fat_node_t *nodep = (fat_node_t *)node;
     317        fat_bs_t *bs;
     318
     319        /*
     320         * The node is not reachable from the file system. This means that the
     321         * link count should be zero and that the index structure cannot be
     322         * found in the position hash. Obviously, we don't need to lock the node
     323         * nor its index structure.
     324         */
     325        assert(nodep->lnkcnt == 0);
     326
     327        /*
     328         * The node may not have any children.
     329         */
     330        assert(fat_has_children(node) == false);
     331
     332        bs = block_bb_get(nodep->idx->dev_handle);
     333        if (nodep->firstc != FAT_CLST_RES0) {
     334                assert(nodep->size);
     335                /* Free all clusters allocated to the node. */
     336                fat_free_clusters(bs, nodep->idx->dev_handle, nodep->firstc);
     337        }
     338
     339        fat_idx_destroy(nodep->idx);
     340        free(nodep);
     341        return EOK;
     342}
     343
     344bool fat_link(void *prnt, void *chld, const char *name)
     345{
     346        return false;   /* not supported at the moment */
     347}
     348
     349int fat_unlink(void *prnt, void *chld)
    292350{
    293351        return ENOTSUP; /* not supported at the moment */
    294352}
    295353
    296 static bool fat_link(void *prnt, void *chld, const char *name)
    297 {
    298         return false;   /* not supported at the moment */
    299 }
    300 
    301 static int fat_unlink(void *prnt, void *chld)
    302 {
    303         return ENOTSUP; /* not supported at the moment */
    304 }
    305 
    306 static void *fat_match(void *prnt, const char *component)
     354void *fat_match(void *prnt, const char *component)
    307355{
    308356        fat_bs_t *bs;
     
    371419}
    372420
    373 static fs_index_t fat_index_get(void *node)
     421fs_index_t fat_index_get(void *node)
    374422{
    375423        fat_node_t *fnodep = (fat_node_t *)node;
     
    379427}
    380428
    381 static size_t fat_size_get(void *node)
     429size_t fat_size_get(void *node)
    382430{
    383431        return ((fat_node_t *)node)->size;
    384432}
    385433
    386 static unsigned fat_lnkcnt_get(void *node)
     434unsigned fat_lnkcnt_get(void *node)
    387435{
    388436        return ((fat_node_t *)node)->lnkcnt;
    389437}
    390438
    391 static bool fat_has_children(void *node)
     439bool fat_has_children(void *node)
    392440{
    393441        fat_bs_t *bs;
     
    439487}
    440488
    441 static void *fat_root_get(dev_handle_t dev_handle)
     489void *fat_root_get(dev_handle_t dev_handle)
    442490{
    443491        return fat_node_get(dev_handle, 0);
    444492}
    445493
    446 static char fat_plb_get_char(unsigned pos)
     494char fat_plb_get_char(unsigned pos)
    447495{
    448496        return fat_reg.plb_ro[pos % PLB_SIZE];
    449497}
    450498
    451 static bool fat_is_directory(void *node)
     499bool fat_is_directory(void *node)
    452500{
    453501        return ((fat_node_t *)node)->type == FAT_DIRECTORY;
    454502}
    455503
    456 static bool fat_is_file(void *node)
     504bool fat_is_file(void *node)
    457505{
    458506        return ((fat_node_t *)node)->type == FAT_FILE;
     
    839887}
    840888
     889void fat_destroy(ipc_callid_t rid, ipc_call_t *request)
     890{
     891        dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
     892        fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
     893        int rc;
     894
     895        fat_node_t *nodep = fat_node_get(dev_handle, index);
     896        if (!nodep) {
     897                ipc_answer_0(rid, ENOENT);
     898                return;
     899        }
     900
     901        rc = fat_destroy_node(nodep);
     902        ipc_answer_0(rid, rc);
     903}
     904
    841905/**
    842906 * @}
Note: See TracChangeset for help on using the changeset viewer.