Changeset 903bac0a in mainline for uspace/srv


Ignore:
Timestamp:
2011-08-19T09:00:38Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e2ab36f1
Parents:
d894fbd (diff), 42a619b (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:

Merge mainline changes.

Location:
uspace/srv
Files:
4 added
1 deleted
45 edited
6 moved

Legend:

Unmodified
Added
Removed
  • uspace/srv/bd/ata_bd/ata_bd.c

    rd894fbd r903bac0a  
    5757#include <stdint.h>
    5858#include <str.h>
    59 #include <devmap.h>
     59#include <loc.h>
    6060#include <sys/types.h>
    6161#include <inttypes.h>
     
    176176               
    177177                snprintf(name, 16, "%s/ata%udisk%d", NAMESPACE, ctl_num, i);
    178                 rc = devmap_device_register(name, &disk[i].devmap_handle);
     178                rc = loc_service_register(name, &disk[i].service_id);
    179179                if (rc != EOK) {
    180180                        printf(NAME ": Unable to register device %s.\n", name);
     
    244244        int rc;
    245245
    246         rc = devmap_driver_register(NAME, ata_bd_connection);
     246        rc = loc_server_register(NAME, ata_bd_connection);
    247247        if (rc < 0) {
    248248                printf(NAME ": Unable to register driver.\n");
     
    277277        ipc_call_t call;
    278278        sysarg_t method;
    279         devmap_handle_t dh;
     279        service_id_t dsid;
    280280        size_t comm_size;       /**< Size of the communication area. */
    281281        unsigned int flags;
     
    285285        int disk_id, i;
    286286
    287         /* Get the device handle. */
    288         dh = IPC_GET_ARG1(*icall);
     287        /* Get the device service ID. */
     288        dsid = IPC_GET_ARG1(*icall);
    289289
    290290        /* Determine which disk device is the client connecting to. */
    291291        disk_id = -1;
    292292        for (i = 0; i < MAX_DISKS; i++)
    293                 if (disk[i].devmap_handle == dh)
     293                if (disk[i].service_id == dsid)
    294294                        disk_id = i;
    295295
  • uspace/srv/bd/ata_bd/ata_bd.h

    rd894fbd r903bac0a  
    116116
    117117        fibril_mutex_t lock;
    118         devmap_handle_t devmap_handle;
     118        service_id_t service_id;
    119119} disk_t;
    120120
  • uspace/srv/bd/file_bd/file_bd.c

    rd894fbd r903bac0a  
    4545#include <as.h>
    4646#include <fibril_synch.h>
    47 #include <devmap.h>
     47#include <loc.h>
    4848#include <sys/types.h>
    4949#include <sys/typefmt.h>
     
    6161static FILE *img;
    6262
    63 static devmap_handle_t devmap_handle;
     63static service_id_t service_id;
    6464static fibril_mutex_t dev_lock;
    6565
     
    117117                return -1;
    118118
    119         rc = devmap_device_register(device_name, &devmap_handle);
     119        rc = loc_service_register(device_name, &service_id);
    120120        if (rc != EOK) {
    121121                printf(NAME ": Unable to register device '%s'.\n",
     
    142142        long img_size;
    143143
    144         rc = devmap_driver_register(NAME, file_bd_connection);
     144        rc = loc_server_register(NAME, file_bd_connection);
    145145        if (rc < 0) {
    146146                printf(NAME ": Unable to register driver.\n");
  • uspace/srv/bd/gxe_bd/gxe_bd.c

    rd894fbd r903bac0a  
    4343#include <as.h>
    4444#include <fibril_synch.h>
    45 #include <devmap.h>
     45#include <loc.h>
    4646#include <sys/types.h>
    4747#include <errno.h>
     
    9292static gxe_bd_t *dev;
    9393
    94 static devmap_handle_t devmap_handle[MAX_DISKS];
     94static service_id_t service_id[MAX_DISKS];
    9595
    9696static fibril_mutex_t dev_lock[MAX_DISKS];
     
    126126        char name[16];
    127127
    128         rc = devmap_driver_register(NAME, gxe_bd_connection);
     128        rc = loc_server_register(NAME, gxe_bd_connection);
    129129        if (rc < 0) {
    130130                printf(NAME ": Unable to register driver.\n");
     
    142142        for (i = 0; i < MAX_DISKS; i++) {
    143143                snprintf(name, 16, "%s/disk%d", NAMESPACE, i);
    144                 rc = devmap_device_register(name, &devmap_handle[i]);
     144                rc = loc_service_register(name, &service_id[i]);
    145145                if (rc != EOK) {
    146146                        printf(NAME ": Unable to register device %s.\n", name);
     
    159159        ipc_call_t call;
    160160        sysarg_t method;
    161         devmap_handle_t dh;
     161        service_id_t dsid;
    162162        unsigned int flags;
    163163        int retval;
     
    167167
    168168        /* Get the device handle. */
    169         dh = IPC_GET_ARG1(*icall);
     169        dsid = IPC_GET_ARG1(*icall);
    170170
    171171        /* Determine which disk device is the client connecting to. */
    172172        disk_id = -1;
    173173        for (i = 0; i < MAX_DISKS; i++)
    174                 if (devmap_handle[i] == dh)
     174                if (service_id[i] == dsid)
    175175                        disk_id = i;
    176176
  • uspace/srv/bd/part/guid_part/guid_part.c

    rd894fbd r903bac0a  
    5151#include <as.h>
    5252#include <fibril_synch.h>
    53 #include <devmap.h>
     53#include <loc.h>
    5454#include <sys/types.h>
    5555#include <sys/typefmt.h>
    5656#include <inttypes.h>
    5757#include <libblock.h>
    58 #include <devmap.h>
     58#include <loc.h>
    5959#include <errno.h>
    6060#include <bool.h>
     
    8181        /** Number of blocks */
    8282        aoff64_t length;
    83         /** Device representing the partition (outbound device) */
    84         devmap_handle_t dev;
     83        /** Service representing the partition (outbound device) */
     84        service_id_t dsid;
    8585        /** Points to next partition structure. */
    8686        struct part *next;
     
    9090
    9191/** Partitioned device (inbound device) */
    92 static devmap_handle_t indev_handle;
     92static service_id_t indev_sid;
    9393
    9494/** List of partitions. This structure is an empty head. */
     
    129129        int i;
    130130        char *name;
    131         devmap_handle_t dev;
     131        service_id_t dsid;
    132132        uint64_t size_mb;
    133133        part_t *part;
    134134
    135         rc = devmap_device_get_handle(dev_name, &indev_handle, 0);
     135        rc = loc_service_get_id(dev_name, &indev_sid, 0);
    136136        if (rc != EOK) {
    137137                printf(NAME ": could not resolve device `%s'.\n", dev_name);
     
    139139        }
    140140
    141         rc = block_init(EXCHANGE_SERIALIZE, indev_handle, 2048);
     141        rc = block_init(EXCHANGE_SERIALIZE, indev_sid, 2048);
    142142        if (rc != EOK)  {
    143143                printf(NAME ": could not init libblock.\n");
     
    147147        /* Determine and verify block size. */
    148148
    149         rc = block_get_bsize(indev_handle, &block_size);
     149        rc = block_get_bsize(indev_sid, &block_size);
    150150        if (rc != EOK) {
    151151                printf(NAME ": error getting block size.\n");
     
    163163                return rc;
    164164
    165         /* Register the driver with device mapper. */
    166         rc = devmap_driver_register(NAME, gpt_connection);
     165        /* Register server with location service. */
     166        rc = loc_server_register(NAME, gpt_connection);
    167167        if (rc != EOK) {
    168                 printf(NAME ": Unable to register driver.\n");
     168                printf(NAME ": Unable to register server.\n");
    169169                return rc;
    170170        }
     
    188188                        return ENOMEM;
    189189
    190                 rc = devmap_device_register(name, &dev);
     190                rc = loc_service_register(name, &dsid);
    191191                if (rc != EOK) {
    192                         printf(NAME ": Unable to register device %s.\n", name);
     192                        printf(NAME ": Unable to register service %s.\n", name);
    193193                        return rc;
    194194                }
     
    199199                    "%" PRIuOFF64 " MB.\n", name, part->length, size_mb);
    200200
    201                 part->dev = dev;
     201                part->dsid = dsid;
    202202                free(name);
    203203
     
    228228        }
    229229
    230         rc = block_read_direct(indev_handle, GPT_HDR_BA, 1, gpt_hdr);
     230        rc = block_read_direct(indev_sid, GPT_HDR_BA, 1, gpt_hdr);
    231231        if (rc != EOK) {
    232232                printf(NAME ": Failed reading GPT header block.\n");
     
    256256        }
    257257
    258         rc = block_read_direct(indev_handle, ba, bcnt, etable);
     258        rc = block_read_direct(indev_sid, ba, bcnt, etable);
    259259        if (rc != EOK) {
    260260                printf(NAME ": Failed reading GPT entries.\n");
     
    303303        }
    304304
    305         part->dev = 0;
     305        part->dsid = 0;
    306306        part->next = NULL;
    307307}
     
    314314        ipc_call_t call;
    315315        sysarg_t method;
    316         devmap_handle_t dh;
     316        service_id_t dh;
    317317        unsigned int flags;
    318318        int retval;
     
    330330         */
    331331        part = plist_head.next;
    332         while (part != NULL && part->dev != dh)
     332        while (part != NULL && part->dsid != dh)
    333333                part = part->next;
    334334
     
    410410                return ELIMIT;
    411411
    412         return block_read_direct(indev_handle, gba, cnt, buf);
     412        return block_read_direct(indev_sid, gba, cnt, buf);
    413413}
    414414
     
    421421                return ELIMIT;
    422422
    423         return block_write_direct(indev_handle, gba, cnt, buf);
     423        return block_write_direct(indev_sid, gba, cnt, buf);
    424424}
    425425
  • uspace/srv/bd/part/mbr_part/mbr_part.c

    rd894fbd r903bac0a  
    6161#include <as.h>
    6262#include <fibril_synch.h>
    63 #include <devmap.h>
     63#include <loc.h>
    6464#include <sys/types.h>
    6565#include <sys/typefmt.h>
    6666#include <inttypes.h>
    6767#include <libblock.h>
    68 #include <devmap.h>
    6968#include <errno.h>
    7069#include <bool.h>
     
    10099        aoff64_t length;
    101100        /** Device representing the partition (outbound device) */
    102         devmap_handle_t dev;
     101        service_id_t dsid;
    103102        /** Points to next partition structure. */
    104103        struct part *next;
     
    141140
    142141/** Partitioned device (inbound device) */
    143 static devmap_handle_t indev_handle;
     142static service_id_t indef_sid;
    144143
    145144/** List of partitions. This structure is an empty head. */
     
    180179        int i;
    181180        char *name;
    182         devmap_handle_t dev;
     181        service_id_t dsid;
    183182        uint64_t size_mb;
    184183        part_t *part;
    185184
    186         rc = devmap_device_get_handle(dev_name, &indev_handle, 0);
     185        rc = loc_service_get_id(dev_name, &indef_sid, 0);
    187186        if (rc != EOK) {
    188187                printf(NAME ": could not resolve device `%s'.\n", dev_name);
     
    190189        }
    191190
    192         rc = block_init(EXCHANGE_SERIALIZE, indev_handle, 2048);
     191        rc = block_init(EXCHANGE_SERIALIZE, indef_sid, 2048);
    193192        if (rc != EOK)  {
    194193                printf(NAME ": could not init libblock.\n");
     
    198197        /* Determine and verify block size. */
    199198
    200         rc = block_get_bsize(indev_handle, &block_size);
     199        rc = block_get_bsize(indef_sid, &block_size);
    201200        if (rc != EOK) {
    202201                printf(NAME ": error getting block size.\n");
     
    214213                return rc;
    215214
    216         /* Register the driver with device mapper. */
    217         rc = devmap_driver_register(NAME, mbr_connection);
     215        /* Register server with location service. */
     216        rc = loc_server_register(NAME, mbr_connection);
    218217        if (rc != EOK) {
    219                 printf(NAME ": Unable to register driver.\n");
     218                printf(NAME ": Unable to register server.\n");
    220219                return rc;
    221220        }
     
    239238                        return ENOMEM;
    240239
    241                 rc = devmap_device_register(name, &dev);
     240                rc = loc_service_register(name, &dsid);
    242241                if (rc != EOK) {
    243                         printf(NAME ": Unable to register device %s.\n", name);
     242                        printf(NAME ": Unable to register service %s.\n", name);
    244243                        return rc;
    245244                }
     
    250249                    "%" PRIu64 " MB.\n", name, part->length, size_mb);
    251250
    252                 part->dev = dev;
     251                part->dsid = dsid;
    253252                free(name);
    254253
     
    281280         */
    282281
    283         rc = block_read_direct(indev_handle, 0, 1, brb);
     282        rc = block_read_direct(indef_sid, 0, 1, brb);
    284283        if (rc != EOK) {
    285284                printf(NAME ": Failed reading MBR block.\n");
     
    332331                 */
    333332                ba = cp.start_addr;
    334                 rc = block_read_direct(indev_handle, ba, 1, brb);
     333                rc = block_read_direct(indef_sid, ba, 1, brb);
    335334                if (rc != EOK) {
    336335                        printf(NAME ": Failed reading EBR block at %"
     
    381380        part->present = (pte->ptype != PT_UNUSED) ? true : false;
    382381
    383         part->dev = 0;
     382        part->dsid = 0;
    384383        part->next = NULL;
    385384}
     
    392391        ipc_call_t call;
    393392        sysarg_t method;
    394         devmap_handle_t dh;
     393        service_id_t dh;
    395394        unsigned int flags;
    396395        int retval;
     
    408407         */
    409408        part = plist_head.next;
    410         while (part != NULL && part->dev != dh)
     409        while (part != NULL && part->dsid != dh)
    411410                part = part->next;
    412411
     
    488487                return ELIMIT;
    489488
    490         return block_read_direct(indev_handle, gba, cnt, buf);
     489        return block_read_direct(indef_sid, gba, cnt, buf);
    491490}
    492491
     
    499498                return ELIMIT;
    500499
    501         return block_write_direct(indev_handle, gba, cnt, buf);
     500        return block_write_direct(indef_sid, gba, cnt, buf);
    502501}
    503502
  • uspace/srv/bd/rd/rd.c

    rd894fbd r903bac0a  
    5252#include <fibril_synch.h>
    5353#include <stdio.h>
    54 #include <devmap.h>
     54#include <loc.h>
    5555#include <ipc/bd.h>
    5656#include <macros.h>
     
    235235            (void *) rd_ph_addr, rd_size);
    236236       
    237         int rc = devmap_driver_register(NAME, rd_connection);
     237        int rc = loc_server_register(NAME, rd_connection);
    238238        if (rc < 0) {
    239239                printf("%s: Unable to register driver (%d)\n", NAME, rc);
     
    241241        }
    242242       
    243         devmap_handle_t devmap_handle;
    244         if (devmap_device_register("bd/initrd", &devmap_handle) != EOK) {
    245                 printf("%s: Unable to register device\n", NAME);
     243        service_id_t service_id;
     244        if (loc_service_register("bd/initrd", &service_id) != EOK) {
     245                printf("%s: Unable to register device service\n", NAME);
    246246                return false;
    247247        }
  • uspace/srv/devman/devman.c

    rd894fbd r903bac0a  
    3737#include <ipc/driver.h>
    3838#include <ipc/devman.h>
    39 #include <devmap.h>
     39#include <loc.h>
    4040#include <str_error.h>
    4141#include <stdio.h>
     
    6666}
    6767
    68 static int devmap_functions_compare(unsigned long key[], hash_count_t keys,
     68static int loc_functions_compare(unsigned long key[], hash_count_t keys,
    6969    link_t *item)
    7070{
    71         fun_node_t *fun = hash_table_get_instance(item, fun_node_t, devmap_fun);
    72         return (fun->devmap_handle == (devmap_handle_t) key[0]);
    73 }
    74 
    75 static int devmap_devices_class_compare(unsigned long key[], hash_count_t keys,
    76     link_t *item)
    77 {
    78         dev_class_info_t *class_info
    79             = hash_table_get_instance(item, dev_class_info_t, devmap_link);
    80         assert(class_info != NULL);
    81 
    82         return (class_info->devmap_handle == (devmap_handle_t) key[0]);
     71        fun_node_t *fun = hash_table_get_instance(item, fun_node_t, loc_fun);
     72        return (fun->service_id == (service_id_t) key[0]);
    8373}
    8474
     
    9989};
    10090
    101 static hash_table_operations_t devmap_devices_ops = {
     91static hash_table_operations_t loc_devices_ops = {
    10292        .hash = devices_hash,
    103         .compare = devmap_functions_compare,
    104         .remove_callback = devices_remove_callback
    105 };
    106 
    107 static hash_table_operations_t devmap_devices_class_ops = {
    108         .hash = devices_hash,
    109         .compare = devmap_devices_class_compare,
     93        .compare = loc_functions_compare,
    11094        .remove_callback = devices_remove_callback
    11195};
     
    701685}
    702686
    703 /** Create devmap path and name for the function. */
    704 void devmap_register_tree_function(fun_node_t *fun, dev_tree_t *tree)
    705 {
    706         char *devmap_pathname = NULL;
    707         char *devmap_name = NULL;
    708        
    709         asprintf(&devmap_name, "%s", fun->pathname);
    710         if (devmap_name == NULL)
     687/** Create loc path and name for the function. */
     688void loc_register_tree_function(fun_node_t *fun, dev_tree_t *tree)
     689{
     690        char *loc_pathname = NULL;
     691        char *loc_name = NULL;
     692       
     693        asprintf(&loc_name, "%s", fun->pathname);
     694        if (loc_name == NULL)
    711695                return;
    712696       
    713         replace_char(devmap_name, '/', DEVMAP_SEPARATOR);
    714        
    715         asprintf(&devmap_pathname, "%s/%s", DEVMAP_DEVICE_NAMESPACE,
    716             devmap_name);
    717         if (devmap_pathname == NULL) {
    718                 free(devmap_name);
     697        replace_char(loc_name, '/', LOC_SEPARATOR);
     698       
     699        asprintf(&loc_pathname, "%s/%s", LOC_DEVICE_NAMESPACE,
     700            loc_name);
     701        if (loc_pathname == NULL) {
     702                free(loc_name);
    719703                return;
    720704        }
    721705       
    722         devmap_device_register_with_iface(devmap_pathname,
    723             &fun->devmap_handle, DEVMAN_CONNECT_FROM_DEVMAP);
    724        
    725         tree_add_devmap_function(tree, fun);
    726        
    727         free(devmap_name);
    728         free(devmap_pathname);
     706        loc_service_register_with_iface(loc_pathname,
     707            &fun->service_id, DEVMAN_CONNECT_FROM_LOC);
     708       
     709        tree_add_loc_function(tree, fun);
     710       
     711        free(loc_name);
     712        free(loc_pathname);
    729713}
    730714
     
    856840        hash_table_create(&tree->devman_functions, DEVICE_BUCKETS, 1,
    857841            &devman_functions_ops);
    858         hash_table_create(&tree->devmap_functions, DEVICE_BUCKETS, 1,
    859             &devmap_devices_ops);
     842        hash_table_create(&tree->loc_functions, DEVICE_BUCKETS, 1,
     843            &loc_devices_ops);
    860844       
    861845        fibril_rwlock_initialize(&tree->rwlock);
     
    950934                link_initialize(&res->dev_functions);
    951935                list_initialize(&res->match_ids.ids);
    952                 list_initialize(&res->classes);
    953936                link_initialize(&res->devman_fun);
    954                 link_initialize(&res->devmap_fun);
     937                link_initialize(&res->loc_fun);
    955938        }
    956939       
     
    11151098       
    11161099        return true;
     1100}
     1101
     1102/** Remove function from device tree.
     1103 *
     1104 * @param tree          Device tree
     1105 * @param node          Function node to remove
     1106 */
     1107void remove_fun_node(dev_tree_t *tree, fun_node_t *fun)
     1108{
     1109        assert(tree != NULL);
     1110        assert(fun != NULL);
     1111        assert(fibril_rwlock_is_write_locked(&tree->rwlock));
     1112       
     1113        /* Remove the node from the handle-to-node map. */
     1114        unsigned long key = fun->handle;
     1115        hash_table_remove(&tree->devman_functions, &key, 1);
     1116       
     1117        /* Remove the node from the list of its parent's children. */
     1118        if (fun->dev != NULL)
     1119                list_remove(&fun->dev_functions);
    11171120}
    11181121
     
    11931196}
    11941197
    1195 /** Find function node by its class name and index. */
    1196 fun_node_t *find_fun_node_by_class(class_list_t *class_list,
    1197     const char *class_name, const char *dev_name)
    1198 {
    1199         assert(class_list != NULL);
    1200         assert(class_name != NULL);
    1201         assert(dev_name != NULL);
    1202 
    1203         fibril_rwlock_read_lock(&class_list->rwlock);
    1204 
    1205         dev_class_t *cl = find_dev_class_no_lock(class_list, class_name);
    1206         if (cl == NULL) {
    1207                 fibril_rwlock_read_unlock(&class_list->rwlock);
    1208                 return NULL;
    1209         }
    1210 
    1211         dev_class_info_t *dev = find_dev_in_class(cl, dev_name);
    1212         if (dev == NULL) {
    1213                 fibril_rwlock_read_unlock(&class_list->rwlock);
    1214                 return NULL;
    1215         }
    1216 
    1217         fun_node_t *fun = dev->fun;
    1218 
    1219         fibril_rwlock_read_unlock(&class_list->rwlock);
    1220 
    1221         return fun;
    1222 }
    1223 
    1224 
    12251198/** Find child function node with a specified name.
    12261199 *
     
    12361209}
    12371210
    1238 /* Device classes */
    1239 
    1240 /** Create device class.
    1241  *
    1242  * @return      Device class.
    1243  */
    1244 dev_class_t *create_dev_class(void)
    1245 {
    1246         dev_class_t *cl;
    1247        
    1248         cl = (dev_class_t *) malloc(sizeof(dev_class_t));
    1249         if (cl != NULL) {
    1250                 memset(cl, 0, sizeof(dev_class_t));
    1251                 list_initialize(&cl->devices);
    1252                 fibril_mutex_initialize(&cl->mutex);
    1253         }
    1254        
    1255         return cl;
    1256 }
    1257 
    1258 /** Create device class info.
    1259  *
    1260  * @return              Device class info.
    1261  */
    1262 dev_class_info_t *create_dev_class_info(void)
    1263 {
    1264         dev_class_info_t *info;
    1265        
    1266         info = (dev_class_info_t *) malloc(sizeof(dev_class_info_t));
    1267         if (info != NULL) {
    1268                 memset(info, 0, sizeof(dev_class_info_t));
    1269                 link_initialize(&info->dev_classes);
    1270                 link_initialize(&info->devmap_link);
    1271                 link_initialize(&info->link);
    1272         }
    1273        
    1274         return info;
    1275 }
    1276 
    1277 size_t get_new_class_dev_idx(dev_class_t *cl)
    1278 {
    1279         size_t dev_idx;
    1280        
    1281         fibril_mutex_lock(&cl->mutex);
    1282         dev_idx = ++cl->curr_dev_idx;
    1283         fibril_mutex_unlock(&cl->mutex);
    1284        
    1285         return dev_idx;
    1286 }
    1287 
    1288 
    1289 /** Create unique device name within the class.
    1290  *
    1291  * @param cl            The class.
    1292  * @param base_dev_name Contains the base name for the device if it was
    1293  *                      specified by the driver when it registered the device by
    1294  *                      the class; NULL if driver specified no base name.
    1295  * @return              The unique name for the device within the class.
    1296  */
    1297 char *create_dev_name_for_class(dev_class_t *cl, const char *base_dev_name)
    1298 {
    1299         char *dev_name;
    1300         const char *base_name;
    1301        
    1302         if (base_dev_name != NULL)
    1303                 base_name = base_dev_name;
    1304         else
    1305                 base_name = cl->base_dev_name;
    1306        
    1307         size_t idx = get_new_class_dev_idx(cl);
    1308         asprintf(&dev_name, "%s%zu", base_name, idx);
    1309        
    1310         return dev_name;
    1311 }
    1312 
    1313 /** Add the device function to the class.
    1314  *
    1315  * The device may be added to multiple classes and a class may contain multiple
    1316  * devices. The class and the device are associated with each other by the
    1317  * dev_class_info_t structure.
    1318  *
    1319  * @param dev           The device.
    1320  * @param class         The class.
    1321  * @param base_dev_name The base name of the device within the class if
    1322  *                      specified by the driver, NULL otherwise.
    1323  * @return              dev_class_info_t structure which associates the device
    1324  *                      with the class.
    1325  */
    1326 dev_class_info_t *add_function_to_class(fun_node_t *fun, dev_class_t *cl,
    1327     const char *base_dev_name)
    1328 {
    1329         dev_class_info_t *info;
    1330 
    1331         assert(fun != NULL);
    1332         assert(cl != NULL);
    1333 
    1334         info = create_dev_class_info();
    1335 
    1336        
    1337         if (info != NULL) {
    1338                 info->dev_class = cl;
    1339                 info->fun = fun;
    1340                
    1341                 /* Add the device to the class. */
    1342                 fibril_mutex_lock(&cl->mutex);
    1343                 list_append(&info->link, &cl->devices);
    1344                 fibril_mutex_unlock(&cl->mutex);
    1345                
    1346                 /* Add the class to the device. */
    1347                 list_append(&info->dev_classes, &fun->classes);
    1348                
    1349                 /* Create unique name for the device within the class. */
    1350                 info->dev_name = create_dev_name_for_class(cl, base_dev_name);
    1351         }
    1352        
    1353         return info;
    1354 }
    1355 
    1356 dev_class_t *get_dev_class(class_list_t *class_list, char *class_name)
    1357 {
    1358         dev_class_t *cl;
    1359        
    1360         fibril_rwlock_write_lock(&class_list->rwlock);
    1361         cl = find_dev_class_no_lock(class_list, class_name);
    1362         if (cl == NULL) {
    1363                 cl = create_dev_class();
    1364                 if (cl != NULL) {
    1365                         cl->name = class_name;
    1366                         cl->base_dev_name = "";
    1367                         add_dev_class_no_lock(class_list, cl);
    1368                 }
    1369         }
    1370 
    1371         fibril_rwlock_write_unlock(&class_list->rwlock);
    1372         return cl;
    1373 }
    1374 
    1375 dev_class_t *find_dev_class_no_lock(class_list_t *class_list,
    1376     const char *class_name)
    1377 {
    1378         dev_class_t *cl;
    1379        
    1380         list_foreach(class_list->classes, link) {
    1381                 cl = list_get_instance(link, dev_class_t, link);
    1382                 if (str_cmp(cl->name, class_name) == 0) {
    1383                         return cl;
    1384                 }
    1385         }
    1386        
    1387         return NULL;
    1388 }
    1389 
    1390 void add_dev_class_no_lock(class_list_t *class_list, dev_class_t *cl)
    1391 {
    1392         list_append(&cl->link, &class_list->classes);
    1393 }
    1394 
    1395 dev_class_info_t *find_dev_in_class(dev_class_t *dev_class, const char *dev_name)
    1396 {
    1397         assert(dev_class != NULL);
    1398         assert(dev_name != NULL);
    1399 
    1400         list_foreach(dev_class->devices, link) {
    1401                 dev_class_info_t *dev = list_get_instance(link,
    1402                     dev_class_info_t, link);
    1403 
    1404                 if (str_cmp(dev->dev_name, dev_name) == 0) {
    1405                         return dev;
    1406                 }
    1407         }
    1408 
    1409         return NULL;
    1410 }
    1411 
    1412 void init_class_list(class_list_t *class_list)
    1413 {
    1414         list_initialize(&class_list->classes);
    1415         fibril_rwlock_initialize(&class_list->rwlock);
    1416         hash_table_create(&class_list->devmap_functions, DEVICE_BUCKETS, 1,
    1417             &devmap_devices_class_ops);
    1418 }
    1419 
    1420 
    1421 /* Devmap devices */
    1422 
    1423 fun_node_t *find_devmap_tree_function(dev_tree_t *tree, devmap_handle_t devmap_handle)
     1211/* loc devices */
     1212
     1213fun_node_t *find_loc_tree_function(dev_tree_t *tree, service_id_t service_id)
    14241214{
    14251215        fun_node_t *fun = NULL;
    14261216        link_t *link;
    1427         unsigned long key = (unsigned long) devmap_handle;
     1217        unsigned long key = (unsigned long) service_id;
    14281218       
    14291219        fibril_rwlock_read_lock(&tree->rwlock);
    1430         link = hash_table_find(&tree->devmap_functions, &key);
     1220        link = hash_table_find(&tree->loc_functions, &key);
    14311221        if (link != NULL)
    1432                 fun = hash_table_get_instance(link, fun_node_t, devmap_fun);
     1222                fun = hash_table_get_instance(link, fun_node_t, loc_fun);
    14331223        fibril_rwlock_read_unlock(&tree->rwlock);
    14341224       
     
    14361226}
    14371227
    1438 fun_node_t *find_devmap_class_function(class_list_t *classes,
    1439     devmap_handle_t devmap_handle)
    1440 {
    1441         fun_node_t *fun = NULL;
    1442         dev_class_info_t *cli;
    1443         link_t *link;
    1444         unsigned long key = (unsigned long)devmap_handle;
    1445        
    1446         fibril_rwlock_read_lock(&classes->rwlock);
    1447         link = hash_table_find(&classes->devmap_functions, &key);
    1448         if (link != NULL) {
    1449                 cli = hash_table_get_instance(link, dev_class_info_t,
    1450                     devmap_link);
    1451                 fun = cli->fun;
    1452         }
    1453         fibril_rwlock_read_unlock(&classes->rwlock);
    1454        
    1455         return fun;
    1456 }
    1457 
    1458 void class_add_devmap_function(class_list_t *class_list, dev_class_info_t *cli)
    1459 {
    1460         unsigned long key = (unsigned long) cli->devmap_handle;
    1461        
    1462         fibril_rwlock_write_lock(&class_list->rwlock);
    1463         hash_table_insert(&class_list->devmap_functions, &key, &cli->devmap_link);
    1464         fibril_rwlock_write_unlock(&class_list->rwlock);
    1465 
    1466         assert(find_devmap_class_function(class_list, cli->devmap_handle) != NULL);
    1467 }
    1468 
    1469 void tree_add_devmap_function(dev_tree_t *tree, fun_node_t *fun)
    1470 {
    1471         unsigned long key = (unsigned long) fun->devmap_handle;
     1228void tree_add_loc_function(dev_tree_t *tree, fun_node_t *fun)
     1229{
     1230        unsigned long key = (unsigned long) fun->service_id;
    14721231        fibril_rwlock_write_lock(&tree->rwlock);
    1473         hash_table_insert(&tree->devmap_functions, &key, &fun->devmap_fun);
     1232        hash_table_insert(&tree->loc_functions, &key, &fun->loc_fun);
    14741233        fibril_rwlock_write_unlock(&tree->rwlock);
    14751234}
  • uspace/srv/devman/devman.h

    rd894fbd r903bac0a  
    11/*
    22 * Copyright (c) 2010 Lenka Trochtova
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    4142#include <adt/hash_table.h>
    4243#include <ipc/devman.h>
    43 #include <ipc/devmap.h>
     44#include <ipc/loc.h>
    4445#include <fibril_synch.h>
    4546#include <atomic.h>
     
    5354#define DEVICE_BUCKETS 256
    5455
    55 #define DEVMAP_CLASS_NAMESPACE "class"
    56 #define DEVMAP_DEVICE_NAMESPACE "devices"
    57 #define DEVMAP_SEPARATOR '\\'
     56#define LOC_DEVICE_NAMESPACE "devices"
     57#define LOC_SEPARATOR '\\'
    5858
    5959struct dev_node;
     
    155155        /** Name of the function, assigned by the device driver */
    156156        char *name;
     157        /** Function type */
     158        fun_type_t ftype;
    157159       
    158160        /** Full path and name of the device in device hierarchy */
     
    170172        match_id_list_t match_ids;
    171173       
    172         /** List of device classes to which this device function belongs. */
    173         list_t classes;
    174         /** Devmap handle if the device function is registered by devmap. */
    175         devmap_handle_t devmap_handle;
     174        /** Service ID if the device function is registered with loc. */
     175        service_id_t service_id;
    176176       
    177177        /**
     
    181181       
    182182        /**
    183          * Used by the hash table of functions indexed by devmap device handles.
    184          */
    185         link_t devmap_fun;
     183         * Used by the hash table of functions indexed by service IDs.
     184         */
     185        link_t loc_fun;
    186186};
    187187
     
    208208       
    209209        /**
    210          * Hash table of devices registered by devmapper, indexed by devmap
    211          * handles.
    212          */
    213         hash_table_t devmap_functions;
     210         * Hash table of services registered with location service, indexed by
     211         * service IDs.
     212         */
     213        hash_table_t loc_functions;
    214214} dev_tree_t;
    215 
    216 typedef struct dev_class {
    217         /** The name of the class. */
    218         const char *name;
    219        
    220         /**
    221          * Pointer to the previous and next class in the list of registered
    222          * classes.
    223          */
    224         link_t link;
    225        
    226         /**
    227          * List of dev_class_info structures - one for each device registered by
    228          * this class.
    229          */
    230         list_t devices;
    231        
    232         /**
    233          * Default base name for the device within the class, might be overrided
    234          * by the driver.
    235          */
    236         const char *base_dev_name;
    237        
    238         /** Unique numerical identifier of the newly added device. */
    239         size_t curr_dev_idx;
    240         /** Synchronize access to the list of devices in this class. */
    241         fibril_mutex_t mutex;
    242 } dev_class_t;
    243 
    244 /**
    245  * Provides n-to-m mapping between function nodes and classes - each function
    246  * can register in an arbitrary number of classes and each class can contain
    247  * an arbitrary number of device functions.
    248  */
    249 typedef struct dev_class_info {
    250         /** The class. */
    251         dev_class_t *dev_class;
    252         /** The device. */
    253         fun_node_t *fun;
    254        
    255         /**
    256          * Pointer to the previous and next class info in the list of devices
    257          * registered by the class.
    258          */
    259         link_t link;
    260        
    261         /**
    262          * Pointer to the previous and next class info in the list of classes
    263          * by which the device is registered.
    264          */
    265         link_t dev_classes;
    266        
    267         /** The name of the device function within the class. */
    268         char *dev_name;
    269         /** The handle of the device by device mapper in the class namespace. */
    270         devmap_handle_t devmap_handle;
    271        
    272         /**
    273          * Link in the hash table of devices registered by the devmapper using
    274          * their class names.
    275          */
    276         link_t devmap_link;
    277 } dev_class_info_t;
    278 
    279 /** The list of device classes. */
    280 typedef struct class_list {
    281         /** List of classes. */
    282         list_t classes;
    283        
    284         /**
    285          * Hash table of devices registered by devmapper using their class name,
    286          * indexed by devmap handles.
    287          */
    288         hash_table_t devmap_functions;
    289        
    290         /** Fibril mutex for list of classes. */
    291         fibril_rwlock_t rwlock;
    292 } class_list_t;
    293215
    294216/* Match ids and scores */
     
    339261extern fun_node_t *find_fun_node_by_path(dev_tree_t *, char *);
    340262extern fun_node_t *find_fun_node_in_device(dev_node_t *, const char *);
    341 extern fun_node_t *find_fun_node_by_class(class_list_t *, const char *, const char *);
    342263
    343264/* Device tree */
     
    347268extern bool insert_dev_node(dev_tree_t *, dev_node_t *, fun_node_t *);
    348269extern bool insert_fun_node(dev_tree_t *, fun_node_t *, char *, dev_node_t *);
    349 
    350 /* Device classes */
    351 
    352 extern dev_class_t *create_dev_class(void);
    353 extern dev_class_info_t *create_dev_class_info(void);
    354 extern size_t get_new_class_dev_idx(dev_class_t *);
    355 extern char *create_dev_name_for_class(dev_class_t *, const char *);
    356 extern dev_class_info_t *add_function_to_class(fun_node_t *, dev_class_t *,
    357     const char *);
    358 
    359 extern void init_class_list(class_list_t *);
    360 
    361 extern dev_class_t *get_dev_class(class_list_t *, char *);
    362 extern dev_class_t *find_dev_class_no_lock(class_list_t *, const char *);
    363 extern dev_class_info_t *find_dev_in_class(dev_class_t *, const char *);
    364 extern void add_dev_class_no_lock(class_list_t *, dev_class_t *);
    365 
    366 /* Devmap devices */
    367 
    368 extern void devmap_register_tree_function(fun_node_t *, dev_tree_t *);
    369 
    370 extern fun_node_t *find_devmap_tree_function(dev_tree_t *, devmap_handle_t);
    371 extern fun_node_t *find_devmap_class_function(class_list_t *, devmap_handle_t);
    372 
    373 extern void class_add_devmap_function(class_list_t *, dev_class_info_t *);
    374 extern void tree_add_devmap_function(dev_tree_t *, fun_node_t *);
     270extern void remove_fun_node(dev_tree_t *, fun_node_t *);
     271
     272/* Loc services */
     273
     274extern void loc_register_tree_function(fun_node_t *, dev_tree_t *);
     275
     276extern fun_node_t *find_loc_tree_function(dev_tree_t *, service_id_t);
     277
     278extern void tree_add_loc_function(dev_tree_t *, fun_node_t *);
    375279
    376280#endif
  • uspace/srv/devman/main.c

    rd894fbd r903bac0a  
    5656#include <ipc/driver.h>
    5757#include <thread.h>
    58 #include <devmap.h>
     58#include <loc.h>
    5959
    6060#include "devman.h"
     
    6464static driver_list_t drivers_list;
    6565static dev_tree_t device_tree;
    66 static class_list_t class_list;
    6766
    6867/** Register running driver. */
     
    279278                return;
    280279        }
    281 
     280       
    282281        fun_node_t *fun = create_fun_node();
     282        fun->ftype = ftype;
     283       
    283284        if (!insert_fun_node(&device_tree, fun, fun_name, pdev)) {
    284285                fibril_rwlock_write_unlock(&tree->rwlock);
     
    326327                }
    327328        } else {
    328                 devmap_register_tree_function(fun, tree);
     329                loc_register_tree_function(fun, tree);
    329330        }
    330331       
     
    333334}
    334335
    335 static void devmap_register_class_dev(dev_class_info_t *cli)
    336 {
    337         /* Create devmap path and name for the device. */
    338         char *devmap_pathname = NULL;
    339 
    340         asprintf(&devmap_pathname, "%s/%s%c%s", DEVMAP_CLASS_NAMESPACE,
    341             cli->dev_class->name, DEVMAP_SEPARATOR, cli->dev_name);
    342         if (devmap_pathname == NULL)
    343                 return;
    344        
    345         /*
    346          * Register the device by the device mapper and remember its devmap
    347          * handle.
    348          */
    349         devmap_device_register_with_iface(devmap_pathname,
    350             &cli->devmap_handle, DEVMAN_CONNECT_FROM_DEVMAP);
    351        
    352         /*
    353          * Add device to the hash map of class devices registered by device
    354          * mapper.
    355          */
    356         class_add_devmap_function(&class_list, cli);
    357        
    358         free(devmap_pathname);
    359 }
    360 
    361 static void devman_add_function_to_class(ipc_callid_t callid, ipc_call_t *call)
     336static void devman_add_function_to_cat(ipc_callid_t callid, ipc_call_t *call)
    362337{
    363338        devman_handle_t handle = IPC_GET_ARG1(*call);
    364        
    365         /* Get class name. */
    366         char *class_name;
    367         int rc = async_data_write_accept((void **) &class_name, true,
     339        category_id_t cat_id;
     340        int rc;
     341       
     342        /* Get category name. */
     343        char *cat_name;
     344        rc = async_data_write_accept((void **) &cat_name, true,
    368345            0, 0, 0, 0);
    369346        if (rc != EOK) {
     
    378355        }
    379356       
    380         dev_class_t *cl = get_dev_class(&class_list, class_name);
    381         dev_class_info_t *class_info = add_function_to_class(fun, cl, NULL);
    382        
    383         /* Register the device's class alias by devmapper. */
    384         devmap_register_class_dev(class_info);
    385        
    386         log_msg(LVL_NOTE, "Function `%s' added to class `%s' as `%s'.",
    387             fun->pathname, class_name, class_info->dev_name);
    388 
     357        rc = loc_category_get_id(cat_name, &cat_id, IPC_FLAG_BLOCKING);
     358        if (rc == EOK) {
     359                loc_service_add_to_cat(fun->service_id, cat_id);
     360        } else {
     361                log_msg(LVL_ERROR, "Failed adding function `%s' to category "
     362                    "`%s'.", fun->pathname, cat_name);
     363        }
     364       
     365        log_msg(LVL_NOTE, "Function `%s' added to category `%s'.",
     366            fun->pathname, cat_name);
     367
     368        async_answer_0(callid, EOK);
     369}
     370
     371/** Remove function. */
     372static void devman_remove_function(ipc_callid_t callid, ipc_call_t *call)
     373{
     374        devman_handle_t fun_handle = IPC_GET_ARG1(*call);
     375        dev_tree_t *tree = &device_tree;
     376        int rc;
     377       
     378        fibril_rwlock_write_lock(&tree->rwlock);
     379       
     380        fun_node_t *fun = find_fun_node_no_lock(&device_tree, fun_handle);
     381        if (fun == NULL) {
     382                fibril_rwlock_write_unlock(&tree->rwlock);
     383                async_answer_0(callid, ENOENT);
     384                return;
     385        }
     386       
     387        log_msg(LVL_DEBUG, "devman_remove_function(fun='%s')", fun->pathname);
     388       
     389        if (fun->ftype == fun_inner) {
     390                /* Handle possible descendants */
     391                /* TODO */
     392                log_msg(LVL_WARN, "devman_remove_function(): not handling "
     393                    "descendants\n");
     394        } else {
     395                /* Unregister from location service */
     396                rc = loc_service_unregister(fun->service_id);
     397                if (rc != EOK) {
     398                        log_msg(LVL_ERROR, "Failed unregistering tree service.");
     399                        fibril_rwlock_write_unlock(&tree->rwlock);
     400                        async_answer_0(callid, EIO);
     401                        return;
     402                }
     403        }
     404       
     405        remove_fun_node(&device_tree, fun);
     406        fibril_rwlock_write_unlock(&tree->rwlock);
     407        delete_fun_node(fun);
     408       
     409        log_msg(LVL_DEBUG, "devman_remove_function() succeeded.");
    389410        async_answer_0(callid, EOK);
    390411}
     
    439460                        devman_add_function(callid, &call);
    440461                        break;
    441                 case DEVMAN_ADD_DEVICE_TO_CLASS:
    442                         devman_add_function_to_class(callid, &call);
     462                case DEVMAN_ADD_DEVICE_TO_CATEGORY:
     463                        devman_add_function_to_cat(callid, &call);
     464                        break;
     465                case DEVMAN_REMOVE_FUNCTION:
     466                        devman_remove_function(callid, &call);
    443467                        break;
    444468                default:
     
    464488       
    465489        free(pathname);
    466 
    467         if (fun == NULL) {
    468                 async_answer_0(iid, ENOENT);
    469                 return;
    470         }
    471 
    472         async_answer_1(iid, EOK, fun->handle);
    473 }
    474 
    475 /** Find handle for the device instance identified by device class name. */
    476 static void devman_function_get_handle_by_class(ipc_callid_t iid,
    477     ipc_call_t *icall)
    478 {
    479         char *classname;
    480         char *devname;
    481 
    482         int rc = async_data_write_accept((void **) &classname, true, 0, 0, 0, 0);
    483         if (rc != EOK) {
    484                 async_answer_0(iid, rc);
    485                 return;
    486         }
    487         rc = async_data_write_accept((void **) &devname, true, 0, 0, 0, 0);
    488         if (rc != EOK) {
    489                 free(classname);
    490                 async_answer_0(iid, rc);
    491                 return;
    492         }
    493 
    494 
    495         fun_node_t *fun = find_fun_node_by_class(&class_list,
    496             classname, devname);
    497 
    498         free(classname);
    499         free(devname);
    500490
    501491        if (fun == NULL) {
     
    544534}
    545535
     536/** Find handle for the function instance identified by its service ID. */
     537static void devman_fun_sid_to_handle(ipc_callid_t iid, ipc_call_t *icall)
     538{
     539        fun_node_t *fun;
     540
     541        fun = find_loc_tree_function(&device_tree, IPC_GET_ARG1(*icall));
     542       
     543        if (fun == NULL) {
     544                async_answer_0(iid, ENOENT);
     545                return;
     546        }
     547
     548        async_answer_1(iid, EOK, fun->handle);
     549}
    546550
    547551/** Function for handling connections from a client to the device manager. */
     
    562566                        devman_function_get_handle(callid, &call);
    563567                        break;
    564                 case DEVMAN_DEVICE_GET_HANDLE_BY_CLASS:
    565                         devman_function_get_handle_by_class(callid, &call);
    566                         break;
    567568                case DEVMAN_DEVICE_GET_DEVICE_PATH:
    568569                        devman_get_device_path_by_handle(callid, &call);
     570                        break;
     571                case DEVMAN_FUN_SID_TO_HANDLE:
     572                        devman_fun_sid_to_handle(callid, &call);
    569573                        break;
    570574                default:
     
    659663}
    660664
    661 /** Function for handling connections from a client forwarded by the device
    662  * mapper to the device manager. */
    663 static void devman_connection_devmapper(ipc_callid_t iid, ipc_call_t *icall)
    664 {
    665         devmap_handle_t devmap_handle = IPC_GET_ARG2(*icall);
     665/** Function for handling connections from a client forwarded by the location
     666 * service to the device manager. */
     667static void devman_connection_loc(ipc_callid_t iid, ipc_call_t *icall)
     668{
     669        service_id_t service_id = IPC_GET_ARG2(*icall);
    666670        fun_node_t *fun;
    667671        dev_node_t *dev;
    668672
    669         fun = find_devmap_tree_function(&device_tree, devmap_handle);
    670         if (fun == NULL)
    671                 fun = find_devmap_class_function(&class_list, devmap_handle);
     673        fun = find_loc_tree_function(&device_tree, service_id);
    672674       
    673675        if (fun == NULL || fun->dev->drv == NULL) {
     676                log_msg(LVL_WARN, "devman_connection_loc(): function "
     677                    "not found.\n");
    674678                async_answer_0(iid, ENOENT);
    675679                return;
     
    677681       
    678682        dev = fun->dev;
    679        
    680         if ((dev->state != DEVICE_USABLE) || (!dev->drv->sess)) {
    681                 async_answer_0(iid, EINVAL);
    682                 return;
    683         }
    684683       
    685684        async_exch_t *exch = async_exchange_begin(dev->drv->sess);
     
    689688       
    690689        log_msg(LVL_DEBUG,
    691             "Forwarding devmapper request for `%s' function to driver `%s'.",
     690            "Forwarding loc service request for `%s' function to driver `%s'.",
    692691            fun->pathname, dev->drv->name);
    693692}
     
    708707                devman_forward(iid, icall, false);
    709708                break;
    710         case DEVMAN_CONNECT_FROM_DEVMAP:
    711                 /* Someone connected through devmap node. */
    712                 devman_connection_devmapper(iid, icall);
     709        case DEVMAN_CONNECT_FROM_LOC:
     710                /* Someone connected through loc node. */
     711                devman_connection_loc(iid, icall);
    713712                break;
    714713        case DEVMAN_CONNECT_TO_PARENTS_DEVICE:
     
    743742        }
    744743
    745         init_class_list(&class_list);
    746        
    747744        /*
    748          * !!! devman_connection ... as the device manager is not a real devmap
     745         * !!! devman_connection ... as the device manager is not a real loc
    749746         * driver (it uses a completely different ipc protocol than an ordinary
    750          * devmap driver) forwarding a connection from client to the devman by
    751          * devmapper would not work.
     747         * loc driver) forwarding a connection from client to the devman by
     748         * location service would not work.
    752749         */
    753         devmap_driver_register(NAME, devman_connection);
     750        loc_server_register(NAME, devman_connection);
    754751       
    755752        return true;
     
    760757        printf(NAME ": HelenOS Device Manager\n");
    761758
    762         if (log_init(NAME, LVL_ERROR) != EOK) {
     759        if (log_init(NAME, LVL_WARN) != EOK) {
    763760                printf(NAME ": Error initializing logging subsystem.\n");
    764761                return -1;
  • uspace/srv/fs/ext2fs/ext2fs_ops.c

    rd894fbd r903bac0a  
    4242#include <libext2.h>
    4343#include <ipc/services.h>
    44 #include <ipc/devmap.h>
     44#include <ipc/loc.h>
    4545#include <macros.h>
    4646#include <async.h>
     
    6969typedef struct ext2fs_instance {
    7070        link_t link;
    71         devmap_handle_t devmap_handle;
     71        service_id_t service_id;
    7272        ext2_filesystem_t *filesystem;
    7373        unsigned int open_nodes_count;
     
    8585 * Forward declarations of auxiliary functions
    8686 */
    87 static int ext2fs_instance_get(devmap_handle_t, ext2fs_instance_t **);
     87static int ext2fs_instance_get(service_id_t, ext2fs_instance_t **);
    8888static int ext2fs_read_directory(ipc_callid_t, aoff64_t, size_t,
    8989    ext2fs_instance_t *, ext2_inode_ref_t *, size_t *);
     
    9797 * Forward declarations of EXT2 libfs operations.
    9898 */
    99 static int ext2fs_root_get(fs_node_t **, devmap_handle_t);
     99static int ext2fs_root_get(fs_node_t **, service_id_t);
    100100static int ext2fs_match(fs_node_t **, fs_node_t *, const char *);
    101 static int ext2fs_node_get(fs_node_t **, devmap_handle_t, fs_index_t);
     101static int ext2fs_node_get(fs_node_t **, service_id_t, fs_index_t);
    102102static int ext2fs_node_open(fs_node_t *);
    103103static int ext2fs_node_put(fs_node_t *);
    104 static int ext2fs_create_node(fs_node_t **, devmap_handle_t, int);
     104static int ext2fs_create_node(fs_node_t **, service_id_t, int);
    105105static int ext2fs_destroy_node(fs_node_t *);
    106106static int ext2fs_link(fs_node_t *, fs_node_t *, const char *);
     
    112112static bool ext2fs_is_directory(fs_node_t *);
    113113static bool ext2fs_is_file(fs_node_t *node);
    114 static devmap_handle_t ext2fs_device_get(fs_node_t *node);
     114static service_id_t ext2fs_device_get(fs_node_t *node);
    115115
    116116/*
     
    134134        ext2fs_node_t *enode = hash_table_get_instance(item, ext2fs_node_t, link);
    135135        assert(keys > 0);
    136         if (enode->instance->devmap_handle !=
    137             ((devmap_handle_t) key[OPEN_NODES_DEV_HANDLE_KEY])) {
     136        if (enode->instance->service_id !=
     137            ((service_id_t) key[OPEN_NODES_DEV_HANDLE_KEY])) {
    138138                return false;
    139139        }
     
    180180
    181181/**
    182  * Find an instance of filesystem for the given devmap_handle
    183  */
    184 int ext2fs_instance_get(devmap_handle_t devmap_handle, ext2fs_instance_t **inst)
    185 {
    186         EXT2FS_DBG("(%" PRIun ", -)", devmap_handle);
     182 * Find an instance of filesystem for the given service_id
     183 */
     184int ext2fs_instance_get(service_id_t service_id, ext2fs_instance_t **inst)
     185{
     186        EXT2FS_DBG("(%" PRIun ", -)", service_id);
    187187        ext2fs_instance_t *tmp;
    188188       
     
    198198                tmp = list_get_instance(link, ext2fs_instance_t, link);
    199199               
    200                 if (tmp->devmap_handle == devmap_handle) {
     200                if (tmp->service_id == service_id) {
    201201                        *inst = tmp;
    202202                        fibril_mutex_unlock(&instance_list_mutex);
     
    213213
    214214
    215 int ext2fs_root_get(fs_node_t **rfn, devmap_handle_t devmap_handle)
    216 {
    217         EXT2FS_DBG("(-, %" PRIun ")", devmap_handle);
    218         return ext2fs_node_get(rfn, devmap_handle, EXT2_INODE_ROOT_INDEX);
     215int ext2fs_root_get(fs_node_t **rfn, service_id_t service_id)
     216{
     217        EXT2FS_DBG("(-, %" PRIun ")", service_id);
     218        return ext2fs_node_get(rfn, service_id, EXT2_INODE_ROOT_INDEX);
    219219}
    220220
     
    289289
    290290/** Instantiate a EXT2 in-core node. */
    291 int ext2fs_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle, fs_index_t index)
    292 {
    293         EXT2FS_DBG("(-,%" PRIun ",%u)", devmap_handle, index);
     291int ext2fs_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index)
     292{
     293        EXT2FS_DBG("(-,%" PRIun ",%u)", service_id, index);
    294294       
    295295        ext2fs_instance_t *inst = NULL;
    296296        int rc;
    297297       
    298         rc = ext2fs_instance_get(devmap_handle, &inst);
     298        rc = ext2fs_instance_get(service_id, &inst);
    299299        if (rc != EOK) {
    300300                return rc;
     
    317317        /* Check if the node is not already open */
    318318        unsigned long key[] = {
    319                 [OPEN_NODES_DEV_HANDLE_KEY] = inst->devmap_handle,
     319                [OPEN_NODES_DEV_HANDLE_KEY] = inst->service_id,
    320320                [OPEN_NODES_INODE_KEY] = index,
    321321        };
     
    411411
    412412        unsigned long key[] = {
    413                 [OPEN_NODES_DEV_HANDLE_KEY] = enode->instance->devmap_handle,
     413                [OPEN_NODES_DEV_HANDLE_KEY] = enode->instance->service_id,
    414414                [OPEN_NODES_INODE_KEY] = enode->inode_ref->index,
    415415        };
     
    429429}
    430430
    431 int ext2fs_create_node(fs_node_t **rfn, devmap_handle_t devmap_handle, int flags)
     431int ext2fs_create_node(fs_node_t **rfn, service_id_t service_id, int flags)
    432432{
    433433        EXT2FS_DBG("");
     
    557557}
    558558
    559 devmap_handle_t ext2fs_device_get(fs_node_t *fn)
     559service_id_t ext2fs_device_get(fs_node_t *fn)
    560560{
    561561        EXT2FS_DBG("");
    562562        ext2fs_node_t *enode = EXT2FS_NODE(fn);
    563         return enode->instance->devmap_handle;
     563        return enode->instance->service_id;
    564564}
    565565
     
    588588 */
    589589
    590 static int ext2fs_mounted(devmap_handle_t devmap_handle, const char *opts,
     590static int ext2fs_mounted(service_id_t service_id, const char *opts,
    591591   fs_index_t *index, aoff64_t *size, unsigned *lnkcnt)
    592592{
     
    610610       
    611611        /* Initialize the filesystem  */
    612         rc = ext2_filesystem_init(fs, devmap_handle);
     612        rc = ext2_filesystem_init(fs, service_id);
    613613        if (rc != EOK) {
    614614                free(fs);
     
    637637        /* Initialize instance */
    638638        link_initialize(&inst->link);
    639         inst->devmap_handle = devmap_handle;
     639        inst->service_id = service_id;
    640640        inst->filesystem = fs;
    641641        inst->open_nodes_count = 0;
     
    666666}
    667667
    668 static int ext2fs_unmounted(devmap_handle_t devmap_handle)
     668static int ext2fs_unmounted(service_id_t service_id)
    669669{
    670670        EXT2FS_DBG("");
     
    672672        int rc;
    673673       
    674         rc = ext2fs_instance_get(devmap_handle, &inst);
     674        rc = ext2fs_instance_get(service_id, &inst);
    675675       
    676676        if (rc != EOK)
     
    698698
    699699static int
    700 ext2fs_read(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t pos,
     700ext2fs_read(service_id_t service_id, fs_index_t index, aoff64_t pos,
    701701    size_t *rbytes)
    702702{
     
    717717        }
    718718       
    719         rc = ext2fs_instance_get(devmap_handle, &inst);
     719        rc = ext2fs_instance_get(service_id, &inst);
    720720        if (rc != EOK) {
    721721                async_answer_0(callid, rc);
     
    907907       
    908908        /* Usual case - we need to read a block from device */
    909         rc = block_get(&block, inst->devmap_handle, fs_block, BLOCK_FLAGS_NONE);
     909        rc = block_get(&block, inst->service_id, fs_block, BLOCK_FLAGS_NONE);
    910910        if (rc != EOK) {
    911911                async_answer_0(callid, rc);
     
    925925
    926926static int
    927 ext2fs_write(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t pos,
     927ext2fs_write(service_id_t service_id, fs_index_t index, aoff64_t pos,
    928928    size_t *wbytes, aoff64_t *nsize)
    929929{
     
    933933
    934934static int
    935 ext2fs_truncate(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t size)
     935ext2fs_truncate(service_id_t service_id, fs_index_t index, aoff64_t size)
    936936{
    937937        EXT2FS_DBG("");
     
    939939}
    940940
    941 static int ext2fs_close(devmap_handle_t devmap_handle, fs_index_t index)
    942 {
    943         EXT2FS_DBG("");
    944         return EOK;
    945 }
    946 
    947 static int ext2fs_destroy(devmap_handle_t devmap_handle, fs_index_t index)
     941static int ext2fs_close(service_id_t service_id, fs_index_t index)
     942{
     943        EXT2FS_DBG("");
     944        return EOK;
     945}
     946
     947static int ext2fs_destroy(service_id_t service_id, fs_index_t index)
    948948{
    949949        EXT2FS_DBG("");
     
    951951}
    952952
    953 static int ext2fs_sync(devmap_handle_t devmap_handle, fs_index_t index)
     953static int ext2fs_sync(service_id_t service_id, fs_index_t index)
    954954{
    955955        EXT2FS_DBG("");
  • uspace/srv/fs/fat/fat.h

    rd894fbd r903bac0a  
    175175
    176176        fibril_mutex_t  lock;
    177         devmap_handle_t devmap_handle;
     177        service_id_t    service_id;
    178178        fs_index_t      index;
    179179        /**
     
    227227extern libfs_ops_t fat_libfs_ops;
    228228
    229 extern int fat_idx_get_new(fat_idx_t **, devmap_handle_t);
    230 extern fat_idx_t *fat_idx_get_by_pos(devmap_handle_t, fat_cluster_t, unsigned);
    231 extern fat_idx_t *fat_idx_get_by_index(devmap_handle_t, fs_index_t);
     229extern int fat_idx_get_new(fat_idx_t **, service_id_t);
     230extern fat_idx_t *fat_idx_get_by_pos(service_id_t, fat_cluster_t, unsigned);
     231extern fat_idx_t *fat_idx_get_by_index(service_id_t, fs_index_t);
    232232extern void fat_idx_destroy(fat_idx_t *);
    233233extern void fat_idx_hashin(fat_idx_t *);
     
    236236extern int fat_idx_init(void);
    237237extern void fat_idx_fini(void);
    238 extern int fat_idx_init_by_devmap_handle(devmap_handle_t);
    239 extern void fat_idx_fini_by_devmap_handle(devmap_handle_t);
     238extern int fat_idx_init_by_service_id(service_id_t);
     239extern void fat_idx_fini_by_service_id(service_id_t);
    240240
    241241#endif
  • uspace/srv/fs/fat/fat_fat.c

    rd894fbd r903bac0a  
    7171 *
    7272 * @param bs            Buffer holding the boot sector for the file.
    73  * @param devmap_handle Device handle of the device with the file.
     73 * @param service_id    Service ID of the device with the file.
    7474 * @param firstc        First cluster to start the walk with.
    7575 * @param lastc         If non-NULL, output argument hodling the last cluster
     
    8282 */
    8383int
    84 fat_cluster_walk(fat_bs_t *bs, devmap_handle_t devmap_handle, fat_cluster_t firstc,
     84fat_cluster_walk(fat_bs_t *bs, service_id_t service_id, fat_cluster_t firstc,
    8585    fat_cluster_t *lastc, uint16_t *numc, uint16_t max_clusters)
    8686{
     
    109109                fidx = clst % (BPS(bs) / sizeof(fat_cluster_t));
    110110                /* read FAT1 */
    111                 rc = block_get(&b, devmap_handle, RSCNT(bs) + fsec,
     111                rc = block_get(&b, service_id, RSCNT(bs) + fsec,
    112112                    BLOCK_FLAGS_NONE);
    113113                if (rc != EOK)
     
    160160                 * when fortunately we have the last cluster number cached.
    161161                 */
    162                 return block_get(block, nodep->idx->devmap_handle,
     162                return block_get(block, nodep->idx->service_id,
    163163                    CLBN2PBN(bs, nodep->lastc_cached_value, bn), flags);
    164164        }
     
    174174
    175175fall_through:
    176         rc = _fat_block_get(block, bs, nodep->idx->devmap_handle, firstc,
     176        rc = _fat_block_get(block, bs, nodep->idx->service_id, firstc,
    177177            &currc, relbn, flags);
    178178        if (rc != EOK)
     
    193193 * @param block         Pointer to a block pointer for storing result.
    194194 * @param bs            Buffer holding the boot sector of the file system.
    195  * @param devmap_handle Device handle of the file system.
     195 * @param service_id    Service ID handle of the file system.
    196196 * @param fcl           First cluster used by the file. Can be zero if the file
    197197 *                      is empty.
     
    205205 */
    206206int
    207 _fat_block_get(block_t **block, fat_bs_t *bs, devmap_handle_t devmap_handle,
     207_fat_block_get(block_t **block, fat_bs_t *bs, service_id_t service_id,
    208208    fat_cluster_t fcl, fat_cluster_t *clp, aoff64_t bn, int flags)
    209209{
     
    222222                /* root directory special case */
    223223                assert(bn < RDS(bs));
    224                 rc = block_get(block, devmap_handle,
     224                rc = block_get(block, service_id,
    225225                    RSCNT(bs) + FATCNT(bs) * SF(bs) + bn, flags);
    226226                return rc;
     
    228228
    229229        max_clusters = bn / SPC(bs);
    230         rc = fat_cluster_walk(bs, devmap_handle, fcl, &c, &clusters, max_clusters);
     230        rc = fat_cluster_walk(bs, service_id, fcl, &c, &clusters, max_clusters);
    231231        if (rc != EOK)
    232232                return rc;
    233233        assert(clusters == max_clusters);
    234234
    235         rc = block_get(block, devmap_handle, CLBN2PBN(bs, c, bn), flags);
     235        rc = block_get(block, service_id, CLBN2PBN(bs, c, bn), flags);
    236236
    237237        if (clp)
     
    281281        /* zero out the initial part of the new cluster chain */
    282282        for (o = boundary; o < pos; o += BPS(bs)) {
    283                 rc = _fat_block_get(&b, bs, nodep->idx->devmap_handle, mcl,
     283                rc = _fat_block_get(&b, bs, nodep->idx->service_id, mcl,
    284284                    NULL, (o - boundary) / BPS(bs), BLOCK_FLAGS_NOREAD);
    285285                if (rc != EOK)
     
    298298 *
    299299 * @param bs            Buffer holding the boot sector for the file system.
    300  * @param devmap_handle Device handle for the file system.
     300 * @param service_id    Service ID for the file system.
    301301 * @param clst          Cluster which to get.
    302302 * @param value         Output argument holding the value of the cluster.
     
    305305 */
    306306int
    307 fat_get_cluster(fat_bs_t *bs, devmap_handle_t devmap_handle, unsigned fatno,
     307fat_get_cluster(fat_bs_t *bs, service_id_t service_id, unsigned fatno,
    308308    fat_cluster_t clst, fat_cluster_t *value)
    309309{
     
    312312        int rc;
    313313
    314         rc = block_get(&b, devmap_handle, RSCNT(bs) + SF(bs) * fatno +
     314        rc = block_get(&b, service_id, RSCNT(bs) + SF(bs) * fatno +
    315315            (clst * sizeof(fat_cluster_t)) / BPS(bs), BLOCK_FLAGS_NONE);
    316316        if (rc != EOK)
     
    327327 *
    328328 * @param bs            Buffer holding the boot sector for the file system.
    329  * @param devmap_handle Device handle for the file system.
     329 * @param service_id    Device service ID for the file system.
    330330 * @param fatno         Number of the FAT instance where to make the change.
    331331 * @param clst          Cluster which is to be set.
     
    335335 */
    336336int
    337 fat_set_cluster(fat_bs_t *bs, devmap_handle_t devmap_handle, unsigned fatno,
     337fat_set_cluster(fat_bs_t *bs, service_id_t service_id, unsigned fatno,
    338338    fat_cluster_t clst, fat_cluster_t value)
    339339{
     
    343343
    344344        assert(fatno < FATCNT(bs));
    345         rc = block_get(&b, devmap_handle, RSCNT(bs) + SF(bs) * fatno +
     345        rc = block_get(&b, service_id, RSCNT(bs) + SF(bs) * fatno +
    346346            (clst * sizeof(fat_cluster_t)) / BPS(bs), BLOCK_FLAGS_NONE);
    347347        if (rc != EOK)
     
    358358 *
    359359 * @param bs            Buffer holding the boot sector of the file system.
    360  * @param devmap_handle Device handle of the file system.
     360 * @param service_id    Service ID of the file system.
    361361 * @param lifo          Chain of allocated clusters.
    362362 * @param nclsts        Number of clusters in the lifo chain.
     
    364364 * @return              EOK on success or a negative error code.
    365365 */
    366 int fat_alloc_shadow_clusters(fat_bs_t *bs, devmap_handle_t devmap_handle,
     366int fat_alloc_shadow_clusters(fat_bs_t *bs, service_id_t service_id,
    367367    fat_cluster_t *lifo, unsigned nclsts)
    368368{
     
    373373        for (fatno = FAT1 + 1; fatno < bs->fatcnt; fatno++) {
    374374                for (c = 0; c < nclsts; c++) {
    375                         rc = fat_set_cluster(bs, devmap_handle, fatno, lifo[c],
     375                        rc = fat_set_cluster(bs, service_id, fatno, lifo[c],
    376376                            c == 0 ? FAT_CLST_LAST1 : lifo[c - 1]);
    377377                        if (rc != EOK)
     
    391391 *
    392392 * @param bs            Buffer holding the boot sector of the file system.
    393  * @param devmap_handle Device handle of the file system.
     393 * @param service_id    Device service ID of the file system.
    394394 * @param nclsts        Number of clusters to allocate.
    395395 * @param mcl           Output parameter where the first cluster in the chain
     
    401401 */
    402402int
    403 fat_alloc_clusters(fat_bs_t *bs, devmap_handle_t devmap_handle, unsigned nclsts,
     403fat_alloc_clusters(fat_bs_t *bs, service_id_t service_id, unsigned nclsts,
    404404    fat_cluster_t *mcl, fat_cluster_t *lcl)
    405405{
     
    419419        fibril_mutex_lock(&fat_alloc_lock);
    420420        for (b = 0, cl = 0; b < SF(bs); b++) {
    421                 rc = block_get(&blk, devmap_handle, RSCNT(bs) + b,
     421                rc = block_get(&blk, service_id, RSCNT(bs) + b,
    422422                    BLOCK_FLAGS_NONE);
    423423                if (rc != EOK)
     
    458458                                        /* update the shadow copies of FAT */
    459459                                        rc = fat_alloc_shadow_clusters(bs,
    460                                             devmap_handle, lifo, nclsts);
     460                                            service_id, lifo, nclsts);
    461461                                        if (rc != EOK)
    462462                                                goto error;
     
    485485         */
    486486        while (found--) {
    487                 rc = fat_set_cluster(bs, devmap_handle, FAT1, lifo[found],
     487                rc = fat_set_cluster(bs, service_id, FAT1, lifo[found],
    488488                    FAT_CLST_RES0);
    489489                if (rc != EOK) {
     
    500500 *
    501501 * @param bs            Buffer hodling the boot sector of the file system.
    502  * @param devmap_handle Device handle of the file system.
     502 * @param service_id    Device service ID of the file system.
    503503 * @param firstc        First cluster in the chain which is to be freed.
    504504 *
     
    506506 */
    507507int
    508 fat_free_clusters(fat_bs_t *bs, devmap_handle_t devmap_handle, fat_cluster_t firstc)
     508fat_free_clusters(fat_bs_t *bs, service_id_t service_id, fat_cluster_t firstc)
    509509{
    510510        unsigned fatno;
     
    515515        while (firstc < FAT_CLST_LAST1) {
    516516                assert(firstc >= FAT_CLST_FIRST && firstc < FAT_CLST_BAD);
    517                 rc = fat_get_cluster(bs, devmap_handle, FAT1, firstc, &nextc);
     517                rc = fat_get_cluster(bs, service_id, FAT1, firstc, &nextc);
    518518                if (rc != EOK)
    519519                        return rc;
    520520                for (fatno = FAT1; fatno < bs->fatcnt; fatno++) {
    521                         rc = fat_set_cluster(bs, devmap_handle, fatno, firstc,
     521                        rc = fat_set_cluster(bs, service_id, fatno, firstc,
    522522                            FAT_CLST_RES0);
    523523                        if (rc != EOK)
     
    544544    fat_cluster_t lcl)
    545545{
    546         devmap_handle_t devmap_handle = nodep->idx->devmap_handle;
     546        service_id_t service_id = nodep->idx->service_id;
    547547        fat_cluster_t lastc;
    548548        uint8_t fatno;
     
    558558                        nodep->lastc_cached_valid = false;
    559559                } else {
    560                         rc = fat_cluster_walk(bs, devmap_handle, nodep->firstc,
     560                        rc = fat_cluster_walk(bs, service_id, nodep->firstc,
    561561                            &lastc, NULL, (uint16_t) -1);
    562562                        if (rc != EOK)
     
    565565
    566566                for (fatno = FAT1; fatno < bs->fatcnt; fatno++) {
    567                         rc = fat_set_cluster(bs, nodep->idx->devmap_handle, fatno,
     567                        rc = fat_set_cluster(bs, nodep->idx->service_id, fatno,
    568568                            lastc, mcl);
    569569                        if (rc != EOK)
     
    591591{
    592592        int rc;
    593         devmap_handle_t devmap_handle = nodep->idx->devmap_handle;
     593        service_id_t service_id = nodep->idx->service_id;
    594594
    595595        /*
     
    602602        if (lcl == FAT_CLST_RES0) {
    603603                /* The node will have zero size and no clusters allocated. */
    604                 rc = fat_free_clusters(bs, devmap_handle, nodep->firstc);
     604                rc = fat_free_clusters(bs, service_id, nodep->firstc);
    605605                if (rc != EOK)
    606606                        return rc;
     
    611611                unsigned fatno;
    612612
    613                 rc = fat_get_cluster(bs, devmap_handle, FAT1, lcl, &nextc);
     613                rc = fat_get_cluster(bs, service_id, FAT1, lcl, &nextc);
    614614                if (rc != EOK)
    615615                        return rc;
     
    617617                /* Terminate the cluster chain in all copies of FAT. */
    618618                for (fatno = FAT1; fatno < bs->fatcnt; fatno++) {
    619                         rc = fat_set_cluster(bs, devmap_handle, fatno, lcl,
     619                        rc = fat_set_cluster(bs, service_id, fatno, lcl,
    620620                            FAT_CLST_LAST1);
    621621                        if (rc != EOK)
     
    624624
    625625                /* Free all following clusters. */
    626                 rc = fat_free_clusters(bs, devmap_handle, nextc);
     626                rc = fat_free_clusters(bs, service_id, nextc);
    627627                if (rc != EOK)
    628628                        return rc;
     
    639639
    640640int
    641 fat_zero_cluster(struct fat_bs *bs, devmap_handle_t devmap_handle, fat_cluster_t c)
     641fat_zero_cluster(struct fat_bs *bs, service_id_t service_id, fat_cluster_t c)
    642642{
    643643        int i;
     
    646646
    647647        for (i = 0; i < SPC(bs); i++) {
    648                 rc = _fat_block_get(&b, bs, devmap_handle, c, NULL, i,
     648                rc = _fat_block_get(&b, bs, service_id, c, NULL, i,
    649649                    BLOCK_FLAGS_NOREAD);
    650650                if (rc != EOK)
     
    666666 * does not contain a fat file system.
    667667 */
    668 int fat_sanity_check(fat_bs_t *bs, devmap_handle_t devmap_handle)
     668int fat_sanity_check(fat_bs_t *bs, service_id_t service_id)
    669669{
    670670        fat_cluster_t e0, e1;
     
    707707
    708708        for (fat_no = 0; fat_no < bs->fatcnt; fat_no++) {
    709                 rc = fat_get_cluster(bs, devmap_handle, fat_no, 0, &e0);
     709                rc = fat_get_cluster(bs, service_id, fat_no, 0, &e0);
    710710                if (rc != EOK)
    711711                        return EIO;
    712712
    713                 rc = fat_get_cluster(bs, devmap_handle, fat_no, 1, &e1);
     713                rc = fat_get_cluster(bs, service_id, fat_no, 1, &e1);
    714714                if (rc != EOK)
    715715                        return EIO;
  • uspace/srv/fs/fat/fat_fat.h

    rd894fbd r903bac0a  
    6161#define fat_clusters_get(numc, bs, dh, fc) \
    6262    fat_cluster_walk((bs), (dh), (fc), NULL, (numc), (uint16_t) -1)
    63 extern int fat_cluster_walk(struct fat_bs *, devmap_handle_t, fat_cluster_t,
     63extern int fat_cluster_walk(struct fat_bs *, service_id_t, fat_cluster_t,
    6464    fat_cluster_t *, uint16_t *, uint16_t);
    6565
    6666extern int fat_block_get(block_t **, struct fat_bs *, struct fat_node *,
    6767    aoff64_t, int);
    68 extern int _fat_block_get(block_t **, struct fat_bs *, devmap_handle_t,
     68extern int _fat_block_get(block_t **, struct fat_bs *, service_id_t,
    6969    fat_cluster_t, fat_cluster_t *, aoff64_t, int);
    7070
     
    7373extern int fat_chop_clusters(struct fat_bs *, struct fat_node *,
    7474    fat_cluster_t);
    75 extern int fat_alloc_clusters(struct fat_bs *, devmap_handle_t, unsigned,
     75extern int fat_alloc_clusters(struct fat_bs *, service_id_t, unsigned,
    7676    fat_cluster_t *, fat_cluster_t *);
    77 extern int fat_free_clusters(struct fat_bs *, devmap_handle_t, fat_cluster_t);
    78 extern int fat_alloc_shadow_clusters(struct fat_bs *, devmap_handle_t,
     77extern int fat_free_clusters(struct fat_bs *, service_id_t, fat_cluster_t);
     78extern int fat_alloc_shadow_clusters(struct fat_bs *, service_id_t,
    7979    fat_cluster_t *, unsigned);
    80 extern int fat_get_cluster(struct fat_bs *, devmap_handle_t, unsigned,
     80extern int fat_get_cluster(struct fat_bs *, service_id_t, unsigned,
    8181    fat_cluster_t, fat_cluster_t *);
    82 extern int fat_set_cluster(struct fat_bs *, devmap_handle_t, unsigned,
     82extern int fat_set_cluster(struct fat_bs *, service_id_t, unsigned,
    8383    fat_cluster_t, fat_cluster_t);
    8484extern int fat_fill_gap(struct fat_bs *, struct fat_node *, fat_cluster_t,
    8585    aoff64_t);
    86 extern int fat_zero_cluster(struct fat_bs *, devmap_handle_t, fat_cluster_t);
    87 extern int fat_sanity_check(struct fat_bs *, devmap_handle_t);
     86extern int fat_zero_cluster(struct fat_bs *, service_id_t, fat_cluster_t);
     87extern int fat_sanity_check(struct fat_bs *, service_id_t);
    8888
    8989#endif
  • uspace/srv/fs/fat/fat_idx.c

    rd894fbd r903bac0a  
    5959typedef struct {
    6060        link_t          link;
    61         devmap_handle_t devmap_handle;
     61        service_id_t    service_id;
    6262
    6363        /** Next unassigned index. */
     
    7676static LIST_INITIALIZE(unused_list);
    7777
    78 static void unused_initialize(unused_t *u, devmap_handle_t devmap_handle)
     78static void unused_initialize(unused_t *u, service_id_t service_id)
    7979{
    8080        link_initialize(&u->link);
    81         u->devmap_handle = devmap_handle;
     81        u->service_id = service_id;
    8282        u->next = 0;
    8383        u->remaining = ((uint64_t)((fs_index_t)-1)) + 1;
     
    8585}
    8686
    87 static unused_t *unused_find(devmap_handle_t devmap_handle, bool lock)
     87static unused_t *unused_find(service_id_t service_id, bool lock)
    8888{
    8989        unused_t *u;
     
    9494        list_foreach(unused_list, l) {
    9595                u = list_get_instance(l, unused_t, link);
    96                 if (u->devmap_handle == devmap_handle)
     96                if (u->service_id == service_id)
    9797                        return u;
    9898        }
     
    108108/**
    109109 * Global hash table of all used fat_idx_t structures.
    110  * The index structures are hashed by the devmap_handle, parent node's first
     110 * The index structures are hashed by the service_id, parent node's first
    111111 * cluster and index within the parent directory.
    112112 */
     
    122122static hash_index_t pos_hash(unsigned long key[])
    123123{
    124         devmap_handle_t devmap_handle = (devmap_handle_t)key[UPH_DH_KEY];
     124        service_id_t service_id = (service_id_t)key[UPH_DH_KEY];
    125125        fat_cluster_t pfc = (fat_cluster_t)key[UPH_PFC_KEY];
    126126        unsigned pdi = (unsigned)key[UPH_PDI_KEY];
     
    142142        h |= (pdi & ((1 << (UPH_BUCKETS_LOG / 4)) - 1)) <<
    143143            (UPH_BUCKETS_LOG / 2);
    144         h |= (devmap_handle & ((1 << (UPH_BUCKETS_LOG / 4)) - 1)) <<
     144        h |= (service_id & ((1 << (UPH_BUCKETS_LOG / 4)) - 1)) <<
    145145            (3 * (UPH_BUCKETS_LOG / 4));
    146146
     
    150150static int pos_compare(unsigned long key[], hash_count_t keys, link_t *item)
    151151{
    152         devmap_handle_t devmap_handle = (devmap_handle_t)key[UPH_DH_KEY];
     152        service_id_t service_id = (service_id_t)key[UPH_DH_KEY];
    153153        fat_cluster_t pfc;
    154154        unsigned pdi;
     
    157157        switch (keys) {
    158158        case 1:
    159                 return (devmap_handle == fidx->devmap_handle);
     159                return (service_id == fidx->service_id);
    160160        case 3:
    161161                pfc = (fat_cluster_t) key[UPH_PFC_KEY];
    162162                pdi = (unsigned) key[UPH_PDI_KEY];
    163                 return (devmap_handle == fidx->devmap_handle) && (pfc == fidx->pfc) &&
     163                return (service_id == fidx->service_id) && (pfc == fidx->pfc) &&
    164164                    (pdi == fidx->pdi);
    165165        default:
     
    183183/**
    184184 * Global hash table of all used fat_idx_t structures.
    185  * The index structures are hashed by the devmap_handle and index.
     185 * The index structures are hashed by the service_id and index.
    186186 */
    187187static hash_table_t ui_hash;
     
    195195static hash_index_t idx_hash(unsigned long key[])
    196196{
    197         devmap_handle_t devmap_handle = (devmap_handle_t)key[UIH_DH_KEY];
     197        service_id_t service_id = (service_id_t)key[UIH_DH_KEY];
    198198        fs_index_t index = (fs_index_t)key[UIH_INDEX_KEY];
    199199
    200200        hash_index_t h;
    201201
    202         h = devmap_handle & ((1 << (UIH_BUCKETS_LOG / 2)) - 1);
     202        h = service_id & ((1 << (UIH_BUCKETS_LOG / 2)) - 1);
    203203        h |= (index & ((1 << (UIH_BUCKETS_LOG / 2)) - 1)) <<
    204204            (UIH_BUCKETS_LOG / 2);
     
    209209static int idx_compare(unsigned long key[], hash_count_t keys, link_t *item)
    210210{
    211         devmap_handle_t devmap_handle = (devmap_handle_t)key[UIH_DH_KEY];
     211        service_id_t service_id = (service_id_t)key[UIH_DH_KEY];
    212212        fs_index_t index;
    213213        fat_idx_t *fidx = list_get_instance(item, fat_idx_t, uih_link);
     
    215215        switch (keys) {
    216216        case 1:
    217                 return (devmap_handle == fidx->devmap_handle);
     217                return (service_id == fidx->service_id);
    218218        case 2:
    219219                index = (fs_index_t) key[UIH_INDEX_KEY];
    220                 return (devmap_handle == fidx->devmap_handle) &&
     220                return (service_id == fidx->service_id) &&
    221221                    (index == fidx->index);
    222222        default:
     
    241241
    242242/** Allocate a VFS index which is not currently in use. */
    243 static bool fat_index_alloc(devmap_handle_t devmap_handle, fs_index_t *index)
     243static bool fat_index_alloc(service_id_t service_id, fs_index_t *index)
    244244{
    245245        unused_t *u;
    246246       
    247247        assert(index);
    248         u = unused_find(devmap_handle, true);
     248        u = unused_find(service_id, true);
    249249        if (!u)
    250250                return false;   
     
    303303
    304304/** Free a VFS index, which is no longer in use. */
    305 static void fat_index_free(devmap_handle_t devmap_handle, fs_index_t index)
     305static void fat_index_free(service_id_t service_id, fs_index_t index)
    306306{
    307307        unused_t *u;
    308308
    309         u = unused_find(devmap_handle, true);
     309        u = unused_find(service_id, true);
    310310        assert(u);
    311311
     
    365365}
    366366
    367 static int fat_idx_create(fat_idx_t **fidxp, devmap_handle_t devmap_handle)
     367static int fat_idx_create(fat_idx_t **fidxp, service_id_t service_id)
    368368{
    369369        fat_idx_t *fidx;
     
    372372        if (!fidx)
    373373                return ENOMEM;
    374         if (!fat_index_alloc(devmap_handle, &fidx->index)) {
     374        if (!fat_index_alloc(service_id, &fidx->index)) {
    375375                free(fidx);
    376376                return ENOSPC;
     
    380380        link_initialize(&fidx->uih_link);
    381381        fibril_mutex_initialize(&fidx->lock);
    382         fidx->devmap_handle = devmap_handle;
     382        fidx->service_id = service_id;
    383383        fidx->pfc = FAT_CLST_RES0;      /* no parent yet */
    384384        fidx->pdi = 0;
     
    389389}
    390390
    391 int fat_idx_get_new(fat_idx_t **fidxp, devmap_handle_t devmap_handle)
     391int fat_idx_get_new(fat_idx_t **fidxp, service_id_t service_id)
    392392{
    393393        fat_idx_t *fidx;
     
    395395
    396396        fibril_mutex_lock(&used_lock);
    397         rc = fat_idx_create(&fidx, devmap_handle);
     397        rc = fat_idx_create(&fidx, service_id);
    398398        if (rc != EOK) {
    399399                fibril_mutex_unlock(&used_lock);
     
    402402               
    403403        unsigned long ikey[] = {
    404                 [UIH_DH_KEY] = devmap_handle,
     404                [UIH_DH_KEY] = service_id,
    405405                [UIH_INDEX_KEY] = fidx->index,
    406406        };
     
    415415
    416416fat_idx_t *
    417 fat_idx_get_by_pos(devmap_handle_t devmap_handle, fat_cluster_t pfc, unsigned pdi)
     417fat_idx_get_by_pos(service_id_t service_id, fat_cluster_t pfc, unsigned pdi)
    418418{
    419419        fat_idx_t *fidx;
    420420        link_t *l;
    421421        unsigned long pkey[] = {
    422                 [UPH_DH_KEY] = devmap_handle,
     422                [UPH_DH_KEY] = service_id,
    423423                [UPH_PFC_KEY] = pfc,
    424424                [UPH_PDI_KEY] = pdi,
     
    432432                int rc;
    433433
    434                 rc = fat_idx_create(&fidx, devmap_handle);
     434                rc = fat_idx_create(&fidx, service_id);
    435435                if (rc != EOK) {
    436436                        fibril_mutex_unlock(&used_lock);
     
    439439               
    440440                unsigned long ikey[] = {
    441                         [UIH_DH_KEY] = devmap_handle,
     441                        [UIH_DH_KEY] = service_id,
    442442                        [UIH_INDEX_KEY] = fidx->index,
    443443                };
     
    458458{
    459459        unsigned long pkey[] = {
    460                 [UPH_DH_KEY] = idx->devmap_handle,
     460                [UPH_DH_KEY] = idx->service_id,
    461461                [UPH_PFC_KEY] = idx->pfc,
    462462                [UPH_PDI_KEY] = idx->pdi,
     
    471471{
    472472        unsigned long pkey[] = {
    473                 [UPH_DH_KEY] = idx->devmap_handle,
     473                [UPH_DH_KEY] = idx->service_id,
    474474                [UPH_PFC_KEY] = idx->pfc,
    475475                [UPH_PDI_KEY] = idx->pdi,
     
    482482
    483483fat_idx_t *
    484 fat_idx_get_by_index(devmap_handle_t devmap_handle, fs_index_t index)
     484fat_idx_get_by_index(service_id_t service_id, fs_index_t index)
    485485{
    486486        fat_idx_t *fidx = NULL;
    487487        link_t *l;
    488488        unsigned long ikey[] = {
    489                 [UIH_DH_KEY] = devmap_handle,
     489                [UIH_DH_KEY] = service_id,
    490490                [UIH_INDEX_KEY] = index,
    491491        };
     
    509509{
    510510        unsigned long ikey[] = {
    511                 [UIH_DH_KEY] = idx->devmap_handle,
     511                [UIH_DH_KEY] = idx->service_id,
    512512                [UIH_INDEX_KEY] = idx->index,
    513513        };
    514         devmap_handle_t devmap_handle = idx->devmap_handle;
     514        service_id_t service_id = idx->service_id;
    515515        fs_index_t index = idx->index;
    516516
     
    526526        fibril_mutex_unlock(&used_lock);
    527527        /* Release the VFS index. */
    528         fat_index_free(devmap_handle, index);
     528        fat_index_free(service_id, index);
    529529        /* The index structure itself is freed in idx_remove_callback(). */
    530530}
     
    548548}
    549549
    550 int fat_idx_init_by_devmap_handle(devmap_handle_t devmap_handle)
     550int fat_idx_init_by_service_id(service_id_t service_id)
    551551{
    552552        unused_t *u;
     
    556556        if (!u)
    557557                return ENOMEM;
    558         unused_initialize(u, devmap_handle);
     558        unused_initialize(u, service_id);
    559559        fibril_mutex_lock(&unused_lock);
    560         if (!unused_find(devmap_handle, false)) {
     560        if (!unused_find(service_id, false)) {
    561561                list_append(&u->link, &unused_list);
    562562        } else {
     
    568568}
    569569
    570 void fat_idx_fini_by_devmap_handle(devmap_handle_t devmap_handle)
     570void fat_idx_fini_by_service_id(service_id_t service_id)
    571571{
    572572        unsigned long ikey[] = {
    573                 [UIH_DH_KEY] = devmap_handle
     573                [UIH_DH_KEY] = service_id
    574574        };
    575575        unsigned long pkey[] = {
    576                 [UPH_DH_KEY] = devmap_handle
     576                [UPH_DH_KEY] = service_id
    577577        };
    578578
     
    590590         * Free the unused and freed structures for this instance.
    591591         */
    592         unused_t *u = unused_find(devmap_handle, true);
     592        unused_t *u = unused_find(service_id, true);
    593593        assert(u);
    594594        list_remove(&u->link);
  • uspace/srv/fs/fat/fat_ops.c

    rd894fbd r903bac0a  
    4343#include <libblock.h>
    4444#include <ipc/services.h>
    45 #include <ipc/devmap.h>
     45#include <ipc/loc.h>
    4646#include <macros.h>
    4747#include <async.h>
     
    7272 * Forward declarations of FAT libfs operations.
    7373 */
    74 static int fat_root_get(fs_node_t **, devmap_handle_t);
     74static int fat_root_get(fs_node_t **, service_id_t);
    7575static int fat_match(fs_node_t **, fs_node_t *, const char *);
    76 static int fat_node_get(fs_node_t **, devmap_handle_t, fs_index_t);
     76static int fat_node_get(fs_node_t **, service_id_t, fs_index_t);
    7777static int fat_node_open(fs_node_t *);
    7878static int fat_node_put(fs_node_t *);
    79 static int fat_create_node(fs_node_t **, devmap_handle_t, int);
     79static int fat_create_node(fs_node_t **, service_id_t, int);
    8080static int fat_destroy_node(fs_node_t *);
    8181static int fat_link(fs_node_t *, fs_node_t *, const char *);
     
    8787static bool fat_is_directory(fs_node_t *);
    8888static bool fat_is_file(fs_node_t *node);
    89 static devmap_handle_t fat_device_get(fs_node_t *node);
     89static service_id_t fat_device_get(fs_node_t *node);
    9090
    9191/*
     
    119119        assert(node->dirty);
    120120
    121         bs = block_bb_get(node->idx->devmap_handle);
     121        bs = block_bb_get(node->idx->service_id);
    122122       
    123123        /* Read the block that contains the dentry of interest. */
    124         rc = _fat_block_get(&b, bs, node->idx->devmap_handle, node->idx->pfc,
     124        rc = _fat_block_get(&b, bs, node->idx->service_id, node->idx->pfc,
    125125            NULL, (node->idx->pdi * sizeof(fat_dentry_t)) / BPS(bs),
    126126            BLOCK_FLAGS_NONE);
     
    144144}
    145145
    146 static int fat_node_fini_by_devmap_handle(devmap_handle_t devmap_handle)
     146static int fat_node_fini_by_service_id(service_id_t service_id)
    147147{
    148148        fat_node_t *nodep;
     
    168168                        goto restart;
    169169                }
    170                 if (nodep->idx->devmap_handle != devmap_handle) {
     170                if (nodep->idx->service_id != service_id) {
    171171                        fibril_mutex_unlock(&nodep->idx->lock);
    172172                        fibril_mutex_unlock(&nodep->lock);
     
    298298                return rc;
    299299
    300         bs = block_bb_get(idxp->devmap_handle);
     300        bs = block_bb_get(idxp->service_id);
    301301
    302302        /* Read the block that contains the dentry of interest. */
    303         rc = _fat_block_get(&b, bs, idxp->devmap_handle, idxp->pfc, NULL,
     303        rc = _fat_block_get(&b, bs, idxp->service_id, idxp->pfc, NULL,
    304304            (idxp->pdi * sizeof(fat_dentry_t)) / BPS(bs), BLOCK_FLAGS_NONE);
    305305        if (rc != EOK) {
     
    322322                 */
    323323                uint16_t clusters;
    324                 rc = fat_clusters_get(&clusters, bs, idxp->devmap_handle,
     324                rc = fat_clusters_get(&clusters, bs, idxp->service_id,
    325325                    uint16_t_le2host(d->firstc));
    326326                if (rc != EOK) {
     
    356356 */
    357357
    358 int fat_root_get(fs_node_t **rfn, devmap_handle_t devmap_handle)
    359 {
    360         return fat_node_get(rfn, devmap_handle, 0);
     358int fat_root_get(fs_node_t **rfn, service_id_t service_id)
     359{
     360        return fat_node_get(rfn, service_id, 0);
    361361}
    362362
     
    369369        unsigned blocks;
    370370        fat_dentry_t *d;
    371         devmap_handle_t devmap_handle;
     371        service_id_t service_id;
    372372        block_t *b;
    373373        int rc;
    374374
    375375        fibril_mutex_lock(&parentp->idx->lock);
    376         devmap_handle = parentp->idx->devmap_handle;
     376        service_id = parentp->idx->service_id;
    377377        fibril_mutex_unlock(&parentp->idx->lock);
    378378
    379         bs = block_bb_get(devmap_handle);
     379        bs = block_bb_get(service_id);
    380380        blocks = parentp->size / BPS(bs);
    381381        for (i = 0; i < blocks; i++) {
     
    402402                                /* hit */
    403403                                fat_node_t *nodep;
    404                                 fat_idx_t *idx = fat_idx_get_by_pos(devmap_handle,
     404                                fat_idx_t *idx = fat_idx_get_by_pos(service_id,
    405405                                    parentp->firstc, i * DPS(bs) + j);
    406406                                if (!idx) {
     
    435435
    436436/** Instantiate a FAT in-core node. */
    437 int fat_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle, fs_index_t index)
     437int fat_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index)
    438438{
    439439        fat_node_t *nodep;
     
    441441        int rc;
    442442
    443         idxp = fat_idx_get_by_index(devmap_handle, index);
     443        idxp = fat_idx_get_by_index(service_id, index);
    444444        if (!idxp) {
    445445                *rfn = NULL;
     
    492492}
    493493
    494 int fat_create_node(fs_node_t **rfn, devmap_handle_t devmap_handle, int flags)
     494int fat_create_node(fs_node_t **rfn, service_id_t service_id, int flags)
    495495{
    496496        fat_idx_t *idxp;
     
    500500        int rc;
    501501
    502         bs = block_bb_get(devmap_handle);
     502        bs = block_bb_get(service_id);
    503503        if (flags & L_DIRECTORY) {
    504504                /* allocate a cluster */
    505                 rc = fat_alloc_clusters(bs, devmap_handle, 1, &mcl, &lcl);
     505                rc = fat_alloc_clusters(bs, service_id, 1, &mcl, &lcl);
    506506                if (rc != EOK)
    507507                        return rc;
    508508                /* populate the new cluster with unused dentries */
    509                 rc = fat_zero_cluster(bs, devmap_handle, mcl);
     509                rc = fat_zero_cluster(bs, service_id, mcl);
    510510                if (rc != EOK) {
    511                         (void) fat_free_clusters(bs, devmap_handle, mcl);
     511                        (void) fat_free_clusters(bs, service_id, mcl);
    512512                        return rc;
    513513                }
     
    516516        rc = fat_node_get_new(&nodep);
    517517        if (rc != EOK) {
    518                 (void) fat_free_clusters(bs, devmap_handle, mcl);
    519                 return rc;
    520         }
    521         rc = fat_idx_get_new(&idxp, devmap_handle);
     518                (void) fat_free_clusters(bs, service_id, mcl);
     519                return rc;
     520        }
     521        rc = fat_idx_get_new(&idxp, service_id);
    522522        if (rc != EOK) {
    523                 (void) fat_free_clusters(bs, devmap_handle, mcl);       
     523                (void) fat_free_clusters(bs, service_id, mcl); 
    524524                (void) fat_node_put(FS_NODE(nodep));
    525525                return rc;
     
    570570        assert(!has_children);
    571571
    572         bs = block_bb_get(nodep->idx->devmap_handle);
     572        bs = block_bb_get(nodep->idx->service_id);
    573573        if (nodep->firstc != FAT_CLST_RES0) {
    574574                assert(nodep->size);
    575575                /* Free all clusters allocated to the node. */
    576                 rc = fat_free_clusters(bs, nodep->idx->devmap_handle,
     576                rc = fat_free_clusters(bs, nodep->idx->service_id,
    577577                    nodep->firstc);
    578578        }
     
    620620       
    621621        fibril_mutex_lock(&parentp->idx->lock);
    622         bs = block_bb_get(parentp->idx->devmap_handle);
     622        bs = block_bb_get(parentp->idx->service_id);
    623623
    624624        blocks = parentp->size / BPS(bs);
     
    659659                return ENOSPC;
    660660        }
    661         rc = fat_alloc_clusters(bs, parentp->idx->devmap_handle, 1, &mcl, &lcl);
     661        rc = fat_alloc_clusters(bs, parentp->idx->service_id, 1, &mcl, &lcl);
    662662        if (rc != EOK) {
    663663                fibril_mutex_unlock(&parentp->idx->lock);
    664664                return rc;
    665665        }
    666         rc = fat_zero_cluster(bs, parentp->idx->devmap_handle, mcl);
     666        rc = fat_zero_cluster(bs, parentp->idx->service_id, mcl);
    667667        if (rc != EOK) {
    668                 (void) fat_free_clusters(bs, parentp->idx->devmap_handle, mcl);
     668                (void) fat_free_clusters(bs, parentp->idx->service_id, mcl);
    669669                fibril_mutex_unlock(&parentp->idx->lock);
    670670                return rc;
     
    672672        rc = fat_append_clusters(bs, parentp, mcl, lcl);
    673673        if (rc != EOK) {
    674                 (void) fat_free_clusters(bs, parentp->idx->devmap_handle, mcl);
     674                (void) fat_free_clusters(bs, parentp->idx->service_id, mcl);
    675675                fibril_mutex_unlock(&parentp->idx->lock);
    676676                return rc;
     
    789789        assert(childp->lnkcnt == 1);
    790790        fibril_mutex_lock(&childp->idx->lock);
    791         bs = block_bb_get(childp->idx->devmap_handle);
    792 
    793         rc = _fat_block_get(&b, bs, childp->idx->devmap_handle, childp->idx->pfc,
     791        bs = block_bb_get(childp->idx->service_id);
     792
     793        rc = _fat_block_get(&b, bs, childp->idx->service_id, childp->idx->pfc,
    794794            NULL, (childp->idx->pdi * sizeof(fat_dentry_t)) / BPS(bs),
    795795            BLOCK_FLAGS_NONE);
     
    841841       
    842842        fibril_mutex_lock(&nodep->idx->lock);
    843         bs = block_bb_get(nodep->idx->devmap_handle);
     843        bs = block_bb_get(nodep->idx->service_id);
    844844
    845845        blocks = nodep->size / BPS(bs);
     
    910910}
    911911
    912 devmap_handle_t fat_device_get(fs_node_t *node)
     912service_id_t fat_device_get(fs_node_t *node)
    913913{
    914914        return 0;
     
    940940
    941941static int
    942 fat_mounted(devmap_handle_t devmap_handle, const char *opts, fs_index_t *index,
     942fat_mounted(service_id_t service_id, const char *opts, fs_index_t *index,
    943943    aoff64_t *size, unsigned *linkcnt)
    944944{
     
    954954
    955955        /* initialize libblock */
    956         rc = block_init(EXCHANGE_SERIALIZE, devmap_handle, BS_SIZE);
     956        rc = block_init(EXCHANGE_SERIALIZE, service_id, BS_SIZE);
    957957        if (rc != EOK)
    958958                return rc;
    959959
    960960        /* prepare the boot block */
    961         rc = block_bb_read(devmap_handle, BS_BLOCK);
     961        rc = block_bb_read(service_id, BS_BLOCK);
    962962        if (rc != EOK) {
    963                 block_fini(devmap_handle);
     963                block_fini(service_id);
    964964                return rc;
    965965        }
    966966
    967967        /* get the buffer with the boot sector */
    968         bs = block_bb_get(devmap_handle);
     968        bs = block_bb_get(service_id);
    969969       
    970970        if (BPS(bs) != BS_SIZE) {
    971                 block_fini(devmap_handle);
     971                block_fini(service_id);
    972972                return ENOTSUP;
    973973        }
    974974
    975975        /* Initialize the block cache */
    976         rc = block_cache_init(devmap_handle, BPS(bs), 0 /* XXX */, cmode);
     976        rc = block_cache_init(service_id, BPS(bs), 0 /* XXX */, cmode);
    977977        if (rc != EOK) {
    978                 block_fini(devmap_handle);
     978                block_fini(service_id);
    979979                return rc;
    980980        }
    981981
    982982        /* Do some simple sanity checks on the file system. */
    983         rc = fat_sanity_check(bs, devmap_handle);
     983        rc = fat_sanity_check(bs, service_id);
    984984        if (rc != EOK) {
    985                 (void) block_cache_fini(devmap_handle);
    986                 block_fini(devmap_handle);
    987                 return rc;
    988         }
    989 
    990         rc = fat_idx_init_by_devmap_handle(devmap_handle);
     985                (void) block_cache_fini(service_id);
     986                block_fini(service_id);
     987                return rc;
     988        }
     989
     990        rc = fat_idx_init_by_service_id(service_id);
    991991        if (rc != EOK) {
    992                 (void) block_cache_fini(devmap_handle);
    993                 block_fini(devmap_handle);
     992                (void) block_cache_fini(service_id);
     993                block_fini(service_id);
    994994                return rc;
    995995        }
     
    998998        fs_node_t *rfn = (fs_node_t *)malloc(sizeof(fs_node_t));
    999999        if (!rfn) {
    1000                 (void) block_cache_fini(devmap_handle);
    1001                 block_fini(devmap_handle);
    1002                 fat_idx_fini_by_devmap_handle(devmap_handle);
     1000                (void) block_cache_fini(service_id);
     1001                block_fini(service_id);
     1002                fat_idx_fini_by_service_id(service_id);
    10031003                return ENOMEM;
    10041004        }
     
    10071007        if (!rootp) {
    10081008                free(rfn);
    1009                 (void) block_cache_fini(devmap_handle);
    1010                 block_fini(devmap_handle);
    1011                 fat_idx_fini_by_devmap_handle(devmap_handle);
     1009                (void) block_cache_fini(service_id);
     1010                block_fini(service_id);
     1011                fat_idx_fini_by_service_id(service_id);
    10121012                return ENOMEM;
    10131013        }
    10141014        fat_node_initialize(rootp);
    10151015
    1016         fat_idx_t *ridxp = fat_idx_get_by_pos(devmap_handle, FAT_CLST_ROOTPAR, 0);
     1016        fat_idx_t *ridxp = fat_idx_get_by_pos(service_id, FAT_CLST_ROOTPAR, 0);
    10171017        if (!ridxp) {
    10181018                free(rfn);
    10191019                free(rootp);
    1020                 (void) block_cache_fini(devmap_handle);
    1021                 block_fini(devmap_handle);
    1022                 fat_idx_fini_by_devmap_handle(devmap_handle);
     1020                (void) block_cache_fini(service_id);
     1021                block_fini(service_id);
     1022                fat_idx_fini_by_service_id(service_id);
    10231023                return ENOMEM;
    10241024        }
     
    10451045}
    10461046
    1047 static int fat_unmounted(devmap_handle_t devmap_handle)
     1047static int fat_unmounted(service_id_t service_id)
    10481048{
    10491049        fs_node_t *fn;
     
    10511051        int rc;
    10521052
    1053         rc = fat_root_get(&fn, devmap_handle);
     1053        rc = fat_root_get(&fn, service_id);
    10541054        if (rc != EOK)
    10551055                return rc;
     
    10761076         * stop using libblock for this instance.
    10771077         */
    1078         (void) fat_node_fini_by_devmap_handle(devmap_handle);
    1079         fat_idx_fini_by_devmap_handle(devmap_handle);
    1080         (void) block_cache_fini(devmap_handle);
    1081         block_fini(devmap_handle);
     1078        (void) fat_node_fini_by_service_id(service_id);
     1079        fat_idx_fini_by_service_id(service_id);
     1080        (void) block_cache_fini(service_id);
     1081        block_fini(service_id);
    10821082
    10831083        return EOK;
     
    10851085
    10861086static int
    1087 fat_read(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t pos,
     1087fat_read(service_id_t service_id, fs_index_t index, aoff64_t pos,
    10881088    size_t *rbytes)
    10891089{
     
    10951095        int rc;
    10961096
    1097         rc = fat_node_get(&fn, devmap_handle, index);
     1097        rc = fat_node_get(&fn, service_id, index);
    10981098        if (rc != EOK)
    10991099                return rc;
     
    11101110        }
    11111111
    1112         bs = block_bb_get(devmap_handle);
     1112        bs = block_bb_get(service_id);
    11131113
    11141114        if (nodep->type == FAT_FILE) {
     
    12131213
    12141214static int
    1215 fat_write(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t pos,
     1215fat_write(service_id_t service_id, fs_index_t index, aoff64_t pos,
    12161216    size_t *wbytes, aoff64_t *nsize)
    12171217{
     
    12251225        int rc;
    12261226       
    1227         rc = fat_node_get(&fn, devmap_handle, index);
     1227        rc = fat_node_get(&fn, service_id, index);
    12281228        if (rc != EOK)
    12291229                return rc;
     
    12401240        }
    12411241
    1242         bs = block_bb_get(devmap_handle);
     1242        bs = block_bb_get(service_id);
    12431243
    12441244        /*
     
    12991299                nclsts = (ROUND_UP(pos + bytes, BPC(bs)) - boundary) / BPC(bs);
    13001300                /* create an independent chain of nclsts clusters in all FATs */
    1301                 rc = fat_alloc_clusters(bs, devmap_handle, nclsts, &mcl, &lcl);
     1301                rc = fat_alloc_clusters(bs, service_id, nclsts, &mcl, &lcl);
    13021302                if (rc != EOK) {
    13031303                        /* could not allocate a chain of nclsts clusters */
     
    13091309                rc = fat_fill_gap(bs, nodep, mcl, pos);
    13101310                if (rc != EOK) {
    1311                         (void) fat_free_clusters(bs, devmap_handle, mcl);
     1311                        (void) fat_free_clusters(bs, service_id, mcl);
    13121312                        (void) fat_node_put(fn);
    13131313                        async_answer_0(callid, rc);
    13141314                        return rc;
    13151315                }
    1316                 rc = _fat_block_get(&b, bs, devmap_handle, lcl, NULL,
     1316                rc = _fat_block_get(&b, bs, service_id, lcl, NULL,
    13171317                    (pos / BPS(bs)) % SPC(bs), flags);
    13181318                if (rc != EOK) {
    1319                         (void) fat_free_clusters(bs, devmap_handle, mcl);
     1319                        (void) fat_free_clusters(bs, service_id, mcl);
    13201320                        (void) fat_node_put(fn);
    13211321                        async_answer_0(callid, rc);
     
    13271327                rc = block_put(b);
    13281328                if (rc != EOK) {
    1329                         (void) fat_free_clusters(bs, devmap_handle, mcl);
     1329                        (void) fat_free_clusters(bs, service_id, mcl);
    13301330                        (void) fat_node_put(fn);
    13311331                        return rc;
     
    13371337                rc = fat_append_clusters(bs, nodep, mcl, lcl);
    13381338                if (rc != EOK) {
    1339                         (void) fat_free_clusters(bs, devmap_handle, mcl);
     1339                        (void) fat_free_clusters(bs, service_id, mcl);
    13401340                        (void) fat_node_put(fn);
    13411341                        return rc;
     
    13501350
    13511351static int
    1352 fat_truncate(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t size)
     1352fat_truncate(service_id_t service_id, fs_index_t index, aoff64_t size)
    13531353{
    13541354        fs_node_t *fn;
     
    13571357        int rc;
    13581358
    1359         rc = fat_node_get(&fn, devmap_handle, index);
     1359        rc = fat_node_get(&fn, service_id, index);
    13601360        if (rc != EOK)
    13611361                return rc;
     
    13641364        nodep = FAT_NODE(fn);
    13651365
    1366         bs = block_bb_get(devmap_handle);
     1366        bs = block_bb_get(service_id);
    13671367
    13681368        if (nodep->size == size) {
     
    13911391                } else {
    13921392                        fat_cluster_t lastc;
    1393                         rc = fat_cluster_walk(bs, devmap_handle, nodep->firstc,
     1393                        rc = fat_cluster_walk(bs, service_id, nodep->firstc,
    13941394                            &lastc, NULL, (size - 1) / BPC(bs));
    13951395                        if (rc != EOK)
     
    14081408}
    14091409
    1410 static int fat_close(devmap_handle_t devmap_handle, fs_index_t index)
     1410static int fat_close(service_id_t service_id, fs_index_t index)
    14111411{
    14121412        return EOK;
    14131413}
    14141414
    1415 static int fat_destroy(devmap_handle_t devmap_handle, fs_index_t index)
     1415static int fat_destroy(service_id_t service_id, fs_index_t index)
    14161416{
    14171417        fs_node_t *fn;
     
    14191419        int rc;
    14201420
    1421         rc = fat_node_get(&fn, devmap_handle, index);
     1421        rc = fat_node_get(&fn, service_id, index);
    14221422        if (rc != EOK)
    14231423                return rc;
     
    14361436}
    14371437
    1438 static int fat_sync(devmap_handle_t devmap_handle, fs_index_t index)
     1438static int fat_sync(service_id_t service_id, fs_index_t index)
    14391439{
    14401440        fs_node_t *fn;
    1441         int rc = fat_node_get(&fn, devmap_handle, index);
     1441        int rc = fat_node_get(&fn, service_id, index);
    14421442        if (rc != EOK)
    14431443                return rc;
  • uspace/srv/fs/locfs/Makefile

    rd894fbd r903bac0a  
    3131LIBS = $(LIBFS_PREFIX)/libfs.a
    3232EXTRA_CFLAGS += -I$(LIBFS_PREFIX)
    33 BINARY = devfs
     33BINARY = locfs
    3434STATIC_NEEDED = y
    3535
    3636SOURCES = \
    37         devfs.c \
    38         devfs_ops.c
     37        locfs.c \
     38        locfs_ops.c
    3939
    4040include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/fs/locfs/locfs.c

    rd894fbd r903bac0a  
    3232
    3333/**
    34  * @file devfs.c
    35  * @brief Devices file system.
     34 * @file locfs.c
     35 * @brief Location-service file system.
    3636 *
    37  * Every device registered to device mapper is represented as a file in this
     37 * Every service registered with location service is represented as a file in this
    3838 * file system.
    3939 */
     
    4646#include <task.h>
    4747#include <libfs.h>
    48 #include "devfs.h"
    49 #include "devfs_ops.h"
     48#include "locfs.h"
     49#include "locfs_ops.h"
    5050
    51 #define NAME  "devfs"
     51#define NAME  "locfs"
    5252
    53 static vfs_info_t devfs_vfs_info = {
     53static vfs_info_t locfs_vfs_info = {
    5454        .name = NAME,
    5555        .concurrent_read_write = false,
     
    6161        printf("%s: HelenOS Device Filesystem\n", NAME);
    6262       
    63         if (!devfs_init()) {
    64                 printf("%s: failed to initialize devfs\n", NAME);
     63        if (!locfs_init()) {
     64                printf("%s: failed to initialize locfs\n", NAME);
    6565                return -1;
    6666        }
     
    7373        }
    7474       
    75         int rc = fs_register(vfs_sess, &devfs_vfs_info, &devfs_ops,
    76             &devfs_libfs_ops);
     75        int rc = fs_register(vfs_sess, &locfs_vfs_info, &locfs_ops,
     76            &locfs_libfs_ops);
    7777        if (rc != EOK) {
    7878                printf("%s: Failed to register file system (%d)\n", NAME, rc);
  • uspace/srv/fs/locfs/locfs.h

    rd894fbd r903bac0a  
    3131 */
    3232
    33 #ifndef DEVFS_DEVFS_H_
    34 #define DEVFS_DEVFS_H_
     33#ifndef LOCFS_LOCFS_H_
     34#define LOCFS_LOCFS_H_
    3535
    3636#include <libfs.h>
    3737
    38 extern vfs_out_ops_t devfs_ops;
    39 extern libfs_ops_t devfs_libfs_ops;
     38extern vfs_out_ops_t locfs_ops;
     39extern libfs_ops_t locfs_libfs_ops;
    4040
    4141#endif
  • uspace/srv/fs/locfs/locfs_ops.c

    rd894fbd r903bac0a  
    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 bool devfs_is_directory(fs_node_t *fn)
    406 {
    407         devfs_node_t *node = (devfs_node_t *) fn->data;
    408        
    409         return ((node->type == DEV_HANDLE_NONE) || (node->type == DEV_HANDLE_NAMESPACE));
    410 }
    411 
    412 static bool devfs_is_file(fs_node_t *fn)
    413 {
    414         devfs_node_t *node = (devfs_node_t *) fn->data;
    415        
    416         return (node->type == DEV_HANDLE_DEVICE);
    417 }
    418 
    419 static devmap_handle_t devfs_device_get(fs_node_t *fn)
    420 {
    421         devfs_node_t *node = (devfs_node_t *) fn->data;
    422        
    423         if (node->type == DEV_HANDLE_DEVICE)
    424                 return node->handle;
     406static bool locfs_is_directory(fs_node_t *fn)
     407{
     408        locfs_node_t *node = (locfs_node_t *) fn->data;
     409       
     410        return ((node->type == LOC_OBJECT_NONE) || (node->type == LOC_OBJECT_NAMESPACE));
     411}
     412
     413static bool locfs_is_file(fs_node_t *fn)
     414{
     415        locfs_node_t *node = (locfs_node_t *) fn->data;
     416       
     417        return (node->type == LOC_OBJECT_SERVICE);
     418}
     419
     420static service_id_t locfs_device_get(fs_node_t *fn)
     421{
     422        locfs_node_t *node = (locfs_node_t *) fn->data;
     423       
     424        if (node->type == LOC_OBJECT_SERVICE)
     425                return node->service_id;
    425426       
    426427        return 0;
     
    428429
    429430/** libfs operations */
    430 libfs_ops_t devfs_libfs_ops = {
    431         .root_get = devfs_root_get,
    432         .match = devfs_match,
    433         .node_get = devfs_node_get,
    434         .node_open = devfs_node_open,
    435         .node_put = devfs_node_put,
    436         .create = devfs_create_node,
    437         .destroy = devfs_destroy_node,
    438         .link = devfs_link_node,
    439         .unlink = devfs_unlink_node,
    440         .has_children = devfs_has_children,
    441         .index_get = devfs_index_get,
    442         .size_get = devfs_size_get,
    443         .lnkcnt_get = devfs_lnkcnt_get,
    444         .is_directory = devfs_is_directory,
    445         .is_file = devfs_is_file,
    446         .device_get = devfs_device_get
     431libfs_ops_t locfs_libfs_ops = {
     432        .root_get = locfs_root_get,
     433        .match = locfs_match,
     434        .node_get = locfs_node_get,
     435        .node_open = locfs_node_open,
     436        .node_put = locfs_node_put,
     437        .create = locfs_create_node,
     438        .destroy = locfs_destroy_node,
     439        .link = locfs_link_node,
     440        .unlink = locfs_unlink_node,
     441        .has_children = locfs_has_children,
     442        .index_get = locfs_index_get,
     443        .size_get = locfs_size_get,
     444        .lnkcnt_get = locfs_lnkcnt_get,
     445        .is_directory = locfs_is_directory,
     446        .is_file = locfs_is_file,
     447        .device_get = locfs_device_get
    447448};
    448449
    449 bool devfs_init(void)
    450 {
    451         if (!hash_table_create(&devices, DEVICES_BUCKETS,
    452             DEVICES_KEYS, &devices_ops))
     450bool locfs_init(void)
     451{
     452        if (!hash_table_create(&services, SERVICES_BUCKETS,
     453            SERVICES_KEYS, &services_ops))
    453454                return false;
    454455       
     
    456457}
    457458
    458 static int devfs_mounted(devmap_handle_t devmap_handle, const char *opts,
     459static int locfs_mounted(service_id_t service_id, const char *opts,
    459460    fs_index_t *index, aoff64_t *size, unsigned *lnkcnt)
    460461{
     
    465466}
    466467
    467 static int devfs_unmounted(devmap_handle_t devmap_handle)
     468static int locfs_unmounted(service_id_t service_id)
    468469{
    469470        return ENOTSUP;
     
    471472
    472473static int
    473 devfs_read(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t pos,
     474locfs_read(service_id_t service_id, fs_index_t index, aoff64_t pos,
    474475    size_t *rbytes)
    475476{
     
    482483                }
    483484               
    484                 dev_desc_t *desc;
    485                 size_t count = devmap_get_namespaces(&desc);
     485                loc_sdesc_t *desc;
     486                size_t count = loc_get_namespaces(&desc);
    486487               
    487488                /* Get rid of root namespace */
     
    507508               
    508509                /* Search root namespace */
    509                 devmap_handle_t namespace;
    510                 if (devmap_namespace_get_handle("", &namespace, 0) == EOK) {
    511                         count = devmap_get_devices(namespace, &desc);
     510                service_id_t namespace;
     511                if (loc_namespace_get_id("", &namespace, 0) == EOK) {
     512                        count = loc_get_services(namespace, &desc);
    512513                       
    513514                        if (pos < count) {
     
    525526        }
    526527       
    527         devmap_handle_type_t type = devmap_handle_probe(index);
    528        
    529         if (type == DEV_HANDLE_NAMESPACE) {
     528        loc_object_type_t type = loc_id_probe(index);
     529       
     530        if (type == LOC_OBJECT_NAMESPACE) {
    530531                /* Namespace directory */
    531532                ipc_callid_t callid;
     
    536537                }
    537538               
    538                 dev_desc_t *desc;
    539                 size_t count = devmap_get_devices(index, &desc);
     539                loc_sdesc_t *desc;
     540                size_t count = loc_get_services(index, &desc);
    540541               
    541542                if (pos < count) {
     
    551552        }
    552553       
    553         if (type == DEV_HANDLE_DEVICE) {
     554        if (type == LOC_OBJECT_SERVICE) {
    554555                /* Device node */
    555556               
    556557                unsigned long key[] = {
    557                         [DEVICES_KEY_HANDLE] = (unsigned long) index
     558                        [SERVICES_KEY_HANDLE] = (unsigned long) index
    558559                };
    559560               
    560                 fibril_mutex_lock(&devices_mutex);
    561                 link_t *lnk = hash_table_find(&devices, key);
     561                fibril_mutex_lock(&services_mutex);
     562                link_t *lnk = hash_table_find(&services, key);
    562563                if (lnk == NULL) {
    563                         fibril_mutex_unlock(&devices_mutex);
     564                        fibril_mutex_unlock(&services_mutex);
    564565                        return ENOENT;
    565566                }
    566567               
    567                 device_t *dev = hash_table_get_instance(lnk, device_t, link);
     568                service_t *dev = hash_table_get_instance(lnk, service_t, link);
    568569                assert(dev->sess);
    569570               
    570571                ipc_callid_t callid;
    571572                if (!async_data_read_receive(&callid, NULL)) {
    572                         fibril_mutex_unlock(&devices_mutex);
     573                        fibril_mutex_unlock(&services_mutex);
    573574                        async_answer_0(callid, EINVAL);
    574575                        return EINVAL;
     
    579580               
    580581                ipc_call_t answer;
    581                 aid_t msg = async_send_4(exch, VFS_OUT_READ, devmap_handle,
     582                aid_t msg = async_send_4(exch, VFS_OUT_READ, service_id,
    582583                    index, LOWER32(pos), UPPER32(pos), &answer);
    583584               
     
    587588                async_exchange_end(exch);
    588589               
    589                 fibril_mutex_unlock(&devices_mutex);
     590                fibril_mutex_unlock(&services_mutex);
    590591               
    591592                /* Wait for reply from the driver. */
     
    601602
    602603static int
    603 devfs_write(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t pos,
     604locfs_write(service_id_t service_id, fs_index_t index, aoff64_t pos,
    604605    size_t *wbytes, aoff64_t *nsize)
    605606{
     
    607608                return ENOTSUP;
    608609       
    609         devmap_handle_type_t type = devmap_handle_probe(index);
    610        
    611         if (type == DEV_HANDLE_NAMESPACE) {
     610        loc_object_type_t type = loc_id_probe(index);
     611       
     612        if (type == LOC_OBJECT_NAMESPACE) {
    612613                /* Namespace directory */
    613614                return ENOTSUP;
    614615        }
    615616       
    616         if (type == DEV_HANDLE_DEVICE) {
     617        if (type == LOC_OBJECT_SERVICE) {
    617618                /* Device node */
    618619                unsigned long key[] = {
    619                         [DEVICES_KEY_HANDLE] = (unsigned long) index
     620                        [SERVICES_KEY_HANDLE] = (unsigned long) index
    620621                };
    621622               
    622                 fibril_mutex_lock(&devices_mutex);
    623                 link_t *lnk = hash_table_find(&devices, key);
     623                fibril_mutex_lock(&services_mutex);
     624                link_t *lnk = hash_table_find(&services, key);
    624625                if (lnk == NULL) {
    625                         fibril_mutex_unlock(&devices_mutex);
     626                        fibril_mutex_unlock(&services_mutex);
    626627                        return ENOENT;
    627628                }
    628629               
    629                 device_t *dev = hash_table_get_instance(lnk, device_t, link);
     630                service_t *dev = hash_table_get_instance(lnk, service_t, link);
    630631                assert(dev->sess);
    631632               
    632633                ipc_callid_t callid;
    633634                if (!async_data_write_receive(&callid, NULL)) {
    634                         fibril_mutex_unlock(&devices_mutex);
     635                        fibril_mutex_unlock(&services_mutex);
    635636                        async_answer_0(callid, EINVAL);
    636637                        return EINVAL;
     
    641642               
    642643                ipc_call_t answer;
    643                 aid_t msg = async_send_4(exch, VFS_OUT_WRITE, devmap_handle,
     644                aid_t msg = async_send_4(exch, VFS_OUT_WRITE, service_id,
    644645                    index, LOWER32(pos), UPPER32(pos), &answer);
    645646               
     
    649650                async_exchange_end(exch);
    650651               
    651                 fibril_mutex_unlock(&devices_mutex);
     652                fibril_mutex_unlock(&services_mutex);
    652653               
    653654                /* Wait for reply from the driver. */
     
    664665
    665666static int
    666 devfs_truncate(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t size)
     667locfs_truncate(service_id_t service_id, fs_index_t index, aoff64_t size)
    667668{
    668669        return ENOTSUP;
    669670}
    670671
    671 static int devfs_close(devmap_handle_t devmap_handle, fs_index_t index)
     672static int locfs_close(service_id_t service_id, fs_index_t index)
    672673{
    673674        if (index == 0)
    674675                return EOK;
    675676       
    676         devmap_handle_type_t type = devmap_handle_probe(index);
    677        
    678         if (type == DEV_HANDLE_NAMESPACE) {
     677        loc_object_type_t type = loc_id_probe(index);
     678       
     679        if (type == LOC_OBJECT_NAMESPACE) {
    679680                /* Namespace directory */
    680681                return EOK;
    681682        }
    682683       
    683         if (type == DEV_HANDLE_DEVICE) {
     684        if (type == LOC_OBJECT_SERVICE) {
    684685                unsigned long key[] = {
    685                         [DEVICES_KEY_HANDLE] = (unsigned long) index
     686                        [SERVICES_KEY_HANDLE] = (unsigned long) index
    686687                };
    687688               
    688                 fibril_mutex_lock(&devices_mutex);
    689                 link_t *lnk = hash_table_find(&devices, key);
     689                fibril_mutex_lock(&services_mutex);
     690                link_t *lnk = hash_table_find(&services, key);
    690691                if (lnk == NULL) {
    691                         fibril_mutex_unlock(&devices_mutex);
     692                        fibril_mutex_unlock(&services_mutex);
    692693                        return ENOENT;
    693694                }
    694695               
    695                 device_t *dev = hash_table_get_instance(lnk, device_t, link);
     696                service_t *dev = hash_table_get_instance(lnk, service_t, link);
    696697                assert(dev->sess);
    697698                dev->refcount--;
     
    699700                if (dev->refcount == 0) {
    700701                        async_hangup(dev->sess);
    701                         hash_table_remove(&devices, key, DEVICES_KEYS);
    702                 }
    703                
    704                 fibril_mutex_unlock(&devices_mutex);
     702                        hash_table_remove(&services, key, SERVICES_KEYS);
     703                }
     704               
     705                fibril_mutex_unlock(&services_mutex);
    705706               
    706707                return EOK;
     
    710711}
    711712
    712 static int devfs_sync(devmap_handle_t devmap_handle, fs_index_t index)
     713static int locfs_sync(service_id_t service_id, fs_index_t index)
    713714{
    714715        if (index == 0)
    715716                return EOK;
    716717       
    717         devmap_handle_type_t type = devmap_handle_probe(index);
    718        
    719         if (type == DEV_HANDLE_NAMESPACE) {
     718        loc_object_type_t type = loc_id_probe(index);
     719       
     720        if (type == LOC_OBJECT_NAMESPACE) {
    720721                /* Namespace directory */
    721722                return EOK;
    722723        }
    723724       
    724         if (type == DEV_HANDLE_DEVICE) {
     725        if (type == LOC_OBJECT_SERVICE) {
    725726                unsigned long key[] = {
    726                         [DEVICES_KEY_HANDLE] = (unsigned long) index
     727                        [SERVICES_KEY_HANDLE] = (unsigned long) index
    727728                };
    728729               
    729                 fibril_mutex_lock(&devices_mutex);
    730                 link_t *lnk = hash_table_find(&devices, key);
     730                fibril_mutex_lock(&services_mutex);
     731                link_t *lnk = hash_table_find(&services, key);
    731732                if (lnk == NULL) {
    732                         fibril_mutex_unlock(&devices_mutex);
     733                        fibril_mutex_unlock(&services_mutex);
    733734                        return ENOENT;
    734735                }
    735736               
    736                 device_t *dev = hash_table_get_instance(lnk, device_t, link);
     737                service_t *dev = hash_table_get_instance(lnk, service_t, link);
    737738                assert(dev->sess);
    738739               
     
    741742               
    742743                ipc_call_t answer;
    743                 aid_t msg = async_send_2(exch, VFS_OUT_SYNC, devmap_handle,
     744                aid_t msg = async_send_2(exch, VFS_OUT_SYNC, service_id,
    744745                    index, &answer);
    745746               
    746747                async_exchange_end(exch);
    747748               
    748                 fibril_mutex_unlock(&devices_mutex);
     749                fibril_mutex_unlock(&services_mutex);
    749750               
    750751                /* Wait for reply from the driver */
     
    758759}
    759760
    760 static int devfs_destroy(devmap_handle_t devmap_handle, fs_index_t index)
     761static int locfs_destroy(service_id_t service_id, fs_index_t index)
    761762{
    762763        return ENOTSUP;
    763764}
    764765
    765 vfs_out_ops_t devfs_ops = {
    766         .mounted = devfs_mounted,
    767         .unmounted = devfs_unmounted,
    768         .read = devfs_read,
    769         .write = devfs_write,
    770         .truncate = devfs_truncate,
    771         .close = devfs_close,
    772         .destroy = devfs_destroy,
    773         .sync = devfs_sync,
     766vfs_out_ops_t locfs_ops = {
     767        .mounted = locfs_mounted,
     768        .unmounted = locfs_unmounted,
     769        .read = locfs_read,
     770        .write = locfs_write,
     771        .truncate = locfs_truncate,
     772        .close = locfs_close,
     773        .destroy = locfs_destroy,
     774        .sync = locfs_sync,
    774775};
    775776
  • uspace/srv/fs/locfs/locfs_ops.h

    rd894fbd r903bac0a  
    3131 */
    3232
    33 #ifndef DEVFS_DEVFS_OPS_H_
    34 #define DEVFS_DEVFS_OPS_H_
     33#ifndef LOCFS_LOCFS_OPS_H_
     34#define LOCFS_LOCFS_OPS_H_
    3535
    3636#include <bool.h>
    3737
    38 extern bool devfs_init(void);
     38extern bool locfs_init(void);
    3939
    4040#endif
  • uspace/srv/fs/tmpfs/tmpfs.h

    rd894fbd r903bac0a  
    6161        fs_node_t *bp;          /**< Back pointer to the FS node. */
    6262        fs_index_t index;       /**< TMPFS node index. */
    63         devmap_handle_t devmap_handle;/**< Device handle. */
     63        service_id_t service_id;/**< Service ID of block device. */
    6464        link_t nh_link;         /**< Nodes hash table link. */
    6565        tmpfs_dentry_type_t type;
     
    7474
    7575extern bool tmpfs_init(void);
    76 extern bool tmpfs_restore(devmap_handle_t);
     76extern bool tmpfs_restore(service_id_t);
    7777
    7878#endif
  • uspace/srv/fs/tmpfs/tmpfs_dump.c

    rd894fbd r903bac0a  
    5555
    5656static bool
    57 tmpfs_restore_recursion(devmap_handle_t dev, size_t *bufpos, size_t *buflen,
     57tmpfs_restore_recursion(service_id_t dsid, size_t *bufpos, size_t *buflen,
    5858    aoff64_t *pos, fs_node_t *pfn)
    5959{
     
    6868                uint32_t size;
    6969               
    70                 if (block_seqread(dev, bufpos, buflen, pos, &entry,
     70                if (block_seqread(dsid, bufpos, buflen, pos, &entry,
    7171                    sizeof(entry)) != EOK)
    7272                        return false;
     
    8282                                return false;
    8383                       
    84                         rc = ops->create(&fn, dev, L_FILE);
     84                        rc = ops->create(&fn, dsid, L_FILE);
    8585                        if (rc != EOK || fn == NULL) {
    8686                                free(fname);
     
    8888                        }
    8989                       
    90                         if (block_seqread(dev, bufpos, buflen, pos, fname,
     90                        if (block_seqread(dsid, bufpos, buflen, pos, fname,
    9191                            entry.len) != EOK) {
    9292                                (void) ops->destroy(fn);
     
    104104                        free(fname);
    105105                       
    106                         if (block_seqread(dev, bufpos, buflen, pos, &size,
     106                        if (block_seqread(dsid, bufpos, buflen, pos, &size,
    107107                            sizeof(size)) != EOK)
    108108                                return false;
     
    116116                       
    117117                        nodep->size = size;
    118                         if (block_seqread(dev, bufpos, buflen, pos, nodep->data,
     118                        if (block_seqread(dsid, bufpos, buflen, pos, nodep->data,
    119119                            size) != EOK)
    120120                                return false;
     
    126126                                return false;
    127127                       
    128                         rc = ops->create(&fn, dev, L_DIRECTORY);
     128                        rc = ops->create(&fn, dsid, L_DIRECTORY);
    129129                        if (rc != EOK || fn == NULL) {
    130130                                free(fname);
     
    132132                        }
    133133                       
    134                         if (block_seqread(dev, bufpos, buflen, pos, fname,
     134                        if (block_seqread(dsid, bufpos, buflen, pos, fname,
    135135                            entry.len) != EOK) {
    136136                                (void) ops->destroy(fn);
     
    148148                        free(fname);
    149149                       
    150                         if (!tmpfs_restore_recursion(dev, bufpos, buflen, pos,
     150                        if (!tmpfs_restore_recursion(dsid, bufpos, buflen, pos,
    151151                            fn))
    152152                                return false;
     
    161161}
    162162
    163 bool tmpfs_restore(devmap_handle_t dev)
     163bool tmpfs_restore(service_id_t dsid)
    164164{
    165165        libfs_ops_t *ops = &tmpfs_libfs_ops;
     
    167167        int rc;
    168168
    169         rc = block_init(EXCHANGE_SERIALIZE, dev, TMPFS_COMM_SIZE);
     169        rc = block_init(EXCHANGE_SERIALIZE, dsid, TMPFS_COMM_SIZE);
    170170        if (rc != EOK)
    171171                return false;
     
    176176       
    177177        char tag[6];
    178         if (block_seqread(dev, &bufpos, &buflen, &pos, tag, 5) != EOK)
     178        if (block_seqread(dsid, &bufpos, &buflen, &pos, tag, 5) != EOK)
    179179                goto error;
    180180       
     
    183183                goto error;
    184184       
    185         rc = ops->root_get(&fn, dev);
     185        rc = ops->root_get(&fn, dsid);
    186186        if (rc != EOK)
    187187                goto error;
    188188
    189         if (!tmpfs_restore_recursion(dev, &bufpos, &buflen, &pos, fn))
    190                 goto error;
    191                
    192         block_fini(dev);
     189        if (!tmpfs_restore_recursion(dsid, &bufpos, &buflen, &pos, fn))
     190                goto error;
     191               
     192        block_fini(dsid);
    193193        return true;
    194194       
    195195error:
    196         block_fini(dev);
     196        block_fini(dsid);
    197197        return false;
    198198}
  • uspace/srv/fs/tmpfs/tmpfs_ops.c

    rd894fbd r903bac0a  
    6969/* Forward declarations of static functions. */
    7070static 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);
     71static int tmpfs_node_get(fs_node_t **, service_id_t, fs_index_t);
    7272static int tmpfs_node_open(fs_node_t *);
    7373static int tmpfs_node_put(fs_node_t *);
    74 static int tmpfs_create_node(fs_node_t **, devmap_handle_t, int);
     74static int tmpfs_create_node(fs_node_t **, service_id_t, int);
    7575static int tmpfs_destroy_node(fs_node_t *);
    7676static int tmpfs_link_node(fs_node_t *, fs_node_t *, const char *);
     
    7878
    7979/* 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);
     80static int tmpfs_root_get(fs_node_t **rfn, service_id_t service_id)
     81{
     82        return tmpfs_node_get(rfn, service_id, TMPFS_SOME_ROOT);
    8383}
    8484
     
    114114}
    115115
    116 static devmap_handle_t tmpfs_device_get(fs_node_t *fn)
     116static service_id_t tmpfs_device_get(fs_node_t *fn)
    117117{
    118118        return 0;
     
    158158        switch (keys) {
    159159        case 1:
    160                 return (nodep->devmap_handle == key[NODES_KEY_DEV]);
     160                return (nodep->service_id == key[NODES_KEY_DEV]);
    161161        case 2:
    162                 return ((nodep->devmap_handle == key[NODES_KEY_DEV]) &&
     162                return ((nodep->service_id == key[NODES_KEY_DEV]) &&
    163163                    (nodep->index == key[NODES_KEY_INDEX]));
    164164        default:
     
    202202        nodep->bp = NULL;
    203203        nodep->index = 0;
    204         nodep->devmap_handle = 0;
     204        nodep->service_id = 0;
    205205        nodep->type = TMPFS_NONE;
    206206        nodep->lnkcnt = 0;
     
    226226}
    227227
    228 static bool tmpfs_instance_init(devmap_handle_t devmap_handle)
     228static bool tmpfs_instance_init(service_id_t service_id)
    229229{
    230230        fs_node_t *rfn;
    231231        int rc;
    232232       
    233         rc = tmpfs_create_node(&rfn, devmap_handle, L_DIRECTORY);
     233        rc = tmpfs_create_node(&rfn, service_id, L_DIRECTORY);
    234234        if (rc != EOK || !rfn)
    235235                return false;
     
    238238}
    239239
    240 static void tmpfs_instance_done(devmap_handle_t devmap_handle)
    241 {
    242         unsigned long key[] = {
    243                 [NODES_KEY_DEV] = devmap_handle
     240static void tmpfs_instance_done(service_id_t service_id)
     241{
     242        unsigned long key[] = {
     243                [NODES_KEY_DEV] = service_id
    244244        };
    245245        /*
     
    270270}
    271271
    272 int tmpfs_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle, fs_index_t index)
    273 {
    274         unsigned long key[] = {
    275                 [NODES_KEY_DEV] = devmap_handle,
     272int tmpfs_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index)
     273{
     274        unsigned long key[] = {
     275                [NODES_KEY_DEV] = service_id,
    276276                [NODES_KEY_INDEX] = index
    277277        };
     
    299299}
    300300
    301 int tmpfs_create_node(fs_node_t **rfn, devmap_handle_t devmap_handle, int lflag)
     301int tmpfs_create_node(fs_node_t **rfn, service_id_t service_id, int lflag)
    302302{
    303303        fs_node_t *rootfn;
     
    318318        nodep->bp->data = nodep;        /* link the FS and TMPFS nodes */
    319319
    320         rc = tmpfs_root_get(&rootfn, devmap_handle);
     320        rc = tmpfs_root_get(&rootfn, service_id);
    321321        assert(rc == EOK);
    322322        if (!rootfn)
     
    324324        else
    325325                nodep->index = tmpfs_next_index++;
    326         nodep->devmap_handle = devmap_handle;
     326        nodep->service_id = service_id;
    327327        if (lflag & L_DIRECTORY)
    328328                nodep->type = TMPFS_DIRECTORY;
     
    332332        /* Insert the new node into the nodes hash table. */
    333333        unsigned long key[] = {
    334                 [NODES_KEY_DEV] = nodep->devmap_handle,
     334                [NODES_KEY_DEV] = nodep->service_id,
    335335                [NODES_KEY_INDEX] = nodep->index
    336336        };
     
    348348
    349349        unsigned long key[] = {
    350                 [NODES_KEY_DEV] = nodep->devmap_handle,
     350                [NODES_KEY_DEV] = nodep->service_id,
    351351                [NODES_KEY_INDEX] = nodep->index
    352352        };
     
    432432
    433433static int
    434 tmpfs_mounted(devmap_handle_t devmap_handle, const char *opts,
     434tmpfs_mounted(service_id_t service_id, const char *opts,
    435435    fs_index_t *index, aoff64_t *size, unsigned *lnkcnt)
    436436{
     
    439439       
    440440        /* Check if this device is not already mounted. */
    441         rc = tmpfs_root_get(&rootfn, devmap_handle);
     441        rc = tmpfs_root_get(&rootfn, service_id);
    442442        if ((rc == EOK) && (rootfn)) {
    443443                (void) tmpfs_node_put(rootfn);
     
    446446
    447447        /* Initialize TMPFS instance. */
    448         if (!tmpfs_instance_init(devmap_handle))
     448        if (!tmpfs_instance_init(service_id))
    449449                return ENOMEM;
    450450
    451         rc = tmpfs_root_get(&rootfn, devmap_handle);
     451        rc = tmpfs_root_get(&rootfn, service_id);
    452452        assert(rc == EOK);
    453453        tmpfs_node_t *rootp = TMPFS_NODE(rootfn);
    454454        if (str_cmp(opts, "restore") == 0) {
    455                 if (!tmpfs_restore(devmap_handle))
     455                if (!tmpfs_restore(service_id))
    456456                        return ELIMIT;
    457457        }
     
    464464}
    465465
    466 static int tmpfs_unmounted(devmap_handle_t devmap_handle)
    467 {
    468         tmpfs_instance_done(devmap_handle);
    469         return EOK;
    470 }
    471 
    472 static int tmpfs_read(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t pos,
     466static int tmpfs_unmounted(service_id_t service_id)
     467{
     468        tmpfs_instance_done(service_id);
     469        return EOK;
     470}
     471
     472static int tmpfs_read(service_id_t service_id, fs_index_t index, aoff64_t pos,
    473473    size_t *rbytes)
    474474{
     
    478478        link_t *hlp;
    479479        unsigned long key[] = {
    480                 [NODES_KEY_DEV] = devmap_handle,
     480                [NODES_KEY_DEV] = service_id,
    481481                [NODES_KEY_INDEX] = index
    482482        };
     
    532532
    533533static int
    534 tmpfs_write(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t pos,
     534tmpfs_write(service_id_t service_id, fs_index_t index, aoff64_t pos,
    535535    size_t *wbytes, aoff64_t *nsize)
    536536{
     
    540540        link_t *hlp;
    541541        unsigned long key[] = {
    542                 [NODES_KEY_DEV] = devmap_handle,
     542                [NODES_KEY_DEV] = service_id,
    543543                [NODES_KEY_INDEX] = index
    544544        };
     
    594594}
    595595
    596 static int tmpfs_truncate(devmap_handle_t devmap_handle, fs_index_t index,
     596static int tmpfs_truncate(service_id_t service_id, fs_index_t index,
    597597    aoff64_t size)
    598598{
     
    601601         */
    602602        unsigned long key[] = {
    603                 [NODES_KEY_DEV] = devmap_handle,
     603                [NODES_KEY_DEV] = service_id,
    604604                [NODES_KEY_INDEX] = index
    605605        };
     
    629629}
    630630
    631 static int tmpfs_close(devmap_handle_t devmap_handle, fs_index_t index)
    632 {
    633         return EOK;
    634 }
    635 
    636 static int tmpfs_destroy(devmap_handle_t devmap_handle, fs_index_t index)
     631static int tmpfs_close(service_id_t service_id, fs_index_t index)
     632{
     633        return EOK;
     634}
     635
     636static int tmpfs_destroy(service_id_t service_id, fs_index_t index)
    637637{
    638638        link_t *hlp;
    639639        unsigned long key[] = {
    640                 [NODES_KEY_DEV] = devmap_handle,
     640                [NODES_KEY_DEV] = service_id,
    641641                [NODES_KEY_INDEX] = index
    642642        };
     
    649649}
    650650
    651 static int tmpfs_sync(devmap_handle_t devmap_handle, fs_index_t index)
     651static int tmpfs_sync(service_id_t service_id, fs_index_t index)
    652652{
    653653        /*
  • uspace/srv/hid/console/console.c

    rd894fbd r903bac0a  
    5353#include <sysinfo.h>
    5454#include <event.h>
    55 #include <devmap.h>
     55#include <loc.h>
    5656#include <fcntl.h>
    5757#include <vfs/vfs.h>
     
    8181        size_t index;             /**< Console index */
    8282        size_t refcount;          /**< Connection reference count */
    83         devmap_handle_t devmap_handle;  /**< Device handle */
     83        service_id_t service_id;  /**< Service ID */
    8484        keybuffer_t keybuffer;    /**< Buffer for incoming keys. */
    8585        screenbuffer_t scr;       /**< Screenbuffer for saving screen
     
    582582                        continue;
    583583               
    584                 if (consoles[i].devmap_handle == (devmap_handle_t) IPC_GET_ARG1(*icall)) {
     584                if (consoles[i].service_id == (service_id_t) IPC_GET_ARG1(*icall)) {
    585585                        cons = &consoles[i];
    586586                        break;
     
    721721}
    722722
    723 static async_sess_t *connect_input(const char *dev_path)
     723static async_sess_t *connect_input(const char *svc_path)
    724724{
    725725        async_sess_t *sess;
    726726        async_exch_t *exch;
    727         devmap_handle_t handle;
    728        
    729         int rc = devmap_device_get_handle(dev_path, &handle, 0);
     727        service_id_t service_id;
     728       
     729        int rc = loc_service_get_id(svc_path, &service_id, 0);
    730730        if (rc == EOK) {
    731                 sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0);
     731                sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 0);
    732732                if (sess == NULL) {
    733733                        printf("%s: Failed to connect to input server\n", NAME);
     
    773773        }
    774774       
    775         /* Register driver */
    776         int rc = devmap_driver_register(NAME, client_connection);
     775        /* Register server */
     776        int rc = loc_server_register(NAME, client_connection);
    777777        if (rc < 0) {
    778                 printf("%s: Unable to register driver (%d)\n", NAME, rc);
     778                printf("%s: Unable to register server (%d)\n", NAME, rc);
    779779                return false;
    780780        }
     
    820820                        consoles[i].refcount = 0;
    821821                       
    822                         char vc[DEVMAP_NAME_MAXLEN + 1];
    823                         snprintf(vc, DEVMAP_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i);
     822                        char vc[LOC_NAME_MAXLEN + 1];
     823                        snprintf(vc, LOC_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i);
    824824                       
    825                         if (devmap_device_register(vc, &consoles[i].devmap_handle) != EOK) {
    826                                 printf("%s: Unable to register device %s\n", NAME, vc);
     825                        if (loc_service_register(vc, &consoles[i].service_id) != EOK) {
     826                                printf("%s: Unable to register service %s\n", NAME, vc);
    827827                                return false;
    828828                        }
  • uspace/srv/hid/input/ctl/kbdev.c

    rd894fbd r903bac0a  
    4848#include <kbd_ctl.h>
    4949#include <kbd_port.h>
     50#include <loc.h>
    5051#include <stdlib.h>
    5152#include <vfs/vfs_sess.h>
    52 
     53#include <sys/typefmt.h>
    5354
    5455static int kbdev_ctl_init(kbd_dev_t *);
     
    7071        /** Session with kbdev device */
    7172        async_sess_t *sess;
    72 
    73         /** File descriptor of open kbdev device */
    74         int fd;
    7573} kbdev_t;
    7674
     
    8482
    8583        kbdev->kbd_dev = kdev;
    86         kbdev->fd = -1;
    8784
    8885        return kbdev;
     
    9390        if (kbdev->sess != NULL)
    9491                async_hangup(kbdev->sess);
    95         if (kbdev->fd >= 0)
    96                 close(kbdev->fd);
    9792        free(kbdev);
    9893}
     
    10095static int kbdev_ctl_init(kbd_dev_t *kdev)
    10196{
    102         const char *pathname;
    10397        async_sess_t *sess;
    10498        async_exch_t *exch;
    10599        kbdev_t *kbdev;
    106         int fd;
    107100        int rc;
    108101
    109         pathname = kdev->dev_path;
    110 
    111         fd = open(pathname, O_RDWR);
    112         if (fd < 0) {
    113                 return -1;
    114         }
    115 
    116         sess = fd_session(EXCHANGE_SERIALIZE, fd);
     102        sess = loc_service_connect(EXCHANGE_SERIALIZE, kdev->svc_id, 0);
    117103        if (sess == NULL) {
    118                 printf("%s: Failed starting session with '%s'\n", NAME, pathname);
    119                 close(fd);
     104                printf("%s: Failed starting session with '%s.'\n", NAME,
     105                    kdev->svc_name);
    120106                return -1;
    121107        }
     
    124110        if (kbdev == NULL) {
    125111                printf("%s: Failed allocating device structure for '%s'.\n",
    126                     NAME, pathname);
     112                    NAME, kdev->svc_name);
    127113                return -1;
    128114        }
    129115
    130         kbdev->fd = fd;
    131116        kbdev->sess = sess;
    132117
    133118        exch = async_exchange_begin(sess);
    134119        if (exch == NULL) {
    135                 printf("%s: Failed starting exchange with '%s'.\n", NAME, pathname);
     120                printf("%s: Failed starting exchange with '%s'.\n", NAME,
     121                    kdev->svc_name);
    136122                kbdev_destroy(kbdev);
    137123                return -1;
     
    141127        if (rc != EOK) {
    142128                printf("%s: Failed creating callback connection from '%s'.\n",
    143                     NAME, pathname);
     129                    NAME, kdev->svc_name);
    144130                async_exchange_end(exch);
    145131                kbdev_destroy(kbdev);
  • uspace/srv/hid/input/generic/input.c

    rd894fbd r903bac0a  
    3838
    3939#include <adt/list.h>
     40#include <bool.h>
    4041#include <ipc/services.h>
    4142#include <ipc/input.h>
     
    5354#include <io/console.h>
    5455#include <io/keycode.h>
    55 #include <devmap.h>
     56#include <loc.h>
    5657#include <input.h>
    5758#include <kbd.h>
     
    6465// FIXME: remove this header
    6566#include <abi/ipc/methods.h>
    66 
    67 /* In microseconds */
    68 #define DISCOVERY_POLL_INTERVAL  (10 * 1000 * 1000)
    6967
    7068#define NUM_LAYOUTS  3
     
    275273        kdev->port_ops = port;
    276274        kdev->ctl_ops = ctl;
    277         kdev->dev_path = NULL;
     275        kdev->svc_id = 0;
    278276       
    279277        /* Initialize port driver. */
     
    303301        mdev->port_ops = port;
    304302        mdev->proto_ops = proto;
    305         mdev->dev_path = NULL;
     303        mdev->svc_id = 0;
    306304       
    307305        /* Initialize port driver. */
     
    324322/** Add new kbdev device.
    325323 *
    326  * @param dev_path Filesystem path to the device (/dev/class/...)
     324 * @param service_id    Service ID of the keyboard device
    327325 *
    328326 */
    329 static int kbd_add_kbdev(const char *dev_path)
     327static int kbd_add_kbdev(service_id_t service_id, kbd_dev_t **kdevp)
    330328{
    331329        kbd_dev_t *kdev = kbd_dev_new();
     
    333331                return -1;
    334332       
    335         kdev->dev_path = dev_path;
     333        kdev->svc_id = service_id;
    336334        kdev->port_ops = NULL;
    337335        kdev->ctl_ops = &kbdev_ctl;
    338336       
     337        int rc = loc_service_get_name(service_id, &kdev->svc_name);
     338        if (rc != EOK) {
     339                kdev->svc_name = NULL;
     340                goto fail;
     341        }
     342       
    339343        /* Initialize controller driver. */
    340344        if ((*kdev->ctl_ops->init)(kdev) != 0) {
     
    343347       
    344348        list_append(&kdev->kbd_devs, &kbd_devs);
     349        *kdevp = kdev;
    345350        return EOK;
    346351       
    347352fail:
     353        if (kdev->svc_name != NULL)
     354                free(kdev->svc_name);
    348355        free(kdev);
    349356        return -1;
     
    352359/** Add new mousedev device.
    353360 *
    354  * @param dev_path Filesystem path to the device (/dev/class/...)
     361 * @param service_id    Service ID of the mouse device
    355362 *
    356363 */
    357 static int mouse_add_mousedev(const char *dev_path)
     364static int mouse_add_mousedev(service_id_t service_id, mouse_dev_t **mdevp)
    358365{
    359366        mouse_dev_t *mdev = mouse_dev_new();
     
    361368                return -1;
    362369       
    363         mdev->dev_path = dev_path;
     370        mdev->svc_id = service_id;
    364371        mdev->port_ops = NULL;
    365372        mdev->proto_ops = &mousedev_proto;
    366373       
     374        int rc = loc_service_get_name(service_id, &mdev->svc_name);
     375        if (rc != EOK) {
     376                mdev->svc_name = NULL;
     377                goto fail;
     378        }
     379       
    367380        /* Initialize controller driver. */
    368381        if ((*mdev->proto_ops->init)(mdev) != 0) {
     
    371384       
    372385        list_append(&mdev->mouse_devs, &mouse_devs);
     386        *mdevp = mdev;
    373387        return EOK;
    374388       
     
    480494}
    481495
    482 /** Periodically check for new input devices.
    483  *
    484  * Looks under /dev/class/keyboard and /dev/class/mouse.
    485  *
    486  * @param arg Ignored
    487  *
    488  */
    489 static int dev_discovery_fibril(void *arg)
    490 {
    491         char *dev_path;
    492         size_t kbd_id = 1;
    493         size_t mouse_id = 1;
     496static int dev_check_new_kbdevs(void)
     497{
     498        category_id_t keyboard_cat;
     499        service_id_t *svcs;
     500        size_t count, i;
     501        bool already_known;
    494502        int rc;
    495503       
    496         while (true) {
    497                 async_usleep(DISCOVERY_POLL_INTERVAL);
    498                
    499                 /*
    500                  * Check for new keyboard device
    501                  */
    502                 rc = asprintf(&dev_path, "/dev/class/keyboard\\%zu", kbd_id);
    503                 if (rc < 0)
    504                         continue;
    505                
    506                 if (kbd_add_kbdev(dev_path) == EOK) {
    507                         printf("%s: Connected keyboard device '%s'\n",
    508                             NAME, dev_path);
    509                        
    510                         /* XXX Handle device removal */
    511                         ++kbd_id;
     504        rc = loc_category_get_id("keyboard", &keyboard_cat, IPC_FLAG_BLOCKING);
     505        if (rc != EOK) {
     506                printf("%s: Failed resolving category 'keyboard'.\n", NAME);
     507                return ENOENT;
     508        }
     509       
     510        /*
     511         * Check for new keyboard devices
     512         */
     513        rc = loc_category_get_svcs(keyboard_cat, &svcs, &count);
     514        if (rc != EOK) {
     515                printf("%s: Failed getting list of keyboard devices.\n",
     516                    NAME);
     517                return EIO;
     518        }
     519
     520        for (i = 0; i < count; i++) {
     521                already_known = false;
     522               
     523                /* Determine whether we already know this device. */
     524                list_foreach(kbd_devs, kdev_link) {
     525                        kbd_dev_t *kdev = list_get_instance(kdev_link,
     526                            kbd_dev_t, kbd_devs);
     527                        if (kdev->svc_id == svcs[i]) {
     528                                already_known = true;
     529                                break;
     530                        }
    512531                }
    513532               
    514                 free(dev_path);
    515                
    516                 /*
    517                  * Check for new mouse device
    518                  */
    519                 rc = asprintf(&dev_path, "/dev/class/mouse\\%zu", mouse_id);
    520                 if (rc < 0)
    521                         continue;
    522                
    523                 if (mouse_add_mousedev(dev_path) == EOK) {
    524                         printf("%s: Connected mouse device '%s'\n",
    525                             NAME, dev_path);
    526                        
    527                         /* XXX Handle device removal */
    528                         ++mouse_id;
     533                if (!already_known) {
     534                        kbd_dev_t *kdev;
     535                        if (kbd_add_kbdev(svcs[i], &kdev) == EOK) {
     536                                printf("%s: Connected keyboard device '%s'\n",
     537                                    NAME, kdev->svc_name);
     538                        }
    529539                }
    530                
    531                 free(dev_path);
    532         }
     540        }
     541       
     542        free(svcs);
     543       
     544        /* XXX Handle device removal */
    533545       
    534546        return EOK;
    535547}
    536548
    537 /** Start a fibril for discovering new devices. */
    538 static void input_start_dev_discovery(void)
    539 {
    540         fid_t fid = fibril_create(dev_discovery_fibril, NULL);
    541         if (!fid) {
    542                 printf("%s: Failed to create device discovery fibril.\n",
     549static int dev_check_new_mousedevs(void)
     550{
     551        category_id_t mouse_cat;
     552        service_id_t *svcs;
     553        size_t count, i;
     554        bool already_known;
     555        int rc;
     556       
     557        rc = loc_category_get_id("mouse", &mouse_cat, IPC_FLAG_BLOCKING);
     558        if (rc != EOK) {
     559                printf("%s: Failed resolving category 'mouse'.\n", NAME);
     560                return ENOENT;
     561        }
     562       
     563        /*
     564         * Check for new mouse devices
     565         */
     566        rc = loc_category_get_svcs(mouse_cat, &svcs, &count);
     567        if (rc != EOK) {
     568                printf("%s: Failed getting list of mouse devices.\n",
    543569                    NAME);
    544                 return;
    545         }
    546        
    547         fibril_add_ready(fid);
     570                return EIO;
     571        }
     572       
     573        for (i = 0; i < count; i++) {
     574                already_known = false;
     575               
     576                /* Determine whether we already know this device. */
     577                list_foreach(mouse_devs, mdev_link) {
     578                        mouse_dev_t *mdev = list_get_instance(mdev_link,
     579                            mouse_dev_t, mouse_devs);
     580                        if (mdev->svc_id == svcs[i]) {
     581                                already_known = true;
     582                                break;
     583                        }
     584                }
     585               
     586                if (!already_known) {
     587                        mouse_dev_t *mdev;
     588                        if (mouse_add_mousedev(svcs[i], &mdev) == EOK) {
     589                                printf("%s: Connected mouse device '%s'\n",
     590                                    NAME, mdev->svc_name);
     591                        }
     592                }
     593        }
     594       
     595        free(svcs);
     596       
     597        /* XXX Handle device removal */
     598       
     599        return EOK;
     600}
     601
     602static int dev_check_new(void)
     603{
     604        int rc;
     605       
     606        rc = dev_check_new_kbdevs();
     607        if (rc != EOK)
     608                return rc;
     609       
     610        rc = dev_check_new_mousedevs();
     611        if (rc != EOK)
     612                return rc;
     613
     614        return EOK;
     615}
     616
     617static void cat_change_cb(void)
     618{
     619        dev_check_new();
     620}
     621
     622/** Start listening for new devices. */
     623static int input_start_dev_discovery(void)
     624{
     625        int rc;
     626
     627        rc = loc_register_cat_change_cb(cat_change_cb);
     628        if (rc != EOK) {
     629                printf("%s: Failed registering callback for device discovery. "
     630                    "(%d)\n", NAME, rc);
     631                return rc;
     632        }
     633
     634        return dev_check_new();
    548635}
    549636
     
    572659       
    573660        /* Register driver */
    574         int rc = devmap_driver_register(NAME, client_connection);
     661        int rc = loc_server_register(NAME, client_connection);
    575662        if (rc < 0) {
    576                 printf("%s: Unable to register driver (%d)\n", NAME, rc);
     663                printf("%s: Unable to register server (%d)\n", NAME, rc);
    577664                return -1;
    578665        }
    579666       
    580         char kbd[DEVMAP_NAME_MAXLEN + 1];
    581         snprintf(kbd, DEVMAP_NAME_MAXLEN, "%s/%s", NAMESPACE, NAME);
    582        
    583         devmap_handle_t devmap_handle;
    584         if (devmap_device_register(kbd, &devmap_handle) != EOK) {
    585                 printf("%s: Unable to register device %s\n", NAME, kbd);
     667        char kbd[LOC_NAME_MAXLEN + 1];
     668        snprintf(kbd, LOC_NAME_MAXLEN, "%s/%s", NAMESPACE, NAME);
     669       
     670        service_id_t service_id;
     671        if (loc_service_register(kbd, &service_id) != EOK) {
     672                printf("%s: Unable to register service %s\n", NAME, kbd);
    586673                return -1;
    587674        }
  • uspace/srv/hid/input/include/kbd.h

    rd894fbd r903bac0a  
    4040
    4141#include <adt/list.h>
     42#include <ipc/loc.h>
    4243
    4344struct kbd_port_ops;
     
    4950        link_t kbd_devs;
    5051
    51         /** Path to the device (only for kbdev devices) */
    52         const char *dev_path;
     52        /** Service ID (only for kbdev devices) */
     53        service_id_t svc_id;
     54
     55        /** Device service name (only for kbdev devices) */
     56        char *svc_name;
    5357
    5458        /** Port ops */
  • uspace/srv/hid/input/include/mouse.h

    rd894fbd r903bac0a  
    3939
    4040#include <adt/list.h>
     41#include <ipc/loc.h>
    4142
    4243struct mouse_port_ops;
     
    4748        link_t mouse_devs;
    4849       
    49         /** Path to the device (only for mouseev devices) */
    50         const char *dev_path;
     50        /** Service ID (only for mousedev devices) */
     51        service_id_t svc_id;
     52       
     53        /** Device service name (only for mousedev devices) */
     54        char *svc_name;
    5155       
    5256        /** Port ops */
  • uspace/srv/hid/input/port/adb.c

    rd894fbd r903bac0a  
    4343#include <fcntl.h>
    4444#include <errno.h>
    45 #include <devmap.h>
     45#include <loc.h>
    4646
    4747static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg);
     
    6666{
    6767        const char *dev = "adb/kbd";
    68         devmap_handle_t handle;
     68        service_id_t service_id;
    6969        async_exch_t *exch;
    7070        int rc;
     
    7272        kbd_dev = kdev;
    7373       
    74         rc = devmap_device_get_handle(dev, &handle, 0);
     74        rc = loc_service_get_id(dev, &service_id, 0);
    7575        if (rc != EOK)
    7676                return rc;
    7777       
    78         dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0);
     78        dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 0);
    7979        if (dev_sess == NULL) {
    8080                printf("%s: Failed to connect to device\n", NAME);
  • uspace/srv/hid/input/port/adb_mouse.c

    rd894fbd r903bac0a  
    4141#include <mouse.h>
    4242#include <errno.h>
    43 #include <devmap.h>
     43#include <loc.h>
    4444#include <stdio.h>
    4545
     
    7979        mouse_dev = mdev;
    8080       
    81         devmap_handle_t handle;
    82         int rc = devmap_device_get_handle(dev, &handle, 0);
     81        service_id_t service_id;
     82        int rc = loc_service_get_id(dev, &service_id, 0);
    8383        if (rc != EOK)
    8484                return rc;
    8585       
    86         dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0);
     86        dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 0);
    8787        if (dev_sess == NULL) {
    8888                printf("%s: Failed to connect to device\n", NAME);
  • uspace/srv/hid/input/port/chardev.c

    rd894fbd r903bac0a  
    4040#include <kbd_port.h>
    4141#include <kbd.h>
    42 #include <devmap.h>
     42#include <loc.h>
    4343#include <errno.h>
    4444#include <stdio.h>
     
    7171static int chardev_port_init(kbd_dev_t *kdev)
    7272{
    73         devmap_handle_t handle;
     73        service_id_t service_id;
    7474        async_exch_t *exch;
    7575        unsigned int i;
     
    7979       
    8080        for (i = 0; i < num_devs; i++) {
    81                 rc = devmap_device_get_handle(in_devs[i], &handle, 0);
     81                rc = loc_service_get_id(in_devs[i], &service_id, 0);
    8282                if (rc == EOK)
    8383                        break;
     
    8989        }
    9090       
    91         dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle,
     91        dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id,
    9292            IPC_FLAG_BLOCKING);
    9393        if (dev_sess == NULL) {
  • uspace/srv/hid/input/port/chardev_mouse.c

    rd894fbd r903bac0a  
    3939#include <async.h>
    4040#include <errno.h>
    41 #include <devmap.h>
     41#include <loc.h>
    4242#include <input.h>
    4343#include <mouse_port.h>
     
    8282static int chardev_port_init(mouse_dev_t *mdev)
    8383{
    84         devmap_handle_t handle;
     84        service_id_t service_id;
    8585        unsigned int i;
    8686        int rc;
     
    8989       
    9090        for (i = 0; i < num_devs; i++) {
    91                 rc = devmap_device_get_handle(in_devs[i], &handle, 0);
     91                rc = loc_service_get_id(in_devs[i], &service_id, 0);
    9292                if (rc == EOK)
    9393                        break;
     
    9999        }
    100100       
    101         dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle,
     101        dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id,
    102102            IPC_FLAG_BLOCKING);
    103103        if (dev_sess == NULL) {
  • uspace/srv/hid/input/proto/mousedev.c

    rd894fbd r903bac0a  
    4444#include <ipc/mouseev.h>
    4545#include <input.h>
     46#include <loc.h>
    4647#include <mouse.h>
    4748#include <mouse_port.h>
    4849#include <mouse_proto.h>
     50#include <sys/typefmt.h>
    4951
    5052/** Mousedev softstate */
     
    5557        /** Session to mouse device */
    5658        async_sess_t *sess;
    57        
    58         /** File descriptor of open mousedev device */
    59         int fd;
    6059} mousedev_t;
    6160
     
    6766       
    6867        mousedev->mouse_dev = mdev;
    69         mousedev->fd = -1;
    7068       
    7169        return mousedev;
     
    7674        if (mousedev->sess != NULL)
    7775                async_hangup(mousedev->sess);
    78        
    79         if (mousedev->fd >= 0)
    80                 close(mousedev->fd);
    8176       
    8277        free(mousedev);
     
    122117static int mousedev_proto_init(mouse_dev_t *mdev)
    123118{
    124         const char *pathname = mdev->dev_path;
    125        
    126         int fd = open(pathname, O_RDWR);
    127         if (fd < 0)
    128                 return -1;
    129        
    130         async_sess_t *sess = fd_session(EXCHANGE_SERIALIZE, fd);
     119        async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE,
     120            mdev->svc_id, 0);
    131121        if (sess == NULL) {
    132                 printf("%s: Failed starting session with '%s'\n", NAME, pathname);
    133                 close(fd);
     122                printf("%s: Failed starting session with '%s'\n", NAME,
     123                    mdev->svc_name);
    134124                return -1;
    135125        }
     
    138128        if (mousedev == NULL) {
    139129                printf("%s: Failed allocating device structure for '%s'.\n",
    140                     NAME, pathname);
     130                    NAME, mdev->svc_name);
    141131                return -1;
    142132        }
    143133       
    144         mousedev->fd = fd;
    145134        mousedev->sess = sess;
    146135       
    147136        async_exch_t *exch = async_exchange_begin(sess);
    148137        if (exch == NULL) {
    149                 printf("%s: Failed starting exchange with '%s'.\n", NAME, pathname);
     138                printf("%s: Failed starting exchange with '%s'.\n", NAME,
     139                    mdev->svc_name);
    150140                mousedev_destroy(mousedev);
    151141                return -1;
     
    157147        if (rc != EOK) {
    158148                printf("%s: Failed creating callback connection from '%s'.\n",
    159                     NAME, pathname);
     149                    NAME, mdev->svc_name);
    160150                mousedev_destroy(mousedev);
    161151                return -1;
  • uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c

    rd894fbd r903bac0a  
    3939#include <ddi.h>
    4040#include <libarch/ddi.h>
    41 #include <devmap.h>
     41#include <loc.h>
    4242#include <io/console.h>
    4343#include <vfs/vfs.h>
     
    9090        printf(NAME ": S3C24xx touchscreen driver\n");
    9191
    92         rc = devmap_driver_register(NAME, s3c24xx_ts_connection);
     92        rc = loc_server_register(NAME, s3c24xx_ts_connection);
    9393        if (rc < 0) {
    9494                printf(NAME ": Unable to register driver.\n");
     
    103103                return -1;
    104104
    105         rc = devmap_device_register(NAMESPACE "/mouse", &ts->devmap_handle);
     105        rc = loc_service_register(NAMESPACE "/mouse", &ts->service_id);
    106106        if (rc != EOK) {
    107107                printf(NAME ": Unable to register device %s.\n",
  • uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.h

    rd894fbd r903bac0a  
    124124        int client_phone;
    125125
    126         /** Device handle */
    127         devmap_handle_t devmap_handle;
     126        /** Service ID */
     127        service_id_t service_id;
    128128
    129129        /** Device/driver state */
  • uspace/srv/hw/bus/cuda_adb/cuda_adb.c

    rd894fbd r903bac0a  
    4343#include <ddi.h>
    4444#include <libarch/ddi.h>
    45 #include <devmap.h>
     45#include <loc.h>
    4646#include <sysinfo.h>
    4747#include <errno.h>
     
    147147int main(int argc, char *argv[])
    148148{
    149         devmap_handle_t devmap_handle;
     149        service_id_t service_id;
    150150        int rc;
    151151        int i;
     
    155155        for (i = 0; i < ADB_MAX_ADDR; ++i) {
    156156                adb_dev[i].client_phone = -1;
    157                 adb_dev[i].devmap_handle = 0;
    158         }
    159 
    160         rc = devmap_driver_register(NAME, cuda_connection);
     157                adb_dev[i].service_id = 0;
     158        }
     159
     160        rc = loc_server_register(NAME, cuda_connection);
    161161        if (rc < 0) {
    162                 printf(NAME ": Unable to register driver.\n");
     162                printf(NAME ": Unable to register server.\n");
    163163                return rc;
    164164        }
    165165
    166         rc = devmap_device_register("adb/kbd", &devmap_handle);
     166        rc = loc_service_register("adb/kbd", &service_id);
    167167        if (rc != EOK) {
    168                 printf(NAME ": Unable to register device %s.\n", "adb/kdb");
     168                printf(NAME ": Unable to register service %s.\n", "adb/kdb");
    169169                return rc;
    170170        }
    171171
    172         adb_dev[2].devmap_handle = devmap_handle;
    173         adb_dev[8].devmap_handle = devmap_handle;
    174 
    175         rc = devmap_device_register("adb/mouse", &devmap_handle);
     172        adb_dev[2].service_id = service_id;
     173        adb_dev[8].service_id = service_id;
     174
     175        rc = loc_service_register("adb/mouse", &service_id);
    176176        if (rc != EOK) {
    177                 printf(NAME ": Unable to register device %s.\n", "adb/mouse");
     177                printf(NAME ": Unable to register servise %s.\n", "adb/mouse");
    178178                return rc;
    179179        }
    180180
    181         adb_dev[9].devmap_handle = devmap_handle;
     181        adb_dev[9].service_id = service_id;
    182182
    183183        if (cuda_init() < 0) {
     
    198198        ipc_call_t call;
    199199        sysarg_t method;
    200         devmap_handle_t dh;
     200        service_id_t dsid;
    201201        int retval;
    202202        int dev_addr, i;
    203203
    204204        /* Get the device handle. */
    205         dh = IPC_GET_ARG1(*icall);
     205        dsid = IPC_GET_ARG1(*icall);
    206206
    207207        /* Determine which disk device is the client connecting to. */
    208208        dev_addr = -1;
    209209        for (i = 0; i < ADB_MAX_ADDR; i++) {
    210                 if (adb_dev[i].devmap_handle == dh)
     210                if (adb_dev[i].service_id == dsid)
    211211                        dev_addr = i;
    212212        }
     
    242242                         */
    243243                        for (i = 0; i < ADB_MAX_ADDR; ++i) {
    244                                 if (adb_dev[i].devmap_handle == dh) {
     244                                if (adb_dev[i].service_id == dsid) {
    245245                                        adb_dev[i].client_phone = IPC_GET_ARG5(call);
    246246                                }
  • uspace/srv/hw/bus/cuda_adb/cuda_adb.h

    rd894fbd r903bac0a  
    3838
    3939#include <sys/types.h>
    40 #include <ipc/devmap.h>
     40#include <ipc/loc.h>
    4141#include <fibril_synch.h>
    4242
     
    104104
    105105typedef struct {
    106         devmap_handle_t devmap_handle;
     106        service_id_t service_id;
    107107        int client_phone;
    108108} adb_dev_t;
  • uspace/srv/hw/char/i8042/i8042.c

    rd894fbd r903bac0a  
    3939#include <ddi.h>
    4040#include <libarch/ddi.h>
    41 #include <devmap.h>
     41#include <loc.h>
    4242#include <async.h>
    4343#include <async_obsolete.h>
     
    135135        printf(NAME ": i8042 PS/2 port driver\n");
    136136
    137         rc = devmap_driver_register(NAME, i8042_connection);
     137        rc = loc_server_register(NAME, i8042_connection);
    138138        if (rc < 0) {
    139                 printf(NAME ": Unable to register driver.\n");
     139                printf(NAME ": Unable to register server.\n");
    140140                return rc;
    141141        }
     
    148148
    149149                snprintf(name, 16, "%s/ps2%c", NAMESPACE, dchar[i]);
    150                 rc = devmap_device_register(name, &i8042_port[i].devmap_handle);
     150                rc = loc_service_register(name, &i8042_port[i].service_id);
    151151                if (rc != EOK) {
    152152                        printf(NAME ": Unable to register device %s.\n", name);
     
    221221        ipc_call_t call;
    222222        sysarg_t method;
    223         devmap_handle_t dh;
     223        service_id_t dsid;
    224224        int retval;
    225225        int dev_id, i;
     
    228228
    229229        /* Get the device handle. */
    230         dh = IPC_GET_ARG1(*icall);
     230        dsid = IPC_GET_ARG1(*icall);
    231231
    232232        /* Determine which disk device is the client connecting to. */
    233233        dev_id = -1;
    234234        for (i = 0; i < MAX_DEVS; i++) {
    235                 if (i8042_port[i].devmap_handle == dh)
     235                if (i8042_port[i].service_id == dsid)
    236236                        dev_id = i;
    237237        }
  • uspace/srv/hw/char/i8042/i8042.h

    rd894fbd r903bac0a  
    5252/** Softstate structure, one for each serial port (primary and aux). */
    5353typedef struct {
    54         devmap_handle_t devmap_handle;
     54        service_id_t service_id;
    5555        int client_phone;
    5656} i8042_port_t;
  • uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c

    rd894fbd r903bac0a  
    3939#include <ddi.h>
    4040#include <libarch/ddi.h>
    41 #include <devmap.h>
     41#include <loc.h>
    4242#include <ipc/char.h>
    4343#include <async.h>
     
    8383        printf(NAME ": S3C24xx on-chip UART driver\n");
    8484
    85         rc = devmap_driver_register(NAME, s3c24xx_uart_connection);
     85        rc = loc_server_register(NAME, s3c24xx_uart_connection);
    8686        if (rc < 0) {
    87                 printf(NAME ": Unable to register driver.\n");
     87                printf(NAME ": Unable to register server.\n");
    8888                return -1;
    8989        }
     
    9696                return -1;
    9797
    98         rc = devmap_device_register(NAMESPACE "/" NAME, &uart->devmap_handle);
     98        rc = loc_service_register(NAMESPACE "/" NAME, &uart->service_id);
    9999        if (rc != EOK) {
    100100                printf(NAME ": Unable to register device %s.\n",
  • uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.h

    rd894fbd r903bac0a  
    8787        int client_phone;
    8888
    89         /** Device handle */
    90         devmap_handle_t devmap_handle;
     89        /** Service ID */
     90        service_id_t service_id;
    9191} s3c24xx_uart_t;
    9292
  • uspace/srv/hw/irc/i8259/i8259.c

    rd894fbd r903bac0a  
    5050#include <async.h>
    5151#include <stdio.h>
    52 #include <ipc/devmap.h>
     52#include <ipc/loc.h>
    5353
    5454#define NAME  "i8259"
  • uspace/srv/hw/irc/obio/obio.c

    rd894fbd r903bac0a  
    5555#include <async.h>
    5656#include <stdio.h>
    57 #include <ipc/devmap.h>
     57#include <ipc/loc.h>
    5858
    5959#define NAME "obio"
  • uspace/srv/loc/Makefile

    rd894fbd r903bac0a  
    2929
    3030USPACE_PREFIX = ../..
    31 BINARY = devmap
     31BINARY = loc
    3232STATIC_NEEDED = y
    3333
    3434SOURCES = \
    35         devmap.c
     35        category.c \
     36        loc.c
    3637
    3738include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/vfs/vfs.h

    rd894fbd r903bac0a  
    3838#include <fibril_synch.h>
    3939#include <sys/types.h>
    40 #include <devmap.h>
     40#include <loc.h>
    4141#include <bool.h>
    4242#include <ipc/vfs.h>
     
    6161#define VFS_PAIR \
    6262        fs_handle_t fs_handle; \
    63         devmap_handle_t devmap_handle;
     63        service_id_t service_id;
    6464
    6565/**
     
    6767 * doesn't contain any state. For a stateful structure, see vfs_node_t.
    6868 *
    69  * @note        fs_handle, devmap_handle and index are meant to be returned in one
     69 * @note        fs_handle, service_id and index are meant to be returned in one
    7070 *              IPC reply.
    7171 */
     
    180180extern void vfs_node_put(vfs_node_t *);
    181181extern void vfs_node_forget(vfs_node_t *);
    182 extern unsigned vfs_nodes_refcount_sum_get(fs_handle_t, devmap_handle_t);
     182extern unsigned vfs_nodes_refcount_sum_get(fs_handle_t, service_id_t);
    183183
    184184
  • uspace/srv/vfs/vfs_file.c

    rd894fbd r903bac0a  
    137137       
    138138        ipc_call_t answer;
    139         aid_t msg = async_send_2(exch, VFS_OUT_CLOSE, file->node->devmap_handle,
     139        aid_t msg = async_send_2(exch, VFS_OUT_CLOSE, file->node->service_id,
    140140            file->node->index, &answer);
    141141       
  • uspace/srv/vfs/vfs_lookup.c

    rd894fbd r903bac0a  
    162162        aid_t req = async_send_5(exch, VFS_OUT_LOOKUP, (sysarg_t) first,
    163163            (sysarg_t) (first + len - 1) % PLB_SIZE,
    164             (sysarg_t) root->devmap_handle, (sysarg_t) lflag, (sysarg_t) index,
     164            (sysarg_t) root->service_id, (sysarg_t) lflag, (sysarg_t) index,
    165165            &answer);
    166166       
     
    185185       
    186186        result->triplet.fs_handle = (fs_handle_t) rc;
    187         result->triplet.devmap_handle = (devmap_handle_t) IPC_GET_ARG1(answer);
     187        result->triplet.service_id = (service_id_t) IPC_GET_ARG1(answer);
    188188        result->triplet.index = (fs_index_t) IPC_GET_ARG2(answer);
    189189        result->size =
  • uspace/srv/vfs/vfs_node.c

    rd894fbd r903bac0a  
    116116                unsigned long key[] = {
    117117                        [KEY_FS_HANDLE] = node->fs_handle,
    118                         [KEY_DEV_HANDLE] = node->devmap_handle,
     118                        [KEY_DEV_HANDLE] = node->service_id,
    119119                        [KEY_INDEX] = node->index
    120120                };
     
    138138                async_exch_t *exch = vfs_exchange_grab(node->fs_handle);
    139139                sysarg_t rc = async_req_2_0(exch, VFS_OUT_DESTROY,
    140                     (sysarg_t) node->devmap_handle, (sysarg_t)node->index);
     140                    (sysarg_t) node->service_id, (sysarg_t)node->index);
    141141               
    142142                assert(rc == EOK);
     
    160160        unsigned long key[] = {
    161161                [KEY_FS_HANDLE] = node->fs_handle,
    162                 [KEY_DEV_HANDLE] = node->devmap_handle,
     162                [KEY_DEV_HANDLE] = node->service_id,
    163163                [KEY_INDEX] = node->index
    164164        };
     
    184184        unsigned long key[] = {
    185185                [KEY_FS_HANDLE] = result->triplet.fs_handle,
    186                 [KEY_DEV_HANDLE] = result->triplet.devmap_handle,
     186                [KEY_DEV_HANDLE] = result->triplet.service_id,
    187187                [KEY_INDEX] = result->triplet.index
    188188        };
     
    200200                memset(node, 0, sizeof(vfs_node_t));
    201201                node->fs_handle = result->triplet.fs_handle;
    202                 node->devmap_handle = result->triplet.devmap_handle;
     202                node->service_id = result->triplet.service_id;
    203203                node->index = result->triplet.index;
    204204                node->size = result->size;
     
    252252        vfs_node_t *node = hash_table_get_instance(item, vfs_node_t, nh_link);
    253253        return (node->fs_handle == (fs_handle_t) key[KEY_FS_HANDLE]) &&
    254             (node->devmap_handle == key[KEY_DEV_HANDLE]) &&
     254            (node->service_id == key[KEY_DEV_HANDLE]) &&
    255255            (node->index == key[KEY_INDEX]);
    256256}
     
    264264        unsigned refcnt;
    265265        fs_handle_t fs_handle;
    266         devmap_handle_t devmap_handle;
     266        service_id_t service_id;
    267267};
    268268
     
    273273
    274274        if ((node->fs_handle == rd->fs_handle) &&
    275             (node->devmap_handle == rd->devmap_handle))
     275            (node->service_id == rd->service_id))
    276276                rd->refcnt += node->refcnt;
    277277}
    278278
    279279unsigned
    280 vfs_nodes_refcount_sum_get(fs_handle_t fs_handle, devmap_handle_t devmap_handle)
     280vfs_nodes_refcount_sum_get(fs_handle_t fs_handle, service_id_t service_id)
    281281{
    282282        struct refcnt_data rd = {
    283283                .refcnt = 0,
    284284                .fs_handle = fs_handle,
    285                 .devmap_handle = devmap_handle
     285                .service_id = service_id
    286286        };
    287287
     
    305305        ipc_call_t answer;
    306306        aid_t req = async_send_2(exch, VFS_OUT_OPEN_NODE,
    307             (sysarg_t) node->devmap_handle, (sysarg_t) node->index, &answer);
     307            (sysarg_t) node->service_id, (sysarg_t) node->index, &answer);
    308308       
    309309        vfs_exchange_release(exch);
  • uspace/srv/vfs/vfs_ops.c

    rd894fbd r903bac0a  
    5454
    5555/* Forward declarations of static functions. */
    56 static int vfs_truncate_internal(fs_handle_t, devmap_handle_t, fs_index_t,
     56static int vfs_truncate_internal(fs_handle_t, service_id_t, fs_index_t,
    5757    aoff64_t);
    5858
     
    6565vfs_pair_t rootfs = {
    6666        .fs_handle = 0,
    67         .devmap_handle = 0
     67        .service_id = 0
    6868};
    6969
    70 static void vfs_mount_internal(ipc_callid_t rid, devmap_handle_t devmap_handle,
     70static void vfs_mount_internal(ipc_callid_t rid, service_id_t service_id,
    7171    fs_handle_t fs_handle, char *mp, char *opts)
    7272{
     
    125125                        exch = vfs_exchange_grab(fs_handle);
    126126                        msg = async_send_1(exch, VFS_OUT_MOUNTED,
    127                             (sysarg_t) devmap_handle, &answer);
     127                            (sysarg_t) service_id, &answer);
    128128                        /* Send the mount options */
    129129                        rc = async_data_write_start(exch, (void *)opts,
     
    150150                       
    151151                        mr_res.triplet.fs_handle = fs_handle;
    152                         mr_res.triplet.devmap_handle = devmap_handle;
     152                        mr_res.triplet.service_id = service_id;
    153153                        mr_res.triplet.index = rindex;
    154154                        mr_res.size = rsize;
     
    157157                       
    158158                        rootfs.fs_handle = fs_handle;
    159                         rootfs.devmap_handle = devmap_handle;
     159                        rootfs.service_id = service_id;
    160160                       
    161161                        /* Add reference to the mounted root. */
     
    178178       
    179179        /*
    180          * At this point, we have all necessary pieces: file system and device
    181          * handles, and we know the mount point VFS node.
     180         * At this point, we have all necessary pieces: file system handle
     181         * and service ID, and we know the mount point VFS node.
    182182         */
    183183       
     
    187187        exch = vfs_exchange_grab(mp_res.triplet.fs_handle);
    188188        msg = async_send_4(exch, VFS_OUT_MOUNT,
    189             (sysarg_t) mp_res.triplet.devmap_handle,
     189            (sysarg_t) mp_res.triplet.service_id,
    190190            (sysarg_t) mp_res.triplet.index,
    191191            (sysarg_t) fs_handle,
    192             (sysarg_t) devmap_handle, &answer);
     192            (sysarg_t) service_id, &answer);
    193193       
    194194        /* Send connection */
     
    234234               
    235235                mr_res.triplet.fs_handle = fs_handle;
    236                 mr_res.triplet.devmap_handle = devmap_handle;
     236                mr_res.triplet.service_id = service_id;
    237237                mr_res.triplet.index = rindex;
    238238                mr_res.size = rsize;
     
    255255void vfs_mount(ipc_callid_t rid, ipc_call_t *request)
    256256{
    257         devmap_handle_t devmap_handle;
     257        service_id_t service_id;
    258258
    259259        /*
     
    262262         * in the request.
    263263         */
    264         devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
     264        service_id = (service_id_t) IPC_GET_ARG1(*request);
    265265       
    266266        /*
     
    350350       
    351351        /* Do the mount */
    352         vfs_mount_internal(rid, devmap_handle, fs_handle, mp, opts);
     352        vfs_mount_internal(rid, service_id, fs_handle, mp, opts);
    353353        free(mp);
    354354        free(fs_name);
     
    409409         */
    410410        if (vfs_nodes_refcount_sum_get(mr_node->fs_handle,
    411             mr_node->devmap_handle) != 2) {
     411            mr_node->service_id) != 2) {
    412412                fibril_rwlock_write_unlock(&namespace_rwlock);
    413413                vfs_node_put(mr_node);
     
    430430                exch = vfs_exchange_grab(mr_node->fs_handle);
    431431                rc = async_req_1_0(exch, VFS_OUT_UNMOUNTED,
    432                     mr_node->devmap_handle);
     432                    mr_node->service_id);
    433433                vfs_exchange_release(exch);
    434434               
     
    441441               
    442442                rootfs.fs_handle = 0;
    443                 rootfs.devmap_handle = 0;
     443                rootfs.service_id = 0;
    444444        } else {
    445445               
     
    470470                exch = vfs_exchange_grab(mp_node->fs_handle);
    471471                rc = async_req_2_0(exch, VFS_OUT_UNMOUNT,
    472                     mp_node->devmap_handle, mp_node->index);
     472                    mp_node->service_id, mp_node->index);
    473473                vfs_exchange_release(exch);
    474474               
     
    575575                if (node->size) {
    576576                        rc = vfs_truncate_internal(node->fs_handle,
    577                             node->devmap_handle, node->index, 0);
     577                            node->service_id, node->index, 0);
    578578                        if (rc) {
    579579                                fibril_rwlock_write_unlock(&node->contents_rwlock);
     
    639639        aid_t msg;
    640640        ipc_call_t answer;
    641         msg = async_send_2(fs_exch, VFS_OUT_SYNC, file->node->devmap_handle,
     641        msg = async_send_2(fs_exch, VFS_OUT_SYNC, file->node->service_id,
    642642            file->node->index, &answer);
    643643       
     
    724724        if (read) {
    725725                rc = async_data_read_forward_4_1(fs_exch, VFS_OUT_READ,
    726                     file->node->devmap_handle, file->node->index,
     726                    file->node->service_id, file->node->index,
    727727                    LOWER32(file->pos), UPPER32(file->pos), &answer);
    728728        } else {
     
    731731               
    732732                rc = async_data_write_forward_4_1(fs_exch, VFS_OUT_WRITE,
    733                     file->node->devmap_handle, file->node->index,
     733                    file->node->service_id, file->node->index,
    734734                    LOWER32(file->pos), UPPER32(file->pos), &answer);
    735735        }
     
    862862}
    863863
    864 int vfs_truncate_internal(fs_handle_t fs_handle, devmap_handle_t devmap_handle,
     864int vfs_truncate_internal(fs_handle_t fs_handle, service_id_t service_id,
    865865    fs_index_t index, aoff64_t size)
    866866{
    867867        async_exch_t *exch = vfs_exchange_grab(fs_handle);
    868868        sysarg_t rc = async_req_4_0(exch, VFS_OUT_TRUNCATE,
    869             (sysarg_t) devmap_handle, (sysarg_t) index, LOWER32(size),
     869            (sysarg_t) service_id, (sysarg_t) index, LOWER32(size),
    870870            UPPER32(size));
    871871        vfs_exchange_release(exch);
     
    890890        fibril_rwlock_write_lock(&file->node->contents_rwlock);
    891891        rc = vfs_truncate_internal(file->node->fs_handle,
    892             file->node->devmap_handle, file->node->index, size);
     892            file->node->service_id, file->node->index, size);
    893893        if (rc == EOK)
    894894                file->node->size = size;
     
    924924       
    925925        aid_t msg;
    926         msg = async_send_3(exch, VFS_OUT_STAT, file->node->devmap_handle,
     926        msg = async_send_3(exch, VFS_OUT_STAT, file->node->service_id,
    927927            file->node->index, true, NULL);
    928928        async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
     
    977977       
    978978        aid_t msg;
    979         msg = async_send_3(exch, VFS_OUT_STAT, node->devmap_handle,
     979        msg = async_send_3(exch, VFS_OUT_STAT, node->service_id,
    980980            node->index, false, NULL);
    981981        async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
     
    11541154        /* Check whether linking to the same file system instance. */
    11551155        if ((old_node->fs_handle != new_par_lr.triplet.fs_handle) ||
    1156             (old_node->devmap_handle != new_par_lr.triplet.devmap_handle)) {
     1156            (old_node->service_id != new_par_lr.triplet.service_id)) {
    11571157                fibril_rwlock_write_unlock(&namespace_rwlock);
    11581158                vfs_node_put(old_node);
  • uspace/srv/vfs/vfs_register.c

    rd894fbd r903bac0a  
    306306        list_foreach(fs_list, cur) {
    307307                fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link);
    308                 if (str_cmp(fs->vfs_info.name, name) == 0) { 
     308                if (str_cmp(fs->vfs_info.name, name) == 0) {
    309309                        handle = fs->fs_handle;
    310310                        break;
Note: See TracChangeset for help on using the changeset viewer.