Changeset e755b3f in mainline
- Timestamp:
- 2016-09-02T16:10:39Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b1956e3
- Parents:
- ae6021d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tester/mm/pager1.c
rae6021d re755b3f 29 29 #include <stdio.h> 30 30 #include <unistd.h> 31 #include <fcntl.h> 31 32 #include <stdlib.h> 32 33 #include <malloc.h> … … 37 38 #include "../tester.h" 38 39 40 #define TEST_FILE "/tmp/testfile" 41 42 const char text[] = "Hello world!"; 43 44 int fd; 45 39 46 static void *create_paged_area(size_t size) 40 47 { 48 TPRINTF("Creating temporary file...\n"); 49 50 fd = open(TEST_FILE, O_CREAT); 51 if (fd < 0) 52 return NULL; 53 (void) unlink(TEST_FILE); 54 if (write(fd, text, sizeof(text)) != sizeof(text)) { 55 close(fd); 56 return NULL; 57 } 58 41 59 async_sess_t *vfs_pager_sess; 42 60 … … 45 63 vfs_pager_sess = service_connect_blocking(SERVICE_VFS, INTERFACE_PAGER, 0); 46 64 47 if (!vfs_pager_sess) 65 if (!vfs_pager_sess) { 66 close(fd); 48 67 return NULL; 68 } 49 69 50 70 TPRINTF("Creating AS area...\n"); 51 71 52 72 void *result = async_as_area_create(AS_AREA_ANY, size, 53 AS_AREA_READ | AS_AREA_CACHEABLE, vfs_pager_sess, 0, 0, 0); 54 if (result == AS_MAP_FAILED) 73 AS_AREA_READ | AS_AREA_CACHEABLE, vfs_pager_sess, fd, 0, 0); 74 if (result == AS_MAP_FAILED) { 75 close(fd); 55 76 return NULL; 77 } 56 78 57 79 return result; … … 73 95 size_t buffer_len = PAGE_SIZE; 74 96 void *buffer = create_paged_area(buffer_len); 75 if (!buffer) {97 if (!buffer) 76 98 return "Cannot allocate memory"; 77 }78 99 79 100 touch_area(buffer, buffer_len); 101 102 as_area_destroy(buffer); 103 close(fd); 80 104 81 105 return NULL;
Note:
See TracChangeset
for help on using the changeset viewer.