Changeset 16dc887 in mainline for uspace/lib/c


Ignore:
Timestamp:
2011-08-16T14:00:32Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
278ac72, b112055
Parents:
3751a08 (diff), cc574511 (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 Location service.

Location:
uspace/lib/c
Files:
1 added
1 deleted
7 edited
2 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    r3751a08 r16dc887  
    6464        generic/cap.c \
    6565        generic/clipboard.c \
    66         generic/devmap.c \
    6766        generic/devman.c \
    6867        generic/device/hw_res.c \
     
    7170        generic/event.c \
    7271        generic/errno.c \
     72        generic/loc.c \
    7373        generic/mem.c \
    7474        generic/str.c \
  • uspace/lib/c/generic/io/io.c

    r3751a08 r16dc887  
    4545#include <vfs/vfs.h>
    4646#include <vfs/vfs_sess.h>
    47 #include <ipc/devmap.h>
     47#include <ipc/loc.h>
    4848#include <adt/list.h>
    4949#include "../private/io.h"
  • uspace/lib/c/generic/vfs/vfs.c

    r3751a08 r16dc887  
    5151#include <assert.h>
    5252#include <str.h>
    53 #include <devmap.h>
     53#include <loc.h>
    5454#include <ipc/vfs.h>
    55 #include <ipc/devmap.h>
     55#include <ipc/loc.h>
    5656
    5757static FIBRIL_MUTEX_INITIALIZE(vfs_mutex);
     
    142142}
    143143
    144 int mount(const char *fs_name, const char *mp, const char *fqdn,
     144int mount(const char *fs_name, const char *mp, const char *fqsn,
    145145    const char *opts, unsigned int flags)
    146146{
    147147        int null_id = -1;
    148         char null[DEVMAP_NAME_MAXLEN];
    149        
    150         if (str_cmp(fqdn, "") == 0) {
     148        char null[LOC_NAME_MAXLEN];
     149       
     150        if (str_cmp(fqsn, "") == 0) {
    151151                /* No device specified, create a fresh
    152152                   null/%d device instead */
    153                 null_id = devmap_null_create();
     153                null_id = loc_null_create();
    154154               
    155155                if (null_id == -1)
    156156                        return ENOMEM;
    157157               
    158                 snprintf(null, DEVMAP_NAME_MAXLEN, "null/%d", null_id);
    159                 fqdn = null;
    160         }
    161        
    162         devmap_handle_t devmap_handle;
    163         int res = devmap_device_get_handle(fqdn, &devmap_handle, flags);
     158                snprintf(null, LOC_NAME_MAXLEN, "null/%d", null_id);
     159                fqsn = null;
     160        }
     161       
     162        service_id_t service_id;
     163        int res = loc_service_get_id(fqsn, &service_id, flags);
    164164        if (res != EOK) {
    165165                if (null_id != -1)
    166                         devmap_null_destroy(null_id);
     166                        loc_null_destroy(null_id);
    167167               
    168168                return res;
     
    173173        if (!mpa) {
    174174                if (null_id != -1)
    175                         devmap_null_destroy(null_id);
     175                        loc_null_destroy(null_id);
    176176               
    177177                return ENOMEM;
     
    181181
    182182        sysarg_t rc_orig;
    183         aid_t req = async_send_2(exch, VFS_IN_MOUNT, devmap_handle, flags, NULL);
     183        aid_t req = async_send_2(exch, VFS_IN_MOUNT, service_id, flags, NULL);
    184184        sysarg_t rc = async_data_write_start(exch, (void *) mpa, mpa_size);
    185185        if (rc != EOK) {
     
    189189               
    190190                if (null_id != -1)
    191                         devmap_null_destroy(null_id);
     191                        loc_null_destroy(null_id);
    192192               
    193193                if (rc_orig == EOK)
     
    204204               
    205205                if (null_id != -1)
    206                         devmap_null_destroy(null_id);
     206                        loc_null_destroy(null_id);
    207207               
    208208                if (rc_orig == EOK)
     
    219219               
    220220                if (null_id != -1)
    221                         devmap_null_destroy(null_id);
     221                        loc_null_destroy(null_id);
    222222               
    223223                if (rc_orig == EOK)
     
    235235               
    236236                if (null_id != -1)
    237                         devmap_null_destroy(null_id);
     237                        loc_null_destroy(null_id);
    238238               
    239239                if (rc_orig == EOK)
     
    248248       
    249249        if ((rc != EOK) && (null_id != -1))
    250                 devmap_null_destroy(null_id);
     250                loc_null_destroy(null_id);
    251251       
    252252        return (int) rc;
     
    335335        ipc_call_t answer;
    336336        aid_t req = async_send_4(exch, VFS_IN_OPEN_NODE, node->fs_handle,
    337             node->devmap_handle, node->index, oflag, &answer);
     337            node->service_id, node->index, oflag, &answer);
    338338       
    339339        vfs_exchange_end(exch);
     
    811811        }
    812812       
    813         if (!stat.device) {
     813        if (!stat.service) {
    814814                errno = ENOENT;
    815815                return NULL;
    816816        }
    817817       
    818         return devmap_device_connect(mgmt, stat.device, 0);
     818        return loc_service_connect(mgmt, stat.service, 0);
    819819}
    820820
     
    826826        if (rc == EOK) {
    827827                node->fs_handle = stat.fs_handle;
    828                 node->devmap_handle = stat.devmap_handle;
     828                node->service_id = stat.service_id;
    829829                node->index = stat.index;
    830830        }
  • uspace/lib/c/include/ipc/devman.h

    r3751a08 r16dc887  
    130130        DEVMAN_CLIENT,
    131131        DEVMAN_CONNECT_TO_DEVICE,
    132         DEVMAN_CONNECT_FROM_DEVMAP,
     132        DEVMAN_CONNECT_FROM_LOC,
    133133        DEVMAN_CONNECT_TO_PARENTS_DEVICE
    134134} devman_interface_t;
  • uspace/lib/c/include/ipc/loc.h

    r3751a08 r16dc887  
    11/*
    22 * Copyright (c) 2007 Josef Cejka
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    2728 */
    2829
    29 /** @addtogroup devmap
     30/** @addtogroup loc
    3031 * @{
    3132 */
    3233
    33 #ifndef LIBC_IPC_DEVMAP_H_
    34 #define LIBC_IPC_DEVMAP_H_
     34#ifndef LIBC_IPC_LOC_H_
     35#define LIBC_IPC_LOC_H_
    3536
    3637#include <ipc/common.h>
    3738
    38 #define DEVMAP_NAME_MAXLEN  255
     39#define LOC_NAME_MAXLEN  255
    3940
    40 typedef sysarg_t devmap_handle_t;
     41typedef sysarg_t service_id_t;
     42typedef sysarg_t category_id_t;
    4143
    4244typedef enum {
    43         DEV_HANDLE_NONE,
    44         DEV_HANDLE_NAMESPACE,
    45         DEV_HANDLE_DEVICE
    46 } devmap_handle_type_t;
     45        LOC_OBJECT_NONE,
     46        LOC_OBJECT_NAMESPACE,
     47        LOC_OBJECT_SERVICE
     48} loc_object_type_t;
    4749
    4850typedef enum {
    49         DEVMAP_DRIVER_REGISTER = IPC_FIRST_USER_METHOD,
    50         DEVMAP_DRIVER_UNREGISTER,
    51         DEVMAP_DEVICE_REGISTER,
    52         DEVMAP_DEVICE_UNREGISTER,
    53         DEVMAP_DEVICE_GET_HANDLE,
    54         DEVMAP_NAMESPACE_GET_HANDLE,
    55         DEVMAP_HANDLE_PROBE,
    56         DEVMAP_NULL_CREATE,
    57         DEVMAP_NULL_DESTROY,
    58         DEVMAP_GET_NAMESPACE_COUNT,
    59         DEVMAP_GET_DEVICE_COUNT,
    60         DEVMAP_GET_NAMESPACES,
    61         DEVMAP_GET_DEVICES
    62 } devmap_request_t;
     51        LOC_SERVER_REGISTER = IPC_FIRST_USER_METHOD,
     52        LOC_SERVER_UNREGISTER,
     53        LOC_SERVICE_ADD_TO_CAT,
     54        LOC_SERVICE_REGISTER,
     55        LOC_SERVICE_UNREGISTER,
     56        LOC_SERVICE_GET_ID,
     57        LOC_NAMESPACE_GET_ID,
     58        LOC_CATEGORY_GET_ID,
     59        LOC_CATEGORY_GET_SVCS,
     60        LOC_ID_PROBE,
     61        LOC_NULL_CREATE,
     62        LOC_NULL_DESTROY,
     63        LOC_GET_NAMESPACE_COUNT,
     64        LOC_GET_SERVICE_COUNT,
     65        LOC_GET_NAMESPACES,
     66        LOC_GET_SERVICES
     67} loc_request_t;
    6368
    64 /** Interface provided by devmap.
     69/** Ports provided by location service.
    6570 *
    66  * Every process that connects to devmap must ask one of following
    67  * interfaces otherwise connection will be refused.
     71 * Every process that connects to loc must ask one of following
     72 * ports, otherwise connection will be refused.
    6873 *
    6974 */
    7075typedef enum {
    71         /** Connect as device driver */
    72         DEVMAP_DRIVER = 1,
    73         /** Connect as client */
    74         DEVMAP_CLIENT,
     76        /** Service supplier (server) port */
     77        LOC_PORT_SUPPLIER = 1,
     78        /** Service consumer (client) port */
     79        LOC_PORT_CONSUMER,
    7580        /** Create new connection to instance of device that
    7681            is specified by second argument of call. */
    77         DEVMAP_CONNECT_TO_DEVICE
    78 } devmap_interface_t;
     82        LOC_CONNECT_TO_SERVICE
     83} loc_interface_t;
    7984
    8085typedef struct {
    81         devmap_handle_t handle;
    82         char name[DEVMAP_NAME_MAXLEN + 1];
    83 } dev_desc_t;
     86        service_id_t id;
     87        char name[LOC_NAME_MAXLEN + 1];
     88} loc_sdesc_t;
    8489
    8590#endif
  • uspace/lib/c/include/ipc/services.h

    r3751a08 r16dc887  
    4545        SERVICE_VIDEO      = FOURCC('v', 'i', 'd', ' '),
    4646        SERVICE_VFS        = FOURCC('v', 'f', 's', ' '),
    47         SERVICE_DEVMAP     = FOURCC('d', 'e', 'v', 'p'),
     47        SERVICE_LOC        = FOURCC('l', 'o', 'c', ' '),
    4848        SERVICE_DEVMAN     = FOURCC('d', 'e', 'v', 'n'),
    4949        SERVICE_IRC        = FOURCC('i', 'r', 'c', ' '),
  • uspace/lib/c/include/loc.h

    r3751a08 r16dc887  
    3333 */
    3434
    35 #ifndef LIBC_DEVMAP_H_
    36 #define LIBC_DEVMAP_H_
     35#ifndef LIBC_LOC_H_
     36#define LIBC_LOC_H_
    3737
    38 #include <ipc/devmap.h>
     38#include <ipc/loc.h>
    3939#include <async.h>
    4040#include <bool.h>
    4141
    42 extern async_exch_t *devmap_exchange_begin_blocking(devmap_interface_t);
    43 extern async_exch_t *devmap_exchange_begin(devmap_interface_t);
    44 extern void devmap_exchange_end(async_exch_t *);
     42extern async_exch_t *loc_exchange_begin_blocking(loc_interface_t);
     43extern async_exch_t *loc_exchange_begin(loc_interface_t);
     44extern void loc_exchange_end(async_exch_t *);
    4545
    46 extern int devmap_driver_register(const char *, async_client_conn_t);
    47 extern int devmap_device_register(const char *, devmap_handle_t *);
    48 extern int devmap_device_register_with_iface(const char *, devmap_handle_t *,
     46extern int loc_server_register(const char *, async_client_conn_t);
     47extern int loc_service_register(const char *, service_id_t *);
     48extern int loc_service_register_with_iface(const char *, service_id_t *,
    4949    sysarg_t);
     50extern int loc_service_add_to_cat(service_id_t, category_id_t);
    5051
    51 extern int devmap_device_get_handle(const char *, devmap_handle_t *,
     52extern int loc_service_get_id(const char *, service_id_t *,
    5253    unsigned int);
    53 extern int devmap_namespace_get_handle(const char *, devmap_handle_t *,
     54extern int loc_namespace_get_id(const char *, service_id_t *,
    5455    unsigned int);
    55 extern devmap_handle_type_t devmap_handle_probe(devmap_handle_t);
     56extern int loc_category_get_id(const char *, category_id_t *,
     57    unsigned int);
     58extern int loc_category_get_svcs(category_id_t, category_id_t **, size_t *);
     59extern loc_object_type_t loc_id_probe(service_id_t);
    5660
    57 extern async_sess_t *devmap_device_connect(exch_mgmt_t, devmap_handle_t,
     61extern async_sess_t *loc_service_connect(exch_mgmt_t, service_id_t,
    5862    unsigned int);
    5963
    60 extern int devmap_null_create(void);
    61 extern void devmap_null_destroy(int);
     64extern int loc_null_create(void);
     65extern void loc_null_destroy(int);
    6266
    63 extern size_t devmap_count_namespaces(void);
    64 extern size_t devmap_count_devices(devmap_handle_t);
     67extern size_t loc_count_namespaces(void);
     68extern size_t loc_count_services(service_id_t);
    6569
    66 extern size_t devmap_get_namespaces(dev_desc_t **);
    67 extern size_t devmap_get_devices(devmap_handle_t, dev_desc_t **);
     70extern size_t loc_get_namespaces(loc_sdesc_t **);
     71extern size_t loc_get_services(service_id_t, loc_sdesc_t **);
    6872
    6973#endif
  • uspace/lib/c/include/sys/stat.h

    r3751a08 r16dc887  
    3939#include <bool.h>
    4040#include <ipc/vfs.h>
    41 #include <ipc/devmap.h>
     41#include <ipc/loc.h>
    4242
    4343struct stat {
    4444        fs_handle_t fs_handle;
    45         devmap_handle_t devmap_handle;
     45        service_id_t service_id;
    4646        fs_index_t index;
    4747        unsigned int lnkcnt;
     
    4949        bool is_directory;
    5050        aoff64_t size;
    51         devmap_handle_t device;
     51        service_id_t service;
    5252};
    5353
  • uspace/lib/c/include/vfs/vfs.h

    r3751a08 r16dc887  
    3838#include <sys/types.h>
    3939#include <ipc/vfs.h>
    40 #include <ipc/devmap.h>
     40#include <ipc/loc.h>
    4141#include <stdio.h>
    4242
     
    4949typedef struct {
    5050        fs_handle_t fs_handle;
    51         devmap_handle_t devmap_handle;
     51        service_id_t service_id;
    5252        fs_index_t index;
    5353} fdi_node_t;
Note: See TracChangeset for help on using the changeset viewer.