ndevfs - a "nano" devfs
Subsystems (2)
Now I just know I'm going to regret this somehow...
Anyway, here's yet-another-ramfs-based filesystem, ndevfs. It's a very tiny:
$ size fs/ndevfs/inode.o text data bss dec hex filename 1571 200 8 1779 6f3 fs/ndevfs/inode.o replacement for devfs for those embedded users who just can't live without the damm thing. It doesn't allow subdirectories, and only uses LSB compliant names. But it works, and should be enough for people to use, if they just can't wean themselves off of the idea of an in-kernel fs to provide device nodes.
Now, with this, is there still anyone out there who just can't live without devfs in their kernel?
Damm, the depths I've sunk to these days, I'm such a people pleaser...
Comments? Questions? Criticisms?
I need sleep.
greg k-h
---------------
ndevfs - a "nano" devfs
For embedded people to use since they seem to hate userspace.
--- drivers/base/class.c | 3 fs/Kconfig | 3 fs/Makefile | 1 fs/ndevfs/Makefile | 4 fs/ndevfs/inode.c | 249 +++++++++++++++++++++++++++++++++++++++++++++++++ fs/partitions/check.c | 6 + include/linux/ndevfs.h | 13 ++ 7 files changed, 279 insertions(+)
fs/Kconfig +3 -0
@@ -1700,6 +1700,9 @@ config RXRPC tristate +config NDEV_FS + bool "Nano Device File System" + endmenu menu "Partition Types"
fs/Makefile +1 -0
@@ -95,3 +95,4 @@ obj-$(CONFIG_HOSTFS) += hostfs/ obj-$(CONFIG_HPPFS) += hppfs/ obj-$(CONFIG_DEBUG_FS) += debugfs/ +obj-$(CONFIG_NDEV_FS) += ndevfs/
include/linux/ndevfs.h new file +13 -0
@@ -0,0 +1,13 @@ +#ifndef _NDEVFS_H_ +#define _NDEVFS_H_ + +#if defined(CONFIG_NDEV_FS ) +extern void ndevfs_create (const char *name,dev_t dev,int is_char); +extern void ndevfs_remove (const char *name); +#else +static inline void ndevfs_create (const char *name,dev_t dev,int is_char) {} +static inline void ndevfs_remove (const char *name) {} +#endif + +#endif +
drivers/base/class.c +3 -0
@@ -17,6 +17,7 @@#include <linux/string.h> #include <linux/kdev_t.h> #include <linux/err.h> +#include <linux/ndevfs.h> #include "base.h" #define to_class_attr (_attr) container_of(_attr, struct class_attribute, attr)
@@ -492,6 +493,7 @@ attr->store =NULL ;class_device_create_file (class_dev, attr); class_dev->devt_attr = attr; +ndevfs_create (class_dev->class_id, class_dev->devt,1 ); }class_device_add_attrs (class_dev);
@@ -595,6 +597,7 @@class_device_remove_file (class_dev, class_dev->devt_attr);kfree (class_dev->devt_attr); class_dev->devt_attr =NULL ; +ndevfs_remove (class_dev->class_id); }class_device_remove_attrs (class_dev);
fs/ndevfs/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +ndevfs-objs := inode.o + +obj-$(CONFIG_NDEV_FS) += ndevfs.o +
fs/ndevfs/inode.c new file +249 -0
249 lines not on this page · raw message
fs/partitions/check.c +6 -0
@@ -18,6 +18,7 @@#include <linux/fs.h> #include <linux/kmod.h> #include <linux/ctype.h> +#include <linux/ndevfs.h> #include "check.h"
@@ -273,6 +274,7 @@ p->start_sect =0 ; p->nr_sects =0 ; p->reads = p->writes = p->read_sectors = p->write_sectors =0 ; +ndevfs_remove (kobject_name (&p->kobj));kobject_unregister (&p->kobj); }
@@ -296,6 +298,7 @@ p->kobj.parent = &disk->kobj; p->kobj.ktype = &ktype_part;kobject_register (&p->kobj); +ndevfs_create (kobject_name (&p->kobj),MKDEV (disk->major, p->partno),0 ); disk->part[part-1 ] = p; }
@@ -323,6 +326,8 @@if ((err =kobject_add (&disk->kobj)))return ;disk_sysfs_symlinks (disk); +ndevfs_create (kobject_name (&disk->kobj), +MKDEV (disk->major, disk->first_minor),0 );kobject_hotplug (&disk->kobj,KOBJ_ADD );/* No minors to use for partitions */
@@ -420,6 +425,7 @@sysfs_remove_link (&disk->driverfs_dev->kobj,"block" );put_device (disk->driverfs_dev); } +ndevfs_remove (kobject_name (&disk->kobj));kobject_hotplug (&disk->kobj,KOBJ_REMOVE );kobject_del (&disk->kobj); }
Quoted 1 line · Greg KH
Now I just know I'm going to regret this somehow...
Why?
Well. I've read several endless discussions about devfs/udev/dev etc. I've a question still, which has been raised by several other people too. The question is this: "what is a naming policy?"
Kernel already have some "naming scheme", used internally. Think about /proc/partitions, /sys nodenames (/sys/block/sda etc), think about dmesg output (serial: registered device tttS0) etc. This is just because devices *have* to be named *somehow*. And, IMHO, there should be a way for the user (or whomever), when he sees that dmesg/partitions/whatever, to access that device in /dev.
That same device can have other names too, like /dev/MyYellowCDBurner or /dev/MyPhotoCamera. I think *that* is a policy. And there's an internal (in-kernel) naming scheme. Which has been here for ages, with alot or programs expected to see "standard" names in /dev (think how lilo or, worse, mdadm, fails when it can't find a device listed in /proc/partitions because the node has been created with different name according to "policy").
More, with dynamic (or semi-dynamic) /dev, like devfs or udev provides, the directory isn't cluttered with alot of unused files anymore (before udev, i was trying to move grouops of devices into subdirs in /dev, like moving all scsi disks (sd) to /dev/sd/, with the only
reason: to have less entries in /dev, some of which can be useful in some future...), it isn't really that matters if it will have flat namespace. Ok ok, with 20K scsi devices, it may be problematic somehow.. i dunno really, a machine with 20K disks usually have apropriate amount of RAM too).
So, to summarize all that. A dynamic /dev, which creates/removes nodes using in-kernel naming scheme (which is here for ages) automatically, and calls external program to help create "policy"-based naming -- i don't think it's a bad idea anyway.
Quoted 11 lines
Anyway, here's yet-another-ramfs-based filesystem, ndevfs. It's a very tiny:
$ size fs/ndevfs/inode.o text data bss dec hex filename 1571 200 8 1779 6f3 fs/ndevfs/inode.o replacement for devfs for those embedded users who just can't live without the damm thing. It doesn't allow subdirectories, and only uses LSB compliant names. But it works, and should be enough for people to use, if they just can't wean themselves off of the idea of an in-kernel fs to provide device nodes.
Quoted 6 lines
Now, with this, is there still anyone out there who just can't live without devfs in their kernel?
Damm, the depths I've sunk to these days, I'm such a people pleaser...
Comments? Questions? Criticisms?
A question. I can't apply this to 2.6.12, it fails in drivers/base/class.c -- the main portion i think. What's this patch against?
I'd love to see how it works but.. can't compile it ;)
And another question. Why it isn't possible to use plain tmpfs for this sort of things? Why to create another filesystem, instead of just using current tmpfs and call mknod/unlink on it as appropriate? This same tmpfs can be used by udev too (to create that "policy"-based names), and it gives us all the directories and other stuff...
Thanks.
/mjt
Greg:
Quoted 3 lines · Greg KH
Now I just know I'm going to regret this somehow...
Now, don't hold back on us here. Tell us how you really feel! :^)
b.g.
Signature · 3 lines
Bill Gatliff Embedded Linux development and training services. [email protected]
On Fri, Jun 24, 2005 at 04:23:49PM +0400, Michael Tokarev wrote:
<snip>
I'll respond to your comments later, it's too early...
Quoted 3 lines
A question. I can't apply this to 2.6.12, it fails in
drivers/base/class.c-- the main portion i think. What's this patch against?
2.6.12-git5, sorry I should have mentioned that.
Quoted 2 lines
And another question. Why it isn't possible to use plain tmpfs for this sort of things?
What do you mean? What's wrong with a ramfs based fs? To use tmpfs would require a lot more work. But if you want to do it, I'll gladly take patches :)
Quoted 2 lines
Why to create another filesystem, instead of just using current tmpfs and call mknod/unlink on it as appropriate?
Um, that's about all that this code does.
Quoted 2 lines
This same tmpfs can be used by udev too (to create that "policy"-based names), and it gives us all the directories and other stuff...
udev doesn't need a kernel specific fs.
thanks,
greg k-h
Quoted 2 lines · Greg KH
Now I just know I'm going to regret this somehow...
;)
Quoted 9 lines
fs/ndevfs/inode.c new file +6
-0@@ -0,0 +1,249 @@ +/* +* inode.c - part of ndevfs, a tiny little device file system +* +* Copyright (C) 2004,2005 Greg Kroah-Hartman <[email protected]> +* +* This program is free software; you can redistribute it and/or
fs/ndevfs/inode.c line 16
Quoted 10 lines
fs/ndevfs/inode.c new file +10
-0+* modify it under the terms of the GNU General Public License version +* 2 as published by the Free Software Foundation. +* +* Written for all of the people out there who just hate userspace solutions. +* +*/ + +/* uncomment to get debug messages */ +#define DEBUG +
Don't you mean here "comment to turn off debug messages?" :-)
-- Steve
Quoted 7 lines
fs/ndevfs/inode.c new file +7
-0+#include <linux/config.h> +#include <linux/module.h> +#include <linux/fs.h> +#include <linux/mount.h> +#include <linux/pagemap.h> +#include <linux/init.h> +#include <linux/namei.h>
Quoted 5 lines · Steven Rostedt
fs/ndevfs/inode.c line 16
Quoted 3 lines
fs/ndevfs/inode.c new file +3
-0+/* uncomment to get debug messages */ +#define DEBUG +Don't you mean here "comment to turn off debug messages?" :-)
Well, I should have commented out that first, the comment is right, the code is wrong :)
thanks,
greg k-h
Quoted 7 lines · Greg KH
Quoted 2 lines · Michael Tokarev
And another question. Why it isn't possible to use plain tmpfs for this sort of things?
What do you mean? What's wrong with a ramfs based fs? To use tmpfs would require a lot more work. But if you want to do it, I'll gladly take patches :)
Hmm. Ramfs and Tmpfs... I mean, we already have several filesystems which works, and are complete filesystems. Tmpfs is just one of them.
The point is as the following. Instead of creating completely new filesystem, there should be a possibility to create just a small layer on top of existing, feature-complete (think directories) filesystem, like tmpfs, with the only difference is that it's especially known by the kernel as containing device nodes (where the kernel should create/delete the nodes), and is mountable as such (not as any generic tmpfs). When a new device is created, ndevfs_mknod() (or similar) is called as in your patch, but the node is created in normal, regular tmpfs, instead of on some stripped-down filesystem.
This tmpfs will be mountable ofcourse, *and* it will support all the other normal filesystem operations. But...
Quoted 4 lines
Quoted 2 lines
Why to create another filesystem, instead of just using current tmpfs and call mknod/unlink on it as appropriate?
Um, that's about all that this code does.
....Ah ok. Well. Hmm. So I misread the code it seems. I thought it does not support directories and symlinks..
Quoted 4 lines
Quoted 2 lines
This same tmpfs can be used by udev too (to create that "policy"-based names), and it gives us all the directories and other stuff...
udev doesn't need a kernel specific fs.
I know. But it should be able to run on top of such an FS to (at least I don't see why it shouldn't), provided it only maintains that "policy" names (symlinks) to "canonical" device nodes (which is easily doable by just stripping config file).
/mjt
Quoted 11 lines · Michael Tokarev
Quoted 7 lines · Greg KH
Quoted 2 lines · Michael Tokarev
And another question. Why it isn't possible to use plain tmpfs for this sort of things?
What do you mean? What's wrong with a ramfs based fs? To use tmpfs would require a lot more work. But if you want to do it, I'll gladly take patches :)
Hmm. Ramfs and Tmpfs... I mean, we already have several filesystems which works, and are complete filesystems. Tmpfs is just one of them.
Heh, I know this quite well :)
Quoted 10 lines
The point is as the following. Instead of creating completely new filesystem, there should be a possibility to create just a small layer on top of existing, feature-complete (think directories) filesystem, like tmpfs, with the only difference is that it's especially known by the kernel as containing device nodes (where the kernel should create/delete the nodes), and is mountable as such (not as any generic tmpfs). When a new device is created,
ndevfs_mknod()(or similar) is called as in your patch, but the node is created in normal, regular tmpfs, instead of on some stripped-down filesystem.
Again, that's exactly what this patch does.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Why to create another filesystem, instead of just using current tmpfs and call mknod/unlink on it as appropriate?
Um, that's about all that this code does.
....Ah ok. Well. Hmm. So I misread the code it seems. I thought it does not support directories and symlinks..
It supports it, but I stipped it down to not allow that, I'll have to add code to enable that, if enough people complain :)
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
This same tmpfs can be used by udev too (to create that "policy"-based names), and it gives us all the directories and other stuff...
udev doesn't need a kernel specific fs.
I know. But it should be able to run on top of such an FS to (at least I don't see why it shouldn't), provided it only maintains that "policy" names (symlinks) to "canonical" device nodes (which is easily doable by just stripping config file).
I eagerly await your patch to show what you are referring to.
thanks,
greg k-h
Quoted 4 lines · Greg KH
Now I just know I'm going to regret this somehow...
Anyway, here's yet-another-ramfs-based filesystem, ndevfs. It's a very tiny:
Quoted 8 lines
$ size fs/ndevfs/inode.o text data bss dec hex filename 1571 200 8 1779 6f3 fs/ndevfs/inode.o replacement for devfs for those embedded users who just can't live without the damm thing. It doesn't allow subdirectories, and only uses LSB compliant names. But it works, and should be enough for people to use, if they just can't wean themselves off of the idea of an in-kernel fs to provide device nodes.
Well. Maybe directories really are of no use, but mknod/symlink/unlink *are* useful. That same mdadm who needs to create /dev/mdX *before* that device is created? And socket for /dev/log...
And oh, directories.. devpts? Stuff like cciss/... represented in sysfs like cciss!... ?
I don't see anything wrong with allowing creating/removing files in the filesystem (except of possible locking issues which can arise) -- in-kernel support just does mknod/unlink on insert/remove, and if that fails (EEXIST/ENOENT), well, so be it...
And since the whole namespace is now flat, another question comes in:
is there any guarantee the names will not overlap? /dev/ttyS0 and /dev/usb/ttyS0 (I don't remember which one it was, but I *think* I saw same names but in different dirs in /dev...)
/mjt
Quoted 4 lines · Greg KH
Now I just know I'm going to regret this somehow...
Anyway, here's yet-another-ramfs-based filesystem, ndevfs.
Here's your code against vanilla 2.6.12.
I ran it on an ARM machine, was able to successfully mount it and do an 'ls'. Not an exhaustive test, obviously.
Only errors I saw in the output were:
...
Freeing init memory: 100K
ndevfs: creating file 'vcs1' with major 7 and minor 1
ndevfs: creating file 'vcsa1' with major 7 and minor 129
ndevfs: creating file 'vcs1' with major 7 and minor 1 ndevfs_create failed with error -17
ndevfs: creating file 'vcsa1' with major 7 and minor 129 ndevfs_create failed with error -17
...
I don't know what vcs1 and vcsa1 are, not sure I really care... :^)
I moved your Kconfig diff; it was showing up in miscellaneous filesystems, I put it in pseudo filesystems instead.
b.g.
Signature · 3 lines
Bill Gatliff [email protected] Professional embedded Linux training.
drivers/base/class.c +7 -2
@@ -16,6 +16,7 @@#include <linux/init.h> #include <linux/string.h> #include <linux/kdev_t.h> +#include <linux/ndevfs.h> #include "base.h" #define to_class_attr (_attr) container_of(_attr, struct class_attribute, attr)
@@ -422,8 +423,10 @@up (&parent->sem); } -if (MAJOR (class_dev->devt)) +if (MAJOR (class_dev->devt)) {class_device_create_file (class_dev, &class_device_attr_dev); +ndevfs_create (class_dev->class_id, class_dev->devt,1 ); + }class_device_add_attrs (class_dev);if (class_dev->dev)
@@ -458,8 +461,10 @@up (&parent->sem); } -if (class_dev->dev) +if (class_dev->dev) {sysfs_remove_link (&class_dev->kobj,"device" ); +ndevfs_remove (class_dev->class_id); + }class_device_remove_attrs (class_dev);kobject_hotplug (&class_dev->kobj,KOBJ_REMOVE );
fs/Kconfig +6 -0
@@ -813,6 +813,12 @@ If you are not using a security module that requires using extended attributes for file security labels, say N. +config NDEV_FS + bool "Nano Device File System" + help + A proposed replacement for devfs. If you aren't sure, + say N. + config TMPFS bool "Virtual memory file system support (former shm fs)" help
fs/Makefile +1 -0
@@ -95,3 +95,4 @@ obj-$(CONFIG_HOSTFS) += hostfs/ obj-$(CONFIG_HPPFS) += hppfs/ obj-$(CONFIG_DEBUG_FS) += debugfs/ +obj-$(CONFIG_NDEV_FS) += ndevfs/
fs/partitions/check.c +6 -0
@@ -18,6 +18,7 @@#include <linux/fs.h> #include <linux/kmod.h> #include <linux/ctype.h> +#include <linux/ndevfs.h> #include <linux/devfs_fs_kernel.h> #include "check.h"
@@ -283,6 +284,7 @@ p->nr_sects =0 ; p->reads = p->writes = p->read_sectors = p->write_sectors =0 ;devfs_remove ("%s/part%d" , disk->devfs_name, part); +ndevfs_remove (kobject_name (&p->kobj));kobject_unregister (&p->kobj); }
@@ -310,6 +312,7 @@ p->kobj.parent = &disk->kobj; p->kobj.ktype = &ktype_part;kobject_register (&p->kobj); +ndevfs_create (kobject_name (&p->kobj),MKDEV (disk->major, p->partno),0 ); disk->part[part-1 ] = p; }
@@ -337,6 +340,8 @@if ((err =kobject_add (&disk->kobj)))return ;disk_sysfs_symlinks (disk); +ndevfs_create (kobject_name (&disk->kobj), +MKDEV (disk->major, disk->first_minor),0 );kobject_hotplug (&disk->kobj,KOBJ_ADD );/* No minors to use for partitions */
@@ -442,6 +447,7 @@sysfs_remove_link (&disk->driverfs_dev->kobj,"block" );put_device (disk->driverfs_dev); } +ndevfs_remove (kobject_name (&disk->kobj));kobject_hotplug (&disk->kobj,KOBJ_REMOVE );kobject_del (&disk->kobj); }
fs/ndevfs/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +ndevfs-objs := inode.o + +obj-$(CONFIG_NDEV_FS) += ndevfs.o +
fs/ndevfs/inode.c new file +249 -0
249 lines not on this page · raw message
include/linux/ndevfs.h new file +13 -0
@@ -0,0 +1,13 @@ +#ifndef _NDEVFS_H_ +#define _NDEVFS_H_ + +#if defined(CONFIG_NDEV_FS ) +extern void ndevfs_create (const char *name,dev_t dev,int is_char); +extern void ndevfs_remove (const char *name); +#else +static inline void ndevfs_create (const char *name,dev_t dev,int is_char) {} +static inline void ndevfs_remove (const char *name) {} +#endif + +#endif +
Quoted 2 lines · Greg KH
Anyway, here's yet-another-ramfs-based filesystem, ndevfs. It's a very tiny:
...
Quoted 5 lines
replacement for devfs for those embedded users who just can't live without the damm thing. It doesn't allow subdirectories, and only uses LSB compliant names. But it works, and should be enough for people to use, if they just can't wean themselves off of the idea of an in-kernel fs to provide device nodes.
As far as ideas go, this is pretty much all I asked for. A simple kernel filesystem to export device nodes with names, rather than just the numbers as sysfs does. The "detecting non-existant device names" thing never meant anything to me personally, and if anyone does care this gives them a simple place to add such a hook - unlike device names I don't see why such a thing would be difficult to maintain as a patch.
It'll obviously need support for symlinks, directories and mknod. And I'm not sure you can change the mode/owner of those devices yet. Also, I have no idea what the device support is like yet (am currently in the middle of nowhere, getting the latest bk to test this patch with over my handphone would not be fun) but looking at the bit where it's getting the names from the device model I can see it encountering problems with oddly named devices. And any devices which aren't dynamic in udev obviously aren't going to work with this patch either.
What's the method for bootstrapping this filesystem onto a system? Is a mount from early userspace the only way you'd accept, or would a kernel parameter to automount over /dev as devfs does be tolerable?
Quoted 2 lines
Now, with this, is there still anyone out there who just can't live without devfs in their kernel?
If devfs could be left alone (disabled, if necessary) until something like this was working, I would be completely mollified.
Quoted 1 line
For embedded people to use since they seem to hate userspace.
Userspace killed my father.
fs/ndevfs/inode.c line 10
Quoted 8 lines · Greg KH
fs/ndevfs/inode.c new file +5
-0+* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License version +* 2 as published by the Free Software Foundation. +* +* Written for all of the people out there who just hate userspace solutions.
No. Whining. License. Please. ;-)
Quoted 10 lines · Mike Bell
Quoted 2 lines · Greg KH
Anyway, here's yet-another-ramfs-based filesystem, ndevfs. It's a very tiny:
...
Quoted 5 lines
replacement for devfs for those embedded users who just can't live without the damm thing. It doesn't allow subdirectories, and only uses LSB compliant names. But it works, and should be enough for people to use, if they just can't wean themselves off of the idea of an in-kernel fs to provide device nodes.
Quoted 7 lines
As far as ideas go, this is pretty much all I asked for. A simple kernel filesystem to export device nodes with names, rather than just the numbers as sysfs does. The "detecting non-existant device names" thing never meant anything to me personally, and if anyone does care this gives them a simple place to add such a hook - unlike device names I don't see why such a thing would be difficult to maintain as a patch.
I had always asked for the simpler and minimal /dev to let a system boot and reach udev start, and I think this is even better !!
Quoted 5 lines
What's the method for bootstrapping this filesystem onto a system? Is a mount from early userspace the only way you'd accept, or would a kernel parameter to automount over /dev as devfs does be tolerable?
I got sad when I read I did not support directories and so on, because that meant I could not run udev on it, but I have thought on an alernative for early userspace:
- mount ndevfs on /mnt
- cp -a /mnt /dev
- umount /mnt
- let init run /etc/rc.d/rc till it gets to mount /dev and start udev
Just a question (kinda newbie's question):
Does ndevfs to be mounted when a device is detected ? Or will it show all the registered devices when mounted ?
TIA
--
J.A. Magallon <jamagallon()able!es> \ Software is like sex:
werewolf!able!es \ It's better when it's free
Mandriva Linux release 2006.0 (Cooker) for i586
Linux 2.6.12-jam2 (gcc 4.0.1 (4.0.1-0.2mdk for Mandriva Linux release 2006.0))
One of the things that most annoys me about udev is that I still need a minimal static dev in order for the system to boot. Could something like this be used as follows?
1) Boot kernel with an arg "automount_ndevfs", which automounts on /dev
2) Init scripts use console, ttyX, hda, sda, etc from ndevfs
3) Init script for udev does:
# mount -t tmpfs udev /.dev # udevstart /.dev # mount --move /.dev /dev # mount -t ndevfs ndevfs /dev/.kerndev
4) Normal userspace apps use /dev
5) When udev is stopped, it can just umount /dev/.kerndev, then umount /dev, then the basic stuff should still work.
Ideally ndevfs should support basic subdirectories and symlinks, so that a simple /dev/pts could be mounted over top of it without any hassle.
Cheers,
Kyle Moffett
--
Somone asked my why I work on this free (http://www.fsf.org/philosophy/)
software stuff and not get a real job. Charles Shultz had the best answer:
"Why do musicians compose symphonies and poets write poems? They do it because life wouldn't have any meaning for them if they didn't. That's why I draw cartoons. It's my life."
-- Charles Shultz
Quoted 7 lines · Kyle Moffett
One of the things that most annoys me about udev is that I still need a minimal static dev in order for the system to boot. Could something like this be used as follows?
1) Boot kernel with an arg "
automount_ndevfs", which automounts on /dev2) Init scripts use console, ttyX, hda, sda, etc from ndevfs
Even more magic piled up in kernel? Please no.
I've moved to initrd-basid start, thus I don't need anything on /dev. My initrd mounts ramfs on /dev and populates it with bare minimum, then udev kicks in.
With dietlibc/uclibc/busybox, initrd can get ridiculously small :) --
vda
Quoted 13 lines · Greg KH
Now I just know I'm going to regret this somehow...
Anyway, here's yet-another-ramfs-based filesystem, ndevfs. It's a very tiny:
$ size fs/ndevfs/inode.o text data bss dec hex filename 1571 200 8 1779 6f3 fs/ndevfs/inode.o replacement for devfs for those embedded users who just can't live without the damm thing. It doesn't allow subdirectories, and only uses LSB compliant names. But it works, and should be enough for people to use, if they just can't wean themselves off of the idea of an in-kernel fs to provide device nodes.
Quoted 4 lines
Now, with this, is there still anyone out there who just can't live without devfs in their kernel?
Damm, the depths I've sunk to these days, I'm such a people pleaser...
Hmm. I'm not pleased. Perhaps you're pleasing the wrong people?
What we really need is a short HOWTO that covers:
- Do you really need a dynamic /dev?
- How to embed a static /dev in your embedded kernel with initramfs
- How to add a dynamic /dev to your kernel with udev
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
Quoted 14 lines · Matt Mackall
Quoted 13 lines · Greg KH
Now I just know I'm going to regret this somehow...
Anyway, here's yet-another-ramfs-based filesystem, ndevfs. It's a very tiny:
$ size fs/ndevfs/inode.o text data bss dec hex filename 1571 200 8 1779 6f3 fs/ndevfs/inode.o replacement for devfs for those embedded users who just can't live without the damm thing. It doesn't allow subdirectories, and only uses LSB compliant names. But it works, and should be enough for people to use, if they just can't wean themselves off of the idea of an in-kernel fs to provide device nodes.
Quoted 6 lines
Quoted 4 lines
Now, with this, is there still anyone out there who just can't live without devfs in their kernel?
Damm, the depths I've sunk to these days, I'm such a people pleaser...
Hmm. I'm not pleased. Perhaps you're pleasing the wrong people?
You are so right, I am. I need to be pleasing me, and devfs in the kernel is not the correct solution. I knew this 4 years ago when Pat and I started working on the driver core (my main goal was to do it to support a udev-like solution), and I still know this today.
So no, I'm not going to be submitting this. But what it is, is a nice proof-of-concept for people who "just can't live without a in-kernel devfs" to show that it can be done in less than 300 lines of code, and only 6 hooks (2 functions in 3 different places) in the main kernel tree. That is managable outside of the main kernel for years, with almost little to no effort.
Quoted 5 lines
What we really need is a short HOWTO that covers:
- Do you really need a dynamic /dev?
- How to embed a static /dev in your embedded kernel with initramfs
- How to add a dynamic /dev to your kernel with udev
Yes, I'm going to start working with some of the people who really know this stuff (the distro developers who make the whole dynamic boot and early boot process work correctly) and we will hash out a coheirant future together, and document it all really well.
But I'm going to wait to do that till next week, the sun is shining, the beer is cold, and I'm going to relax now...
Thanks for calling me on this, I appreciate it. You weren't the only one either, which is a good thing.
greg k-h
Quoted 10 lines · Greg KH
Quoted 5 lines
What we really need is a short HOWTO that covers:
- Do you really need a dynamic /dev?
- How to embed a static /dev in your embedded kernel with initramfs
- How to add a dynamic /dev to your kernel with udevYes, I'm going to start working with some of the people who really know this stuff (the distro developers who make the whole dynamic boot and early boot process work correctly) and we will hash out a coheirant future together, and document it all really well.
I hope "distro developers" will include folk like Open Embedded developers rather than just targetting the Red Hat's, Debians and SuSE's ?
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Quoted 6 lines · Greg KH
So no, I'm not going to be submitting this. But what it is, is a nice proof-of-concept for people who "just can't live without a in-kernel devfs" to show that it can be done in less than 300 lines of code, and only 6 hooks (2 functions in 3 different places) in the main kernel tree. That is managable outside of the main kernel for years, with almost little to no effort.
Except that it isn't.
The "everything in the root" model just doesn't seem to work. It's been so long since I used linux without devfs I hadn't thought about how things like ALSA and the input subsystem have gone beyond supporting device nodes in a subdirectory to actually requiring device nodes to be in a subdirectory.
The obvious (and less important) legacy stuff has the old standard names, but for the newer, properly named stuff like the input subsystem and ALSA, it's just yet another incompatible naming scheme, and this one doesn't even have the advantage of being an improvement in /dev cleanliness like devfs tried to be.
For it to be manageable outside the mainline kernel the device names /have/ to be inside the mainline kernel and have to be something applications recognise without patching. When the ones in sysfs don't work, we're back to needing the ones drivers provide through devfs hooks, since I somehow don't see you modifying sysfs to accommodate a project like this. :)
It's a shame too, once I had symlink, mkdir, mknod, chown/chmod and unlink of symlinks working on the filesystem I was able to boot up with it as /dev on my laptop, and figured it would just be a matter of de-devfsifying my scripts, but it looks now like the names it implements are just plain unworkable rather than merely inconvenient, quite aside from the unholy amount of pointless chmoding required.
What could work is using the devfs-style registration hooks with a filesystem like this, but that returns us to what I proposed (and I believe a few people before me actually have coded up) of a simply cleaned up and simplified devfs. Which, as far as I know, you outright reject.
Quoted 8 lines · Mike Bell
Quoted 6 lines · Greg KH
So no, I'm not going to be submitting this. But what it is, is a nice proof-of-concept for people who "just can't live without a in-kernel devfs" to show that it can be done in less than 300 lines of code, and only 6 hooks (2 functions in 3 different places) in the main kernel tree. That is managable outside of the main kernel for years, with almost little to no effort.
Quoted 7 lines
Except that it isn't.
The "everything in the root" model just doesn't seem to work. It's been so long since I used linux without devfs I hadn't thought about how things like ALSA and the input subsystem have gone beyond supporting device nodes in a subdirectory to actually requiring device nodes to be in a subdirectory.
AFAIK there is no requirement in input subsystem that devices should be created under /dev/input. When devfs is activated they are created there by default, but that's it.
Signature · 1 line
Dmitry
Quoted 3 lines · Dmitry Torokhov
AFAIK there is no requirement in input subsystem that devices should be created under
/dev/input. When devfs is activated they are created there by default, but that's it.
Things which accept a path to an event file as an argument will work just fine. But anything which tries autodiscovery HAS to be able to find the device nodes. Think directfb, most (but not all) of the X patches, any user-space driver that wants to find the hardware it owns, etc.
This illustrates nicely my reasons for preferring devfs.
1) Predictable, canonical device names are a Good Thing.
2) If you accept that, exporting the device names from the kernel is the most sensible way to do it.
For point one, how do you do autodiscovery otherwise? You can look at sysfs or /proc/bus/input/devices to find out what input devices are on the system, but if the device nodes can be named anything then how do you find them? Grep over all of /dev and find the guy with the right major/minor? Or create your own private device node using the dev sysfs parameter? Or use some crazy interface to udev's configuration files to find out what the hell it decided to name the node?
For point two, without doubting the need for a userspace utility to do chown and symlinks to meaningful names, I cannot conceive of how anyone could say "I need a device node named /dev/input/event0 with this major/minor created and deleted according to in-kernel events. The best way to do this is to export an empty ram-backed filesystem and mount it on /dev from userspace, use a second kernel-generated filesystem to export a file called /sys/class/input/event0/dev with the major and minor in it, use a second kernel->userspace interface to send an event to a userspace helper which will read that value, look up that it's supposed to be named /dev/input/event0, and mknod the corresponding device file". Not if the node is always going to be named /dev/input/event0.
udev can do lots of amazing things, but ONE of the things it does, creating device nodes, could be done much better in the kernel IMHO. The only thing udev offers over a devfs-like solution in this regard is the ability to have those device nodes use all sorts of wacky, random names. And that's not a feature in my book, it's a colossal bug. If you want wacky, random names, make them symlinks. And please don't confuse hatred for ide/host0/bus0/target0/lun0/part1 versus hda1 with hatred of standardized names. Picking a dumb standard one time doesn't mean standards are dumb.
Quoted 10 lines · Arnd Bergmann
Quoted 7 lines · Greg KH
+
+??????????????list_for_each_entry(entry, &entries, node) { +??????????????????????????????if (strcmp(name, &entry->name[0])== 0) { +??????????????????????????????????????????????dentry =entry->dentry; +??????????????????????????????????????????????break; +??????????????????????????????}
+??????????????}This list search looks like it is missing a mutex around it,
Yes.
Quoted 1 line
and the elements of the list never get freed properly.
Yeah, I noticed that after I posted it.
I was at the end of my self-imposed, "I'm only giving myself 3 hours for this", and didn't want to touch it anymore :)
Quoted 2 lines
Is it possible to use
lookup_one_len()instead? That should make it possible not to use an extra list of entries at all.
Yeah, I originally tried a different function from namei.c, but getting the mount point was a bit messy at the moment.
I'll take some time later this week and fix this up and post it one more time for anyone else to use.
But remember, I'll be posting it, and not asking for it to be accepted, as I was wrong. devfs is not needed, it's wrong, and will be removed from the kernel. But more about that later...
thanks,
greg k-h
Quoted 7 lines · Russell King
Quoted 6 lines · Greg KH
Quoted 5 lines
What we really need is a short HOWTO that covers:
- Do you really need a dynamic /dev?
- How to embed a static /dev in your embedded kernel with initramfs
- How to add a dynamic /dev to your kernel with udev
Quoted 7 lines
Quoted 4 lines
Yes, I'm going to start working with some of the people who really know this stuff (the distro developers who make the whole dynamic boot and early boot process work correctly) and we will hash out a coheirant future together, and document it all really well.
I hope "distro developers" will include folk like Open Embedded developers rather than just targetting the Red Hat's, Debians and SuSE's ?
Of course, if there are any people you can think of that I should contact about this, in the embedded world, please give me their names/email addresses (offlist if you wish.)
thanks,
greg k-h
Quoted 2 lines · Kyle Moffett
One of the things that most annoys me about udev is that I still need a minimal static dev in order for the system to boot.
Why? You should not. Works just fine for me here :)
I suggest you work on your init scripts some more...
greg k-h
Quoted 5 lines · Mike Bell
Quoted 3 lines · Dmitry Torokhov
AFAIK there is no requirement in input subsystem that devices should be created under
/dev/input. When devfs is activated they are created there by default, but that's it.
Quoted 8 lines
Things which accept a path to an event file as an argument will work just fine. But anything which tries autodiscovery HAS to be able to find the device nodes. Think directfb, most (but not all) of the X patches, any user-space driver that wants to find the hardware it owns, etc.
This illustrates nicely my reasons for preferring devfs.
1) Predictable, canonical device names are a Good Thing.
And impossible for the kernel to generate given hotpluggable devices.
Quoted 2 lines
2) If you accept that, exporting the device names from the kernel is the most sensible way to do it.
I don't accept it, and neither does anyone else. See my previous posts about devfs and udev for more details, I'm not going to go into this again...
Good luck,
greg k-h
Quoted 3 lines · Bill Gatliff
I moved your
Kconfigdiff; it was showing up in miscellaneous filesystems, I put it in pseudo filesystems instead.
Ah, thanks, that's a better place for it.
greg k-h
Quoted 3 lines · Greg KH
Quoted 1 line
1) Predictable, canonical device names are a Good Thing.
And impossible for the kernel to generate given hotpluggable devices.
Bull. It's clear I'm talking about per-subsystem, not having individual devices show up with the same name each time. Or are you suggesting that hotplug might somehow turn my keyboard into a hard drive?
Quoted 1 line
I don't accept it, and neither does anyone else.
So then explain this to me, I've got a GUI sound player, on first invocation it displays a list of sound cards installed on the system, allows the user to select one, and then plays the sound file. How is it supposed to do that if the device nodes for sound card 0 could be named anything? I can get a list of sound cards from /proc/asound or /sys/class/sound, but unless the sound card device nodes are predictably named there's no way to find them short of searching every node in /dev.
Quoted 7 lines · Mike Bell
Quoted 3 lines · Greg KH
Quoted 1 line
1) Predictable, canonical device names are a Good Thing.
And impossible for the kernel to generate given hotpluggable devices.
Bull. It's clear I'm talking about per-subsystem, not having individual devices show up with the same name each time.
you still can't have that. think USB harddisks for example. The only way you can do this reliable is to use UUIDs from the disks. Guess what.. udev does that. devfs doesn't.
Same for PCI hotplug; the "path" to your pci IDE controller might change after you "hotplugged" some stuff. And no that's not just high end hardware; most docking stations are like this too. Again, only the disk UUID is usable for getting stable naming.
Quoted 9 lines
Quoted 1 line
I don't accept it, and neither does anyone else.
So then explain this to me, I've got a GUI sound player, on first invocation it displays a list of sound cards installed on the system, allows the user to select one, and then plays the sound file. How is it supposed to do that if the device nodes for sound card 0 could be named anything? I can get a list of sound cards from
/proc/asoundor/sys/class/sound, but unless the sound card device nodes are predictably named there's no way to find them short of searching every node in /dev.
actually.. linphone for example shows you the name of the device, not the device node. And at runtime it finds which device node belongs to that name somehow. I didn't look at the code how it does that, but it sure isn't impossible since it's done in practice already.
Quoted 3 lines · Arjan van de Ven
you still can't have that. think USB harddisks for example. The only way you can do this reliable is to use UUIDs from the disks. Guess what.. udev does that. devfs doesn't.
I thought I had made it clear that I wasn't talking about uniquely identifying a given piece of hardware, that can only be done in userspace (and often not even there).
What I'm talking about is the ability to find the device node that corresponds to the first entry in /proc/bus/input/devices, or play a sound file on the system's first sound card, or for X to find the drm device node that corresponds to a given video card. All these things are easy if you know that /dev/input/event0 is the device node for the first entry, but if that device node could be called /dev/myfunkykeyboard (note, the device name, you could still have a symlink to said name if you wanted without breaking anything), in a world where udev's supposed feature of allowing devices to be named anything you want is actually used, this isn't possible without scanning all of /dev.
Quoted 4 lines
actually.. linphone for example shows you the name of the device, not the device node. And at runtime it finds which device node belongs to that name somehow. I didn't look at the code how it does that, but it sure isn't impossible since it's done in practice already.
It is impossible though, if you make use of that particular feature of udev. Give it a try, move all your alsa device nodes to other names and see how completely unusable ALSA becomes. Those device nodes HAVE to exist and HAVE to point to the right devices in order for ALSA to work.
linphone and other programs "just work" because they know where to find their device nodes. If anything, you're arguing my point.
Am Dienstag, 28. Juni 2005 09:40 schrieb Greg KH:
Quoted 11 lines · Mike Bell
Quoted 10 lines · Dmitry Torokhov
Quoted 3 lines
AFAIK there is no requirement in input subsystem that devices should be created under
/dev/input. When devfs is activated they are created there by default, but that's it.Things which accept a path to an event file as an argument will work just fine. But anything which tries autodiscovery HAS to be able to find the device nodes. Think directfb, most (but not all) of the X patches, any user-space driver that wants to find the hardware it owns, etc.
Quoted 5 lines
Quoted 3 lines
This illustrates nicely my reasons for preferring devfs.
1) Predictable, canonical device names are a Good Thing.
And impossible for the kernel to generate given hotpluggable devices.
That is not true. The kernel can generate predictable device names. It just cannot generate _stable_ device names under all circumstances.
Regards
Oliver
Quoted 5 lines · Greg KH
Quoted 2 lines · Kyle Moffett
One of the things that most annoys me about udev is that I still need a minimal static dev in order for the system to boot.
Why? You should not. Works just fine for me here :)
Er, don't you need /dev/console for console output to happen? (And that it's a good idea to have /dev/null around too). Or has that changed?
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/
Quoted 9 lines · Tom Rini
Quoted 5 lines · Greg KH
Quoted 2 lines · Kyle Moffett
One of the things that most annoys me about udev is that I still need a minimal static dev in order for the system to boot.
Why? You should not. Works just fine for me here :)
Er, don't you need
/dev/consolefor console output to happen? (And that it's a good idea to have/dev/nullaround too). Or has that changed?
scripts/gen_initramfs_list.sh creates that for every kernel.
Quoted 7 lines · Olaf Hering
Quoted 5 lines · Tom Rini
Quoted 4 lines · Greg KH
Quoted 2 lines · Kyle Moffett
One of the things that most annoys me about udev is that I still need a minimal static dev in order for the system to boot.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Why? You should not. Works just fine for me here :)
Er, don't you need
/dev/consolefor console output to happen? (And that it's a good idea to have/dev/nullaround too). Or has that changed?
scripts/gen_initramfs_list.shcreates that for every kernel.
I get "Warning: unable to open initial console", so on post 2.6.12 (but now stale) git. Does userspace need to be doing something as well?
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/
Quoted 10 lines · Arjan van de Ven
Quoted 8 lines
So then explain this to me, I've got a GUI sound player, on first invocation it displays a list of sound cards installed on the system, allows the user to select one, and then plays the sound file. How is it supposed to do that if the device nodes for sound card 0 could be named anything? I can get a list of sound cards from
/proc/asoundor/sys/class/sound, but unless the sound card device nodes are predictably named there's no way to find them short of searching every node in /dev.
Quoted 4 lines
actually.. linphone for example shows you the name of the device, not the device node. And at runtime it finds which device node belongs to that name somehow. I didn't look at the code how it does that, but it sure isn't impossible since it's done in practice already.
I took a quick look and for OSS devices linphone seems to just loop over /dev/dsp* so if the names were moved, I doubt it would work.
But it also seems to have ALSA support and in that case it uses snd_card_get_name in a for loop to build a list of available cards, since all ALSA functions use card index numbers they should work fine independent of device file names.
Jim.
Quoted 1 line · Tom Rini
On Tue, Jun 28, 2005 at 11:08:04PM +0200, Olaf Hering wrote:
[]
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Er, don't you need
/dev/consolefor console output to happen? (And that it's a good idea to have/dev/nullaround too). Or has that changed?
scripts/gen_initramfs_list.shcreates that for every kernel.I get "Warning: unable to open initial console", so on post 2.6.12 (but now stale) git. Does userspace need to be doing something as well?
Are you using initramfs (cpio archive of the root fs)? Or "ol'good" initrd (cramfs, romfs, whatever)?
/mjt
Quoted 6 lines · Michael Tokarev
Quoted 1 line · Tom Rini
On Tue, Jun 28, 2005 at 11:08:04PM +0200, Olaf Hering wrote:
[]
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Er, don't you need
/dev/consolefor console output to happen? (And that it's a good idea to have/dev/nullaround too). Or has that changed?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
scripts/gen_initramfs_list.shcreates that for every kernel.I get "Warning: unable to open initial console", so on post 2.6.12 (but now stale) git. Does userspace need to be doing something as well?
Are you using initramfs (cpio archive of the root fs)? Or "ol'good" initrd (cramfs, romfs, whatever)?
I'm just booting the kernel as normal, and assuming that the initramfs that's built by default is used before my real rootfs happens.
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/
Quoted 7 lines · Jim Crilly
I took a quick look and for OSS devices linphone seems to just loop over
/dev/dsp*so if the names were moved, I doubt it would work.But it also seems to have ALSA support and in that case it uses
snd_card_get_namein a for loop to build a list of available cards, since all ALSA functions use card index numbers they should work fine independent of device file names.
No, they shouldn't. Try it and see. Yes, your /program/ uses the sound card index, but that's because the ALSA library internally assumes that sound card index 0 corresponds to certain device nodes.
Eventually every program has to be able to find the device node. That's just obvious, if you don't need the device node why have it in the first place? And if it can't predict what that device node will be named, the only thing it can do (short of creating its own private device node, which breaks all sorts of stuff /and/ is dumb /and/ doesn't work unless you're root) is search over every single device node in /dev to find the one with the correct major/minor. Or ask the user to type it in manually, which is all well and good for maybe an admin configuring some system, but is completely broken for anything GUI or automatic.
Hence my conclusion, predictable device file names are a requirement. udev's "name the device whatever you want" works fine for running vi on /etc/fstab, but when you want a program to do anything intelligent like present a list of available choices, you need to be able to find the device node.
Quoted 12 lines · Oliver Neukum
Am Dienstag, 28. Juni 2005 09:40 schrieb Greg KH:
Quoted 11 lines · Mike Bell
Quoted 10 lines · Dmitry Torokhov
Quoted 3 lines
AFAIK there is no requirement in input subsystem that devices should be created under
/dev/input. When devfs is activated they are created there by default, but that's it.Things which accept a path to an event file as an argument will work just fine. But anything which tries autodiscovery HAS to be able to find the device nodes. Think directfb, most (but not all) of the X patches, any user-space driver that wants to find the hardware it owns, etc.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
This illustrates nicely my reasons for preferring devfs.
1) Predictable, canonical device names are a Good Thing.
And impossible for the kernel to generate given hotpluggable devices.
That is not true. The kernel can generate predictable device names. It just cannot generate _stable_ device names under all circumstances.
Well, I view "canonical" as, "this is the name for this specific device, and will always be that name". But, if others think of it differently, hey, that's fine with me too.
And yes, I also agree with your statement.
thanks,
greg k-h
Quoted 4 lines · Mike Bell
Quoted 3 lines · Jim Crilly
I took a quick look and for OSS devices linphone seems to just loop over
/dev/dsp*so if the names were moved, I doubt it would work.
Quoted 8 lines
Quoted 4 lines
But it also seems to have ALSA support and in that case it uses
snd_card_get_namein a for loop to build a list of available cards, since all ALSA functions use card index numbers they should work fine independent of device file names.No, they shouldn't. Try it and see. Yes, your /program/ uses the sound card index, but that's because the ALSA library internally assumes that sound card index 0 corresponds to certain device nodes.
I stand corrected then. I didn't actually try anything with linphone, the ALSA API just makes it look like the device nodes don't matter.
Quoted 11 lines
Eventually every program has to be able to find the device node. That's just obvious, if you don't need the device node why have it in the first place? And if it can't predict what that device node will be named, the only thing it can do (short of creating its own private device node, which breaks all sorts of stuff /and/ is dumb /and/ doesn't work unless you're root) is search over every single device node in /dev to find the one with the correct major/minor. Or ask the user to type it in manually, which is all well and good for maybe an admin configuring some system, but is completely broken for anything GUI or automatic.
Quoted 5 lines
Hence my conclusion, predictable device file names are a requirement. udev's "name the device whatever you want" works fine for running vi on
/etc/fstab, but when you want a program to do anything intelligent like present a list of available choices, you need to be able to find the device node.
Well it looks like the ALSA library already abstracts the device node enough that the app itself doesn't know what file is being used because it just calls snd_card_get_name, snd_open_pcm, etc with the ALSA index. So wouldn't it be feasible to make ALSA a little bit smarter so that it could track/find the device nodes no matter what name they have? I'm not advocating for or against it, but from my cursory look at the API it looks possible to do without breaking any ALSA apps.
Jim.
Quoted 5 lines · Jim Crilly
Well it looks like the ALSA library already abstracts the device node enough that the app itself doesn't know what file is being used because it just calls
snd_card_get_name,snd_open_pcm, etc with the ALSA index. So wouldn't it be feasible to make ALSA a little bit smarter so that it could track/find the device nodes no matter what name they have?
You could in theory do that to ALSA. Except for the aforementioned "how?". How is ALSA supposed to find out what its new device node name is? You could invent some sort of crazy libudev, but I think it would require a major redesign of how udev works, forcing it to keep state or such. The only alternatives I can see are what I already mentioned, searching every single device node in /dev to find the right one.
Which is why I conclude (and, evidently, Greg agrees) that consistent naming schemes for /dev are very important. Now if I could just find out why devfs's failure to allow such broken configurations is a bug in his mind. :)
Quoted 5 lines · David Lang
worse yet, go way back in the archives and you will find that prior to being merged into the kernel devfs supported two nameing schemes, the one you see now and a compatability version that matched the standard /dev names. one requirement for allowing it to be merged was to remove the compatability set of names.
Yes, I vaguely remember. IIRC Linus was the one who mandated the use of a directory based structure before devfs would be merged, though I think the particular choice of names was not his fault.
Which is why I've asked people to seperate their distaste for the names devfs uses from distaste for having a standard set of names.
Originally I was hoping that all those plans to move partition detection into userspace using device-mapper would help eliminate people's objections to devfs (AFAIK the devfs-style names hated most by far are block devices, which are way too long), but it didn't work out that way.
Quoted 14 lines · Mike Bell
Quoted 5 lines · Jim Crilly
Well it looks like the ALSA library already abstracts the device node enough that the app itself doesn't know what file is being used because it just calls
snd_card_get_name,snd_open_pcm, etc with the ALSA index. So wouldn't it be feasible to make ALSA a little bit smarter so that it could track/find the device nodes no matter what name they have?You could in theory do that to ALSA. Except for the aforementioned "how?". How is ALSA supposed to find out what its new device node name is? You could invent some sort of crazy libudev, but I think it would require a major redesign of how udev works, forcing it to keep state or such. The only alternatives I can see are what I already mentioned, searching every single device node in /dev to find the right one.
Quoted 4 lines
Which is why I conclude (and, evidently, Greg agrees) that consistent naming schemes for /dev are very important. Now if I could just find out why devfs's failure to allow such broken configurations is a bug in his mind. :)
worse yet, go way back in the archives and you will find that prior to being merged into the kernel devfs supported two nameing schemes, the one you see now and a compatability version that matched the standard /dev names. one requirement for allowing it to be merged was to remove the compatability set of names.
David Lang
Signature · 2 lines
There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. -- C.A.R. Hoare
Am Dienstag, 28. Juni 2005 22:08 schrieben Sie:
Quoted 17 lines · Oliver Neukum
Quoted 16 lines
Am Dienstag, 28. Juni 2005 09:40 schrieb Greg KH:
Quoted 15 lines · Mike Bell
Quoted 13 lines · Dmitry Torokhov
Quoted 3 lines
AFAIK there is no requirement in input subsystem that devices should be created under
/dev/input. When devfs is activated they are created there by default, but that's it.Things which accept a path to an event file as an argument will work just fine. But anything which tries autodiscovery HAS to be able to find the device nodes. Think directfb, most (but not all) of the X patches, any user-space driver that wants to find the hardware it owns, etc.
This illustrates nicely my reasons for preferring devfs.
1) Predictable, canonical device names are a Good Thing.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
And impossible for the kernel to generate given hotpluggable devices.
That is not true. The kernel can generate predictable device names. It just cannot generate _stable_ device names under all circumstances.
Well, I view "canonical" as, "this is the name for this specific device, and will always be that name". But, if others think of it differently, hey, that's fine with me too.
Isn't the canonical way to use canonical to mean a name that is independent of a particular system but set in a standard? Such a name could be generated only if the device itself is unique. Short of network cards and bluetooth devices you'll be short on canonical, stable names.
In other cases you have heuristics and system configuration. These are nice to have, but have limits and problems. Firstly, they are heuristics and thus a bit risky to use. Secondly, they sometimes need system configuration. And this very much limits usefullness to embedded and indeed single user systems.
What devfs and udev can do, and a static dev cannot, is names independent of order of detection. As for ressources, it is an illusion to think that user space means less ressources. A demon means page tables and a kernel stack. That 12K unswappable memory in the best case.
Regards
Oliver
Quoted 2 lines · Oliver Neukum
What devfs and udev can do, and a static dev cannot, is names independent of order of detection.
devfs can not do that.
Quoted 3 lines
As for ressources, it is an illusion to think that user space means less ressources. A demon means page tables and a kernel stack. That 12K unswappable memory in the best case.
You don't have to run the udevd process if you are worried about an extra process in your kernel tables. Although this is the first time I have heard anyone voice the "oh no, not another userspace task running" point :)
thanks,
greg k-h
Am Mittwoch, 29. Juni 2005 18:06 schrieben Sie:
Quoted 5 lines · Oliver Neukum
Quoted 2 lines
What devfs and udev can do, and a static dev cannot, is names independent of order of detection.
devfs can not do that.
Why not?
Quoted 5 lines
Quoted 3 lines
As for ressources, it is an illusion to think that user space means less ressources. A demon means page tables and a kernel stack. That 12K unswappable memory in the best case.
You don't have to run the udevd process if you are worried about an
What about events arriving out of order?
Quoted 3 lines
extra process in your kernel tables. Although this is the first time I have heard anyone voice the "oh no, not another userspace task running" point :)
Well, you should have. 16K is a more realistic figure. Tasks have their cost. In fact:
root 1 0.0 0.0 684 248 ? S 16:58 0:01 init [5] root 2 0.0 0.0 0 0 ? SN 16:58 0:00 [ksoftirqd/0] root 3 0.0 0.0 0 0 ? S< 16:58 0:00 [events/0] root 4 0.0 0.0 0 0 ? S< 16:58 0:00 [khelper] root 5 0.0 0.0 0 0 ? S< 16:58 0:00 [kthread] <snip> root 3424 0.0 0.1 2032 632 tty3 Ss+ 16:59 0:00 /sbin/mingetty tty3 root 3425 0.0 0.1 2032 632 tty4 Ss+ 16:59 0:00 /sbin/mingetty tty4 root 3426 0.0 0.1 2032 632 tty5 Ss+ 16:59 0:00 /sbin/mingetty tty5 root 3427 0.0 0.1 2032 632 tty6 Ss+ 16:59 0:00 /sbin/mingetty tty6
Counting this I arrive at 51*16K = 816K. That's a whole lot of unswappable memory. Thinking user space cheap is an automatic reflex these days. It's sometimes misleading like all blind reflexes.
It makes me feel a fool for caring about __init and __exit.
Regards
Oliver