Changeset c9f3b45c in mainline for uspace/srv/devman/main.c


Ignore:
Timestamp:
2010-05-27T15:16:49Z (14 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
692c40cb
Parents:
957cfa58
Message:

devman, libdrv: replace async_string_receive by async_data_write_accept

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/main.c

    r957cfa58 rc9f3b45c  
    6161static dev_tree_t device_tree;
    6262
    63 /** Wrapper for receiving strings
    64  *
    65  * This wrapper only makes it more comfortable to use async_data_write_*
    66  * functions to receive strings.
    67  *
    68  * @param str      Pointer to string pointer (which should be later disposed
    69  *                 by free()). If the operation fails, the pointer is not
    70  *                 touched.
    71  * @param max_size Maximum size (in bytes) of the string to receive. 0 means
    72  *                 no limit.
    73  * @param received If not NULL, the size of the received data is stored here.
    74  *
    75  * @return Zero on success or a value from @ref errno.h on failure.
    76  *
    77  */
    78 static int async_string_receive(char **str, const size_t max_size, size_t *received)
    79 {
    80         ipc_callid_t callid;
    81         size_t size;
    82         if (!async_data_write_receive(&callid, &size)) {
    83                 ipc_answer_0(callid, EINVAL);
    84                 return EINVAL;
    85         }
    86        
    87         if ((max_size > 0) && (size > max_size)) {
    88                 ipc_answer_0(callid, EINVAL);
    89                 return EINVAL;
    90         }
    91        
    92         char *data = (char *) malloc(size + 1);
    93         if (data == NULL) {
    94                 ipc_answer_0(callid, ENOMEM);
    95                 return ENOMEM;
    96         }
    97        
    98         int rc = async_data_write_finalize(callid, data, size);
    99         if (rc != EOK) {
    100                 free(data);
    101                 return rc;
    102         }
    103        
    104         data[size] = 0;
    105         *str = data;
    106         if (received != NULL)
    107                 *received = size;
    108        
    109         return EOK;
    110 }
    11163
    11264/**
     
    12981       
    13082        // Get driver name
    131         int rc = async_string_receive(&drv_name, DEVMAN_NAME_MAXLEN, NULL);     
     83        int rc = async_data_write_accept((void **)&drv_name, true, 0, 0, 0, 0);
    13284        if (rc != EOK) {
    13385                ipc_answer_0(iid, rc);
     
    205157       
    206158        char *match_id_str;
    207         rc = async_string_receive(&match_id_str, DEVMAN_NAME_MAXLEN, NULL);     
     159        rc = async_data_write_accept((void **)&match_id_str, true, 0, 0, 0, 0);
    208160        match_id->id = match_id_str;
    209161        if (EOK != rc) {
     
    262214       
    263215        char *dev_name = NULL;
    264         int rc = async_string_receive(&dev_name, DEVMAN_NAME_MAXLEN, NULL);     
     216        int rc = async_data_write_accept((void **)&dev_name, true, 0, 0, 0, 0);
    265217        if (EOK != rc) {
    266218                fibril_rwlock_write_unlock(&tree->rwlock);
     
    354306static void devman_device_get_handle(ipc_callid_t iid, ipc_call_t *icall)
    355307{
    356         char *pathname;
    357        
    358         /* Get fqdn */
    359         int rc = async_string_receive(&pathname, 0, NULL);
     308        char *pathname;
     309        int rc = async_data_write_accept((void **)&pathname, true, 0, 0, 0, 0);
    360310        if (rc != EOK) {
    361311                ipc_answer_0(iid, rc);
Note: See TracChangeset for help on using the changeset viewer.