First thing you need to have firmly welded into your head is that in Unix everything is a file, and a file is just a stream of bytes.
Disk drives, graphics cards, mice, network cards, files, directories, memory, etc. etc. etc. everything is a file and file is just a stream of bytes.
So the short answer is is that anything that can read a file, can read any file.
Ooh. "cat" can. "less" can. And editor can! Wow!
Ok, cool it for a moment. Some of those files are pretty big and a editor that pulls the whole file into memory may struggle a little, especially if it is the "memory" file !
ls -l /proc/kcore
-r-------- 1 root root 519241728 Apr 21 08:40 /proc/kcore
Next you may find some of the "special files" are there but nothing is attached or you don't have permission.
cat /dev/hdd
cat: /dev/hdd: Permission denied
So you need to be root...
su -
Password: ******
cat /dev/hdd
cat: /dev/hdd: No such device or address
The file is there, but there is no device behind it. So opening the file gets me nowhere fast.
Lets try /dev/hda
cat /dev/hda
....screenfulls of binary garbage...
Well, that worked. Sort of. (Hint to unscramble your terminal type "reset" and hit enter)
You can write to it too. DON'T DO THIS! NO! THIS WILL ZERO YOUR HARDDRIVE NO QUESTIONS ASKED!!!!
cat /dev/zero > /dev/hda
Don't DO THAT!!!
How ever, block and char special devices usually speak some protocol. You say something to them (write to file) and they say something in some strict format back to you.
Often you will find life easier to talk to them via an appropriate driver. eg. the /dev/hd* you use
"mount /dev/hdc /mnt/cdrom" and mount and the OS do magic for your and turn that ghastly stream of bytes into a file system.
Or use X windows to talk to your graphics card. etc.
So the question really is, so now you know you can _always_ read and write to a block and char special, which one is it and what do you want to say to it?
Last edited by cyent; 04-20-2005 at 06:39 PM.
|