Reputation: 11
I am working on a Linux project. I want to know which syscalls are called in what sequence when we mount a filesystem using mount command and also which syscalls are called when we read,write,delete files in that file system.
Is there any good resource for this ?
Thanks
Upvotes: 0
Views: 67
Reputation: 2366
How about using strace
?
For example like this:
> sudo strace mount /tmp/loop_image mount_point/ -o loop
execve("/bin/mount", ["mount", "/tmp/loop_image", "mount_point/", "-o", "loop"], [/* 19 vars */]) = 0
brk(0) = 0x195c000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7faeb36c6000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=136922, ...}) = 0
mmap(NULL, 136922, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7faeb36a4000
... etc ...
Just few system calls here, I skipped the rest, but I think this way you can see what is called when mount is executed.
You can use strace
also for your own programs, so you can create simple programs with the use cases you need, and see what is being called on the kernel side.
Upvotes: 1