How Linux system calls interact with filesystem

Viewed 1099

Lately I faced this excercise:

Given this sequence of system calls in a Linux C language program:

fd = open("f123", O_RDWRT | O_CREAT, 0777);
lseek(fd, 0x1000000L, 0);
write(fd, &fd, sizeof(int));

draw the file system data structures and disk blocks that are modified by these operations, considering a 4 KByte block size, and index block pointers of 4 bytes.

For the first system call (open) I realized how it works and schematized it in this way: open system call

Now, skipping the draw part (I realize it would make difficult to answer), I'd like to understand how lseek and write works in term of inodes and index blocks (whatever they are).

I tried figuring that lseek computes the correct inode (as block size is known), but still no clue on how it actually works.

1 Answers
Related