[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sheflug] Where is /dev/eth0 ? What are major & minor device numbers?



On 30 May 2002 21:07:58 +0100
Alex Hudson <home [at] alexhudson.com> wrote:

> On Thu, 2002-05-30 at 19:57, Andrew Basterfield wrote:
> > It's certainly not essential to get connected to a LAN, I have never
> > seen a /dev/eth0, ethernet devices don't need to interact with the
> > filesystem so they don't get /dev/ entries.
> 
> Things don't sit in /dev/ if they need to interact with the filesystem -
> they sit there because the filesystem is a convenient method of
> accessing devices - (almost) everything is a file. You'd have a hard
> time arguing /dev/mixed, for example, needs to interact with the fs.

I should have said 'become part of the filesystem' rather than 'interact
with the filesystem'. If the person writing the kernel driver decides he
wants to interact with his driver through normal file I/O he used to use a
device special file. These don't have to be in /dev, they can be anywhere
in the filesystem (you can copy /dev/fd0 to /tmp or wherever and mount
/tmp/fd0).

> > DevFS _doesn't_ use major and minor number, 
> 
> rendevous:~# ls -l /dev/hda
> brw-rw----    1 root     disk       3,   0 Jan 24 16:26 /dev/hda
> rendevous:~# ls -l /devfs/ide/host0/bus0/target0/lun0/cd 
> brw-rw-rw-    1 root     root       3,   0 Jan  1  1970
> /devfs/ide/host0/bus0/target0/lun0/cd

> Hmmm....

Hmmm.... indeed.

They're there for compatibility but they're no longer used by the kernel
to identify which device a /dev entry corresponds to. With the traditional
scheme you could rename the device special file /dev/hda to
/dev/primary_master and the kernel would still associate it with the IDE
primary master because it would look up it's major and minor. The device
special file could have any filename you chose, the names were only
convention.

With devfs the kernel is in charge of the names, you can't rename /dev
entries with devfs. Now the kernel can map on the name rather than the
major and minor, as it knows it isn't going to change.

Read /usr/src/linux/filesystems/devfs/README. Part of the reason for
moving to devfs is that major and minor numbers have to be officially
allocated (by Linus?) and we're running out of numbers. New kernel drivers
with a devfs-only interface won't have major and minor numbers at all.

<Quoting help from 'make menuconfig' devfs helpbox>

This is support for devfs, a virtual file system (like /proc) which
provides the file system interface to device drivers, normally found
in /dev. Devfs does not depend on major and minor number allocations.

</Quote>

> > it's the old filesystem based device nodes 
> 
> Devfs is filesystem based. "Device Filesystem" = Devfs.

Devfs is not a filesystem, a filesystem is a system for storing files.
Procfs and devfs and such like are virtual filesystems, filesystem-like
kernel interfaces.

> > that use major and minor numbers. DevFS is much more sensible.
> 
> Actually, it's Linux (the kernel) which uses major/minors, so you have
> to implement them (as Devfs does).

Nope. See above. Devfs retains majors and minors for backwards
compatibility only.

> > Yes, but not for network devices as they don't need a /dev entry.
> > Mandrake may have had one for some reason but none of my boxes do.
> 
> I have seen them related to sniffing stuff - vastly uncommon on Linux
> though. eth* lives in a special space all of it's own.

Yes, but as a general interface to the networking layer, not a specific
device for a specific NIC like /dev/eth0. Ancient UNIX used to have /dev/
entries for network devices but that died out a long time ago.

--Andrew

-- 
sparc sun4c stuff:
	http://www.lostgeneration.freeserve.co.uk/sparc
PGP key for list [at] lostgeneration.freeserve.co.uk:
	http://www.lostgeneration.freeserve.co.uk/list.freeserve.co.uk.asc

Attachment: pgp00041.pgp
Description: PGP signature