Next | What's a file? | 9 |
Now suppose Fred's process has the file open, say for reading
(writing is exactly the same)
Say Fred's process tries to read 20 bytes from file #3:
char buf[20]; int br = read(3, buf, 20);
The kernel gets the file pointer
It gets the current offset from the file pointer
It gets the file extent from the inode:
loff_t i_size; 4096
The amount read will be the lesser of:
extent - current offset
amount requested
Let's call this number_read
Next | Copyright © 2007 M. J. Dominus |