Advertisement
rfmonk

large_file.c

Dec 28th, 2013
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #define _LARGE64_SOURCE
  2. #include <sys/stat.h>
  3. #include <fcntl.h>
  4. #include "tlpi_hdr.h"
  5.  
  6. int
  7. main(int argc, char *argv[])
  8. {
  9.     int fd;
  10.     off64_t off;
  11.  
  12.     if (argc != 3 || strcmp(argv[1], "--help") == 0)
  13.         usageErr("%s pathname offset\n", argv[0]);
  14.  
  15.     fd = open64(argv[1], O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
  16.     if (fd == -1)
  17.         errExit("open64");
  18.  
  19.     off = atoll(argv[2]);
  20.     if (lseek64(fd, off, SEEK_SET) == -1)
  21.         errExit("lseek64");
  22.  
  23.     if (write(fd, "test", 4) == -1)
  24.         errExit("write");
  25.     exit(EXIT_SUCCESS);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement