Questions tagged [mknod]
33 questions
51
votes
3 answers
How can I create a device node from the init_module code of a Linux kernel module?
I am writing a module for the Linux kernel, and I want to create some device nodes in the init() function:
int init_module(void)
{
Major = register_chrdev(0, DEVICE_NAME, &fops);
// Now I want to create device nodes
// with the returned…

Alptugay
- 1,676
- 4
- 22
- 29
51
votes
2 answers
What is the opposite of `mknod`?
I am learning to write character device drivers from the Kernel Module Programming Guide, and used mknod to create a node in /dev to talk to my driver.
However, I cannot find any obvious way to remove it, after checking the manpage and observing…

merlin2011
- 71,677
- 44
- 195
- 329
15
votes
1 answer
Python module 'os' has no attribute 'mknod'
I want to create a new file in Python for that I am using mknod command, but getting error as:
os.mknod();
AttributeError: module 'os' has no attribute 'mknod'
I am using windows and attributes other than 'mknod' are working.

Manthan Sharma
- 329
- 1
- 3
- 12
7
votes
2 answers
How to create tun interface inside Docker container image?
I'm trying to create a Docker image with a /dev/net/tun device so that the image can be used across Linux, Mac and Windows host machines. The device does not need access to the host's network interface.
Note that passing --device…

moof2k
- 1,678
- 1
- 17
- 19
4
votes
1 answer
New device node created on host does not get reflected in Docker container when using --device flag
I'm running a container with the following options:
docker run -d --device=/dev/bus/usb:/dev/bus/usb --device=/dev/ttyS0:/dev/ttyS0 instr_img
Inside the container I have a Python code which resets a USB device that in turn causes a device file in…

rung
- 49
- 4
4
votes
2 answers
C: creating named pipe using mknod() not working
Language: C
OS: Ubuntu
I'm simply trying to create a FIFO named pipe using the command:
state = mknod("pipe.txt", S_IFIFO | 0666, 0);
the problem is i always get the state's value to be -1 (meaning it has failed) instead of 0.
perror returns…

Popokoko
- 6,413
- 16
- 47
- 58
3
votes
3 answers
Using mknod on Ubuntu in c program
I am trying to make a c program where i am using mknod command like
#include
#include
#include
char info[50];
main() {
int fdr;
int rc = mknod("testfile",'b',0);
if(rc<0) {
perror("Error in mnod");
…

asb
- 910
- 3
- 10
- 19
3
votes
3 answers
how to write a bash script that would get minor and major device numbers of /dev/random
I am trying to run a program in a chrooted environment, and it needs /dev/random as a resource.
Manually I can do ls -l on it and then create the file again with mknod c xx yy, but I need to make it automatic and I don't think these version numbers…

user3779430
- 420
- 5
- 16
3
votes
1 answer
Why are directory files not read using fread?
I was going through an example from Maurice Bach's Unix Book. He writes a simple copy program like mentioned below. However it fails when the inputfile is a directory file. I did stumble upon opendir and few other such API's - should I use that?
If…

Nishant
- 20,354
- 18
- 69
- 101
3
votes
1 answer
mknod error while trying to make a device driver file with shell
My code
#!/bin/sh
major=$(awk '$2=="module_dev" {print $1}' /proc/devices)
echo $major
mknod /dev/module_dev c $major 0
I'm practicing character device drivers, and this is one of the examples.
The code above is ought to create a device driver…

user3062950
- 61
- 1
- 6
2
votes
2 answers
Redirecting stdin through a FIFO
I'm running a server app (written in Java) under GNU/Linux which takes input (from stdin, I guess) and interprets it to run some commands. I dont want to run the app inside a terminal window (I'd like to run a daemon), but I'd still like to be able…

kaoD
- 1,534
- 14
- 25
2
votes
1 answer
C program that controls mplayer
I have to do program in C on linux, that can control mplayer using mknod() function.
When I run mplayer by this command
mplayer -input file=/tmp/film spiderman.ts
I want to control that with my C program just like with the echo function
echo…

Piodo
- 616
- 4
- 20
2
votes
1 answer
openconnect in dockers/IBM bluemix (Error: TUNSETIFF failed: Inappropriate ioctl for device)
I've created my own container image based on Ubuntu 14.04 and installed openconnect using apt-get. I can ping google, and access the app I have running on the port I expect.
Now I am trying to get a VPN connection from the container to a on-prem…

Thomas Hubregtsen
- 449
- 1
- 5
- 22
2
votes
2 answers
Implicit declaration of function ‘mknod’ but I have the headers included
I am trying to make a C program that uses named pipes to communicate with a C++ program on a Raspberry Pi 3.
The warning that GCC is spitting out when I compile some code of mine:
/home/pi/BluetoothTest/btooth.c|76|warning: implicit declaration of…

cyborgdragon
- 109
- 6
2
votes
1 answer
mknod() not creating named pipe
I'm trying to create a FIFO named pipe using the mknod() command:
int main() {
char* file="pipe.txt";
int state;
state = mknod(file, S_IFIFO & 0777, 0);
printf("%d",state);
return 0;
}
But the file is not created in my current directory. I tried…

aashima
- 1,203
- 12
- 31