Question

In the file util-linux-2.17.2/mount/umount.c, line #246, it is written res = umount (node);.

But where's the umount function located? I've searched so much, but didn't find.

Was it helpful?

Solution

umount is a call to the library function of the same name in libc. This function in turn makes a call to the umount system call. How a library function makes a call to the kernel to execute a particular function can be found out by reading about how system calls works. This link might help you in the process How do system calls work?

If you want to know where the system call umount is present, then download the latest kernel. Go to file fs/namespace.c. There you will find

SYSCALL_DEFINE2(umount, char __user *, name, int, flags)

and

SYSCALL_DEFINE1(oldumount, char __user *, name)

which define the umount and the oldumount functions.

OTHER TIPS

The umount function is part of your libc system library. You can find as much using e.g. objdump -T /lib/libc.so.6 | grep umount. The .text entry in one of the output columns will indicate that that function (and its sibling umount2) are defined in that library, as symbols for executable code (as opposed to global variables).

That function is implemented to execute a kernel syscall, usually via a small piece of assembly code. Contrary to most syscalls, glibc doesn't simply include this syscall in its master list of linux syscalls. Instead, it has some dedicated assembly code in place for this. The meaning of this is hidden behind many layers of macro expansion, and I can't get the preprocessot to emit the final assembly code just now.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top