Changeset c47e1a8 in mainline for uspace/srv/devman
- Timestamp:
- 2010-05-21T07:50:04Z (15 years ago)
- 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. - Location:
- uspace/srv/devman
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/Makefile
rcf8cc36 rc47e1a8 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 32 33 OUTPUT = devman 31 BINARY = devman 34 32 35 33 SOURCES = \ … … 39 37 util.c 40 38 41 include ../Makefile.common39 include $(USPACE_PREFIX)/Makefile.common -
uspace/srv/devman/devman.c
rcf8cc36 rc47e1a8 38 38 39 39 #include "devman.h" 40 #include "util.h"41 40 42 41 /** Allocate and initialize a new driver structure. … … 74 73 * @return the match id. 75 74 */ 76 char * read_match_id(c onst char **buf)75 char * read_match_id(char **buf) 77 76 { 78 77 char *res = NULL; … … 100 99 * @return true if at least one match id and associated match score was successfully read, false otherwise. 101 100 */ 102 bool parse_match_ids(c onst char *buf, match_id_list_t *ids)101 bool parse_match_ids(char *buf, match_id_list_t *ids) 103 102 { 104 103 int score = 0; … … 158 157 bool opened = false; 159 158 int fd; 160 off_t len = 0;159 size_t len = 0; 161 160 162 161 fd = open(conf_path, O_RDONLY); … … 315 314 printf(NAME ": create_root_node\n"); 316 315 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); 319 318 match_id_t *id = create_match_id(); 320 id->id = "root";319 id->id = clone_string("root"); 321 320 id->score = 100; 322 321 add_match_id(&node->match_ids, id); … … 392 391 printf(NAME ": start_driver '%s'\n", drv->name); 393 392 394 c har *argv[2];393 const char *argv[2]; 395 394 396 395 argv[0] = drv->name; 397 396 argv[1] = NULL; 398 397 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); 401 401 return false; 402 402 } … … 682 682 char *rel_path = path; 683 683 char *next_path_elem = NULL; 684 size_t elem_size = 0;685 684 bool cont = '/' == rel_path[0]; 686 685 -
uspace/srv/devman/devman.h
rcf8cc36 rc47e1a8 37 37 #include <bool.h> 38 38 #include <dirent.h> 39 #include <str ing.h>39 #include <str.h> 40 40 #include <adt/list.h> 41 41 #include <ipc/ipc.h> … … 145 145 int get_match_score(driver_t *drv, node_t *dev); 146 146 147 bool parse_match_ids(c onst char *buf, match_id_list_t *ids);147 bool parse_match_ids(char *buf, match_id_list_t *ids); 148 148 bool read_match_ids(const char *conf_path, match_id_list_t *ids); 149 char * read_id(const char **buf) ; 149 char * read_match_id(char **buf); 150 char * read_id(const char **buf); 150 151 151 152 // Drivers … … 165 166 } 166 167 167 driver_t * create_driver( );168 driver_t * create_driver(void); 168 169 bool get_driver_info(const char *base_path, const char *name, driver_t *drv); 169 170 int lookup_available_drivers(driver_list_t *drivers_list, const char *dir_path); -
uspace/srv/devman/main.c
rcf8cc36 rc47e1a8 45 45 #include <fibril_synch.h> 46 46 #include <stdlib.h> 47 #include <str ing.h>47 #include <str.h> 48 48 #include <dirent.h> 49 49 #include <fcntl.h> … … 60 60 static driver_list_t drivers_list; 61 61 static 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 */ 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 } 62 111 63 112 /** … … 155 204 match_id->score = IPC_GET_ARG1(call); 156 205 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; 158 209 if (EOK != rc) { 159 210 delete_match_id(match_id); -
uspace/srv/devman/match.c
rcf8cc36 rc47e1a8 32 32 33 33 34 #include <str ing.h>34 #include <str.h> 35 35 36 36 #include "devman.h" -
uspace/srv/devman/util.c
rcf8cc36 rc47e1a8 32 32 33 33 #include <stdlib.h> 34 #include <str ing.h>34 #include <str.h> 35 35 36 36 #include "util.h" … … 62 62 } 63 63 64 c onst char * get_path_elem_end(constchar *path)64 char * get_path_elem_end(char *path) 65 65 { 66 66 while (0 != *path && '/' != *path) { -
uspace/srv/devman/util.h
rcf8cc36 rc47e1a8 35 35 36 36 #include <ctype.h> 37 #include <str.h> 38 #include <malloc.h> 37 39 38 40 39 41 char * get_abs_path(const char *base_path, const char *name, const char *ext); 40 c onst char * get_path_elem_end(constchar *path);42 char * get_path_elem_end(char *path); 41 43 42 static inline bool skip_spaces(c onst char **buf)44 static inline bool skip_spaces(char **buf) 43 45 { 44 46 while (isspace(**buf)) { … … 65 67 } 66 68 69 static 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 67 79 #endif
Note:
See TracChangeset
for help on using the changeset viewer.