09-15-2008
First of all, ioctl is a driver entry point. So look at the documentation for the driver to see what each argument does. Most of the ioctl calls will be documented on a man page, like this one:
http://www.linuxmanpages.com/man4/tty_ioctl.4.php
Those sub-fields you ask about are mostly suggestions to the driver writer on how to use the argument. Very few drivers will use the length subfield. The ascii character (15-8) and the op code (7-0) are pretty universal. The ascii character enables drivers to diagnose the famous "inappropiate ioctl for device" error. But most driver writers ignore the other stuff.
That character is not unique to each driver the way that the major number is. For example, there might be 3 or 4 mag tape drivers, each with a unique major number to control each type of tape drive. But the "mt -f /dev/tape rewind" command will send the exact same ioctl to each one.
10 More Discussions You Might Find Interesting
1. Linux
Hi Everyone!
How can we make a socket() system call from a linux module executing in kernel space?
If any one knows, kindly tell me. It will be great.
I want to use the socket interface in linux kernel space for sending raw packets over the network.
Hamayun (0 Replies)
Discussion started by: mian_m_hamayun
0 Replies
2. UNIX for Advanced & Expert Users
Hi,
I am trying to implement SSH between two systems say ukblx151 & ukapx047 with ID say khzs228, i follow the following process:
Step-1) $ ssh-keygen -t rsa -f rsa
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your... (9 Replies)
Discussion started by: vishal_ranjan
9 Replies
3. UNIX for Advanced & Expert Users
Hi,
Ho do I differentiate system call from library call?
for example if I am using chmod , how do I find out if it is a system call or library call?
Thanks
Muru (2 Replies)
Discussion started by: muru
2 Replies
4. Programming
How the c compiler differentiates the system calls and function calls? (1 Reply)
Discussion started by: rangaswamy
1 Replies
5. Programming
Hi
I'm studing the system call. I've written a small program that return the time spent in doing some operations. Now I'd like to write one that return the time spent in user mode of a process.
I'm reading that i should use the tms struct:
clock_t times(struct tms *buf);
struct tms {... (2 Replies)
Discussion started by: Dedalus
2 Replies
6. Linux
I encountered a variety of difficulties when implementing a system call as simple as HelloWorld example in Linux so far.
Firstly, according to the book "Linux Kernel Development Second Edition", I tried to implement a syscall in 2.6.31 but no way absolutely because 2.6.10 has a very different way... (5 Replies)
Discussion started by: sunnyhay
5 Replies
7. Programming
I have a cgi script which is called after certain time interval, which has this:
system ("ls -l /tmp/cgic* | grep -v \"cgicsave.env\" | awk '{print $5}'");
During the execution of this script,the output is 0 sometimes. But due to this the system call is not working at all and doesnt o/p... (2 Replies)
Discussion started by: xs2punit
2 Replies
8. Shell Programming and Scripting
Hi Gurus,
I have scheduled a script using cron scheduler. Script works fine when i run it manually. But it gives the following error in cron log.
stty: tcgetattr: A specified file does not support the ioctl system call.
I have given the following statement in cron.
0-59 * * * *... (5 Replies)
Discussion started by: svajhala
5 Replies
9. Programming
hi everyone
i wrote a system call and compiled the kernel succesfully...
my system call is in a file in the kernel folder named my_syscall1.c (kernel/my_syscall1.c)
the header file for this system call i added it in the folder include like this include/my_syscall1/my_syscall1.h
my problem is... (2 Replies)
Discussion started by: demis87
2 Replies
10. Shell Programming and Scripting
Trying to figure out a load issue with a webserver. I have traced a php script and noticed the following
connect(4, {sa_family=AF_INET, sin_port=htons(3306), sin_addr=inet_addr("XX.XX.XX.XX")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000035>
poll(, 1, 2000) = 1 () <0.000120>... (5 Replies)
Discussion started by: rajan007
5 Replies
LEARN ABOUT FREEBSD
ioctl
IOCTL(2) BSD System Calls Manual IOCTL(2)
NAME
ioctl -- control device
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <sys/ioctl.h>
int
ioctl(int fd, unsigned long request, ...);
DESCRIPTION
The ioctl() system call manipulates the underlying device parameters of special files. In particular, many operating characteristics of
character special files (e.g. terminals) may be controlled with ioctl() requests. The argument fd must be an open file descriptor.
The third argument to ioctl() is traditionally named char *argp. Most uses of ioctl(), however, require the third argument to be a caddr_t
or an int.
An ioctl() request has encoded in it whether the argument is an ``in'' argument or ``out'' argument, and the size of the argument argp in
bytes. Macros and defines used in specifying an ioctl request are located in the file <sys/ioctl.h>.
GENERIC IOCTLS
Some generic ioctls are not implemented for all types of file descriptors. These include:
FIONREAD int
Get the number of bytes that are immediately available for reading.
FIONWRITE int
Get the number of bytes in the descriptor's send queue. These bytes are data which has been written to the descriptor but which are
being held by the kernel for further processing. The nature of the required processing depends on the underlying device. For TCP
sockets, these bytes have not yet been acknowledged by the other side of the connection.
FIONSPACE int
Get the free space in the descriptor's send queue. This value is the size of the send queue minus the number of bytes being held in
the queue. Note: while this value represents the number of bytes that may be added to the queue, other resource limitations may
cause a write not larger than the send queue's space to be blocked. One such limitation would be a lack of network buffers for a
write to a network connection.
RETURN VALUES
If an error has occurred, a value of -1 is returned and errno is set to indicate the error.
ERRORS
The ioctl() system call will fail if:
[EBADF] The fd argument is not a valid descriptor.
[ENOTTY] The fd argument is not associated with a character special device.
[ENOTTY] The specified request does not apply to the kind of object that the descriptor fd references.
[EINVAL] The request or argp argument is not valid.
[EFAULT] The argp argument points outside the process's allocated address space.
SEE ALSO
execve(2), fcntl(2), intro(4), tty(4)
HISTORY
The ioctl() function appeared in Version 7 AT&T UNIX.
BSD
September 11, 2013 BSD