简体   繁体   中英

Where can i find __ioctl?

In the android sdk path sdk/bionic/libc/bionic/ there are the C API resource code, such as fork.c, ioctl.c etc.. when open ioctl.c:

#include <stdarg.h>

extern int __ioctl(int, int, void *);

int ioctl(int fd, int request, ...)
{
    va_list ap;
    void * arg;
    enter code here
    va_start(ap, request);
    arg = va_arg(ap, void *);
    va_end(ap);

    return __ioctl(fd, request, arg);
}

extern int __ioctl(int, int, void *); this means __ioctl(int, int, void *) has been defined somewhere. So I want to know where is the original defined place. Thanks a lot!

As mentioned, the _ ioctl is just a wrapper to a syscall, implemented in asm. In the AOSP code, it can be found in bionic/libc/arch-XXX/syscalls/ _ioctl.S where arch-XXX is arch-arm, arch-x86 or arch-mips depending on your target architecture.

It may be elsewhere in the bionic tree (grep is your friend), or automatically generated as part of the build process, but either way, it's completely uninteresting. It's just a syscall wrapper. All of the interesting work is in the kernel.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM