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