1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#include <cassert>
4#include <mos/types.h>
5#include <string.h>
6#include <sys/mman.h>
7#include <unistd.h>
8
9int main(void)
10{
11 fd_t fd = memfd_create("name", MFD_CLOEXEC);
12
13 const int writtensize = write(fd, buffer: "Hello, World!", size: 13);
14 assert(writtensize == 13);
15
16 const int pos = lseek(fd, offset: 0, SEEK_SET);
17 assert(pos == 0);
18
19 char buf[13];
20 const int readsize = read(fd, buffer: buf, size: 13);
21 assert(readsize == 13);
22
23 const int cmp = memcmp(a: buf, b: "Hello, World!", size: 13);
24 assert(cmp == 0);
25}
26