Questions tagged [ioctl]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
21 views

Not understanding the use of EVIOCGRAB for touchscreen devices

I am looking at a userspace library which handles touchscreen events from the Linux kernel. The following line of code, I can't understand what it does. What is the purpose of EVIOCGRAB when passed to ...
user avatar
-4 votes
1 answer
64 views

Reparenting a process

I create a Linux Kernel Module and I try to find a way to re-parent a given process or change a given process PID. Is there any way of doing that? I found the following link but I could not make it ...
user avatar
0 votes
1 answer
67 views

Efficiently disable fs-verity on large files

If the FS_IOC_ENABLE_VERITY ioctl was used to enable fs-verity on a file (e.g., with the fsverity enable command), and then I want to write to that file again, how can I disable fs-verity on it? Right ...
user avatar
0 votes
2 answers
229 views

Two different function prototypes for Linux kernel module ioctl

As pointed out in this question, the prototype for the ioctl function inside a Linux kernel module is: (version 1) int ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg); or (...
user avatar
  • 4,503
0 votes
0 answers
64 views

Where is a list of all supported IOCTL request codes defining the variable 3rd parameter of the call documented?

I am struggling to perform ioctl linux calls from a .NET app, using C# interoperability (P/Invoke). In order to isolate my problem, I thought of trying the simplest ioctl call I can find, instead of ...
user avatar
  • 298
0 votes
1 answer
67 views

Is socket sys (libc) function supposed to always return the same result for the same parameters?

I am writing a C# app that basically does a similar job that iwlist. I am having trouble, though, in porting the IOCTL calls into .NET. I mean, the interop code I have written so far (to enable my ....
user avatar
  • 298
3 votes
1 answer
841 views

Are ioctl calls blocking?

I am writing some code around libgpiod's interface. For example, I want to set a line to output high. Under the hood, libgpiod opens an fd provided by the kernel for the line, and then calls ioctl(fd, ...
user avatar
  • 4,610
0 votes
1 answer
71 views

Is there any way to change the I2C slave device address on a Linux board?

Aim: setAddress in i2c Slave Devices software side. example : 3 sensor with same address 0x29. through some method sensor1 to set 0x22, sensor2 to set 0x25, sersor3 to set 0x28. info: I have 3 similar ...
user avatar
1 vote
0 answers
26 views

How is ioctl handled in Linux?

When I trigger ioctl. Does linux just call ioctl from some fops struct, or does it do something more (handle some basic operations). I think I heard this once, but there is little information about ...
user avatar
  • 169
2 votes
0 answers
101 views

What could go wrong with sending input to /dev/tty?

My setup entails sending inputs to another terminal program running Bash in the same machine and same X session. I'm using ttyecho for that which, to put it short, sends input to /dev/tty/[id], ...
user avatar
-1 votes
1 answer
65 views

Does BTRFS support the ioctl(fd, FIFREEZE) system call?

the manpage of fsfreeze states: FSFREEZE(8) System Administration FSFREEZE(8) ...
user avatar
  • 517
2 votes
1 answer
93 views

FIDEDUPERANGE ioctl doesn't behave as expected on btrfs

According to ioctl_fideduperange, The maximum size of src_length is filesystem dependent and is typically 16 MiB. However, I've been able use src_length of > 1 Gib successfully with a single call ...
user avatar
  • 623
4 votes
3 answers
255 views

How can I run a program in its own tty?

I'm messing with TIOCSTI which shoves data into the terminal's input buffer. I want to be able to capture this data before it arrives at the shell or redirects it to a file. To better illustrate what ...
user avatar
0 votes
1 answer
550 views

Set can baudrate with ioctl or similar from C/C++

I'm currently setting the baudrate of my can0 with ip link: /sbin/ip link set can0 up type can bitrate 250000 I'm just wondering how to do the same from within C/C++?
user avatar
  • 131
1 vote
0 answers
84 views

How to use the Linux BLKPG ioctl?

For informing the kernel about partition layout changes, Linux has the BLKPG ioctl, but it's unclear how to use it. It has no useful documentation. It's defined in blkpg.h, but it uses the _IO macro, ...
user avatar
6 votes
1 answer
3k views

device-mapper: reload ioctl on osprober-linux-nvme0n1p7 failed: Device or resource busy

I ran into the error device-mapper: reload ioctl on osprober-linux-nvme0n1p7 failed: Device or resource busy while compiling the kernel in Ubuntu Studio. I use ZFS for my main drive. ...
user avatar
  • 63
1 vote
1 answer
1k views

Linux ioctl VT_GETSTATE fails if process is run manually

I'm using the ioctl syscall on Linux to get the current tty in a C program. I don't know why the ioctl fails if the program is run manually (as root) while it works as expected if the init.d script ...
user avatar
  • 175
1 vote
0 answers
122 views

Detect if filesystem supports FIEMAP ioctl

How can I query the kernel to find out if a mounted filesystem supports the FIEMAP ioctl? Is there a way to request the inode_operations struct for a given filesystem? As a workaround, I just test ...
user avatar
4 votes
1 answer
595 views

How to I set the permissions necessary to make the ioctl CDROM_SEND_PACKET command run?

I've run into an error stemming from lacking permissions when using the CDIO library to issue an eject command to my USB CD-ROM drive. I always get an error message like this: INFO: ioctl ...
user avatar
  • 317
0 votes
0 answers
219 views

How to run a process in background on startup?

I'm trying to run a process(myfile) on startup on my yocto linux board, but I'm getting either IOCTL or segmentation fault while I use nohup or & to run in background. I could run myfile in ...
user avatar
2 votes
2 answers
347 views

What does the ioctl CDROMPLAYMSF command do exactly?

I've got a USB 2.0 CD/DVD drive, which is (amongst other use cases) used to play music CDs. But: The drive seems to ignore CDROMPLAYMSF commands. The host is a Raspberry Pi 3B with the current ...
user avatar
  • 317
8 votes
1 answer
2k views

Get all ioctl code and which module they map

By doc. , ioctl signature is int ioctl(int fd, int request, ...) . request is the code of ioctl. Is there any way to know what are all the possible ioctl request code that available in my linux? And ...
user avatar
  • 221
5 votes
1 answer
6k views

Why is CAP_NET_ADMIN insufficient permissions for ioctl(TUNSETIFF)?

I'm trying to write a tun/tap program in Rust. Since I don't want it to run as root I've added CAP_NET_ADMIN to the binary's capabilities: $sudo setcap cap_net_admin=eip target/release/tunnel $getcap ...
user avatar
0 votes
1 answer
3k views

netcat error: Inappropriate ioctl for device

Im trying to create a 'reverse shell' using a bash oneliner and a netcat listener. This combination worked great a few days ago however now it only gives errors when connection. Does anyone know what ...
user avatar
  • 101
9 votes
2 answers
3k views

How to prevent DTR on open for cdc_acm?

I have an Arduino Uno attached over USB, using the cdc_acm driver. It is available at /dev/ttyACM0. The convention for the Arduino's serial interface is for the DTR signal to be used for a reset ...
user avatar
1 vote
1 answer
495 views

mapping of ioctl to its definition

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);...
user avatar
  • 41
0 votes
1 answer
4k views

Inappropriate ioctl for device while reading flags on <file>

I am unable to set or view file attributes using lsattr and chattr commands on Reiser File System. Following result is observed: chattr +i Temp.txt chattr: Inappropriate ioctl for device while ...
user avatar
1 vote
0 answers
248 views

Is it possible to access AES key of Self-encrypting drives (SEDs) in userspace?

In AES Hardware Encryption, is it possible to send or access AES key to and from hardware to userspace/software? Is there an available IOCTL for this?
user avatar
  • 31
6 votes
1 answer
1k views

What does a rmlint's "clone" for btrfs do?

I was reading the rmlint manual, and one of the duplicate handlers are clone and reflink: · clone: btrfs only. Try to clone both files with the BTRFS_IOC_FILE_EXTENT_SAME ioctl(3p). This will ...
user avatar
  • 9,052
1 vote
0 answers
354 views

Max transfer size in SG_IO/SG_ATA_16

I need to pass a direct, raw ATA request to a hard drive (0x25, READ DMA EXT), to disobey max sector count (long story), and to bypass all possible OS caches, buffers, reorderings et al. ...
user avatar
1 vote
1 answer
122 views

How detect playing video by ioctl?

Is it possible to detect video playing by ioctl in linux. Maybe detect decoding of the video file. How about this is working with flash player and html5 video? Can you provide some information how ...
user avatar
  • 11
0 votes
1 answer
170 views

Why does libdevmapper have data structures?

As I'm looking through libdevmapper.h for clues on how to properly use device mapper ioctls (or potentially use libdevmapper instead), I'm confused as to why there is code in here for creating/...
user avatar
  • 97
5 votes
0 answers
894 views

Documentation on Device Mapper ioctls?

In the Red Hat documentation on Device Mapper, it reads: "the application interface to the Device Mapper is the ioctl system call." So far, I understand that the ioctls are sent to /dev/mapper/...
user avatar
  • 97
3 votes
1 answer
2k views

Does keyboard input always go through a controlling terminal?

Am I right that all input typed from the keyboard goes through a controlling terminal? That means that if a program is run without a controlling terminal, it won't be able to receive any user input. ...
user avatar
10 votes
1 answer
17k views

How can I list net work devices and ipv4 address on linux without ifconfig/ip command [duplicate]

I already figured out that on Linux I can list network devices (cd /proc/net/dev_snmp6/ && for device in *; do echo $device; done|sort) but how can I get the ipv4 address of the device? I ...
user avatar
  • 990
15 votes
1 answer
5k views

Usage difference between device files, ioctl, sysfs, netlink

I'm trying to clarify which is the most useful (in terms of functionality) method of interacting with devices in Linux. As I understand, device files expose only part of functionality (address blocks ...
user avatar
3 votes
0 answers
2k views

how to detect CD physically inserted into drive

How to detect that CD was physically inserted into CD mechanics ASAP? The CD is mounted automatically but it takes like 20 seconds sometimes - and it is just then that I know the CD is inserted.. ...
user avatar
  • 163
1 vote
1 answer
2k views

Changing readahead value using blockdev command

I am trying to modify read ahead value using blockdev. When I issue this command blockdev --setra xxx /dev/sda - it changes the readahead value of the entire partition in that device, which is fine. ...
user avatar
8 votes
1 answer
10k views

bash: no job control in this shell

I have a minimal Linux system. init is /bin/bash, only bare minimum of libraries in /lib/, /dev/ is populated statically, no daemons running (no udev, ..) When bash starts, I get following error: ...
user avatar
1 vote
1 answer
1k views

HDIO_GETGEO and HDIO_GET_IDENTITY in Linux using C++

Can anyone explain the core difference between HDIO_GETGEO and HDIO_GET_IDENTITY? From the Linux documentation and this document titled: Summary of HDIO_ ioctl calls., I know that the former is for ...
user avatar
  • 1,253
12 votes
1 answer
18k views

Is it possible to get network interface index not via /sys?

So what I'm looking for is an interface index (or name) but the real one. if_nametoindex(3) and ioctl(2) don't seem to help me here. Now the only way I found how to do this is via /sys. Let me ...
user avatar
  • 2,788
7 votes
1 answer
7k views

GNU/Linux: "device mapper: create ioctl failed" "device or resource busy"

I can't mount my encrypted devices anymore. The error is: device mapper: create ioctl failed device or resource busy This error arises both with two different programs to access TrueCrypt ...
user avatar
  • 1,789
2 votes
0 answers
409 views

How do I assign the controlling terminal to other process?

I use TIOCSCTTY to forcibly take over the controlling terminal in other "remote" application. But after the application finishes running, controlling terminal gets orphaned and bash stops reacting to ...
user avatar
  • 5,176
7 votes
1 answer
6k views

Where do I find ioctl EVIOCGRAB documented?

I want to use the ioctl EVIOCGRAB function in a C based program, and from googling around I have found various bits of example source code that use the function, but I am struggling to find explicit ...
user avatar
  • 227