Last active
January 3, 2019 18:00
-
-
Save matwey/e5f3756a9e7090c1cd0b0d3dcef06ad4 to your computer and use it in GitHub Desktop.
qemu pwrite test case
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define _GNU_SOURCE | |
| #include <stdlib.h> | |
| #include <stdio.h> | |
| #include <unistd.h> | |
| #include <sys/types.h> | |
| #include <sys/stat.h> | |
| #include <fcntl.h> | |
| #include <string.h> | |
| /* | |
| System | Result | |
| -------------------------+---------------- | |
| Native x86_64 4.12.14 | pwrite ret = 0 | |
| Native aarch64 4.4.159 | pwrite ret = 0 | |
| qemu-aarch64 at x86_64 | pwrite ret = -1 | |
| ( 20d6c7312f1b8 ) | | |
| */ | |
| int main(int argc, char** argv) { | |
| int fd = open("test.dat", O_CREAT | O_RDWR, 0644); | |
| if (fd < 0) { | |
| perror("open"); | |
| return 1; | |
| } | |
| int ret = fallocate(fd, 0, 0, 1000); | |
| if (ret < 0) { | |
| perror("fallocate"); | |
| return 1; | |
| } | |
| ssize_t ret_pwrite = pwrite(fd, NULL, 0, 0); | |
| printf("pwrite ret = %ld\n", ret_pwrite); | |
| close(fd); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment