Why do Ethernet devices not show up in "/dev"?
Generally I have noticed that plugging in a new device in a Linux system causes a new entry to be listed in /dev
(assuming you have the correct drivers).
For example:
- When you plug in a new hard drive you get
/dev/sdb
. - When you plug in a serial device you get
/dev/ttyS0
.
When I plug in an Ethernet device, why don't I get something like /dev/eth0
?
Is there a device listing for Ethernet ports?
I know you can see port names using ifconfig
, I am just wondering if something shows up in /dev
too.
It's a good question. The reason is essentially historical; different groups with different goals and priorities added pieces of Unix over time, and the differences among various APIs are a reflection of this history. I think the original device file concept goes back to Bell Labs, whereas network sockets were added later at UC Berkeley. Bell was trying to create a nice clean maintainable paradigm for AT&T's operations, whereas Berkeley needed to add internet features that didn't fit easily into that paradigm. Technically it would be possible to go back and create a /dev/eth0
file today (see below), but it would involve rewriting a prohibitive amount of legacy code.
Slight OT: If the subject interests you, consider taking a look at Plan 9, which took "everything is a file" to greater extremes (just don't expect it to have very many modern, usable applications):
http://www.faqs.org/docs/artu/plan9.html
many facilities that under Unix are accessed through various ad-hoc interfaces like BSD sockets, fcntl(2), and ioctl(2) are in Plan 9 accessed through ordinary read and write operations on special files analogous to device files