I (out of curiosity) wondered where the user space shell for the ioctl system call is defined on x86_64 Linux. My first thought was glibc - after checking the open characters in the installed version on my Fedora 24 block, I see that (if I'm not mistaken) libc provides the ioctl character as "W", which means that it is a weak character with a default implementation. By default, the implementation in the glibc source tree in misc / ioctl.c appears to be a stub, although it simply sets errno to ENOSYS and returns -1.
However, ioctl works (obviously, or my system is not very usable). I know that this is probably assembly code somewhere in a file that is somehow assembled and linked, thereby overriding the weak character open by glibc. I also know that applications can be directly invoked by ioctl using a system call, either through the glibc syscall shell, or directly using the assembly.
However, given the source code of the library that I accidentally observed (libdrm), it includes the standard ioctl / usr / include / sys / ioctl.h header and doesn't seem to contain its own shell implementation, which I can see, I wonder where I must watch.
This is part of my push to better understand the lower levels of the GNU / Linux system. Thanks for any pointers and apologies if this has been asked before, but I don't see any answer if it has.
UPDATE: I neglected the mention above, but I also checked the vdso virtual library displayed by the kernel - I could only find the following in it:
0000000000000a00 W clock_gettime 0000000000000db0 W getcpu 0000000000000c40 W gettimeofday 0000000000000000 A LINUX_2.6 0000000000000d90 W time 0000000000000a00 T __vdso_clock_gettime 0000000000000db0 T __vdso_getcpu 0000000000000c40 T __vdso_gettimeofday 0000000000000d90 T __vdso_time
UPDATE: it would seem that I was mistaken in the fact that the default definition of glibc is a stub. As pointed out in the comments, the demo shows that it is making a real system call. I wrote an answer to reflect this.
source share