Changeset a35b458 in mainline for uspace/app/bdsh/cmds
- Timestamp:
- 2018-03-02T20:10:49Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- Location:
- uspace/app/bdsh/cmds
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/builtin_cmds.c
r3061bc1 ra35b458 107 107 108 108 cmd += builtin; 109 109 110 110 iostate_t *old_iostate = get_iostate(); 111 111 set_iostate(new_iostate); 112 112 113 113 if (NULL != cmd->entry) { 114 114 rc = ((int)cmd->entry(argv, usr)); … … 116 116 rc = CL_ENOENT; 117 117 } 118 118 119 119 set_iostate(old_iostate); 120 120 -
uspace/app/bdsh/cmds/mod_cmds.c
r3061bc1 ra35b458 129 129 130 130 mod += module; 131 131 132 132 iostate_t *old_iostate = get_iostate(); 133 133 set_iostate(new_iostate); … … 138 138 rc = CL_ENOENT; 139 139 } 140 140 141 141 set_iostate(old_iostate); 142 142 -
uspace/app/bdsh/cmds/modules/cat/cat.c
r3061bc1 ra35b458 110 110 console_set_pos(console, 0, console_rows-1); 111 111 console_set_color(console, COLOR_WHITE, COLOR_BLUE, 0); 112 112 113 113 printf("ENTER/SPACE/PAGE DOWN - next page, " 114 114 "ESC/Q - quit, C - continue unpaged"); 115 115 fflush(stdout); 116 116 117 117 console_set_style(console, STYLE_NORMAL); 118 118 } … … 122 122 cons_event_t ev; 123 123 kbd_event_t *kev; 124 124 125 125 while (true) { 126 126 if (!console_get_event(console, &ev)) { … … 129 129 if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) { 130 130 kev = &ev.ev.key; 131 131 132 132 if (kev->key == KC_ESCAPE || kev->key == KC_Q) { 133 133 should_quit = true; … … 190 190 191 191 bool reading_stdin = dash_represents_stdin && (str_cmp(fname, "-") == 0); 192 192 193 193 if (reading_stdin) { 194 194 fd = fileno(stdin); … … 201 201 } 202 202 } 203 203 204 204 if (fd < 0) { 205 205 printf("Unable to open %s\n", fname); … … 255 255 } 256 256 } 257 257 258 258 rc = vfs_read(fd, &pos, buff + copied_bytes, bytes_to_read, 259 259 &bytes); … … 283 283 paged_char(c); 284 284 } 285 285 286 286 } 287 287 count += bytes; 288 288 reads++; 289 289 } 290 290 291 291 if (reading_stdin) 292 292 fflush(stdout); … … 317 317 sysarg_t rows, cols; 318 318 errno_t rc; 319 319 320 320 /* 321 321 * reset global state … … 392 392 if (buffer < 4) 393 393 buffer = CAT_DEFAULT_BUFLEN; 394 394 395 395 if (more) { 396 396 rc = console_get_size(console, &cols, &rows); -
uspace/app/bdsh/cmds/modules/cmp/cmp.c
r3061bc1 ra35b458 120 120 unsigned int argc; 121 121 int c, opt_ind; 122 122 123 123 argc = cli_count_args(argv); 124 124 -
uspace/app/bdsh/cmds/modules/cp/cp.c
r3061bc1 ra35b458 196 196 str_cpy(src_path, src_len + 1, src); 197 197 str_rtrim(src_path, '/'); 198 198 199 199 /* Get the last component name from the src path */ 200 200 src_fname = get_last_path_component(src_path); 201 201 202 202 /* Initialize dest_path with the dest argument */ 203 203 str_cpy(dest_path, PATH_MAX, dest); … … 206 206 /* e.g. cp file_name /data */ 207 207 /* e.g. cp file_name /data/ */ 208 208 209 209 /* dest is a directory, 210 210 * append the src filename to it. -
uspace/app/bdsh/cmds/modules/kcon/kcon.c
r3061bc1 ra35b458 43 43 { 44 44 printf("`kcon' switches to the kernel debug console.\n"); 45 45 46 46 if (level != HELP_SHORT) 47 47 printf("Usage: %s\n", cmdname); 48 48 49 49 return; 50 50 } … … 54 54 { 55 55 unsigned int argc = cli_count_args(argv); 56 56 57 57 if (argc != 1) { 58 58 printf("%s - incorrect number of arguments. Try `%s --help'\n", … … 60 60 return CMD_FAILURE; 61 61 } 62 62 63 63 if (console_kcon()) 64 64 return CMD_SUCCESS; -
uspace/app/bdsh/cmds/modules/ls/ls.c
r3061bc1 ra35b458 111 111 struct dir_elem_t const *da = a; 112 112 struct dir_elem_t const *db = b; 113 113 114 114 if ((da->s.is_directory && db->s.is_file) || 115 115 ((da->s.is_directory == db->s.is_directory) && … … 141 141 struct dir_elem_t *tosort; 142 142 struct dirent *dp; 143 143 144 144 if (!dirp) 145 145 return -1; … … 150 150 return -1; 151 151 } 152 152 153 153 tosort = (struct dir_elem_t *) malloc(alloc_blocks * sizeof(*tosort)); 154 154 if (!tosort) { … … 157 157 return -1; 158 158 } 159 159 160 160 while ((dp = readdir(dirp))) { 161 161 if (nbdirs + 1 > alloc_blocks) { 162 162 alloc_blocks += alloc_blocks; 163 163 164 164 tmp = (struct dir_elem_t *) realloc(tosort, 165 165 alloc_blocks * sizeof(struct dir_elem_t)); … … 170 170 tosort = tmp; 171 171 } 172 172 173 173 /* fill the name field */ 174 174 tosort[nbdirs].name = (char *) malloc(str_size(dp->d_name) + 1); … … 189 189 } 190 190 } 191 191 192 192 if (ls.sort) 193 193 qsort(&tosort[0], nbdirs, sizeof(struct dir_elem_t), ls_cmp); 194 194 195 195 for (i = 0; i < nbdirs; i++) 196 196 ls_print(&tosort[i]); … … 214 214 } 215 215 } 216 216 217 217 out: 218 218 for(i = 0; i < nbdirs; i++) … … 239 239 DIR *subdirp; 240 240 struct dir_elem_t *dir_list; 241 241 242 242 const char * const trailing_slash = "/"; 243 243 … … 294 294 } 295 295 } 296 296 297 297 ret = CMD_SUCCESS; 298 298 … … 355 355 356 356 argc = cli_count_args(argv); 357 357 358 358 for (c = 0, optreset = 1, optind = 0, opt_ind = 0; c != -1;) { 359 359 c = getopt_long(argc, argv, "hur", long_options, &opt_ind); -
uspace/app/bdsh/cmds/modules/mkfile/mkfile.c
r3061bc1 ra35b458 171 171 if (create_sparse && file_size > 0) { 172 172 const char byte = 0x00; 173 173 174 174 pos = file_size - 1; 175 175 rc = vfs_write(fd, &pos, &byte, sizeof(char), &nwritten); -
uspace/app/bdsh/cmds/modules/printf/printf.c
r3061bc1 ra35b458 55 55 } 56 56 57 57 58 58 return; 59 59 } -
uspace/app/bdsh/cmds/modules/rm/rm.c
r3061bc1 ra35b458 189 189 190 190 closedir(dirp); 191 191 192 192 return ret; 193 193 } -
uspace/app/bdsh/cmds/modules/touch/touch.c
r3061bc1 ra35b458 69 69 cmdname); 70 70 } 71 71 72 72 return; 73 73 } … … 85 85 int fd = -1; 86 86 char *buff = NULL; 87 87 88 88 DIR *dirp; 89 89 90 90 for (c = 0, optreset = 1, optind = 0, longind = 0; c != -1; ) { 91 91 c = getopt_long(argc, argv, "c", long_options, &longind); … … 96 96 } 97 97 } 98 98 99 99 if (argc - optind < 1) { 100 100 printf("%s: Incorrect number of arguments. Try `help %s extended'\n", … … 102 102 return CMD_FAILURE; 103 103 } 104 104 105 105 for (i = optind; argv[i] != NULL; i++) { 106 106 buff = str_dup(argv[i]); … … 110 110 continue; 111 111 } 112 112 113 113 dirp = opendir(buff); 114 114 if (dirp) { … … 119 119 continue; 120 120 } 121 121 122 122 /* Check whether file exists if -c (--no-create) option is given */ 123 123 if ((!no_create) || … … 128 128 } 129 129 } 130 130 131 131 if (fd < 0) { 132 132 cli_error(CL_EFAIL, "Could not update or create `%s'", buff); … … 138 138 fd = -1; 139 139 } 140 140 141 141 free(buff); 142 142 } 143 143 144 144 if (ret) 145 145 return CMD_FAILURE;
Note:
See TracChangeset
for help on using the changeset viewer.