yggdrasil/test.c

33 lines
795 B
C
Raw Normal View History

#include <sys/mman.h>
#include <stdlib.h>
#include <string.h>
2025-02-24 11:00:56 +02:00
#include <dlfcn.h>
2024-11-20 15:39:10 +02:00
#include <stdio.h>
#include <fcntl.h>
2024-11-20 15:39:10 +02:00
2025-02-24 11:00:56 +02:00
int main(int argc, char **argv) {
int fd = open("test.dat", O_RDWR | O_CREAT, 0644);
if (fd < 0) {
perror("open()");
return EXIT_FAILURE;
}
if (ftruncate(fd, 0x1000 * 4) != 0) {
perror("ftruncate()");
return EXIT_FAILURE;
}
void *data;
if ((data = mmap(NULL, 0x1000 * 4, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0)) == MAP_FAILED) {
perror("mmap()");
return EXIT_FAILURE;
}
memset(data + 0x1000 * 0, 'a', 0x1000);
memset(data + 0x1000 * 1, 'b', 0x1000);
memset(data + 0x1000 * 2, 'c', 0x1000);
memset(data + 0x1000 * 3, 'd', 0x1000);
close(fd);
return EXIT_SUCCESS;
2024-11-11 15:19:36 +02:00
}