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
15
votes
3 answers

unlocked_ioctl vs normal ioctl

In my driver's file_operations structure, I have: struct file_operations Fops = { read: device_read, write: device_write, unlocked_ioctl: device_ioctl, ... }; I.e. there is no ioctl field used. Is this sufficient to avoid Big Kernel…
anon
14
votes
4 answers

Reading / writing from using I2C on Linux

I'm trying to read/write to a FM24CL64-GTR FRAM chip that is connected over a I2C bus on address 0b 1010 011. When I'm trying to write 3 bytes (data address 2 bytes, + data one byte), I get a kernel message ([12406.360000] i2c-adapter i2c-0:…
TheSeeker
  • 2,849
  • 5
  • 24
  • 20
14
votes
3 answers

How to set errno in Linux device driver?

I am designing a Linux character device driver. I want to set errno when error occurs in ioctl() system call. long my_own_ioctl(struct file *file, unsigned int req, unsigned long arg) { long ret = 0; BOOL isErr = FALSE; // some…
Andrew Chang
  • 1,289
  • 1
  • 18
  • 38
13
votes
2 answers

ioctl is not called if cmd = 2

I am developing a kernel module that uses unlocked_ioctl. I tested it with kernel version 2.6.24-23-generic and it works perfectly. Now I tried it with kernel version 3.3.1-1-ARCH and something weird happens: the ioctl function is not executed when…
12
votes
2 answers

Get IPv6 addresses in linux using ioctl

I trying to get IPv6 addresses in my linux OS like following: sd = Socket_m(AF_INET6_m, SOCK_DGRAM_m, 0); ifc.ifc_buf = buffer_p; ifc.ifc_len = buffSize; Ioctl_m(sd, SIOCGIFCONF, &ifc); It works succesfully if any IPv4 address are configured for…
Yury Bushev
  • 642
  • 9
  • 25
11
votes
3 answers

Maximum buffer length for sendto?

How do you get the maximum number of bytes that can be passed to a sendto(..) call for a socket opened as a UDP port?
epatel
  • 45,805
  • 17
  • 110
  • 144
11
votes
1 answer

Where are ioctl parameters (such as 0x1268 / BLKSSZGET) actually specified?

I am looking for a definitive specification describing the expected arguments and behavior of ioctl 0x1268 (BLKSSZGET). This number is declared in many places (none of which contain a definitive reference source), such as linux/fs.h, but I can find…
Jason C
  • 38,729
  • 14
  • 126
  • 182
10
votes
2 answers

Set IP address using SIOCSIFADDR ioctl

I am trying to get and set the IP address using the IOCTL interface on Linux. I am successfully able to get and set it. When I set the ip address, ifconfig eth0 shows a proper IP address, but then the system gets disconnected. i.e. System is not…
PrashantB
  • 309
  • 2
  • 4
  • 13
10
votes
3 answers

How to check if interface is up

Title pretty much says it all. If I run ifconfig, I get this: eth0: flags=4163 mtu 1500 inet -snip- netmask 255.255.255.0 broadcast -snip- ... Using this, I can know if it's up or not (
MiJyn
  • 5,327
  • 4
  • 37
  • 64
10
votes
3 answers

How to properly convert a C ioctl call to a python fcntl.ioctl call?

Following an example on resetting a serial port in Linux I wanted to translate the following snippet fd = open(filename, O_WRONLY); ioctl(fd, USBDEVFS_RESET, 0); close(fd); into valid python code. Here is what I have tried so far file_handler =…
Alex
  • 41,580
  • 88
  • 260
  • 469
9
votes
2 answers

Send IOCTL to Windows device driver - CreateFile fails

I want to send an IOCTL command to a PC/SC reader connected to my computer (win7 64 bit). In order to send an IOCTL command I need a HANDLE to the device, which I'm unable to create. The device is listed as "OMNIKEY 1021" in the device manager, the…
bmotmans
  • 15,650
  • 5
  • 20
  • 14
9
votes
3 answers

Is it possible to call a user-space callback function from kernel space in Linux (ioctl)?

Is it possible to expand the ioctl interface in Linux so that the user-space application can send a pointer to a function to the kernel space driver? I'm in particular thinking of ways to handle the stream in user-controllable way but doing it in…
Makis
  • 12,468
  • 10
  • 62
  • 71
9
votes
4 answers

How Linux knows which ioctl function to call?

Here is the ioctl call in user space: int ioctl(int fd, int cmd, ...); As far as I know, when we want to perfrom IO operations, we define our own ioctl function with a set of requests (commands), assign our ioctl to a file_operations structure like…
Amumu
  • 17,924
  • 31
  • 84
  • 131
9
votes
3 answers

Using RNDADDENTROPY to add entropy to /dev/random

I have a device which generates some noise that I want to add to the entropy pool for the /dev/random device in an embedded Linux system. I'm reading the man page on /dev/random and I don't really understand the structure that you pass into the…
Benjamin Leinweber
  • 2,774
  • 1
  • 24
  • 41
8
votes
4 answers

C/C++ Linux MAC Address of all interfaces

I am using the following code to retrieve all MAC addresses for current computer: ifreq ifr; ifconf ifc; char buf[1024]; int sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); if (sock == -1) { ... }; ifc.ifc_len = sizeof(buf); ifc.ifc_buf = buf; if…
user1173626
  • 153
  • 1
  • 2
  • 8
1
2
3
46 47