Changeset 15f3c3f in mainline for uspace/srv/fs/locfs/locfs_ops.c


Ignore:
Timestamp:
2011-06-22T22:00:52Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
86ffa27f
Parents:
ef09a7a
Message:

Rename devmap to loc, devfs to locfs.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/locfs/locfs_ops.c

    ref09a7a r15f3c3f  
    3232
    3333/**
    34  * @file devfs_ops.c
    35  * @brief Implementation of VFS operations for the devfs file system server.
     34 * @file locfs_ops.c
     35 * @brief Implementation of VFS operations for the locfs file system server.
    3636 */
    3737
     
    4444#include <fibril_synch.h>
    4545#include <adt/hash_table.h>
    46 #include <ipc/devmap.h>
     46#include <ipc/loc.h>
    4747#include <sys/stat.h>
    4848#include <libfs.h>
    4949#include <assert.h>
    50 #include "devfs.h"
    51 #include "devfs_ops.h"
     50#include "locfs.h"
     51#include "locfs_ops.h"
    5252
    5353typedef struct {
    54         devmap_handle_type_t type;
    55         devmap_handle_t handle;
    56 } devfs_node_t;
    57 
    58 /** Opened devices structure */
     54        loc_object_type_t type;
     55        service_id_t service_id;
     56} locfs_node_t;
     57
     58/** Opened services structure */
    5959typedef struct {
    60         devmap_handle_t handle;
     60        service_id_t service_id;
    6161        async_sess_t *sess;       /**< If NULL, the structure is incomplete. */
    6262        size_t refcount;
    6363        link_t link;
    6464        fibril_condvar_t cv;      /**< Broadcast when completed. */
    65 } device_t;
    66 
    67 /** Hash table of opened devices */
    68 static hash_table_t devices;
     65} service_t;
     66
     67/** Hash table of opened services */
     68static hash_table_t services;
    6969
    7070/** Hash table mutex */
    71 static FIBRIL_MUTEX_INITIALIZE(devices_mutex);
    72 
    73 #define DEVICES_KEYS        1
    74 #define DEVICES_KEY_HANDLE  0
    75 #define DEVICES_BUCKETS     256
     71static FIBRIL_MUTEX_INITIALIZE(services_mutex);
     72
     73#define SERVICES_KEYS        1
     74#define SERVICES_KEY_HANDLE  0
     75#define SERVICES_BUCKETS     256
    7676
    7777/* Implementation of hash table interface for the nodes hash table. */
    78 static hash_index_t devices_hash(unsigned long key[])
    79 {
    80         return key[DEVICES_KEY_HANDLE] % DEVICES_BUCKETS;
    81 }
    82 
    83 static int devices_compare(unsigned long key[], hash_count_t keys, link_t *item)
    84 {
    85         device_t *dev = hash_table_get_instance(item, device_t, link);
    86         return (dev->handle == (devmap_handle_t) key[DEVICES_KEY_HANDLE]);
    87 }
    88 
    89 static void devices_remove_callback(link_t *item)
    90 {
    91         free(hash_table_get_instance(item, device_t, link));
    92 }
    93 
    94 static hash_table_operations_t devices_ops = {
    95         .hash = devices_hash,
    96         .compare = devices_compare,
    97         .remove_callback = devices_remove_callback
     78static hash_index_t services_hash(unsigned long key[])
     79{
     80        return key[SERVICES_KEY_HANDLE] % SERVICES_BUCKETS;
     81}
     82
     83static int services_compare(unsigned long key[], hash_count_t keys, link_t *item)
     84{
     85        service_t *dev = hash_table_get_instance(item, service_t, link);
     86        return (dev->service_id == (service_id_t) key[SERVICES_KEY_HANDLE]);
     87}
     88
     89static void services_remove_callback(link_t *item)
     90{
     91        free(hash_table_get_instance(item, service_t, link));
     92}
     93
     94static hash_table_operations_t services_ops = {
     95        .hash = services_hash,
     96        .compare = services_compare,
     97        .remove_callback = services_remove_callback
    9898};
    9999
    100 static int devfs_node_get_internal(fs_node_t **rfn, devmap_handle_type_t type,
    101     devmap_handle_t handle)
    102 {
    103         devfs_node_t *node = (devfs_node_t *) malloc(sizeof(devfs_node_t));
     100static int locfs_node_get_internal(fs_node_t **rfn, loc_object_type_t type,
     101    service_id_t service_id)
     102{
     103        locfs_node_t *node = (locfs_node_t *) malloc(sizeof(locfs_node_t));
    104104        if (node == NULL) {
    105105                *rfn = NULL;
     
    116116        fs_node_initialize(*rfn);
    117117        node->type = type;
    118         node->handle = handle;
     118        node->service_id = service_id;
    119119       
    120120        (*rfn)->data = node;
     
    122122}
    123123
    124 static int devfs_root_get(fs_node_t **rfn, devmap_handle_t devmap_handle)
    125 {
    126         return devfs_node_get_internal(rfn, DEV_HANDLE_NONE, 0);
    127 }
    128 
    129 static int devfs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component)
    130 {
    131         devfs_node_t *node = (devfs_node_t *) pfn->data;
     124static int locfs_root_get(fs_node_t **rfn, service_id_t service_id)
     125{
     126        return locfs_node_get_internal(rfn, LOC_OBJECT_NONE, 0);
     127}
     128
     129static int locfs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component)
     130{
     131        locfs_node_t *node = (locfs_node_t *) pfn->data;
    132132        int ret;
    133133       
    134         if (node->handle == 0) {
     134        if (node->service_id == 0) {
    135135                /* Root directory */
    136136               
    137                 dev_desc_t *devs;
    138                 size_t count = devmap_get_namespaces(&devs);
     137                loc_sdesc_t *nspaces;
     138                size_t count = loc_get_namespaces(&nspaces);
    139139               
    140140                if (count > 0) {
     
    142142                        for (pos = 0; pos < count; pos++) {
    143143                                /* Ignore root namespace */
    144                                 if (str_cmp(devs[pos].name, "") == 0)
     144                                if (str_cmp(nspaces[pos].name, "") == 0)
    145145                                        continue;
    146146                               
    147                                 if (str_cmp(devs[pos].name, component) == 0) {
    148                                         ret = devfs_node_get_internal(rfn, DEV_HANDLE_NAMESPACE, devs[pos].handle);
    149                                         free(devs);
     147                                if (str_cmp(nspaces[pos].name, component) == 0) {
     148                                        ret = locfs_node_get_internal(rfn, LOC_OBJECT_NAMESPACE, nspaces[pos].id);
     149                                        free(nspaces);
    150150                                        return ret;
    151151                                }
    152152                        }
    153153                       
    154                         free(devs);
     154                        free(nspaces);
    155155                }
    156156               
    157157                /* Search root namespace */
    158                 devmap_handle_t namespace;
    159                 if (devmap_namespace_get_handle("", &namespace, 0) == EOK) {
    160                         count = devmap_get_devices(namespace, &devs);
     158                service_id_t namespace;
     159                loc_sdesc_t *svcs;
     160                if (loc_namespace_get_id("", &namespace, 0) == EOK) {
     161                        count = loc_get_services(namespace, &svcs);
    161162                       
    162163                        if (count > 0) {
    163164                                size_t pos;
    164165                                for (pos = 0; pos < count; pos++) {
    165                                         if (str_cmp(devs[pos].name, component) == 0) {
    166                                                 ret = devfs_node_get_internal(rfn, DEV_HANDLE_DEVICE, devs[pos].handle);
    167                                                 free(devs);
     166                                        if (str_cmp(svcs[pos].name, component) == 0) {
     167                                                ret = locfs_node_get_internal(rfn, LOC_OBJECT_SERVICE, svcs[pos].id);
     168                                                free(svcs);
    168169                                                return ret;
    169170                                        }
    170171                                }
    171172                               
    172                                 free(devs);
     173                                free(svcs);
    173174                        }
    174175                }
     
    178179        }
    179180       
    180         if (node->type == DEV_HANDLE_NAMESPACE) {
     181        if (node->type == LOC_OBJECT_NAMESPACE) {
    181182                /* Namespace directory */
    182183               
    183                 dev_desc_t *devs;
    184                 size_t count = devmap_get_devices(node->handle, &devs);
     184                loc_sdesc_t *svcs;
     185                size_t count = loc_get_services(node->service_id, &svcs);
    185186                if (count > 0) {
    186187                        size_t pos;
    187188                        for (pos = 0; pos < count; pos++) {
    188                                 if (str_cmp(devs[pos].name, component) == 0) {
    189                                         ret = devfs_node_get_internal(rfn, DEV_HANDLE_DEVICE, devs[pos].handle);
    190                                         free(devs);
     189                                if (str_cmp(svcs[pos].name, component) == 0) {
     190                                        ret = locfs_node_get_internal(rfn, LOC_OBJECT_SERVICE, svcs[pos].id);
     191                                        free(svcs);
    191192                                        return ret;
    192193                                }
    193194                        }
    194195                       
    195                         free(devs);
     196                        free(svcs);
    196197                }
    197198               
     
    204205}
    205206
    206 static int devfs_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle, fs_index_t index)
    207 {
    208         return devfs_node_get_internal(rfn, devmap_handle_probe(index), index);
    209 }
    210 
    211 static int devfs_node_open(fs_node_t *fn)
    212 {
    213         devfs_node_t *node = (devfs_node_t *) fn->data;
    214        
    215         if (node->handle == 0) {
     207static int locfs_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index)
     208{
     209        return locfs_node_get_internal(rfn, loc_id_probe(index), index);
     210}
     211
     212static int locfs_node_open(fs_node_t *fn)
     213{
     214        locfs_node_t *node = (locfs_node_t *) fn->data;
     215       
     216        if (node->service_id == 0) {
    216217                /* Root directory */
    217218                return EOK;
    218219        }
    219220       
    220         devmap_handle_type_t type = devmap_handle_probe(node->handle);
    221        
    222         if (type == DEV_HANDLE_NAMESPACE) {
     221        loc_object_type_t type = loc_id_probe(node->service_id);
     222       
     223        if (type == LOC_OBJECT_NAMESPACE) {
    223224                /* Namespace directory */
    224225                return EOK;
    225226        }
    226227       
    227         if (type == DEV_HANDLE_DEVICE) {
     228        if (type == LOC_OBJECT_SERVICE) {
    228229                /* Device node */
    229230               
    230231                unsigned long key[] = {
    231                         [DEVICES_KEY_HANDLE] = (unsigned long) node->handle
     232                        [SERVICES_KEY_HANDLE] = (unsigned long) node->service_id
    232233                };
    233234                link_t *lnk;
    234235               
    235                 fibril_mutex_lock(&devices_mutex);
     236                fibril_mutex_lock(&services_mutex);
    236237restart:
    237                 lnk = hash_table_find(&devices, key);
     238                lnk = hash_table_find(&services, key);
    238239                if (lnk == NULL) {
    239                         device_t *dev = (device_t *) malloc(sizeof(device_t));
     240                        service_t *dev = (service_t *) malloc(sizeof(service_t));
    240241                        if (dev == NULL) {
    241                                 fibril_mutex_unlock(&devices_mutex);
     242                                fibril_mutex_unlock(&services_mutex);
    242243                                return ENOMEM;
    243244                        }
    244245                       
    245                         dev->handle = node->handle;
     246                        dev->service_id = node->service_id;
    246247                       
    247248                        /* Mark as incomplete */
     
    255256                         * below.
    256257                         */
    257                         hash_table_insert(&devices, key, &dev->link);
     258                        hash_table_insert(&services, key, &dev->link);
    258259                       
    259260                        /*
    260                          * Drop the mutex to allow recursive devfs requests.
     261                         * Drop the mutex to allow recursive locfs requests.
    261262                         */
    262                         fibril_mutex_unlock(&devices_mutex);
    263                        
    264                         async_sess_t *sess = devmap_device_connect(EXCHANGE_SERIALIZE,
    265                             node->handle, 0);
    266                        
    267                         fibril_mutex_lock(&devices_mutex);
     263                        fibril_mutex_unlock(&services_mutex);
     264                       
     265                        async_sess_t *sess = loc_service_connect(
     266                            EXCHANGE_SERIALIZE, node->service_id, 0);
     267                       
     268                        fibril_mutex_lock(&services_mutex);
    268269                       
    269270                        /*
     
    278279                                 * entry and free the device structure.
    279280                                 */
    280                                 hash_table_remove(&devices, key, DEVICES_KEYS);
    281                                 fibril_mutex_unlock(&devices_mutex);
     281                                hash_table_remove(&services, key, SERVICES_KEYS);
     282                                fibril_mutex_unlock(&services_mutex);
    282283                               
    283284                                return ENOENT;
     
    287288                        dev->sess = sess;
    288289                } else {
    289                         device_t *dev = hash_table_get_instance(lnk, device_t, link);
     290                        service_t *dev = hash_table_get_instance(lnk, service_t, link);
    290291                       
    291292                        if (!dev->sess) {
     
    297298                                 * fibril_condvar_wait().
    298299                                 */
    299                                 fibril_condvar_wait(&dev->cv, &devices_mutex);
     300                                fibril_condvar_wait(&dev->cv, &services_mutex);
    300301                                goto restart;
    301302                        }
     
    304305                }
    305306               
    306                 fibril_mutex_unlock(&devices_mutex);
     307                fibril_mutex_unlock(&services_mutex);
    307308               
    308309                return EOK;
     
    312313}
    313314
    314 static int devfs_node_put(fs_node_t *fn)
     315static int locfs_node_put(fs_node_t *fn)
    315316{
    316317        free(fn->data);
     
    319320}
    320321
    321 static int devfs_create_node(fs_node_t **rfn, devmap_handle_t devmap_handle, int lflag)
     322static int locfs_create_node(fs_node_t **rfn, service_id_t service_id, int lflag)
    322323{
    323324        assert((lflag & L_FILE) ^ (lflag & L_DIRECTORY));
     
    327328}
    328329
    329 static int devfs_destroy_node(fs_node_t *fn)
     330static int locfs_destroy_node(fs_node_t *fn)
    330331{
    331332        return ENOTSUP;
    332333}
    333334
    334 static int devfs_link_node(fs_node_t *pfn, fs_node_t *cfn, const char *nm)
     335static int locfs_link_node(fs_node_t *pfn, fs_node_t *cfn, const char *nm)
    335336{
    336337        return ENOTSUP;
    337338}
    338339
    339 static int devfs_unlink_node(fs_node_t *pfn, fs_node_t *cfn, const char *nm)
     340static int locfs_unlink_node(fs_node_t *pfn, fs_node_t *cfn, const char *nm)
    340341{
    341342        return ENOTSUP;
    342343}
    343344
    344 static int devfs_has_children(bool *has_children, fs_node_t *fn)
    345 {
    346         devfs_node_t *node = (devfs_node_t *) fn->data;
    347        
    348         if (node->handle == 0) {
    349                 size_t count = devmap_count_namespaces();
     345static int locfs_has_children(bool *has_children, fs_node_t *fn)
     346{
     347        locfs_node_t *node = (locfs_node_t *) fn->data;
     348       
     349        if (node->service_id == 0) {
     350                size_t count = loc_count_namespaces();
    350351                if (count > 0) {
    351352                        *has_children = true;
     
    354355               
    355356                /* Root namespace */
    356                 devmap_handle_t namespace;
    357                 if (devmap_namespace_get_handle("", &namespace, 0) == EOK) {
    358                         count = devmap_count_devices(namespace);
     357                service_id_t namespace;
     358                if (loc_namespace_get_id("", &namespace, 0) == EOK) {
     359                        count = loc_count_services(namespace);
    359360                        if (count > 0) {
    360361                                *has_children = true;
     
    367368        }
    368369       
    369         if (node->type == DEV_HANDLE_NAMESPACE) {
    370                 size_t count = devmap_count_devices(node->handle);
     370        if (node->type == LOC_OBJECT_NAMESPACE) {
     371                size_t count = loc_count_services(node->service_id);
    371372                if (count > 0) {
    372373                        *has_children = true;
     
    382383}
    383384
    384 static fs_index_t devfs_index_get(fs_node_t *fn)
    385 {
    386         devfs_node_t *node = (devfs_node_t *) fn->data;
    387         return node->handle;
    388 }
    389 
    390 static aoff64_t devfs_size_get(fs_node_t *fn)
     385static fs_index_t locfs_index_get(fs_node_t *fn)
     386{
     387        locfs_node_t *node = (locfs_node_t *) fn->data;
     388        return node->service_id;
     389}
     390
     391static aoff64_t locfs_size_get(fs_node_t *fn)
    391392{
    392393        return 0;
    393394}
    394395
    395 static unsigned int devfs_lnkcnt_get(fs_node_t *fn)
    396 {
    397         devfs_node_t *node = (devfs_node_t *) fn->data;
    398        
    399         if (node->handle == 0)
     396static unsigned int locfs_lnkcnt_get(fs_node_t *fn)
     397{
     398        locfs_node_t *node = (locfs_node_t *) fn->data;
     399       
     400        if (node->service_id == 0)
    400401                return 0;
    401402       
     
    403404}
    404405
    405 static char devfs_plb_get_char(unsigned pos)
    406 {
    407         return devfs_reg.plb_ro[pos % PLB_SIZE];
    408 }
    409 
    410 static bool devfs_is_directory(fs_node_t *fn)
    411 {
    412         devfs_node_t *node = (devfs_node_t *) fn->data;
    413        
    414         return ((node->type == DEV_HANDLE_NONE) || (node->type == DEV_HANDLE_NAMESPACE));
    415 }
    416 
    417 static bool devfs_is_file(fs_node_t *fn)
    418 {
    419         devfs_node_t *node = (devfs_node_t *) fn->data;
    420        
    421         return (node->type == DEV_HANDLE_DEVICE);
    422 }
    423 
    424 static devmap_handle_t devfs_device_get(fs_node_t *fn)
    425 {
    426         devfs_node_t *node = (devfs_node_t *) fn->data;
    427        
    428         if (node->type == DEV_HANDLE_DEVICE)
    429                 return node->handle;
     406static char locfs_plb_get_char(unsigned pos)
     407{
     408        return locfs_reg.plb_ro[pos % PLB_SIZE];
     409}
     410
     411static bool locfs_is_directory(fs_node_t *fn)
     412{
     413        locfs_node_t *node = (locfs_node_t *) fn->data;
     414       
     415        return ((node->type == LOC_OBJECT_NONE) || (node->type == LOC_OBJECT_NAMESPACE));
     416}
     417
     418static bool locfs_is_file(fs_node_t *fn)
     419{
     420        locfs_node_t *node = (locfs_node_t *) fn->data;
     421       
     422        return (node->type == LOC_OBJECT_SERVICE);
     423}
     424
     425static service_id_t locfs_device_get(fs_node_t *fn)
     426{
     427        locfs_node_t *node = (locfs_node_t *) fn->data;
     428       
     429        if (node->type == LOC_OBJECT_SERVICE)
     430                return node->service_id;
    430431       
    431432        return 0;
     
    433434
    434435/** libfs operations */
    435 libfs_ops_t devfs_libfs_ops = {
    436         .root_get = devfs_root_get,
    437         .match = devfs_match,
    438         .node_get = devfs_node_get,
    439         .node_open = devfs_node_open,
    440         .node_put = devfs_node_put,
    441         .create = devfs_create_node,
    442         .destroy = devfs_destroy_node,
    443         .link = devfs_link_node,
    444         .unlink = devfs_unlink_node,
    445         .has_children = devfs_has_children,
    446         .index_get = devfs_index_get,
    447         .size_get = devfs_size_get,
    448         .lnkcnt_get = devfs_lnkcnt_get,
    449         .plb_get_char = devfs_plb_get_char,
    450         .is_directory = devfs_is_directory,
    451         .is_file = devfs_is_file,
    452         .device_get = devfs_device_get
     436libfs_ops_t locfs_libfs_ops = {
     437        .root_get = locfs_root_get,
     438        .match = locfs_match,
     439        .node_get = locfs_node_get,
     440        .node_open = locfs_node_open,
     441        .node_put = locfs_node_put,
     442        .create = locfs_create_node,
     443        .destroy = locfs_destroy_node,
     444        .link = locfs_link_node,
     445        .unlink = locfs_unlink_node,
     446        .has_children = locfs_has_children,
     447        .index_get = locfs_index_get,
     448        .size_get = locfs_size_get,
     449        .lnkcnt_get = locfs_lnkcnt_get,
     450        .plb_get_char = locfs_plb_get_char,
     451        .is_directory = locfs_is_directory,
     452        .is_file = locfs_is_file,
     453        .device_get = locfs_device_get
    453454};
    454455
    455 bool devfs_init(void)
    456 {
    457         if (!hash_table_create(&devices, DEVICES_BUCKETS,
    458             DEVICES_KEYS, &devices_ops))
     456bool locfs_init(void)
     457{
     458        if (!hash_table_create(&services, SERVICES_BUCKETS,
     459            SERVICES_KEYS, &services_ops))
    459460                return false;
    460461       
     
    462463}
    463464
    464 void devfs_mounted(ipc_callid_t rid, ipc_call_t *request)
     465void locfs_mounted(ipc_callid_t rid, ipc_call_t *request)
    465466{
    466467        char *opts;
     
    478479}
    479480
    480 void devfs_mount(ipc_callid_t rid, ipc_call_t *request)
    481 {
    482         libfs_mount(&devfs_libfs_ops, devfs_reg.fs_handle, rid, request);
    483 }
    484 
    485 void devfs_unmounted(ipc_callid_t rid, ipc_call_t *request)
     481void locfs_mount(ipc_callid_t rid, ipc_call_t *request)
     482{
     483        libfs_mount(&locfs_libfs_ops, locfs_reg.fs_handle, rid, request);
     484}
     485
     486void locfs_unmounted(ipc_callid_t rid, ipc_call_t *request)
    486487{
    487488        async_answer_0(rid, ENOTSUP);
    488489}
    489490
    490 void devfs_unmount(ipc_callid_t rid, ipc_call_t *request)
    491 {
    492         libfs_unmount(&devfs_libfs_ops, rid, request);
    493 }
    494 
    495 void devfs_lookup(ipc_callid_t rid, ipc_call_t *request)
    496 {
    497         libfs_lookup(&devfs_libfs_ops, devfs_reg.fs_handle, rid, request);
    498 }
    499 
    500 void devfs_open_node(ipc_callid_t rid, ipc_call_t *request)
    501 {
    502         libfs_open_node(&devfs_libfs_ops, devfs_reg.fs_handle, rid, request);
    503 }
    504 
    505 void devfs_stat(ipc_callid_t rid, ipc_call_t *request)
    506 {
    507         libfs_stat(&devfs_libfs_ops, devfs_reg.fs_handle, rid, request);
    508 }
    509 
    510 void devfs_read(ipc_callid_t rid, ipc_call_t *request)
     491void locfs_unmount(ipc_callid_t rid, ipc_call_t *request)
     492{
     493        libfs_unmount(&locfs_libfs_ops, rid, request);
     494}
     495
     496void locfs_lookup(ipc_callid_t rid, ipc_call_t *request)
     497{
     498        libfs_lookup(&locfs_libfs_ops, locfs_reg.fs_handle, rid, request);
     499}
     500
     501void locfs_open_node(ipc_callid_t rid, ipc_call_t *request)
     502{
     503        libfs_open_node(&locfs_libfs_ops, locfs_reg.fs_handle, rid, request);
     504}
     505
     506void locfs_stat(ipc_callid_t rid, ipc_call_t *request)
     507{
     508        libfs_stat(&locfs_libfs_ops, locfs_reg.fs_handle, rid, request);
     509}
     510
     511void locfs_read(ipc_callid_t rid, ipc_call_t *request)
    511512{
    512513        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
     
    523524                }
    524525               
    525                 dev_desc_t *desc;
    526                 size_t count = devmap_get_namespaces(&desc);
     526                loc_sdesc_t *desc;
     527                size_t count = loc_get_namespaces(&desc);
    527528               
    528529                /* Get rid of root namespace */
     
    548549               
    549550                /* Search root namespace */
    550                 devmap_handle_t namespace;
    551                 if (devmap_namespace_get_handle("", &namespace, 0) == EOK) {
    552                         count = devmap_get_devices(namespace, &desc);
     551                service_id_t namespace;
     552                if (loc_namespace_get_id("", &namespace, 0) == EOK) {
     553                        count = loc_get_services(namespace, &desc);
    553554                       
    554555                        if (pos < count) {
     
    567568        }
    568569       
    569         devmap_handle_type_t type = devmap_handle_probe(index);
    570        
    571         if (type == DEV_HANDLE_NAMESPACE) {
     570        loc_object_type_t type = loc_id_probe(index);
     571       
     572        if (type == LOC_OBJECT_NAMESPACE) {
    572573                /* Namespace directory */
    573574                ipc_callid_t callid;
     
    579580                }
    580581               
    581                 dev_desc_t *desc;
    582                 size_t count = devmap_get_devices(index, &desc);
     582                loc_sdesc_t *desc;
     583                size_t count = loc_get_services(index, &desc);
    583584               
    584585                if (pos < count) {
     
    595596        }
    596597       
    597         if (type == DEV_HANDLE_DEVICE) {
     598        if (type == LOC_OBJECT_SERVICE) {
    598599                /* Device node */
    599600               
    600601                unsigned long key[] = {
    601                         [DEVICES_KEY_HANDLE] = (unsigned long) index
     602                        [SERVICES_KEY_HANDLE] = (unsigned long) index
    602603                };
    603604               
    604                 fibril_mutex_lock(&devices_mutex);
    605                 link_t *lnk = hash_table_find(&devices, key);
     605                fibril_mutex_lock(&services_mutex);
     606                link_t *lnk = hash_table_find(&services, key);
    606607                if (lnk == NULL) {
    607                         fibril_mutex_unlock(&devices_mutex);
     608                        fibril_mutex_unlock(&services_mutex);
    608609                        async_answer_0(rid, ENOENT);
    609610                        return;
    610611                }
    611612               
    612                 device_t *dev = hash_table_get_instance(lnk, device_t, link);
     613                service_t *dev = hash_table_get_instance(lnk, service_t, link);
    613614                assert(dev->sess);
    614615               
    615616                ipc_callid_t callid;
    616617                if (!async_data_read_receive(&callid, NULL)) {
    617                         fibril_mutex_unlock(&devices_mutex);
     618                        fibril_mutex_unlock(&services_mutex);
    618619                        async_answer_0(callid, EINVAL);
    619620                        async_answer_0(rid, EINVAL);
     
    634635                async_exchange_end(exch);
    635636               
    636                 fibril_mutex_unlock(&devices_mutex);
     637                fibril_mutex_unlock(&services_mutex);
    637638               
    638639                /* Wait for reply from the driver. */
     
    649650}
    650651
    651 void devfs_write(ipc_callid_t rid, ipc_call_t *request)
     652void locfs_write(ipc_callid_t rid, ipc_call_t *request)
    652653{
    653654        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
     
    657658        }
    658659       
    659         devmap_handle_type_t type = devmap_handle_probe(index);
    660        
    661         if (type == DEV_HANDLE_NAMESPACE) {
     660        loc_object_type_t type = loc_id_probe(index);
     661       
     662        if (type == LOC_OBJECT_NAMESPACE) {
    662663                /* Namespace directory */
    663664                async_answer_0(rid, ENOTSUP);
     
    665666        }
    666667       
    667         if (type == DEV_HANDLE_DEVICE) {
     668        if (type == LOC_OBJECT_SERVICE) {
    668669                /* Device node */
    669670                unsigned long key[] = {
    670                         [DEVICES_KEY_HANDLE] = (unsigned long) index
     671                        [SERVICES_KEY_HANDLE] = (unsigned long) index
    671672                };
    672673               
    673                 fibril_mutex_lock(&devices_mutex);
    674                 link_t *lnk = hash_table_find(&devices, key);
     674                fibril_mutex_lock(&services_mutex);
     675                link_t *lnk = hash_table_find(&services, key);
    675676                if (lnk == NULL) {
    676                         fibril_mutex_unlock(&devices_mutex);
     677                        fibril_mutex_unlock(&services_mutex);
    677678                        async_answer_0(rid, ENOENT);
    678679                        return;
    679680                }
    680681               
    681                 device_t *dev = hash_table_get_instance(lnk, device_t, link);
     682                service_t *dev = hash_table_get_instance(lnk, service_t, link);
    682683                assert(dev->sess);
    683684               
    684685                ipc_callid_t callid;
    685686                if (!async_data_write_receive(&callid, NULL)) {
    686                         fibril_mutex_unlock(&devices_mutex);
     687                        fibril_mutex_unlock(&services_mutex);
    687688                        async_answer_0(callid, EINVAL);
    688689                        async_answer_0(rid, EINVAL);
     
    703704                async_exchange_end(exch);
    704705               
    705                 fibril_mutex_unlock(&devices_mutex);
     706                fibril_mutex_unlock(&services_mutex);
    706707               
    707708                /* Wait for reply from the driver. */
     
    718719}
    719720
    720 void devfs_truncate(ipc_callid_t rid, ipc_call_t *request)
     721void locfs_truncate(ipc_callid_t rid, ipc_call_t *request)
    721722{
    722723        async_answer_0(rid, ENOTSUP);
    723724}
    724725
    725 void devfs_close(ipc_callid_t rid, ipc_call_t *request)
     726void locfs_close(ipc_callid_t rid, ipc_call_t *request)
    726727{
    727728        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
     
    732733        }
    733734       
    734         devmap_handle_type_t type = devmap_handle_probe(index);
    735        
    736         if (type == DEV_HANDLE_NAMESPACE) {
     735        loc_object_type_t type = loc_id_probe(index);
     736       
     737        if (type == LOC_OBJECT_NAMESPACE) {
    737738                /* Namespace directory */
    738739                async_answer_0(rid, EOK);
     
    740741        }
    741742       
    742         if (type == DEV_HANDLE_DEVICE) {
     743        if (type == LOC_OBJECT_SERVICE) {
    743744                unsigned long key[] = {
    744                         [DEVICES_KEY_HANDLE] = (unsigned long) index
     745                        [SERVICES_KEY_HANDLE] = (unsigned long) index
    745746                };
    746747               
    747                 fibril_mutex_lock(&devices_mutex);
    748                 link_t *lnk = hash_table_find(&devices, key);
     748                fibril_mutex_lock(&services_mutex);
     749                link_t *lnk = hash_table_find(&services, key);
    749750                if (lnk == NULL) {
    750                         fibril_mutex_unlock(&devices_mutex);
     751                        fibril_mutex_unlock(&services_mutex);
    751752                        async_answer_0(rid, ENOENT);
    752753                        return;
    753754                }
    754755               
    755                 device_t *dev = hash_table_get_instance(lnk, device_t, link);
     756                service_t *dev = hash_table_get_instance(lnk, service_t, link);
    756757                assert(dev->sess);
    757758                dev->refcount--;
     
    759760                if (dev->refcount == 0) {
    760761                        async_hangup(dev->sess);
    761                         hash_table_remove(&devices, key, DEVICES_KEYS);
    762                 }
    763                
    764                 fibril_mutex_unlock(&devices_mutex);
     762                        hash_table_remove(&services, key, SERVICES_KEYS);
     763                }
     764               
     765                fibril_mutex_unlock(&services_mutex);
    765766               
    766767                async_answer_0(rid, EOK);
     
    771772}
    772773
    773 void devfs_sync(ipc_callid_t rid, ipc_call_t *request)
     774void locfs_sync(ipc_callid_t rid, ipc_call_t *request)
    774775{
    775776        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
     
    780781        }
    781782       
    782         devmap_handle_type_t type = devmap_handle_probe(index);
    783        
    784         if (type == DEV_HANDLE_NAMESPACE) {
     783        loc_object_type_t type = loc_id_probe(index);
     784       
     785        if (type == LOC_OBJECT_NAMESPACE) {
    785786                /* Namespace directory */
    786787                async_answer_0(rid, EOK);
     
    788789        }
    789790       
    790         if (type == DEV_HANDLE_DEVICE) {
     791        if (type == LOC_OBJECT_SERVICE) {
    791792                unsigned long key[] = {
    792                         [DEVICES_KEY_HANDLE] = (unsigned long) index
     793                        [SERVICES_KEY_HANDLE] = (unsigned long) index
    793794                };
    794795               
    795                 fibril_mutex_lock(&devices_mutex);
    796                 link_t *lnk = hash_table_find(&devices, key);
     796                fibril_mutex_lock(&services_mutex);
     797                link_t *lnk = hash_table_find(&services, key);
    797798                if (lnk == NULL) {
    798                         fibril_mutex_unlock(&devices_mutex);
     799                        fibril_mutex_unlock(&services_mutex);
    799800                        async_answer_0(rid, ENOENT);
    800801                        return;
    801802                }
    802803               
    803                 device_t *dev = hash_table_get_instance(lnk, device_t, link);
     804                service_t *dev = hash_table_get_instance(lnk, service_t, link);
    804805                assert(dev->sess);
    805806               
     
    813814                async_exchange_end(exch);
    814815               
    815                 fibril_mutex_unlock(&devices_mutex);
     816                fibril_mutex_unlock(&services_mutex);
    816817               
    817818                /* Wait for reply from the driver */
     
    827828}
    828829
    829 void devfs_destroy(ipc_callid_t rid, ipc_call_t *request)
     830void locfs_destroy(ipc_callid_t rid, ipc_call_t *request)
    830831{
    831832        async_answer_0(rid, ENOTSUP);
Note: See TracChangeset for help on using the changeset viewer.