/* fs1a.c Jim Plank CS360 Dup lecture We print out the seek pointers in fs1.c */ #include #include #include #include /* lseek(fd, 0, 1) returns the value of the current lseek offset */ int main() { int fd1, fd2; fd1 = open("file1.txt", O_WRONLY | O_CREAT | O_TRUNC, 0644); fd2 = open("file1.txt", O_WRONLY); printf("Before writing Jim: lseek(fd1, 0, 1): %d. lseek(fd2, 0, 1): %d\n", (int) lseek(fd1, 0, 1), (int) lseek(fd2, 0, 1)); write(fd1, "Jim\n", strlen("Jim\n")); printf("Before writing Plank: lseek(fd1, 0, 1): %d. lseek(fd2, 0, 1): %d\n", (int) lseek(fd1, 0, 1), (int) lseek(fd2, 0, 1)); write(fd2, "Plank\n", strlen("Plank\n")); printf("After writing Plank: lseek(fd1, 0, 1): %d. lseek(fd2, 0, 1): %d\n", (int) lseek(fd1, 0, 1), (int) lseek(fd2, 0, 1)); close(fd1); close(fd2); return 0; }