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

int
main(void)
{
    int fd;
    char buf[10];

    if ((fd = open("log3", O_RDWR | O_APPEND)) == -1)
        err(EXIT_FAILURE, "open");

    write(fd, "salam\n", 6);
    lseek(fd, -9L, SEEK_END);
    read(fd, buf, 6);
    printf("%s", buf);
    write(fd, "Ok!\n", 4);

    exit(EXIT_SUCCESS);
}
