Changeset 6afc9d7 in mainline for uspace/app
- Timestamp:
- 2015-10-06T19:01:36Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0328987
- Parents:
- f1f7584
- Location:
- uspace/app
- Files:
-
- 23 edited
-
bdsh/cmds/builtins/cd/cd.c (modified) (1 diff)
-
bdsh/cmds/modules/cat/cat.c (modified) (1 diff)
-
bdsh/cmds/modules/cp/cp.c (modified) (8 diffs)
-
bdsh/cmds/modules/ls/ls.c (modified) (4 diffs)
-
bdsh/cmds/modules/mkdir/mkdir.c (modified) (5 diffs)
-
bdsh/cmds/modules/mkfile/mkfile.c (modified) (4 diffs)
-
bdsh/cmds/modules/mount/mount.c (modified) (2 diffs)
-
bdsh/cmds/modules/mv/mv.c (modified) (1 diff)
-
bdsh/cmds/modules/pwd/pwd.c (modified) (1 diff)
-
bdsh/cmds/modules/rm/rm.c (modified) (4 diffs)
-
bdsh/cmds/modules/touch/touch.c (modified) (1 diff)
-
bdsh/cmds/modules/unmount/unmount.c (modified) (1 diff)
-
bdsh/compl.c (modified) (1 diff)
-
bdsh/exec.c (modified) (2 diffs)
-
df/df.c (modified) (1 diff)
-
init/init.c (modified) (4 diffs)
-
taskdump/elf_core.c (modified) (6 diffs)
-
taskdump/symtab.c (modified) (3 diffs)
-
tester/hw/misc/virtchar1.c (modified) (2 diffs)
-
tester/vfs/vfs1.c (modified) (3 diffs)
-
trace/trace.c (modified) (2 diffs)
-
untar/main.c (modified) (1 diff)
-
viewer/viewer.c (modified) (2 diffs)
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); -
uspace/app/bdsh/compl.c
rf1f7584 r6afc9d7 360 360 asprintf(&ent_path, "%s/%s", *cs->path, dent->d_name); 361 361 struct stat ent_stat; 362 if (stat(ent_path, &ent_stat) != EOK) {362 if (stat(ent_path, &ent_stat) != 0) { 363 363 /* Error */ 364 364 free(ent_path); -
uspace/app/bdsh/exec.c
rf1f7584 r6afc9d7 61 61 62 62 fd = open(f, O_RDONLY); 63 if (fd > -1) {63 if (fd >= 0) { 64 64 close(fd); 65 65 return 0; … … 113 113 114 114 for (i = 0; i < 3 && files[i] != NULL; i++) { 115 if ( fhandle(files[i], &file_handles[i]) == EOK) {115 if (vfs_fhandle(files[i], &file_handles[i]) == EOK) { 116 116 file_handles_p[i] = &file_handles[i]; 117 117 } -
uspace/app/df/df.c
rf1f7584 r6afc9d7 119 119 120 120 LIST_INITIALIZE(mtab_list); 121 get_mtab_list(&mtab_list);121 vfs_get_mtab_list(&mtab_list); 122 122 123 123 print_header(); 124 124 list_foreach(mtab_list, link, mtab_ent_t, mtab_ent) { 125 statfs(mtab_ent->mp, &st); 126 print_statfs(&st, mtab_ent->fs_name, mtab_ent->mp); 125 if (statfs(mtab_ent->mp, &st) == 0) { 126 print_statfs(&st, mtab_ent->fs_name, mtab_ent->mp); 127 } else { 128 fprintf(stderr, "Cannot get information for '%s' (%d).\n", 129 mtab_ent->mp, errno); 130 } 127 131 } 128 132 -
uspace/app/init/init.c
rf1f7584 r6afc9d7 126 126 opts = "restore"; 127 127 128 int rc = mount(fstype, ROOT_MOUNT_POINT, ROOT_DEVICE, opts,128 int rc = vfs_mount(fstype, ROOT_MOUNT_POINT, ROOT_DEVICE, opts, 129 129 IPC_FLAG_BLOCKING, 0); 130 130 return mount_report("Root filesystem", ROOT_MOUNT_POINT, fstype, … … 143 143 static bool mount_locfs(void) 144 144 { 145 int rc = mount(LOCFS_FS_TYPE, LOCFS_MOUNT_POINT, "", "",145 int rc = vfs_mount(LOCFS_FS_TYPE, LOCFS_MOUNT_POINT, "", "", 146 146 IPC_FLAG_BLOCKING, 0); 147 147 return mount_report("Location service filesystem", LOCFS_MOUNT_POINT, … … 152 152 { 153 153 struct stat s; 154 if (stat(path, &s) == ENOENT) {154 if (stat(path, &s) != 0) { 155 155 printf("%s: Unable to stat %s\n", NAME, path); 156 156 return ENOENT; … … 299 299 static bool mount_tmpfs(void) 300 300 { 301 int rc = mount(TMPFS_FS_TYPE, TMPFS_MOUNT_POINT, "", "", 0, 0);301 int rc = vfs_mount(TMPFS_FS_TYPE, TMPFS_MOUNT_POINT, "", "", 0, 0); 302 302 return mount_report("Temporary filesystem", TMPFS_MOUNT_POINT, 303 303 TMPFS_FS_TYPE, NULL, rc); -
uspace/app/taskdump/elf_core.c
rf1f7584 r6afc9d7 207 207 } 208 208 209 rc = write _all(fd, &elf_hdr, sizeof(elf_hdr));209 rc = write(fd, &elf_hdr, sizeof(elf_hdr)); 210 210 if (rc != sizeof(elf_hdr)) { 211 211 printf("Failed writing ELF header.\n"); … … 215 215 216 216 for (i = 0; i < n_ph; ++i) { 217 rc = write _all(fd, &p_hdr[i], sizeof(p_hdr[i]));217 rc = write(fd, &p_hdr[i], sizeof(p_hdr[i])); 218 218 if (rc != sizeof(p_hdr[i])) { 219 219 printf("Failed writing program header.\n"); … … 236 236 note.type = NT_PRSTATUS; 237 237 238 rc = write _all(fd, ¬e, sizeof(elf_note_t));238 rc = write(fd, ¬e, sizeof(elf_note_t)); 239 239 if (rc != sizeof(elf_note_t)) { 240 240 printf("Failed writing note header.\n"); … … 243 243 } 244 244 245 rc = write _all(fd, "CORE", note.namesz);245 rc = write(fd, "CORE", note.namesz); 246 246 if (rc != (ssize_t) note.namesz) { 247 247 printf("Failed writing note header.\n"); … … 257 257 } 258 258 259 rc = write _all(fd, &pr_status, sizeof(elf_prstatus_t));259 rc = write(fd, &pr_status, sizeof(elf_prstatus_t)); 260 260 if (rc != sizeof(elf_prstatus_t)) { 261 261 printf("Failed writing register data.\n"); … … 321 321 } 322 322 323 rc = write _all(fd, buffer, to_copy);323 rc = write(fd, buffer, to_copy); 324 324 if (rc != (ssize_t) to_copy) { 325 325 printf("Failed writing memory contents.\n"); -
uspace/app/taskdump/symtab.c
rf1f7584 r6afc9d7 88 88 } 89 89 90 rc = read _all(fd, &elf_hdr, sizeof(elf_header_t));90 rc = read(fd, &elf_hdr, sizeof(elf_header_t)); 91 91 if (rc != sizeof(elf_header_t)) { 92 92 printf("failed reading elf header\n"); … … 310 310 return EIO; 311 311 312 rc = read _all(fd, sec_hdr, sizeof(elf_section_header_t));312 rc = read(fd, sec_hdr, sizeof(elf_section_header_t)); 313 313 if (rc != sizeof(elf_section_header_t)) 314 314 return EIO; … … 346 346 } 347 347 348 rc = read _all(fd, *ptr, size);348 rc = read(fd, *ptr, size); 349 349 if (rc != (ssize_t) size) { 350 350 printf("failed reading chunk\n"); -
uspace/app/tester/hw/misc/virtchar1.c
rf1f7584 r6afc9d7 58 58 int fd = open(path, O_RDONLY); 59 59 if (fd < 0) { 60 TPRINTF(" ...error: %s\n", str_error( fd));60 TPRINTF(" ...error: %s\n", str_error(errno)); 61 61 if (fd == ENOENT) { 62 62 TPRINTF(" (error was ENOENT: " \ … … 69 69 70 70 TPRINTF(" Asking for session...\n"); 71 async_sess_t *sess = fd_session(fd, INTERFACE_DDF);71 async_sess_t *sess = vfs_fd_session(fd, INTERFACE_DDF); 72 72 if (!sess) { 73 73 close(fd); -
uspace/app/tester/vfs/vfs1.c
rf1f7584 r6afc9d7 70 70 const char *test_vfs1(void) 71 71 { 72 int rc; 73 if ((rc = mkdir(TEST_DIRECTORY, 0)) != 0) { 74 TPRINTF("rc=%d\n", rc); 72 if (mkdir(TEST_DIRECTORY, 0) != 0) { 73 TPRINTF("rc=%d\n", errno); 75 74 return "mkdir() failed"; 76 75 } … … 93 92 94 93 char buf[BUF_SIZE]; 94 TPRINTF("read..\n"); 95 95 while ((cnt = read(fd0, buf, BUF_SIZE))) { 96 TPRINTF("read returns %zd\n", cnt); 96 97 if (cnt < 0) 97 98 return "read() failed"; … … 112 113 return rv; 113 114 114 if (rename(TEST_FILE, TEST_FILE2) )115 if (rename(TEST_FILE, TEST_FILE2) != 0) 115 116 return "rename() failed"; 116 117 TPRINTF("Renamed %s to %s\n", TEST_FILE, TEST_FILE2); 117 118 118 if (unlink(TEST_FILE2) )119 if (unlink(TEST_FILE2) != 0) 119 120 return "unlink() failed"; 120 121 TPRINTF("Unlinked %s\n", TEST_FILE2); 121 122 122 if (rmdir(TEST_DIRECTORY) )123 if (rmdir(TEST_DIRECTORY) != 0) 123 124 return "rmdir() failed"; 124 125 TPRINTF("Removed directory %s\n", TEST_DIRECTORY); -
uspace/app/trace/trace.c
rf1f7584 r6afc9d7 57 57 #include "proto.h" 58 58 #include <ipc/services.h> 59 #include "../../srv/vfs/vfs.h"59 #include <ipc/vfs.h> 60 60 #include <ipc/console.h> 61 61 … … 528 528 int fd_stderr; 529 529 530 if ((stdin != NULL) && ( fhandle(stdin, &fd_stdin) == EOK))530 if ((stdin != NULL) && (vfs_fhandle(stdin, &fd_stdin) == EOK)) 531 531 files[0] = &fd_stdin; 532 532 else 533 533 files[0] = NULL; 534 534 535 if ((stdout != NULL) && ( fhandle(stdout, &fd_stdout) == EOK))535 if ((stdout != NULL) && (vfs_fhandle(stdout, &fd_stdout) == EOK)) 536 536 files[1] = &fd_stdout; 537 537 else 538 538 files[1] = NULL; 539 539 540 if ((stderr != NULL) && ( fhandle(stderr, &fd_stderr) == EOK))540 if ((stderr != NULL) && (vfs_fhandle(stderr, &fd_stderr) == EOK)) 541 541 files[2] = &fd_stderr; 542 542 else -
uspace/app/untar/main.c
rf1f7584 r6afc9d7 103 103 static int handle_directory(const tar_header_t *header, FILE *tarfile) 104 104 { 105 int rc = mkdir(header->filename, 0755); 106 if (rc == EEXIST) { 107 // printf("Note: directory %s already exists.\n", header->filename); 108 rc = EOK; 109 } 110 if (rc != EOK) { 111 fprintf(stderr, "Failed to create directory %s: %s.\n", 112 header->filename, str_error(rc)); 113 return rc; 105 if (mkdir(header->filename, 0755) != 0) { 106 if (errno != EEXIST) { 107 fprintf(stderr, "Failed to create directory %s: %s.\n", 108 header->filename, str_error(errno)); 109 return errno; 110 } 114 111 } 115 112 -
uspace/app/viewer/viewer.c
rf1f7584 r6afc9d7 98 98 { 99 99 int fd = open(fname, O_RDONLY); 100 if (fd <0)100 if (fd != 0) 101 101 return false; 102 102 103 103 struct stat stat; 104 104 int rc = fstat(fd, &stat); 105 if (rc != EOK) {105 if (rc != 0) { 106 106 close(fd); 107 107 return false; … … 114 114 } 115 115 116 ssize_t rd = read _all(fd, tga, stat.size);116 ssize_t rd = read(fd, tga, stat.size); 117 117 if ((rd < 0) || (rd != (ssize_t) stat.size)) { 118 118 free(tga);
Note:
See TracChangeset
for help on using the changeset viewer.
