LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Ubuntu (https://www.linuxquestions.org/questions/ubuntu-63/)
-   -   Where is "ioctl.c" in ubuntu? (https://www.linuxquestions.org/questions/ubuntu-63/where-is-ioctl-c-in-ubuntu-815252/)

jeremy28 06-20-2010 05:26 AM

Where is "ioctl.c" in ubuntu?
 
Hi all

I'm using ubuntu 9.04;

I want to know where is the "ioctl" source code?
It's header file can be found in "/usr/include/sys/ioctl.h"

And is as below:

Code:

#ifndef        _SYS_IOCTL_H
#define        _SYS_IOCTL_H        1

#include <features.h>

__BEGIN_DECLS

/* Get the list of `ioctl' requests and related constants.  */
#include <bits/ioctls.h>

/* Define some types used by `ioctl' requests.  */
#include <bits/ioctl-types.h>

/* On a Unix system, the system <sys/ioctl.h> probably defines some of
  the symbols we define in <sys/ttydefaults.h> (usually with the same
  values).  The code to generate <bits/ioctls.h> has omitted these
  symbols to avoid the conflict, but a Unix program expects <sys/ioctl.h>
  to define them, so we must include <sys/ttydefaults.h> here.  */
#include <sys/ttydefaults.h>

/* Perform the I/O control operation specified by REQUEST on FD.
  One argument may follow; its presence and type depend on REQUEST.
  Return value depends on REQUEST.  Usually -1 indicates error.  */
extern int ioctl (int __fd, unsigned long int __request, ...) __THROW;

__END_DECLS

#endif /* sys/ioctl.h */

I want to access the source code of it: "ioctl.c", specially the implementation of function:
Code:

extern int ioctl (int __fd, unsigned long int __request, ...) __THROW;
Could you guide me where it is?

THX.

knudfl 06-20-2010 05:42 AM

The file is found in the glibc-2.9 source code :
glibc-2.9/misc/ioctl.c
( find glibc-2.9/ -name ioctl.c )

http://archive.ubuntu.com/ubuntu/poo....9.orig.tar.gz

http://packages.ubuntu.com/source/jaunty/glibc
..

jeremy28 09-04-2010 06:48 AM

Hi;

I saw this source and found only this piece of code in it:
Code:

#include <errno.h>
  #include <sys/ioctl.h>
 
  /* Perform the I/O control operation specified by REQUEST on FD.
    The actual type and use of ARG and the return value depend on  REQUEST.  */

  int
  __ioctl (fd, request)
      int fd;
      unsigned long int request;
  {
    __set_errno (ENOSYS);
    return -1;
  }
  stub_warning (ioctl)
 
  weak_alias (__ioctl, ioctl)
  #include <stub-tag.h>

I want its actual implementation that may consist of a big switch statement that selects the correct behavior according to the "request" argument, either in kernel side or user side!

Could you hep me again?!

TIA.

knudfl 09-07-2010 11:56 AM

Actually not a suject, I am familar with.

Google .. ioctl in linux kernel ..
http://www.google.com/search?hl=en&s...=&oq=&gs_rfai=
> 562,000 hits, this one is the first
http://tldp.org/LDP/lkmpg/2.6/html/x892.html

Please see § Example 7-3. ioctl.c : A "100 line file",
but then again, the site is dated 2007.
..


All times are GMT -5. The time now is 08:39 AM.