ioctl (Input Output ConTroL) is a system call for device-specific I/O operations and other operations which cannot be expressed by regular system calls and it provides an interface through which an application can communicate directly with a device driver(or any other global kernel space variables). Applications can use the standard control codes or device-specific control codes to perform direct input and output operations.
Questions tagged [ioctl]
691 questions
5
votes
1 answer
Can't change terminal size on pty/N (works on ttyN)
I use the next to change terminal size:
rc = ioctl(fd, TIOCSWINSZ, &ws);
When I run this under linux text terminal (switching by Alt-Ctrl-F1), the result is that I expect to see. The whole my input and output within ranges given by ioctl…

van
- 249
- 2
- 10
5
votes
2 answers
Listing ioctl calls from userspace to kernelspace
Might be my question sounds more naive.
But I wanted to know if it is possible to list the ioctl calls made from user space to kernel space in Linux.

codingfreak
- 4,467
- 11
- 48
- 60
5
votes
1 answer
Asynchronous Sockets in Linux-- Polling vs. Callback via
In deciding to implement asynchronous sockets in my simple server (linux), I have run into a problem. I was going to continually poll(), and do some cleanup and caching between calls. Now this seems wastefull, so I did more digging and found a way…

Jon Weldon
- 115
- 2
- 8
5
votes
4 answers
Using Linux ioctl with Mono
I'm trying to do ioctl command through Mono framework, but I cant find what I'm looking for.
I'm trying to send command to a DVB card that has a kernel module. I hope someone can link or explain clearly how this can be done. Any example with Mono…

rozon
- 2,518
- 4
- 23
- 37
4
votes
1 answer
Adding new IOCTL's into kernel (number range)
I'm writing new kernel module and I add implement new IOCTL's.
Is there any rule that I should follow with IOCTL's numbering ?
Maybe there is some "user range" ?
I work with kernel 2.6.21 on embedded platform.

Bartlomiej Grzeskowiak
- 1,009
- 5
- 16
- 35
4
votes
2 answers
Android ioctl - root permissions and usage
I'm working on some routing functionality in an Android app, and need to access ioctls. Since apps that use ioctls need root permission to run, the only way I've been able to call them is linking a separate executable and calling that from Java…

derekerdmann
- 17,696
- 11
- 76
- 110
4
votes
1 answer
How to replace set_fs(KERNEL_DS) for a kernel 5.10.x module driver version
I've been updating a custom module driver to a 5.10.x linux kernel version. My driver adds a layer over a cdc-acm device. To replicate the behavior the next little driver is used.
#include
#include
#include…

Jorge
- 41
- 1
- 3
4
votes
1 answer
Why is CDROM_TOC.Length an UCHAR[2] instead of WORD?
In the documentation the length is made of two unsigned bytes:
Length
Indicates the length, in bytes, of the table of contents data. This length value does not include the length of the Length member itself.
When you form a WORD in Little Endian,…

aybe
- 15,516
- 9
- 57
- 105
4
votes
1 answer
How to receive data send with DeviceIoControl at the Driver.c controlFunction? IOCTL,Driver
Let's say I have following code. Loading,unloading,driver entry etc works.
Driver.c
#define IO_INCREMENT_VALUE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x0001, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
#define IO_RECEIVE_RANDOM_BUFFER CTL_CODE(FILE_DEVICE_UNKNOWN,…

Ojav
- 678
- 6
- 22
4
votes
1 answer
SPI_IOC_MESSAGE(N) on Raspberry Pi 3
I am working on a project on a Raspberry Pi 3, and I saw this code line :
ioctl(sSpiObj.spiFd, SPI_IOC_MESSAGE(1), &sSpiTransfer);
I don't know what SPI_IOC_MESSAGE(1) does, and I tried to find on the internet its explanation, but I…

hasan bucak
- 75
- 1
- 1
- 8
4
votes
2 answers
How to IOCTL properly from golang
I am trying to port bit of raspberrypi's userspace code from C to golang and I've run into a program involving ioctl().
I am having trouble specifically with following C code
#define MAJOR_NUM 100
#define IOCTL_MBOX_PROPERTY _IOWR(MAJOR_NUM, 0,…

Sigma
- 742
- 2
- 9
- 24
4
votes
1 answer
Possible sources for CHS disk geometry
I am trying to determine the "correct" CHS from a block device:
#include
#include
#include
#include
#include
#include
int main(int argv, char **argv) {
int r;
int f;
…

lash
- 746
- 1
- 7
- 23
4
votes
1 answer
Running ioctl in Python returns ENOTTY - inappropriate ioctl for device
Hey i am having an issue trying to call ioctl linux system call from python.
Running the following line in C application i manage to get the parent file descriptor of a given linux namespace file descriptor.
#define NS_GET_PARENT _IO(NSIO,…

Dor Dali
- 43
- 6
4
votes
4 answers
What are the network ioctl man pages?
I would like to use the ioctl SIOCGIFADDR to determine the address of an interface in Linux. I found some web references that explain how to do this, but it seems like there should be some reference for this already on my system. Is there a man page…

Jim Hunziker
- 14,111
- 8
- 58
- 64
4
votes
0 answers
How can I determine if a block is occupied in Linux through an ioctl call?
In Linux, we can call the FIBMAP() ioctl to determine which blocks a file occupies within a file system.
What I am curious about is- how can I determine if any random block is occupied with a file (or any data). Is there an ioctl to do this as…

rocktone
- 49
- 2