#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <err.h>
#include <string.h>

int
main(int argc, char *argv[])
{
    int fd;
    off_t off;

    if (argc != 3 || strcmp(argv[1], "--help") == 0)
        errx(EXIT_FAILURE, "usage: %s pathname offset", argv[0]);

    fd = open(argv[1], O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
    if (fd == -1)
        err(EXIT_FAILURE, "open");

    off = atoll(argv[2]);
    if (lseek(fd, off, SEEK_SET) == -1)
        err(EXIT_FAILURE, "lseek");

    if (write(fd, "test", 4) == -1)
        err(EXIT_FAILURE, "write");

    exit(EXIT_SUCCESS);
}
