Changes in uspace/app/bdsh/cmds/modules/cp/cp.c [8e3498b:39330200] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/cp/cp.c
r8e3498b r39330200 28 28 29 29 #include <errno.h> 30 #include <str_error.h> 30 31 #include <stdio.h> 31 32 #include <stdlib.h> … … 79 80 static dentry_type_t get_type(const char *path) 80 81 { 81 struct stat s;82 83 int r = vfs_stat_path(path, &s);82 vfs_stat_t s; 83 84 errno_t r = vfs_stat_path(path, &s); 84 85 85 86 if (r != EOK) … … 175 176 } 176 177 177 static int do_copy(const char *src, const char *dest,178 static errno_t do_copy(const char *src, const char *dest, 178 179 size_t blen, int vb, int recursive, int force, int interactive) 179 180 { 180 int rc = EOK;181 errno_t rc = EOK; 181 182 char dest_path[PATH_MAX]; 182 183 char src_path[PATH_MAX]; … … 265 266 266 267 /* call copy_file and exit */ 267 rc = (copy_file(src, dest_path, blen, vb) < 0); 268 if (copy_file(src, dest_path, blen, vb) < 0) { 269 rc = EIO; 270 } 268 271 269 272 } else if (src_type == TYPE_DIR) { … … 337 340 */ 338 341 while ((dp = readdir(dir))) { 339 struct stat src_s;340 struct stat dest_s;342 vfs_stat_t src_s; 343 vfs_stat_t dest_s; 341 344 342 345 char src_dent[PATH_MAX]; … … 385 388 int fd1, fd2; 386 389 size_t rbytes, wbytes; 387 int rc;390 errno_t rc; 388 391 off64_t total; 389 392 char *buff = NULL; 390 393 aoff64_t posr = 0, posw = 0; 391 struct stat st;394 vfs_stat_t st; 392 395 393 396 if (vb) 394 397 printf("Copying %s to %s\n", src, dest); 395 398 396 fd1 = vfs_lookup_open(src, WALK_REGULAR, MODE_READ);397 if ( fd1 < 0) {399 rc = vfs_lookup_open(src, WALK_REGULAR, MODE_READ, &fd1); 400 if (rc != EOK) { 398 401 printf("Unable to open source file %s\n", src); 399 402 return -1; 400 403 } 401 404 402 fd2 = vfs_lookup_open(dest, WALK_REGULAR | WALK_MAY_CREATE, MODE_WRITE);403 if ( fd2 < 0) {405 rc = vfs_lookup_open(dest, WALK_REGULAR | WALK_MAY_CREATE, MODE_WRITE, &fd2); 406 if (rc != EOK) { 404 407 printf("Unable to open destination file %s\n", dest); 405 408 vfs_put(fd1); … … 432 435 433 436 if (rc != EOK) { 434 printf("\nError copying %s , (%d)\n", src, rc);435 return rc;437 printf("\nError copying %s: %s\n", src, str_error(rc)); 438 return -1; 436 439 } 437 440 … … 441 444 if (buff) 442 445 free(buff); 443 return rc; 446 if (rc != EOK) { 447 return -1; 448 } else { 449 return 0; 450 } 444 451 } 445 452 … … 472 479 int force = 0, interactive = 0; 473 480 int c, opt_ind; 474 int64_t ret;481 errno_t ret; 475 482 476 483 con = console_init(stdin, stdout);
Note:
See TracChangeset
for help on using the changeset viewer.