Changes in uspace/app/devctl/devctl.c [1a5b252:7beb220] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/devctl/devctl.c
r1a5b252 r7beb220 37 37 #include <stdio.h> 38 38 #include <stdlib.h> 39 #include <str_error.h>40 39 #include <sys/typefmt.h> 41 40 … … 44 43 #define MAX_NAME_LENGTH 1024 45 44 46 static int fun_ subtree_print(devman_handle_t funh, int lvl)45 static int fun_tree_print(devman_handle_t funh, int lvl) 47 46 { 48 47 char name[MAX_NAME_LENGTH]; … … 85 84 86 85 for (i = 0; i < count; i++) 87 fun_ subtree_print(cfuns[i], lvl + 1);86 fun_tree_print(cfuns[i], lvl + 1); 88 87 89 88 free(cfuns); … … 91 90 } 92 91 93 static int fun_tree_print(void)92 int main(int argc, char *argv[]) 94 93 { 95 94 devman_handle_t root_fun; … … 99 98 if (rc != EOK) { 100 99 printf(NAME ": Error resolving root function.\n"); 101 return EIO;100 return 1; 102 101 } 103 102 104 rc = fun_ subtree_print(root_fun, 0);103 rc = fun_tree_print(root_fun, 0); 105 104 if (rc != EOK) 106 return EIO;107 108 return EOK;109 }110 111 static int fun_online(const char *path)112 {113 devman_handle_t funh;114 int rc;115 116 rc = devman_fun_get_handle(path, &funh, 0);117 if (rc != EOK) {118 printf(NAME ": Error resolving device function '%s' (%s)\n",119 path, str_error(rc));120 return rc;121 }122 123 rc = devman_fun_online(funh);124 if (rc != EOK) {125 printf(NAME ": Failed to online function '%s'.\n", path);126 return rc;127 }128 129 return EOK;130 }131 132 static int fun_offline(const char *path)133 {134 devman_handle_t funh;135 int rc;136 137 rc = devman_fun_get_handle(path, &funh, 0);138 if (rc != EOK) {139 printf(NAME ": Error resolving device function '%s' (%s)\n",140 path, str_error(rc));141 return rc;142 }143 144 rc = devman_fun_offline(funh);145 if (rc != EOK) {146 printf(NAME ": Failed to offline function '%s'.\n", path);147 return rc;148 }149 150 return EOK;151 }152 153 static void print_syntax(void)154 {155 printf("syntax: devctl [(online|offline) <function>]\n");156 }157 158 int main(int argc, char *argv[])159 {160 int rc;161 162 if (argc == 1) {163 rc = fun_tree_print();164 if (rc != EOK)165 return 2;166 } else if (str_cmp(argv[1], "online") == 0) {167 if (argc < 3) {168 printf(NAME ": Argument missing.\n");169 print_syntax();170 return 1;171 }172 173 rc = fun_online(argv[2]);174 if (rc != EOK) {175 return 2;176 }177 } else if (str_cmp(argv[1], "offline") == 0) {178 if (argc < 3) {179 printf(NAME ": Argument missing.\n");180 print_syntax();181 return 1;182 }183 184 rc = fun_offline(argv[2]);185 if (rc != EOK) {186 return 2;187 }188 } else {189 printf(NAME ": Invalid argument '%s'.\n", argv[1]);190 print_syntax();191 105 return 1; 192 }193 106 194 107 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.