Changes in uspace/app/tester/vfs/vfs1.c [f77c1c9:8d2dd7f2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tester/vfs/vfs1.c
rf77c1c9 r8d2dd7f2 31 31 #include <stdlib.h> 32 32 #include <stddef.h> 33 #include <str_error.h>34 33 #include <str.h> 35 34 #include <vfs/vfs.h> … … 73 72 rc = vfs_link_path(TEST_DIRECTORY, KIND_DIRECTORY, NULL); 74 73 if (rc != EOK) { 75 TPRINTF("rc=% s\n", str_error_name(rc));74 TPRINTF("rc=%d\n", rc); 76 75 return "vfs_link_path() failed"; 77 76 } 78 77 TPRINTF("Created directory %s\n", TEST_DIRECTORY); 79 78 80 int fd0; 81 rc = vfs_lookup_open(TEST_FILE, WALK_REGULAR | WALK_MAY_CREATE, 82 MODE_READ | MODE_WRITE, &fd0); 83 if (rc != EOK) 79 int fd0 = vfs_lookup_open(TEST_FILE, WALK_REGULAR | WALK_MAY_CREATE, 80 MODE_READ | MODE_WRITE); 81 if (fd0 < 0) 84 82 return "vfs_lookup_open() failed"; 85 83 TPRINTF("Created file %s (fd=%d)\n", TEST_FILE, fd0); 86 84 87 85 size_t size = sizeof(text); 88 size_t cnt; 89 rc = vfs_write(fd0, &pos, text, size, &cnt); 90 if (rc != EOK) 86 ssize_t cnt = vfs_write(fd0, &pos, text, size); 87 if (cnt < 0) 91 88 return "write() failed"; 92 89 TPRINTF("Written %zd bytes\n", cnt); … … 96 93 char buf[BUF_SIZE]; 97 94 TPRINTF("read..\n"); 98 while (( rc = vfs_read(fd0, &pos, buf, BUF_SIZE, &cnt))) {99 TPRINTF("read returns rc = %s, cnt = %zu\n", str_error_name(rc), cnt);100 if ( rc != EOK)95 while ((cnt = vfs_read(fd0, &pos, buf, BUF_SIZE))) { 96 TPRINTF("read returns %zd\n", cnt); 97 if (cnt < 0) 101 98 return "read() failed"; 102 99 103 int icnt = (int) cnt;104 if ( (size_t) icnt != cnt) {100 int _cnt = (int) cnt; 101 if (_cnt != cnt) { 105 102 /* Count overflow, just to be sure. */ 106 103 TPRINTF("Read %zd bytes\n", cnt); 107 104 } else { 108 TPRINTF("Read %zd bytes: \"%.*s\"\n", cnt, icnt, buf);105 TPRINTF("Read %zd bytes: \"%.*s\"\n", cnt, _cnt, buf); 109 106 } 110 107 }
Note:
See TracChangeset
for help on using the changeset viewer.