Changeset c47e1a8 in mainline for uspace/srv/devman


Ignore:
Timestamp:
2010-05-21T07:50:04Z (15 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d51ee2b
Parents:
cf8cc36 (diff), 15b592b (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 (rev. 451)

Location:
uspace/srv/devman
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/Makefile

    rcf8cc36 rc47e1a8  
    2929
    3030USPACE_PREFIX = ../..
    31 LIBS = $(LIBC_PREFIX)/libc.a
    32 
    33 OUTPUT = devman
     31BINARY = devman
    3432
    3533SOURCES = \
     
    3937        util.c
    4038
    41 include ../Makefile.common
     39include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/devman/devman.c

    rcf8cc36 rc47e1a8  
    3838
    3939#include "devman.h"
    40 #include "util.h"
    4140
    4241/** Allocate and initialize a new driver structure.
     
    7473 * @return the match id.
    7574 */
    76 char * read_match_id(const char **buf)
     75char * read_match_id(char **buf)
    7776{
    7877        char *res = NULL;
     
    10099 * @return true if at least one match id and associated match score was successfully read, false otherwise.
    101100 */
    102 bool parse_match_ids(const char *buf, match_id_list_t *ids)
     101bool parse_match_ids(char *buf, match_id_list_t *ids)
    103102{
    104103        int score = 0;
     
    158157        bool opened = false;
    159158        int fd;         
    160         off_t len = 0;
     159        size_t len = 0;
    161160       
    162161        fd = open(conf_path, O_RDONLY);
     
    315314        printf(NAME ": create_root_node\n");
    316315        node_t *node = create_dev_node();
    317         if (node) {
    318                 insert_dev_node(tree, node, "", NULL);
     316        if (node) {             
     317                insert_dev_node(tree, node, clone_string(""), NULL);
    319318                match_id_t *id = create_match_id();
    320                 id->id = "root";
     319                id->id = clone_string("root");
    321320                id->score = 100;
    322321                add_match_id(&node->match_ids, id);
     
    392391        printf(NAME ": start_driver '%s'\n", drv->name);
    393392       
    394         char *argv[2];
     393        const char *argv[2];
    395394       
    396395        argv[0] = drv->name;
    397396        argv[1] = NULL;
    398397       
    399         if (!task_spawn(drv->binary_path, argv)) {
    400                 printf(NAME ": error spawning %s\n", drv->name);
     398        int err;
     399        if (!task_spawn(drv->binary_path, argv, &err)) {
     400                printf(NAME ": error spawning %s, errno = %d\n", drv->name, err);
    401401                return false;
    402402        }
     
    682682        char *rel_path = path;
    683683        char *next_path_elem = NULL;
    684         size_t elem_size = 0;
    685684        bool cont = '/' == rel_path[0];
    686685       
  • uspace/srv/devman/devman.h

    rcf8cc36 rc47e1a8  
    3737#include <bool.h>
    3838#include <dirent.h>
    39 #include <string.h>
     39#include <str.h>
    4040#include <adt/list.h>
    4141#include <ipc/ipc.h>
     
    145145int get_match_score(driver_t *drv, node_t *dev);
    146146
    147 bool parse_match_ids(const char *buf, match_id_list_t *ids);
     147bool parse_match_ids(char *buf, match_id_list_t *ids);
    148148bool read_match_ids(const char *conf_path, match_id_list_t *ids);
    149 char * read_id(const char **buf) ;
     149char * read_match_id(char **buf);
     150char * read_id(const char **buf);
    150151
    151152// Drivers
     
    165166}
    166167
    167 driver_t * create_driver();
     168driver_t * create_driver(void);
    168169bool get_driver_info(const char *base_path, const char *name, driver_t *drv);
    169170int lookup_available_drivers(driver_list_t *drivers_list, const char *dir_path);
  • uspace/srv/devman/main.c

    rcf8cc36 rc47e1a8  
    4545#include <fibril_synch.h>
    4646#include <stdlib.h>
    47 #include <string.h>
     47#include <str.h>
    4848#include <dirent.h>
    4949#include <fcntl.h>
     
    6060static driver_list_t drivers_list;
    6161static dev_tree_t device_tree;
     62
     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 */
     78static 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}
    62111
    63112/**
     
    155204        match_id->score = IPC_GET_ARG1(call);
    156205       
    157         rc = async_string_receive(&match_id->id, DEVMAN_NAME_MAXLEN, NULL);     
     206        char *match_id_str;
     207        rc = async_string_receive(&match_id_str, DEVMAN_NAME_MAXLEN, NULL);     
     208        match_id->id = match_id_str;
    158209        if (EOK != rc) {
    159210                delete_match_id(match_id);
  • uspace/srv/devman/match.c

    rcf8cc36 rc47e1a8  
    3232 
    3333 
    34 #include <string.h>
     34#include <str.h>
    3535
    3636#include "devman.h"
  • uspace/srv/devman/util.c

    rcf8cc36 rc47e1a8  
    3232
    3333#include <stdlib.h>
    34 #include <string.h>
     34#include <str.h>
    3535 
    3636#include "util.h"
     
    6262}
    6363
    64 const char * get_path_elem_end(const char *path)
     64char * get_path_elem_end(char *path)
    6565{
    6666        while (0 != *path && '/' != *path) {
  • uspace/srv/devman/util.h

    rcf8cc36 rc47e1a8  
    3535
    3636#include <ctype.h>
     37#include <str.h>
     38#include <malloc.h>
    3739
    3840
    3941char * get_abs_path(const char *base_path, const char *name, const char *ext);
    40 const char * get_path_elem_end(const char *path);
     42char * get_path_elem_end(char *path);
    4143
    42 static inline bool skip_spaces(const char **buf)
     44static inline bool skip_spaces(char **buf)
    4345{
    4446        while (isspace(**buf)) {
     
    6567}
    6668
     69static inline char * clone_string(const char *s)
     70{
     71        size_t size = str_size(s) + 1;
     72        char *str = (char *)malloc(size);
     73        if (NULL != str) {
     74                str_cpy(str, size, s);
     75        }
     76        return str;
     77}
     78
    6779#endif
Note: See TracChangeset for help on using the changeset viewer.