Results 1 to 4 of 4
I am wondering how you can create your own device file.
I have read that mknod is the command to do this.
However how do you get the major and ...
- 10-18-2011 #1Just Joined!
- Join Date
- Apr 2011
- Posts
- 87
device file ?
I am wondering how you can create your own device file.
I have read that mknod is the command to do this.
However how do you get the major and minor numbers for a particular device ? (like for a thumb drive , HDD , webcam ,...etc?)
And how can I create a device file that is like /dev/zero but instead of sending/receiving zeros I can send/receive 1's or any other words/numbers I want?
By reading the man pages for it, it seems their are 2 different types of device files block and character. So everything that doesn't spit back characters I am assuming is block.
Confused though what /dev/dsp or /dev/null are interms of block or character?
Any help with creating devices file would be great.
I am assuming if you deleted your /dev folder you could recreate it using this command. Correct me if I am wrong
- 10-18-2011 #2
Look in the kernel documentation. There's a file called devices.txt that lists all the node numbers.
/dev/null is definitely char and I think /dev/dsp is too. Block devices are disks and disk equivalents like pen-drives and flash-cards.By reading the man pages for it, it seems their are 2 different types of device files block and character. So everything that doesn't spit back characters I am assuming is block.
Confused though what /dev/dsp or /dev/null are interms of block or character?
I think if you deleted /dev, your system would crash! But modern 2.6 kernels use a dynamic /dev directory created by udev at boot, so you would have /dev back again when you rebooted.I am assuming if you deleted your /dev folder you could recreate it using this command. Correct me if I am wrong"I'm just a little old lady; don't try to dazzle me with jargon!"
- 10-18-2011 #3Just Joined!
- Join Date
- Apr 2011
- Posts
- 87
Ok, they both are character devices looking at the device.txt. (for /dev/dsp , dev/null ,...etc)
So I have tried creating my own device that is equivalent to /dev/zero but it doesn't seem to work or let me do anything with it even when I sudo.
I created it by this command
sudo mknod zeroit c 5 5
the 5 5 is the major and minor numbers for the zero device file and the c is for character unbuffered special file.
when I do cat zeroit > tmp | hexedit or dd if=zeroit of=/dev/sdb count=1 ...etc it doesn't seem to work
But when I use /dev/zero instead everything works fine?
ls -ltr gives
crw-r--r-- 1 root root 5, 5 2011-10-18 17:06 zeroit
So make mknod created it but I just cann't do anything with it?
Question 2
Is their away to create with mknod a device file that spites back all ones instead of all zeros?
- 10-19-2011 #4
My guess is that this doesn't work because you can't have two different devices in the same family with the same nodes.
To create a device that spewed out 1's rather than 0's, you would first need to write a suitable kernel module. Just creating a device file wouldn't do the trick because device files are only an interface with the kernel. I don't know if that would even be possible; you'd have to post a question in the kernel forum."I'm just a little old lady; don't try to dazzle me with jargon!"


Reply With Quote

