mapping of ioctl to its definition
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
The prototype of ioctl in linux driver modules is
int ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg);
or
long ioctl(struct file *f, unsigned int cmd, unsigned long arg);
but inside sys/ioctl.h it is
int ioctl(int fd, int request, void *argp);
The first argument type is different, is there any module between ioctl calling program and driver that converts this argument(From file descriptor to file structure pointer)?
How this mapping works?(From file descriptor to file).
kernel drivers file-descriptors ioctl
add a comment |Â
up vote
0
down vote
favorite
The prototype of ioctl in linux driver modules is
int ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg);
or
long ioctl(struct file *f, unsigned int cmd, unsigned long arg);
but inside sys/ioctl.h it is
int ioctl(int fd, int request, void *argp);
The first argument type is different, is there any module between ioctl calling program and driver that converts this argument(From file descriptor to file structure pointer)?
How this mapping works?(From file descriptor to file).
kernel drivers file-descriptors ioctl
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
The prototype of ioctl in linux driver modules is
int ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg);
or
long ioctl(struct file *f, unsigned int cmd, unsigned long arg);
but inside sys/ioctl.h it is
int ioctl(int fd, int request, void *argp);
The first argument type is different, is there any module between ioctl calling program and driver that converts this argument(From file descriptor to file structure pointer)?
How this mapping works?(From file descriptor to file).
kernel drivers file-descriptors ioctl
The prototype of ioctl in linux driver modules is
int ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg);
or
long ioctl(struct file *f, unsigned int cmd, unsigned long arg);
but inside sys/ioctl.h it is
int ioctl(int fd, int request, void *argp);
The first argument type is different, is there any module between ioctl calling program and driver that converts this argument(From file descriptor to file structure pointer)?
How this mapping works?(From file descriptor to file).
kernel drivers file-descriptors ioctl
asked May 2 at 13:27
Xter
65
65
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
In $kernel_root/fs/ioctl.c
(in 4.13) there's:
SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)
That SYSCALL_DEFINE3
is a macro that takes those parameters and expands it to the appropriate signature for the system call. That function is the logical entry point for the ioctl
system call from user space. That function, in turn, looks up the struct fd
corresponding to the given file descriptor and calls do_vfs_ioctl
passing the struct file
associated with the struct fd
. The call will wind through the VFS layer before it reaches a driver, but that should give you a place to start looking.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
In $kernel_root/fs/ioctl.c
(in 4.13) there's:
SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)
That SYSCALL_DEFINE3
is a macro that takes those parameters and expands it to the appropriate signature for the system call. That function is the logical entry point for the ioctl
system call from user space. That function, in turn, looks up the struct fd
corresponding to the given file descriptor and calls do_vfs_ioctl
passing the struct file
associated with the struct fd
. The call will wind through the VFS layer before it reaches a driver, but that should give you a place to start looking.
add a comment |Â
up vote
0
down vote
accepted
In $kernel_root/fs/ioctl.c
(in 4.13) there's:
SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)
That SYSCALL_DEFINE3
is a macro that takes those parameters and expands it to the appropriate signature for the system call. That function is the logical entry point for the ioctl
system call from user space. That function, in turn, looks up the struct fd
corresponding to the given file descriptor and calls do_vfs_ioctl
passing the struct file
associated with the struct fd
. The call will wind through the VFS layer before it reaches a driver, but that should give you a place to start looking.
add a comment |Â
up vote
0
down vote
accepted
up vote
0
down vote
accepted
In $kernel_root/fs/ioctl.c
(in 4.13) there's:
SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)
That SYSCALL_DEFINE3
is a macro that takes those parameters and expands it to the appropriate signature for the system call. That function is the logical entry point for the ioctl
system call from user space. That function, in turn, looks up the struct fd
corresponding to the given file descriptor and calls do_vfs_ioctl
passing the struct file
associated with the struct fd
. The call will wind through the VFS layer before it reaches a driver, but that should give you a place to start looking.
In $kernel_root/fs/ioctl.c
(in 4.13) there's:
SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)
That SYSCALL_DEFINE3
is a macro that takes those parameters and expands it to the appropriate signature for the system call. That function is the logical entry point for the ioctl
system call from user space. That function, in turn, looks up the struct fd
corresponding to the given file descriptor and calls do_vfs_ioctl
passing the struct file
associated with the struct fd
. The call will wind through the VFS layer before it reaches a driver, but that should give you a place to start looking.
answered May 2 at 14:01
Andy Dalton
4,7561520
4,7561520
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f441321%2fmapping-of-ioctl-to-its-definition%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password