Questions tagged [ioctl]

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.

691 questions
150
votes
2 answers

IOCTL Linux device driver

Can anyone explain me, What is IOCTL? What is it used for? How can I use it? Why can't I define new function that does the same work as IOCTL?
flashdisk
  • 3,652
  • 3
  • 16
  • 22
85
votes
12 answers

"inappropriate ioctl for device"

I have a Perl script running in an AIX box. The script tries to open a file from a certain directory and it fails to read the file because file has no read permission, but I get a different error saying inappropriate ioctl for device. Shouldn't it…
someguy
  • 1,193
  • 1
  • 12
  • 17
38
votes
2 answers

How to invoke ioctl in shell script?

I'm trying to execute an ioctl call on a system with only bash and primitive base utilities. Is there any way to execute arbitrary ioctl command (if the params are simply integers) to a specific device file in /dev in shell script, without writing C…
Hung-Te Lin
  • 381
  • 1
  • 3
  • 3
28
votes
5 answers

Detect laptop lid closure and opening

Is it possible to detect when a laptop's lid is open or closed? From what I've read, this isn't possible, but SO has helped me with the impossible before. The only thing I've found that might be in the right direction is an MSDN blog post about…
Brad
  • 159,648
  • 54
  • 349
  • 530
27
votes
1 answer

Linux driver: ioctl or sysfs?

I'm writing a driver to control some custom hardware. In the old days (i.e. 15yrs ago) I was doing this with ioctls, but am now digging into sysfs as a possible alternative. As I understand it, ioctls aren't totally deprecated, but sysfs is…
ColH
  • 453
  • 5
  • 10
24
votes
2 answers

what is the meaning of this macro _IOR(MY_MACIG, 0, int)?

i was going through ioctl sample programs to check how it communicates with kernel space. in program WRITE_IOCTL is used as command #define WRITE_IOCTL _IOW(MY_MACIG, 1, int) ioctl(fd, WRITE_IOCTL, "hello world") I am not able to understand what…
Rafal
  • 1,120
  • 3
  • 15
  • 23
20
votes
1 answer

USBDEVFS_RESET vs IOCTL_USB_RESET

I seem tangled between different abstractions on the USB stack.. what is the difference betweeen IOCTL_USB_RESET and USBDEVFS_RESET fired against an USB device? Will both calls finally trigger the same low level actions on the interface, or is there…
dronus
  • 10,774
  • 8
  • 54
  • 80
19
votes
3 answers

Sending ATA commands directly to device in Windows?

I’m trying to send ATA commands to a physical disk in Windows, and get the response from the device. Note: In this case I want to send the IDENTIFY DEVICE (0xEC) command. The device will respond with a 512-byte block of data. (In particular…
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
17
votes
4 answers

Linux - ioctl with FIONREAD always 0

I'm trying to get to know how many bytes there are readable at my TCP socket. I am calling ioctl with the Flag "FIONREAD" which should actually give me this value. When I call the function I get as return val 0 ( so no Error ) but also my integer…
Toby
  • 3,815
  • 14
  • 51
  • 67
17
votes
2 answers

Using ioctl communication between Kernel mode and user mode

I want to communicate with my kernel module using ioctl. I have written two c program one for kernel module and other for user mode. I am getting this error while compiling kernel module: error: unknown field ‘ioctl’ specified in initializer at this…
Dalchand
  • 223
  • 1
  • 3
  • 8
17
votes
7 answers

How can I get to know the IP address for interfaces in C?

Let's say I'm running a program called IpAddresses.c. I want that program to get all IP addresses this device has according to each interface. Just like ifconfig. How can I do that? I don't know much about ioctl, but I read it might help me.
gvalero87
  • 855
  • 3
  • 15
  • 32
16
votes
3 answers

Retrieving a List of network interfaces in node.js (ioctl SIOCGIFCONF)

I'm new to node and am hacking together a node application utilizing node_pcap to capture packet data and do interesting things with it. One of the inputs to capturing data is the network interface to listen on, i.e. "eth0". I thought it would be…
weak
  • 207
  • 1
  • 3
  • 6
16
votes
2 answers

How can I set the RTS with ioctl() in a Mac plugin?

I am able to set the RTS with ioctl in a small Terminal app, but not in my Mac plugin code, although both run the same code. In the plugin I can only "get" the serial ports flags/pins, but not "set" them. In the Terminal app I can both "get and…
Alyoshak
  • 2,696
  • 10
  • 43
  • 70
16
votes
5 answers

Beep on Linux in C

I want to generate a beep sound with a specific frequency and length (for different sound signals) using the system beeper (and only the speakers if beeper is not available / accessible). I know it is possible to do this by using ioctl, but that…
omnidan
  • 1,162
  • 2
  • 12
  • 25
15
votes
5 answers

HDD serial number flipped every 2 bytes in Windows XP, Vista and 7 but not in Windows 8

I need to get HDD serial number to use it as a key for licensing a software. I used diskid32 code in this url: http://www.winsim.com/diskid32/diskid32.html It used the DeviceIoControl Win32 API with the IO control code of…
A.Danesh
  • 844
  • 11
  • 40
1
2 3
46 47