Changeset 368ee04 in mainline for uspace/app/tester
- Timestamp:
- 2017-04-05T18:10:39Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 93ad8166
- Parents:
- 39f892a9 (diff), 2166728 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace/app/tester
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tester/hw/misc/virtchar1.c
r39f892a9 r368ee04 45 45 #include <vfs/vfs.h> 46 46 #include <vfs/vfs_sess.h> 47 #include <sys/stat.h>48 #include <fcntl.h>49 47 #include "../../tester.h" 50 48 … … 56 54 { 57 55 TPRINTF("Opening `%s'...\n", path); 58 int fd = open(path, O_RDONLY);56 int fd = vfs_lookup(path, WALK_REGULAR); 59 57 if (fd < 0) { 60 58 TPRINTF(" ...error: %s\n", str_error(errno)); … … 71 69 async_sess_t *sess = vfs_fd_session(fd, INTERFACE_DDF); 72 70 if (!sess) { 73 close(fd);71 vfs_put(fd); 74 72 TPRINTF(" ...error: %s\n", str_error(errno)); 75 73 return "Failed to get session to device"; … … 92 90 TPRINTF(" Closing session and file descriptor\n"); 93 91 async_hangup(sess); 94 close(fd);92 vfs_put(fd); 95 93 96 94 return NULL; -
uspace/app/tester/mm/pager1.c
r39f892a9 r368ee04 28 28 29 29 #include <stdio.h> 30 #include <unistd.h> 31 #include <fcntl.h> 30 #include <vfs/vfs.h> 32 31 #include <stdlib.h> 33 32 #include <malloc.h> … … 48 47 TPRINTF("Creating temporary file...\n"); 49 48 50 fd = open(TEST_FILE, O_CREAT); 49 fd = vfs_lookup_open(TEST_FILE, WALK_REGULAR | WALK_MAY_CREATE, 50 MODE_READ | MODE_WRITE); 51 51 if (fd < 0) 52 52 return NULL; 53 (void) unlink(TEST_FILE); 54 if (write(fd, text, sizeof(text)) != sizeof(text)) { 55 close(fd); 53 (void) vfs_unlink_path(TEST_FILE); 54 55 if (vfs_write(fd, (aoff64_t []) {0}, text, sizeof(text)) < 0) { 56 vfs_put(fd); 56 57 return NULL; 57 58 } … … 64 65 65 66 if (!vfs_pager_sess) { 66 close(fd);67 vfs_put(fd); 67 68 return NULL; 68 69 } … … 73 74 AS_AREA_READ | AS_AREA_CACHEABLE, vfs_pager_sess, fd, 0, 0); 74 75 if (result == AS_MAP_FAILED) { 75 close(fd);76 vfs_put(fd); 76 77 return NULL; 77 78 } … … 101 102 102 103 as_area_destroy(buffer); 103 close(fd);104 vfs_put(fd); 104 105 105 106 return NULL; -
uspace/app/tester/vfs/vfs1.c
r39f892a9 r368ee04 33 33 #include <vfs/vfs.h> 34 34 #include <unistd.h> 35 #include <fcntl.h>36 35 #include <dirent.h> 37 36 #include <loc.h> 38 37 #include <sys/types.h> 39 #include <sys/stat.h>40 38 #include "../tester.h" 41 39 … … 70 68 const char *test_vfs1(void) 71 69 { 72 if (mkdir(TEST_DIRECTORY, 0) != 0) { 73 TPRINTF("rc=%d\n", errno); 74 return "mkdir() failed"; 70 aoff64_t pos = 0; 71 int rc; 72 73 rc = vfs_link_path(TEST_DIRECTORY, KIND_DIRECTORY, NULL); 74 if (rc != EOK) { 75 TPRINTF("rc=%d\n", rc); 76 return "vfs_link_path() failed"; 75 77 } 76 78 TPRINTF("Created directory %s\n", TEST_DIRECTORY); 77 79 78 int fd0 = open(TEST_FILE, O_CREAT); 80 int fd0 = vfs_lookup_open(TEST_FILE, WALK_REGULAR | WALK_MAY_CREATE, 81 MODE_READ | MODE_WRITE); 79 82 if (fd0 < 0) 80 return " open() failed";83 return "vfs_lookup_open() failed"; 81 84 TPRINTF("Created file %s (fd=%d)\n", TEST_FILE, fd0); 82 85 83 86 size_t size = sizeof(text); 84 ssize_t cnt = write(fd0, text, size);87 ssize_t cnt = vfs_write(fd0, &pos, text, size); 85 88 if (cnt < 0) 86 89 return "write() failed"; 87 90 TPRINTF("Written %zd bytes\n", cnt); 88 89 if (lseek(fd0, 0, SEEK_SET) != 0) 90 return "lseek() failed"; 91 TPRINTF("Sought to position 0\n"); 91 92 pos = 0; 92 93 93 94 char buf[BUF_SIZE]; 94 95 TPRINTF("read..\n"); 95 while ((cnt = read(fd0, buf, BUF_SIZE))) {96 while ((cnt = vfs_read(fd0, &pos, buf, BUF_SIZE))) { 96 97 TPRINTF("read returns %zd\n", cnt); 97 98 if (cnt < 0) … … 107 108 } 108 109 109 close(fd0);110 vfs_put(fd0); 110 111 111 112 const char *rv = read_root(); … … 113 114 return rv; 114 115 115 if ( rename(TEST_FILE, TEST_FILE2) != 0)116 return " rename() failed";116 if (vfs_rename_path(TEST_FILE, TEST_FILE2) != EOK) 117 return "vfs_rename_path() failed"; 117 118 TPRINTF("Renamed %s to %s\n", TEST_FILE, TEST_FILE2); 118 119 119 if ( unlink(TEST_FILE2) != 0)120 return " unlink() failed";120 if (vfs_unlink_path(TEST_FILE2) != EOK) 121 return "vfs_unlink_path() failed"; 121 122 TPRINTF("Unlinked %s\n", TEST_FILE2); 122 123 123 if ( rmdir(TEST_DIRECTORY) != 0)124 return " rmdir() failed";124 if (vfs_unlink_path(TEST_DIRECTORY) != EOK) 125 return "vfs_unlink_path() failed"; 125 126 TPRINTF("Removed directory %s\n", TEST_DIRECTORY); 126 127
Note:
See TracChangeset
for help on using the changeset viewer.