/* gcc -D_GNU_SOURCE -o lseek lseek.c */ #include #include #include #include #include #include #include #include char buffer[63*1024]; int main(int argc, char *argv[]) { loff_t offset; int fildes = open(argv[1], O_RDONLY|O_LARGEFILE, 0600); if (fildes == -1) { printf("errno=%d %s\n", errno, strerror(errno)); exit(1); } offset = (loff_t) strtoul(argv[2],NULL, 0) * 1024 * 1024; offset = lseek(fildes, offset, SEEK_SET); printf("offset=%Lu\n", offset); read(fildes, buffer, sizeof(buffer)); return 0; }