Questions tagged [character-device]
Character special files or character devices.
30 questions
0 votes
1 answer
160 views
Best way to continuosly cat tty to journal
I have a serial device that shows output at /dev/ttyX. I can cat this and watch the output come in on my current terminal, But I want to log the output to the system journal even if I'm not at a ...
1 vote
1 answer
509 views
Udev rule for syfs class/device attribute ownership
This was originally asked on Stack Overflow, but it was closed for being off-topic. Hopefully this is the right forum for the question. I'm writing a character device driver that exposes class and ...
1 vote
1 answer
345 views
Why does lseek() return ESPIPE, when driver doesn't provide implementation?
Linux Device Drivers, 3rd Edition states: if the llseek method is missing from the device's operations, the default implementation in the kernel performs seeks by modifying filp->f_pos Yet I have ...
2 votes
1 answer
716 views
What's inside a character device file?
A character device file is a special linux file where you can read from and write to an infinite number of chars and other file operations that you can define inside a kernel device driver. But does ...
0 votes
0 answers
133 views
Why piping cat into head -c 5 for a chardev results in many more calls to the driver's read than just calling head -c 5 on the chardev?
Taking inspiration from this blog post, I'm playing around with linux device drivers (which I'm studying from ). The read field of the file_operations associated with the driver is initialized to the ...
4 votes
1 answer
3k views
What is the modern way of creating devices files in /dev/?
tl;dr If I want my module do adhere to modern practices, should I create devices in /dev/ via mknod in a shell script or via class_create and device_create C functions directly in the module source ...
0 votes
1 answer
3k views
Is there any difference between #include <linux/ioctl.h> and #include <sys/ioctl.h>?
I have to write a device driver code for temperature sensor using IOCTL, when I was going through a lot of sample codes, I found while surfing the net, I came across this difference in header file, I ...
0 votes
1 answer
1k views
What's the difference between structures "cdev" and "inode" in the context of device driver programming?
I am currently studying device drivers in an operating systems course and am getting confused regarding the difference between the "inode" structs and "cdev" structs. Could someone ...
0 votes
1 answer
453 views
Problem printing the content of a waiting queue in Linux kernel
Context: Consider the following set of operations {A, B, C, D, E}: (A) : On the read() function of my device driver, I add the calling thread to a wait queue wq if a driver's buffer buf is empty. ...
0 votes
1 answer
552 views
Linux kernel register_chdev returned value
This video shows an example Raspberry Pi Linux kernel module which creates a new character device. It uses the kernel API register_chdev. In a comment to the video (I can not generate a direct link to ...
0 votes
1 answer
161 views
On UNIX OS, for which of the following I/O devices the access is not via a special file of type "character I/O"? [duplicate]
On UNIX OS, for which of the following I/O devices the access is not via a special file of type "character I/O"? Mouse Screen Disk On Key (USB) Printer None of the above This question is ...
1 vote
1 answer
1k views
How to open and read a character device as binary file?
I'm working with USB and I want to read the content of usb device descriptor in /dev/bus/usb/00x/00y - it is a character device. I used fopen to open it as a binary file with "rb" parameter. ...
0 votes
1 answer
2k views
Concurrent write access to character device file
I am wondering what happens when two processes write to a character device file at the same time. Currently, I am mostly worried about /dev/spidev0.0 on a Raspberry pi. If I assume correctly that it's ...
1 vote
0 answers
195 views
MITM / Proxy for Character devices
I have a character devices file, say /dev/X and I would like to capture every interaction which goes in and out of /dev/X. I'm looking for a way to create some kind of MITM/Proxy to that file. Edit: ...
2 votes
0 answers
176 views
May a character device only handle blocking I/O?
Let's consider the following (imaginary) device: a clock which takes 1 second to query, then returns the current time. We want to write a character device driver for it, which supports read operations ...