This sequence of operations results in incorrect behaviour.
It does the overwrite but fails to append
#include <stdio.h>
#include <fcntl.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#define FILE_PATH "/mnt/pmem_emul/test.txt"
int main() {
// Create the file
int fd = open(FILE_PATH, O_CREAT | O_RDWR);
char buf[] = "Hello";
// Write something onto it
int ret = write(fd, buf, strlen(buf));
assert(fd>=0);
assert(ret>=0);
close(fd);
fd = open(FILE_PATH, O_RDWR);
assert(fd>=0);
// Seek to a valid offset within the file size.
lseek(fd, 3, SEEK_SET);
// Write a few byes
char buf2[] = "world";
ret = write(fd, buf2, strlen(buf2));
assert(ret>=0);
close(fd);
}