Changeset 6afc9d7 in mainline for uspace/app/bdsh/cmds
- Timestamp:
- 2015-10-06T19:01:36Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0328987
- Parents:
- f1f7584
- Location:
- uspace/app/bdsh/cmds
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/builtins/cd/cd.c
rf1f7584 r6afc9d7 57 57 previous_directory_set = true; 58 58 59 int rc = chdir(new_dir); 60 if (rc != EOK) { 61 return rc; 62 } 59 if (chdir(new_dir) != 0) 60 return errno; 63 61 64 62 str_cpy(previous_directory, PATH_MAX, previous_directory_tmp); -
uspace/app/bdsh/cmds/modules/cat/cat.c
rf1f7584 r6afc9d7 244 244 245 245 bytes = read(fd, buff + copied_bytes, bytes_to_read); 246 bytes += copied_bytes;247 246 copied_bytes = 0; 248 247 -
uspace/app/bdsh/cmds/modules/cp/cp.c
rf1f7584 r6afc9d7 27 27 */ 28 28 29 #include <errno.h> 29 30 #include <stdio.h> 30 31 #include <stdlib.h> … … 84 85 int r = stat(path, &s); 85 86 86 if (r )87 if (r != 0) 87 88 return TYPE_NONE; 88 89 else if (s.is_directory) … … 234 235 */ 235 236 if (force && !interactive) { 236 if (unlink(dest_path) ) {237 if (unlink(dest_path) != 0) { 237 238 printf("Unable to remove %s\n", 238 239 dest_path); … … 245 246 if (overwrite) { 246 247 printf("Overwriting file: %s\n", dest_path); 247 if (unlink(dest_path) ) {248 if (unlink(dest_path) != 0) { 248 249 printf("Unable to remove %s\n", dest_path); 249 250 goto exit; … … 294 295 merge_paths(dest_path, PATH_MAX, src_dirname); 295 296 296 if (mkdir(dest_path, 0) == -1) {297 if (mkdir(dest_path, 0) != 0) { 297 298 printf("Unable to create " 298 299 "dest directory %s\n", dest_path); … … 308 309 * e.g. cp -r /src /data/new_dir_src 309 310 */ 310 if (mkdir(dest_path, 0) ) {311 if (mkdir(dest_path, 0) != 0) { 311 312 printf("Unable to create " 312 313 "dest directory %s\n", dest_path); … … 405 406 } 406 407 407 while ((bytes = read _all(fd1, buff, blen)) > 0) {408 if ((bytes = write _all(fd2, buff, bytes)) < 0)408 while ((bytes = read(fd1, buff, blen)) > 0) { 409 if ((bytes = write(fd2, buff, bytes)) < 0) 409 410 break; 410 411 copied += bytes; … … 412 413 413 414 if (bytes < 0) { 414 printf("\nError copying %s, (%d)\n", src, bytes);415 printf("\nError copying %s, (%d)\n", src, errno); 415 416 copied = bytes; 416 417 } -
uspace/app/bdsh/cmds/modules/ls/ls.c
rf1f7584 r6afc9d7 31 31 * As more stuff is completed and exposed in libc, this will improve */ 32 32 33 #include <errno.h> 33 34 #include <stdio.h> 34 35 #include <stdlib.h> … … 187 188 if (rc != 0) { 188 189 printf("ls: skipping bogus node %s\n", buff); 189 printf(" rc=%d\n", rc);190 printf("error=%d\n", errno); 190 191 goto out; 191 192 } … … 314 315 static unsigned int ls_scope(const char *path, struct dir_elem_t *de) 315 316 { 316 if (stat(path, &de->s) ) {317 if (stat(path, &de->s) != 0) { 317 318 cli_error(CL_ENOENT, "%s", path); 318 319 return LS_BOGUS; … … 376 377 } 377 378 } 378 379 379 380 argc -= optind; 380 381 381 382 de.name = (char *) malloc(PATH_MAX); 382 383 if (!de.name) { 383 cli_error(CL_ENOMEM, "%s: ", cmdname);384 cli_error(CL_ENOMEM, "%s: Out of memory", cmdname); 384 385 return CMD_FAILURE; 385 386 } 386 387 memset(de.name, 0, PATH_MAX); 387 388 if (argc == 0) 389 getcwd(de.name, PATH_MAX); 390 else 388 389 if (argc == 0) { 390 if (getcwd(de.name, PATH_MAX) == NULL) { 391 cli_error(CL_EFAIL, "%s: Failed determining working " 392 "directory", cmdname); 393 return CMD_FAILURE; 394 } 395 } else { 391 396 str_cpy(de.name, PATH_MAX, argv[optind]); 397 } 392 398 393 399 scope = ls_scope(de.name, &de); -
uspace/app/bdsh/cmds/modules/mkdir/mkdir.c
rf1f7584 r6afc9d7 89 89 { 90 90 /* Ensure we would always work with absolute and canonified path. */ 91 char *path = absolutize(user_path, NULL);91 char *path = vfs_absolutize(user_path, NULL); 92 92 if (path == NULL) { 93 93 cli_error(CL_ENOMEM, "%s: path too big?", cmdname); … … 95 95 } 96 96 97 int rc;98 97 int ret = 0; 99 98 100 99 if (!create_parents) { 101 rc = mkdir(path, 0); 102 if (rc != EOK) { 100 if (mkdir(path, 0) != 0) { 103 101 cli_error(CL_EFAIL, "%s: could not create %s (%s)", 104 cmdname, path, str_error( rc));102 cmdname, path, str_error(errno)); 105 103 ret = 1; 106 104 } … … 137 135 char slash_char = path[prev_off]; 138 136 path[prev_off] = 0; 139 rc = mkdir(path, 0); 140 if (rc == EEXIST) { 141 rc = EOK; 142 } 143 144 if (rc != EOK) { 137 138 if (mkdir(path, 0) != 0 && errno != EEXIST) { 145 139 cli_error(CL_EFAIL, "%s: could not create %s (%s)", 146 cmdname, path, str_error( rc));140 cmdname, path, str_error(errno)); 147 141 ret = 1; 148 142 goto leave; … … 152 146 } 153 147 /* Create the final directory. */ 154 rc = mkdir(path, 0); 155 if (rc != EOK) { 148 if (mkdir(path, 0) != 0) { 156 149 cli_error(CL_EFAIL, "%s: could not create %s (%s)", 157 cmdname, path, str_error( rc));150 cmdname, path, str_error(errno)); 158 151 ret = 1; 159 152 } … … 214 207 215 208 if (follow && (argv[optind] != NULL)) { 216 chdir(argv[optind]); 209 if (chdir(argv[optind]) != 0) 210 printf("%s: Error switching to directory.", cmdname); 217 211 } 218 212 -
uspace/app/bdsh/cmds/modules/mkfile/mkfile.c
rf1f7584 r6afc9d7 27 27 */ 28 28 29 #include <errno.h> 29 30 #include <stdio.h> 30 31 #include <stdlib.h> … … 166 167 167 168 if ((rc2 = lseek(fd, file_size - 1, SEEK_SET)) < 0) 168 goto e xit;169 goto error; 169 170 170 171 rc2 = write(fd, &byte, sizeof(char)); 171 goto exit; 172 if (rc2 < 0) 173 goto error; 174 return CMD_SUCCESS; 172 175 } 173 176 … … 183 186 rc = write(fd, buffer, to_write); 184 187 if (rc <= 0) { 185 printf("%s: Error writing file (% zd).\n", cmdname, rc);188 printf("%s: Error writing file (%d).\n", cmdname, errno); 186 189 close(fd); 187 190 return CMD_FAILURE; … … 191 194 192 195 free(buffer); 193 exit: 194 rc = close(fd); 195 196 if (rc != 0 || rc2 < 0) { 197 printf("%s: Error writing file (%zd).\n", cmdname, rc); 198 return CMD_FAILURE; 199 } 196 197 if (close(fd) < 0) 198 goto error; 200 199 201 200 return CMD_SUCCESS; 201 error: 202 printf("%s: Error writing file (%d).\n", cmdname, errno); 203 return CMD_FAILURE; 202 204 } -
uspace/app/bdsh/cmds/modules/mount/mount.c
rf1f7584 r6afc9d7 72 72 int rc; 73 73 74 get_mtab_list(&mtab_list);74 vfs_get_mtab_list(&mtab_list); 75 75 76 76 list_foreach(mtab_list, link, mtab_ent_t, mtab_ent) { … … 150 150 mopts = t_argv[4]; 151 151 152 rc = mount(t_argv[1], t_argv[2], dev, mopts, 0, instance);152 rc = vfs_mount(t_argv[1], t_argv[2], dev, mopts, 0, instance); 153 153 if (rc != EOK) { 154 154 printf("Unable to mount %s filesystem to %s on %s (rc=%d)\n", -
uspace/app/bdsh/cmds/modules/mv/mv.c
rf1f7584 r6afc9d7 60 60 61 61 rc = rename(argv[1], argv[2]); 62 if (rc != EOK) {63 printf("Unable to rename %s to %s ( rc=%d)\n",64 argv[1], argv[2], rc);62 if (rc != 0) { 63 printf("Unable to rename %s to %s (error=%d)\n", 64 argv[1], argv[2], errno); 65 65 return CMD_FAILURE; 66 66 } -
uspace/app/bdsh/cmds/modules/pwd/pwd.c
rf1f7584 r6afc9d7 56 56 57 57 memset(buff, 0, PATH_MAX); 58 getcwd(buff, PATH_MAX);59 58 60 if ( ! buff) {59 if (getcwd(buff, PATH_MAX) == NULL) { 61 60 cli_error(CL_EFAIL, 62 61 "Unable to determine the current working directory"); -
uspace/app/bdsh/cmds/modules/rm/rm.c
rf1f7584 r6afc9d7 27 27 */ 28 28 29 #include <errno.h> 29 30 #include <stdio.h> 30 31 #include <stdlib.h> … … 131 132 static unsigned int rm_single(const char *path) 132 133 { 133 if (unlink(path) ) {134 if (unlink(path) != 0) { 134 135 cli_error(CL_EFAIL, "rm: could not remove file %s", path); 135 136 return 1; … … 150 151 151 152 fd = open(path, O_RDONLY); 152 if (fd > 0) {153 if (fd >= 0) { 153 154 close(fd); 154 155 return RM_FILE; … … 210 211 rc = rmdir(path); 211 212 if (rc == 0) 212 return ret;213 return errno; 213 214 214 215 cli_error(CL_ENOTSUP, "Can not remove %s", path); -
uspace/app/bdsh/cmds/modules/touch/touch.c
rf1f7584 r6afc9d7 123 123 124 124 /* Check whether file exists if -c (--no-create) option is given */ 125 if ((!no_create) || ((no_create) && (stat(buff, &file_stat) == EOK)))125 if ((!no_create) || ((no_create) && (stat(buff, &file_stat) == 0))) 126 126 fd = open(buff, O_RDWR | O_CREAT); 127 127 -
uspace/app/bdsh/cmds/modules/unmount/unmount.c
rf1f7584 r6afc9d7 66 66 } 67 67 68 rc = unmount(argv[1]);68 rc = vfs_unmount(argv[1]); 69 69 if (rc != EOK) { 70 70 printf("Unable to unmount %s (rc=%d)\n", argv[1], rc);
Note:
See TracChangeset
for help on using the changeset viewer.