#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <err.h>
#include "../lpi.h"
int
main(void)
{
    int fd;
    int flags;
    char buf[50];

    fd = open("log5", O_CREAT);
    if (fd == -1)
        err(EXIT_FAILURE, "open");

    flags = fcntl(fd, F_GETFL);
    printf("%s\n", toBase(flags, 16, 8, 4, ' '));

    sprintf(buf, "/proc/%d/fdinfo/%d", getpid(), fd);
    int n = printFile(buf);

    printf("\n%d bytes read\n", n);
    exit(EXIT_SUCCESS);
}
