Changeset 90478727 in mainline for uspace/app
- Timestamp:
- 2012-08-12T11:46:44Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 41b764b7
- Parents:
- e1e4192 (diff), 371cb6c (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/app
- Files:
-
- 9 edited
- 1 moved
-
bdsh/cmds/modules/cat/cat.c (modified) (8 diffs)
-
devctl/devctl.c (modified) (2 diffs)
-
loc/loc.c (modified) (2 diffs)
-
sportdmp/sportdmp.c (modified) (2 diffs)
-
tester/mm/common.c (modified) (1 diff)
-
tester/mm/mapping1.c (modified) (1 diff)
-
usbinfo/Makefile (modified) (1 diff)
-
usbinfo/list.c (moved) (moved from uspace/app/lsusb/main.c ) (5 diffs)
-
usbinfo/main.c (modified) (7 diffs)
-
usbinfo/usbinfo.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/cat/cat.c
re1e4192 r90478727 62 62 static sysarg_t console_rows = 0; 63 63 static bool should_quit = false; 64 static bool dash_represents_stdin = false; 64 65 65 66 static console_ctrl_t *console = NULL; … … 73 74 { "more", no_argument, 0, 'm' }, 74 75 { "hex", no_argument, 0, 'x' }, 76 { "stdin", no_argument, 0, 's' }, 75 77 { 0, 0, 0, 0 } 76 78 }; … … 93 95 " -m, --more Pause after each screen full\n" 94 96 " -x, --hex Print bytes as hex values\n" 97 " -s --stdin Treat `-' in file list as standard input\n" 95 98 "Currently, %s is under development, some options don't work.\n", 96 99 cmdname, cmdname); … … 172 175 off64_t file_size = 0, length = 0; 173 176 174 fd = open(fname, O_RDONLY); 177 bool reading_stdin = dash_represents_stdin && (str_cmp(fname, "-") == 0); 178 179 if (reading_stdin) { 180 fd = fileno(stdin); 181 /* Allow storing the whole UTF-8 character. */ 182 blen = STR_BOUNDS(1); 183 } else 184 fd = open(fname, O_RDONLY); 185 175 186 if (fd < 0) { 176 187 printf("Unable to open %s\n", fname); … … 207 218 208 219 do { 209 bytes = read(fd, buff + copied_bytes, ( 210 (length != CAT_FULL_FILE && length - (off64_t)count <= (off64_t)(blen - copied_bytes)) ? 211 (size_t)(length - count) : 212 (blen - copied_bytes) ) ); 220 size_t bytes_to_read; 221 if (reading_stdin) { 222 bytes_to_read = 1; 223 } else { 224 if ((length != CAT_FULL_FILE) && 225 (length - (off64_t)count <= (off64_t)(blen - copied_bytes))) { 226 bytes_to_read = (size_t) (length - count); 227 } else { 228 bytes_to_read = blen - copied_bytes; 229 } 230 } 231 232 bytes = read(fd, buff + copied_bytes, bytes_to_read); 213 233 bytes += copied_bytes; 214 234 copied_bytes = 0; … … 242 262 reads++; 243 263 } 264 265 if (reading_stdin) 266 fflush(stdout); 244 267 } while (bytes > 0 && !should_quit && (count < length || length == CAT_FULL_FILE)); 245 268 … … 284 307 285 308 for (c = 0, optind = 0, opt_ind = 0; c != -1;) { 286 c = getopt_long(argc, argv, "xhvmH:t:b: ", long_options, &opt_ind);309 c = getopt_long(argc, argv, "xhvmH:t:b:s", long_options, &opt_ind); 287 310 switch (c) { 288 311 case 'h': … … 318 341 hex = true; 319 342 break; 343 case 's': 344 dash_represents_stdin = true; 345 break; 320 346 } 321 347 } -
uspace/app/devctl/devctl.c
re1e4192 r90478727 44 44 #define MAX_NAME_LENGTH 1024 45 45 46 char name[MAX_NAME_LENGTH]; 47 char drv_name[MAX_NAME_LENGTH]; 48 46 49 static int fun_subtree_print(devman_handle_t funh, int lvl) 47 50 { 48 char name[MAX_NAME_LENGTH];49 51 devman_handle_t devh; 50 52 devman_handle_t *cfuns; … … 57 59 58 60 rc = devman_fun_get_name(funh, name, MAX_NAME_LENGTH); 59 if (rc != EOK) { 60 str_cpy(name, MAX_NAME_LENGTH, "unknown"); 61 return ENOMEM; 62 } 61 if (rc != EOK) 62 return ELIMIT; 63 63 64 64 if (name[0] == '\0') 65 65 str_cpy(name, MAX_NAME_LENGTH, "/"); 66 66 67 printf("%s (%" PRIun ")\n", name, funh); 67 rc = devman_fun_get_driver_name(funh, drv_name, MAX_NAME_LENGTH); 68 if (rc != EOK && rc != EINVAL) 69 return ELIMIT; 70 71 if (rc == EINVAL) 72 printf("%s\n", name); 73 else 74 printf("%s : %s\n", name, drv_name); 68 75 69 76 rc = devman_fun_get_child(funh, &devh); -
uspace/app/loc/loc.c
re1e4192 r90478727 48 48 size_t svc_cnt; 49 49 char *svc_name; 50 char *server_name; 50 51 int rc; 51 52 size_t j; 52 53 53 printf("%s (%" PRIun "):\n", cat_name, cat_id);54 printf("%s:\n", cat_name); 54 55 55 56 rc = loc_category_get_svcs(cat_id, &svc_ids, &svc_cnt); … … 67 68 continue; 68 69 } 69 printf("\t%s (%" PRIun ")\n", svc_name, svc_ids[j]); 70 71 rc = loc_service_get_server_name(svc_ids[j], &server_name); 72 if (rc != EOK && rc != EINVAL) { 73 free(svc_name); 74 printf(NAME ": Unknown service name (SID %" 75 PRIun ").\n", svc_ids[j]); 76 continue; 77 } 78 79 if (rc == EOK) 80 printf("\t%s : %s\n", svc_name, server_name); 81 else 82 printf("\t%s\n", svc_name); 83 70 84 free(svc_name); 85 free(server_name); 71 86 } 72 87 -
uspace/app/sportdmp/sportdmp.c
re1e4192 r90478727 37 37 static void syntax_print(void) 38 38 { 39 fprintf(stderr, "Usage: sportdmp <baud> <device_service>\n");39 fprintf(stderr, "Usage: sportdmp [--baud=<baud>] [device_service]\n"); 40 40 } 41 41 42 42 int main(int argc, char **argv) 43 43 { 44 const char* svc_path = "devices/\\hw\\pci0\\00:01.0\\com1\\a";45 44 sysarg_t baud = 9600; 45 service_id_t svc_id; 46 46 47 if (argc > 1) { 47 int arg = 1; 48 int rc; 49 50 if (argc > arg && str_test_prefix(argv[arg], "--baud=")) { 51 size_t arg_offset = str_lsize(argv[arg], 7); 52 char* arg_str = argv[arg] + arg_offset; 53 if (str_length(arg_str) == 0) { 54 fprintf(stderr, "--baud requires an argument\n"); 55 syntax_print(); 56 return 1; 57 } 48 58 char *endptr; 49 baud = strtol(arg v[1], &endptr, 10);59 baud = strtol(arg_str, &endptr, 10); 50 60 if (*endptr != '\0') { 51 61 fprintf(stderr, "Invalid value for baud\n"); … … 53 63 return 1; 54 64 } 65 arg++; 55 66 } 56 67 57 if (argc > 2) { 58 svc_path = argv[2]; 68 if (argc > arg) { 69 rc = loc_service_get_id(argv[arg], &svc_id, 0); 70 if (rc != EOK) { 71 fprintf(stderr, "Cannot find device service %s\n", 72 argv[arg]); 73 return 1; 74 } 75 arg++; 76 } 77 else { 78 category_id_t serial_cat_id; 79 80 rc = loc_category_get_id("serial", &serial_cat_id, 0); 81 if (rc != EOK) { 82 fprintf(stderr, "Failed getting id of category " 83 "'serial'\n"); 84 return 1; 85 } 86 87 service_id_t *svc_ids; 88 size_t svc_count; 89 90 rc = loc_category_get_svcs(serial_cat_id, &svc_ids, &svc_count); if (rc != EOK) { 91 fprintf(stderr, "Failed getting list of services\n"); 92 return 1; 93 } 94 95 if (svc_count == 0) { 96 fprintf(stderr, "No service in category 'serial'\n"); 97 free(svc_ids); 98 return 1; 99 } 100 101 svc_id = svc_ids[0]; 102 free(svc_ids); 59 103 } 60 104 61 if (argc > 3) { 105 if (argc > arg) { 106 fprintf(stderr, "Too many arguments\n"); 62 107 syntax_print(); 63 108 return 1; 64 109 } 65 110 66 service_id_t svc_id;67 int rc = loc_service_get_id(svc_path, &svc_id, IPC_FLAG_BLOCKING);68 if (rc != EOK) {69 fprintf(stderr, "Cannot find device service %s\n", svc_path);70 return 1;71 }72 111 73 112 async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE, svc_id, 74 113 IPC_FLAG_BLOCKING); 75 114 if (!sess) { 76 fprintf(stderr, "Failed connecting to service %s\n", svc_path);115 fprintf(stderr, "Failed connecting to service\n"); 77 116 } 78 117 -
uspace/app/tester/mm/common.c
re1e4192 r90478727 342 342 link_initialize(&area->link); 343 343 344 area->addr = as_area_create( (void *) -1, size,344 area->addr = as_area_create(AS_AREA_ANY, size, 345 345 AS_AREA_WRITE | AS_AREA_READ); 346 if (area->addr == (void *) -1) {346 if (area->addr == AS_MAP_FAILED) { 347 347 free(area); 348 348 check_consistency("map_area (a)"); -
uspace/app/tester/mm/mapping1.c
re1e4192 r90478727 42 42 TPRINTF("Creating AS area...\n"); 43 43 44 void *result = as_area_create( (void *) -1, size,44 void *result = as_area_create(AS_AREA_ANY, size, 45 45 AS_AREA_READ | AS_AREA_WRITE); 46 if (result == (void *) -1)46 if (result == AS_MAP_FAILED) 47 47 return NULL; 48 48 -
uspace/app/usbinfo/Makefile
re1e4192 r90478727 47 47 hid.c \ 48 48 info.c \ 49 list.c \ 49 50 main.c 50 51 -
uspace/app/usbinfo/list.c
re1e4192 r90478727 47 47 #include <usb/hc.h> 48 48 49 # define NAME "lsusb"49 #include "usbinfo.h" 50 50 51 51 #define MAX_USB_ADDRESS USB11_ADDRESS_MAX … … 90 90 } 91 91 92 int main(int argc, char *argv[])92 void list(void) 93 93 { 94 94 category_id_t usbhc_cat; … … 102 102 printf(NAME ": Error resolving category '%s'", 103 103 USB_HC_CATEGORY); 104 return 1;104 return; 105 105 } 106 106 … … 108 108 if (rc != EOK) { 109 109 printf(NAME ": Error getting list of host controllers.\n"); 110 return 1;110 return; 111 111 } 112 112 … … 131 131 132 132 free(svcs); 133 134 return 0;135 133 } 136 134 -
uspace/app/usbinfo/main.c
re1e4192 r90478727 62 62 63 63 _OPTION("-h --help", "Print this help and exit."); 64 _OPTION("-l --list", "Print a list of host controllers and devices."); 64 65 _OPTION("-i --identification", "Brief device identification."); 65 66 _OPTION("-m --match-ids", "Print match ids generated for the device."); … … 82 83 {"help", no_argument, NULL, 'h'}, 83 84 {"identification", no_argument, NULL, 'i'}, 85 {"list", no_argument, NULL, 'l'}, 84 86 {"match-ids", no_argument, NULL, 'm'}, 85 87 {"descriptor-tree", no_argument, NULL, 't'}, … … 91 93 {0, 0, NULL, 0} 92 94 }; 93 static const char *short_options = "hi mtTsSrR";95 static const char *short_options = "hilmtTsSrR"; 94 96 95 97 static usbinfo_action_t actions[] = { … … 146 148 } 147 149 150 bool something_active = false; 148 151 /* 149 152 * Process command-line options. They determine what shall be … … 156 159 switch (opt) { 157 160 case -1: 161 break; 162 case 'l': 163 list(); 158 164 break; 159 165 case '?': … … 168 174 if (actions[idx].opt == opt) { 169 175 actions[idx].active = true; 176 something_active = true; 170 177 break; 171 178 } … … 178 185 179 186 /* Set the default action. */ 180 int idx = 0;181 bool something_active = false;182 while (actions[idx].opt != 0) {183 if (actions[idx].active) {184 something_active = true;185 break;186 }187 idx++;188 }189 187 if (!something_active) { 190 188 actions[0].active = true; -
uspace/app/usbinfo/usbinfo.h
re1e4192 r90478727 79 79 dump_descriptor_in_tree_t, size_t, void *); 80 80 81 void list(void); 81 82 82 83 void dump_short_device_identification(usbinfo_device_t *);
Note:
See TracChangeset
for help on using the changeset viewer.
