Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/tmpfs/tmpfs_ops.c

    rffa2c8ef r75160a6  
    2929/** @addtogroup fs
    3030 * @{
    31  */
     31 */ 
    3232
    3333/**
     
    3939#include "tmpfs.h"
    4040#include "../../vfs/vfs.h"
    41 #include <macros.h>
    42 #include <stdint.h>
     41#include <ipc/ipc.h>
    4342#include <async.h>
    4443#include <errno.h>
    4544#include <atomic.h>
    4645#include <stdlib.h>
    47 #include <str.h>
     46#include <string.h>
    4847#include <stdio.h>
    4948#include <assert.h>
     
    6867
    6968/* Forward declarations of static functions. */
    70 static int tmpfs_match(fs_node_t **, fs_node_t *, const char *);
    71 static int tmpfs_node_get(fs_node_t **, devmap_handle_t, fs_index_t);
    72 static int tmpfs_node_open(fs_node_t *);
    73 static int tmpfs_node_put(fs_node_t *);
    74 static int tmpfs_create_node(fs_node_t **, devmap_handle_t, int);
    75 static int tmpfs_destroy_node(fs_node_t *);
     69static fs_node_t *tmpfs_match(fs_node_t *, const char *);
     70static fs_node_t *tmpfs_node_get(dev_handle_t, fs_index_t);
     71static void tmpfs_node_put(fs_node_t *);
     72static fs_node_t *tmpfs_create_node(dev_handle_t, int);
    7673static int tmpfs_link_node(fs_node_t *, fs_node_t *, const char *);
    7774static int tmpfs_unlink_node(fs_node_t *, fs_node_t *, const char *);
     75static int tmpfs_destroy_node(fs_node_t *);
    7876
    7977/* Implementation of helper functions. */
    80 static int tmpfs_root_get(fs_node_t **rfn, devmap_handle_t devmap_handle)
    81 {
    82         return tmpfs_node_get(rfn, devmap_handle, TMPFS_SOME_ROOT);
    83 }
    84 
    85 static int tmpfs_has_children(bool *has_children, fs_node_t *fn)
    86 {
    87         *has_children = !list_empty(&TMPFS_NODE(fn)->cs_head);
    88         return EOK;
    89 }
    90 
    9178static fs_index_t tmpfs_index_get(fs_node_t *fn)
    9279{
     
    9481}
    9582
    96 static aoff64_t tmpfs_size_get(fs_node_t *fn)
     83static size_t tmpfs_size_get(fs_node_t *fn)
    9784{
    9885        return TMPFS_NODE(fn)->size;
     
    10491}
    10592
     93static bool tmpfs_has_children(fs_node_t *fn)
     94{
     95        return !list_empty(&TMPFS_NODE(fn)->cs_head);
     96}
     97
     98static fs_node_t *tmpfs_root_get(dev_handle_t dev_handle)
     99{
     100        return tmpfs_node_get(dev_handle, TMPFS_SOME_ROOT);
     101}
     102
    106103static char tmpfs_plb_get_char(unsigned pos)
    107104{
     
    117114{
    118115        return TMPFS_NODE(fn)->type == TMPFS_FILE;
    119 }
    120 
    121 static devmap_handle_t tmpfs_device_get(fs_node_t *fn)
    122 {
    123         return 0;
    124116}
    125117
    126118/** libfs operations */
    127119libfs_ops_t tmpfs_libfs_ops = {
    128         .root_get = tmpfs_root_get,
    129120        .match = tmpfs_match,
    130121        .node_get = tmpfs_node_get,
    131         .node_open = tmpfs_node_open,
    132122        .node_put = tmpfs_node_put,
    133123        .create = tmpfs_create_node,
     
    135125        .link = tmpfs_link_node,
    136126        .unlink = tmpfs_unlink_node,
    137         .has_children = tmpfs_has_children,
    138127        .index_get = tmpfs_index_get,
    139128        .size_get = tmpfs_size_get,
    140129        .lnkcnt_get = tmpfs_lnkcnt_get,
     130        .has_children = tmpfs_has_children,
     131        .root_get = tmpfs_root_get,
    141132        .plb_get_char = tmpfs_plb_get_char,
    142133        .is_directory = tmpfs_is_directory,
    143         .is_file = tmpfs_is_file,
    144         .device_get = tmpfs_device_get
     134        .is_file = tmpfs_is_file
    145135};
    146136
     
    148138hash_table_t nodes;
    149139
    150 #define NODES_KEY_DEV   0       
    151 #define NODES_KEY_INDEX 1
     140#define NODES_KEY_INDEX 0
     141#define NODES_KEY_DEV   1
    152142
    153143/* Implementation of hash table interface for the nodes hash table. */
     
    161151        tmpfs_node_t *nodep = hash_table_get_instance(item, tmpfs_node_t,
    162152            nh_link);
    163        
    164         switch (keys) {
    165         case 1:
    166                 return (nodep->devmap_handle == key[NODES_KEY_DEV]);
    167         case 2:
    168                 return ((nodep->devmap_handle == key[NODES_KEY_DEV]) &&
    169                     (nodep->index == key[NODES_KEY_INDEX]));
    170         default:
    171                 assert((keys == 1) || (keys == 2));
    172         }
    173 
    174         return 0;
     153        return (nodep->index == key[NODES_KEY_INDEX] &&
     154            nodep->dev_handle == key[NODES_KEY_DEV]);
    175155}
    176156
    177157static void nodes_remove_callback(link_t *item)
    178158{
    179         tmpfs_node_t *nodep = hash_table_get_instance(item, tmpfs_node_t,
    180             nh_link);
    181 
    182         while (!list_empty(&nodep->cs_head)) {
    183                 tmpfs_dentry_t *dentryp = list_get_instance(nodep->cs_head.next,
    184                     tmpfs_dentry_t, link);
    185 
    186                 assert(nodep->type == TMPFS_DIRECTORY);
    187                 list_remove(&dentryp->link);
    188                 free(dentryp);
    189         }
    190 
    191         if (nodep->data) {
    192                 assert(nodep->type == TMPFS_FILE);
    193                 free(nodep->data);
    194         }
    195         free(nodep->bp);
    196         free(nodep);
    197159}
    198160
     
    208170        nodep->bp = NULL;
    209171        nodep->index = 0;
    210         nodep->devmap_handle = 0;
     172        nodep->dev_handle = 0;
    211173        nodep->type = TMPFS_NONE;
    212174        nodep->lnkcnt = 0;
     
    232194}
    233195
    234 static bool tmpfs_instance_init(devmap_handle_t devmap_handle)
     196static bool tmpfs_instance_init(dev_handle_t dev_handle)
    235197{
    236198        fs_node_t *rfn;
    237         int rc;
    238199       
    239         rc = tmpfs_create_node(&rfn, devmap_handle, L_DIRECTORY);
    240         if (rc != EOK || !rfn)
     200        rfn = tmpfs_create_node(dev_handle, L_DIRECTORY);
     201        if (!rfn)
    241202                return false;
    242203        TMPFS_NODE(rfn)->lnkcnt = 0;    /* FS root is not linked */
     
    244205}
    245206
    246 static void tmpfs_instance_done(devmap_handle_t devmap_handle)
    247 {
    248         unsigned long key[] = {
    249                 [NODES_KEY_DEV] = devmap_handle
    250         };
    251         /*
    252          * Here we are making use of one special feature of our hash table
    253          * implementation, which allows to remove more items based on a partial
    254          * key match. In the following, we are going to remove all nodes
    255          * matching our device handle. The nodes_remove_callback() function will
    256          * take care of resource deallocation.
    257          */
    258         hash_table_remove(&nodes, key, 1);
    259 }
    260 
    261 int tmpfs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component)
     207fs_node_t *tmpfs_match(fs_node_t *pfn, const char *component)
    262208{
    263209        tmpfs_node_t *parentp = TMPFS_NODE(pfn);
     
    266212        for (lnk = parentp->cs_head.next; lnk != &parentp->cs_head;
    267213            lnk = lnk->next) {
    268                 tmpfs_dentry_t *dentryp;
    269                 dentryp = list_get_instance(lnk, tmpfs_dentry_t, link);
    270                 if (!str_cmp(dentryp->name, component)) {
    271                         *rfn = FS_NODE(dentryp->node);
    272                         return EOK;
    273                 }
    274         }
    275 
    276         *rfn = NULL;
    277         return EOK;
    278 }
    279 
    280 int tmpfs_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle, fs_index_t index)
     214                tmpfs_dentry_t *dentryp = list_get_instance(lnk, tmpfs_dentry_t,
     215                    link);
     216                if (!str_cmp(dentryp->name, component))
     217                        return FS_NODE(dentryp->node);
     218        }
     219
     220        return NULL;
     221}
     222
     223fs_node_t *tmpfs_node_get(dev_handle_t dev_handle, fs_index_t index)
    281224{
    282225        unsigned long key[] = {
    283                 [NODES_KEY_DEV] = devmap_handle,
    284                 [NODES_KEY_INDEX] = index
     226                [NODES_KEY_INDEX] = index,
     227                [NODES_KEY_DEV] = dev_handle
    285228        };
    286229        link_t *lnk = hash_table_find(&nodes, key);
    287         if (lnk) {
    288                 tmpfs_node_t *nodep;
    289                 nodep = hash_table_get_instance(lnk, tmpfs_node_t, nh_link);
    290                 *rfn = FS_NODE(nodep);
    291         } else {
    292                 *rfn = NULL;
    293         }
    294         return EOK;     
    295 }
    296 
    297 int tmpfs_node_open(fs_node_t *fn)
     230        if (!lnk)
     231                return NULL;
     232        return FS_NODE(hash_table_get_instance(lnk, tmpfs_node_t, nh_link));
     233}
     234
     235void tmpfs_node_put(fs_node_t *fn)
    298236{
    299237        /* nothing to do */
    300         return EOK;
    301 }
    302 
    303 int tmpfs_node_put(fs_node_t *fn)
    304 {
    305         /* nothing to do */
    306         return EOK;
    307 }
    308 
    309 int tmpfs_create_node(fs_node_t **rfn, devmap_handle_t devmap_handle, int lflag)
    310 {
    311         fs_node_t *rootfn;
    312         int rc;
    313 
     238}
     239
     240fs_node_t *tmpfs_create_node(dev_handle_t dev_handle, int lflag)
     241{
    314242        assert((lflag & L_FILE) ^ (lflag & L_DIRECTORY));
    315243
    316244        tmpfs_node_t *nodep = malloc(sizeof(tmpfs_node_t));
    317245        if (!nodep)
    318                 return ENOMEM;
     246                return NULL;
    319247        tmpfs_node_initialize(nodep);
    320248        nodep->bp = malloc(sizeof(fs_node_t));
    321249        if (!nodep->bp) {
    322250                free(nodep);
    323                 return ENOMEM;
     251                return NULL;
    324252        }
    325253        fs_node_initialize(nodep->bp);
    326254        nodep->bp->data = nodep;        /* link the FS and TMPFS nodes */
    327 
    328         rc = tmpfs_root_get(&rootfn, devmap_handle);
    329         assert(rc == EOK);
    330         if (!rootfn)
     255        if (!tmpfs_root_get(dev_handle))
    331256                nodep->index = TMPFS_SOME_ROOT;
    332257        else
    333258                nodep->index = tmpfs_next_index++;
    334         nodep->devmap_handle = devmap_handle;
     259        nodep->dev_handle = dev_handle;
    335260        if (lflag & L_DIRECTORY)
    336261                nodep->type = TMPFS_DIRECTORY;
     
    340265        /* Insert the new node into the nodes hash table. */
    341266        unsigned long key[] = {
    342                 [NODES_KEY_DEV] = nodep->devmap_handle,
    343                 [NODES_KEY_INDEX] = nodep->index
     267                [NODES_KEY_INDEX] = nodep->index,
     268                [NODES_KEY_DEV] = nodep->dev_handle
    344269        };
    345270        hash_table_insert(&nodes, key, &nodep->nh_link);
    346         *rfn = FS_NODE(nodep);
    347         return EOK;
    348 }
    349 
    350 int tmpfs_destroy_node(fs_node_t *fn)
    351 {
    352         tmpfs_node_t *nodep = TMPFS_NODE(fn);
    353        
    354         assert(!nodep->lnkcnt);
    355         assert(list_empty(&nodep->cs_head));
    356 
    357         unsigned long key[] = {
    358                 [NODES_KEY_DEV] = nodep->devmap_handle,
    359                 [NODES_KEY_INDEX] = nodep->index
    360         };
    361         hash_table_remove(&nodes, key, 2);
    362 
    363         /*
    364          * The nodes_remove_callback() function takes care of the actual
    365          * resource deallocation.
    366          */
    367         return EOK;
     271        return FS_NODE(nodep);
    368272}
    369273
     
    439343}
    440344
     345int tmpfs_destroy_node(fs_node_t *fn)
     346{
     347        tmpfs_node_t *nodep = TMPFS_NODE(fn);
     348       
     349        assert(!nodep->lnkcnt);
     350        assert(list_empty(&nodep->cs_head));
     351
     352        unsigned long key[] = {
     353                [NODES_KEY_INDEX] = nodep->index,
     354                [NODES_KEY_DEV] = nodep->dev_handle
     355        };
     356        hash_table_remove(&nodes, key, 2);
     357
     358        if (nodep->type == TMPFS_FILE)
     359                free(nodep->data);
     360        free(nodep->bp);
     361        free(nodep);
     362        return EOK;
     363}
     364
    441365void tmpfs_mounted(ipc_callid_t rid, ipc_call_t *request)
    442366{
    443         devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
    444         fs_node_t *rootfn;
    445         int rc;
    446        
    447         /* Accept the mount options. */
    448         char *opts;
    449         rc = async_data_write_accept((void **) &opts, true, 0, 0, 0, NULL);
    450         if (rc != EOK) {
    451                 async_answer_0(rid, rc);
    452                 return;
    453         }
    454 
    455         /* Check if this device is not already mounted. */
    456         rc = tmpfs_root_get(&rootfn, devmap_handle);
    457         if ((rc == EOK) && (rootfn)) {
    458                 (void) tmpfs_node_put(rootfn);
     367        dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
     368
     369        /* accept the mount options */
     370        ipc_callid_t callid;
     371        size_t size;
     372        if (!ipc_data_write_receive(&callid, &size)) {
     373                ipc_answer_0(callid, EINVAL);
     374                ipc_answer_0(rid, EINVAL);
     375                return;
     376        }
     377        char *opts = malloc(size + 1);
     378        if (!opts) {
     379                ipc_answer_0(callid, ENOMEM);
     380                ipc_answer_0(rid, ENOMEM);
     381                return;
     382        }
     383        ipcarg_t retval = ipc_data_write_finalize(callid, opts, size);
     384        if (retval != EOK) {
     385                ipc_answer_0(rid, retval);
    459386                free(opts);
    460                 async_answer_0(rid, EEXIST);
    461                 return;
    462         }
     387                return;
     388        }
     389        opts[size] = '\0';
    463390
    464391        /* Initialize TMPFS instance. */
    465         if (!tmpfs_instance_init(devmap_handle)) {
    466                 free(opts);
    467                 async_answer_0(rid, ENOMEM);
    468                 return;
    469         }
    470 
    471         rc = tmpfs_root_get(&rootfn, devmap_handle);
    472         assert(rc == EOK);
    473         tmpfs_node_t *rootp = TMPFS_NODE(rootfn);
     392        if (!tmpfs_instance_init(dev_handle)) {
     393                ipc_answer_0(rid, ENOMEM);
     394                return;
     395        }
     396
     397        tmpfs_node_t *rootp = TMPFS_NODE(tmpfs_root_get(dev_handle));
    474398        if (str_cmp(opts, "restore") == 0) {
    475                 if (tmpfs_restore(devmap_handle))
    476                         async_answer_3(rid, EOK, rootp->index, rootp->size,
     399                if (tmpfs_restore(dev_handle))
     400                        ipc_answer_3(rid, EOK, rootp->index, rootp->size,
    477401                            rootp->lnkcnt);
    478402                else
    479                         async_answer_0(rid, ELIMIT);
     403                        ipc_answer_0(rid, ELIMIT);
    480404        } else {
    481                 async_answer_3(rid, EOK, rootp->index, rootp->size,
     405                ipc_answer_3(rid, EOK, rootp->index, rootp->size,
    482406                    rootp->lnkcnt);
    483407        }
    484         free(opts);
    485408}
    486409
     
    490413}
    491414
    492 void tmpfs_unmounted(ipc_callid_t rid, ipc_call_t *request)
    493 {
    494         devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
    495 
    496         tmpfs_instance_done(devmap_handle);
    497         async_answer_0(rid, EOK);
    498 }
    499 
    500 void tmpfs_unmount(ipc_callid_t rid, ipc_call_t *request)
    501 {
    502         libfs_unmount(&tmpfs_libfs_ops, rid, request);
    503 }
    504 
    505415void tmpfs_lookup(ipc_callid_t rid, ipc_call_t *request)
    506416{
     
    510420void tmpfs_read(ipc_callid_t rid, ipc_call_t *request)
    511421{
    512         devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
    513         fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
    514         aoff64_t pos =
    515             (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
    516        
     422        dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
     423        fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
     424        off_t pos = (off_t)IPC_GET_ARG3(*request);
     425
    517426        /*
    518427         * Lookup the respective TMPFS node.
     
    520429        link_t *hlp;
    521430        unsigned long key[] = {
    522                 [NODES_KEY_DEV] = devmap_handle,
    523                 [NODES_KEY_INDEX] = index
     431                [NODES_KEY_INDEX] = index,
     432                [NODES_KEY_DEV] = dev_handle,
    524433        };
    525434        hlp = hash_table_find(&nodes, key);
    526435        if (!hlp) {
    527                 async_answer_0(rid, ENOENT);
     436                ipc_answer_0(rid, ENOENT);
    528437                return;
    529438        }
    530439        tmpfs_node_t *nodep = hash_table_get_instance(hlp, tmpfs_node_t,
    531440            nh_link);
    532        
     441
    533442        /*
    534443         * Receive the read request.
     
    536445        ipc_callid_t callid;
    537446        size_t size;
    538         if (!async_data_read_receive(&callid, &size)) {
    539                 async_answer_0(callid, EINVAL);
    540                 async_answer_0(rid, EINVAL);
     447        if (!ipc_data_read_receive(&callid, &size)) {
     448                ipc_answer_0(callid, EINVAL);   
     449                ipc_answer_0(rid, EINVAL);
    541450                return;
    542451        }
     
    544453        size_t bytes;
    545454        if (nodep->type == TMPFS_FILE) {
    546                 bytes = min(nodep->size - pos, size);
    547                 (void) async_data_read_finalize(callid, nodep->data + pos,
     455                bytes = max(0, min(nodep->size - pos, size));
     456                (void) ipc_data_read_finalize(callid, nodep->data + pos,
    548457                    bytes);
    549458        } else {
    550459                tmpfs_dentry_t *dentryp;
    551460                link_t *lnk;
    552                 aoff64_t i;
     461                int i;
    553462               
    554463                assert(nodep->type == TMPFS_DIRECTORY);
     
    560469                 */
    561470                for (i = 0, lnk = nodep->cs_head.next;
    562                     (i < pos) && (lnk != &nodep->cs_head);
     471                    i < pos && lnk != &nodep->cs_head;
    563472                    i++, lnk = lnk->next)
    564473                        ;
    565474
    566475                if (lnk == &nodep->cs_head) {
    567                         async_answer_0(callid, ENOENT);
    568                         async_answer_1(rid, ENOENT, 0);
     476                        ipc_answer_0(callid, ENOENT);
     477                        ipc_answer_1(rid, ENOENT, 0);
    569478                        return;
    570479                }
     
    572481                dentryp = list_get_instance(lnk, tmpfs_dentry_t, link);
    573482
    574                 (void) async_data_read_finalize(callid, dentryp->name,
     483                (void) ipc_data_read_finalize(callid, dentryp->name,
    575484                    str_size(dentryp->name) + 1);
    576485                bytes = 1;
     
    580489         * Answer the VFS_READ call.
    581490         */
    582         async_answer_1(rid, EOK, bytes);
     491        ipc_answer_1(rid, EOK, bytes);
    583492}
    584493
    585494void tmpfs_write(ipc_callid_t rid, ipc_call_t *request)
    586495{
    587         devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
    588         fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
    589         aoff64_t pos =
    590             (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
    591        
     496        dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
     497        fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
     498        off_t pos = (off_t)IPC_GET_ARG3(*request);
     499
    592500        /*
    593501         * Lookup the respective TMPFS node.
     
    595503        link_t *hlp;
    596504        unsigned long key[] = {
    597                 [NODES_KEY_DEV] = devmap_handle,
    598                 [NODES_KEY_INDEX] = index
     505                [NODES_KEY_INDEX] = index,
     506                [NODES_KEY_DEV] = dev_handle
    599507        };
    600508        hlp = hash_table_find(&nodes, key);
    601509        if (!hlp) {
    602                 async_answer_0(rid, ENOENT);
     510                ipc_answer_0(rid, ENOENT);
    603511                return;
    604512        }
     
    611519        ipc_callid_t callid;
    612520        size_t size;
    613         if (!async_data_write_receive(&callid, &size)) {
    614                 async_answer_0(callid, EINVAL);
    615                 async_answer_0(rid, EINVAL);
     521        if (!ipc_data_write_receive(&callid, &size)) {
     522                ipc_answer_0(callid, EINVAL);   
     523                ipc_answer_0(rid, EINVAL);
    616524                return;
    617525        }
     
    622530        if (pos + size <= nodep->size) {
    623531                /* The file size is not changing. */
    624                 (void) async_data_write_finalize(callid, nodep->data + pos, size);
    625                 async_answer_2(rid, EOK, size, nodep->size);
     532                (void) ipc_data_write_finalize(callid, nodep->data + pos, size);
     533                ipc_answer_2(rid, EOK, size, nodep->size);
    626534                return;
    627535        }
     
    636544        void *newdata = realloc(nodep->data, nodep->size + delta);
    637545        if (!newdata) {
    638                 async_answer_0(callid, ENOMEM);
    639                 async_answer_2(rid, EOK, 0, nodep->size);
     546                ipc_answer_0(callid, ENOMEM);
     547                ipc_answer_2(rid, EOK, 0, nodep->size);
    640548                return;
    641549        }
     
    644552        nodep->size += delta;
    645553        nodep->data = newdata;
    646         (void) async_data_write_finalize(callid, nodep->data + pos, size);
    647         async_answer_2(rid, EOK, size, nodep->size);
     554        (void) ipc_data_write_finalize(callid, nodep->data + pos, size);
     555        ipc_answer_2(rid, EOK, size, nodep->size);
    648556}
    649557
    650558void tmpfs_truncate(ipc_callid_t rid, ipc_call_t *request)
    651559{
    652         devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
    653         fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
    654         aoff64_t size =
    655             (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
    656        
     560        dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
     561        fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
     562        size_t size = (off_t)IPC_GET_ARG3(*request);
     563
    657564        /*
    658565         * Lookup the respective TMPFS node.
    659566         */
     567        link_t *hlp;
    660568        unsigned long key[] = {
    661                 [NODES_KEY_DEV] = devmap_handle,
    662                 [NODES_KEY_INDEX] = index
     569                [NODES_KEY_INDEX] = index,
     570                [NODES_KEY_DEV] = dev_handle
    663571        };
    664         link_t *hlp = hash_table_find(&nodes, key);
     572        hlp = hash_table_find(&nodes, key);
    665573        if (!hlp) {
    666                 async_answer_0(rid, ENOENT);
     574                ipc_answer_0(rid, ENOENT);
    667575                return;
    668576        }
    669577        tmpfs_node_t *nodep = hash_table_get_instance(hlp, tmpfs_node_t,
    670578            nh_link);
    671        
     579
    672580        if (size == nodep->size) {
    673                 async_answer_0(rid, EOK);
    674                 return;
    675         }
    676        
    677         if (size > SIZE_MAX) {
    678                 async_answer_0(rid, ENOMEM);
    679                 return;
    680         }
    681        
     581                ipc_answer_0(rid, EOK);
     582                return;
     583        }
     584
    682585        void *newdata = realloc(nodep->data, size);
    683586        if (!newdata) {
    684                 async_answer_0(rid, ENOMEM);
    685                 return;
    686         }
    687        
     587                ipc_answer_0(rid, ENOMEM);
     588                return;
     589        }
    688590        if (size > nodep->size) {
    689591                size_t delta = size - nodep->size;
    690592                memset(newdata + nodep->size, 0, delta);
    691593        }
    692        
    693594        nodep->size = size;
    694595        nodep->data = newdata;
    695         async_answer_0(rid, EOK);
     596        ipc_answer_0(rid, EOK);
    696597}
    697598
    698599void tmpfs_close(ipc_callid_t rid, ipc_call_t *request)
    699600{
    700         async_answer_0(rid, EOK);
     601        ipc_answer_0(rid, EOK);
    701602}
    702603
    703604void tmpfs_destroy(ipc_callid_t rid, ipc_call_t *request)
    704605{
    705         devmap_handle_t devmap_handle = (devmap_handle_t)IPC_GET_ARG1(*request);
     606        dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
    706607        fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
    707608        int rc;
     
    709610        link_t *hlp;
    710611        unsigned long key[] = {
    711                 [NODES_KEY_DEV] = devmap_handle,
    712                 [NODES_KEY_INDEX] = index
     612                [NODES_KEY_INDEX] = index,
     613                [NODES_KEY_DEV] = dev_handle
    713614        };
    714615        hlp = hash_table_find(&nodes, key);
    715616        if (!hlp) {
    716                 async_answer_0(rid, ENOENT);
     617                ipc_answer_0(rid, ENOENT);
    717618                return;
    718619        }
     
    720621            nh_link);
    721622        rc = tmpfs_destroy_node(FS_NODE(nodep));
    722         async_answer_0(rid, rc);
     623        ipc_answer_0(rid, rc);
    723624}
    724625
     
    735636void tmpfs_sync(ipc_callid_t rid, ipc_call_t *request)
    736637{
    737         /*
    738          * TMPFS keeps its data structures always consistent,
    739          * thus the sync operation is a no-op.
    740          */
    741         async_answer_0(rid, EOK);
     638        /* Dummy implementation */
     639        ipc_answer_0(rid, EOK);
    742640}
    743641
Note: See TracChangeset for help on using the changeset viewer.