2003-02-25 10:21:17

by Adam J. Richter

[permalink] [raw]
Subject: Patch: 2.5.62 devfs shrink

Here is an update to my patch to shrink devfs for linux-2.5.62.
The patch is a net deletion of 2407 lines. It contains the following new
changes:

- Maneesh Soni submitted a patch for operation with the
read-copy-update code, which was extremely good timing,
as that code apparently got integrated into 2.5.62.

- Fixed a bug reported by Alistair Strachan where
pseudo-terminals could not be allocated by non-super-user
processes (devfs needed to set CAP_DAC_OVERRIDE in a couple
of places).

- Restore the devfs=nomount option, to accomodate a distribution
compatability problem reported by Steven Cole. devfs=nomount
suppresses the effect CONFIG_DEVFS_MOUNT--that is, mounting
of /dev before the kernel invokes /sbin/init. Note: perhsps
we should eliminate CONFIG_DEVFS_MOUNT entirely. I'll have
to check to see if it is needed by systems that boot directly
to a hardware device rather than to an initial ramdisk.


Presumably because of the size of all of the "-" lines in the
patch, the linux-kernel mailing list filters it out, so I'll just post
a URL for it:

ftp://ftp.yggdrasil.com/pub/dist/device_control/devfs/smalldevfs-2.5.62-v10.patch

Also, here is the URL for the latest devfs_helper user level
program (version 0.2, unchanged). It is a reduced functionality
replacement for devfsd.

ftp://ftp.yggdrasil.com/pub/dist/device_control/devfs/devfs_helper-0.2.tar.gz


I'll also describe my "to do" list for this software, in case
anyone spots something I've forgotten:

- Submit a patch to the -mm kernels, as Andrew has been
kind enough to distribute this change in his -mm kernels.
- Write a small FAQ list on moving from old devfs.
- Remove CONFIG_DEVFS_MOUNT?
- Probably request integration after linux-2.7.0.

Adam J. Richter __ ______________ 575 Oroville Road
[email protected] \ / Milpitas, California 95035
+1 408 309-6081 | g g d r a s i l United States of America
"Free Software For The Rest Of Us."


2003-02-25 21:43:37

by Andrew Morton

[permalink] [raw]
Subject: Re: Patch: 2.5.62 devfs shrink

"Adam J. Richter" <[email protected]> wrote:
>
> Here is an update to my patch to shrink devfs for linux-2.5.62.

Adam, could you please provide a description of the incompatibilities between
this implementation and the present one? For both kernel and userspace.

And would you also please provide a list of operations which people need to
perform to migrate existing setups to the new code.

And should I drop the below patch?

diff -puN init/do_mounts.c~devfs-fix init/do_mounts.c
--- 25/init/do_mounts.c~devfs-fix 2003-01-16 19:39:56.000000000 -0800
+++ 25-akpm/init/do_mounts.c 2003-01-16 19:39:56.000000000 -0800
@@ -853,11 +853,6 @@ void prepare_namespace(void)
{
int is_floppy;

-#ifdef CONFIG_DEVFS_FS
- sys_mount("devfs", "/dev", "devfs", 0, NULL);
- do_devfs = 1;
-#endif
-
md_run_setup();

if (saved_root_name[0]) {

_

2003-02-25 23:44:20

by Dave Jones

[permalink] [raw]
Subject: Re: Patch: 2.5.62 devfs shrink

On Tue, Feb 25, 2003 at 01:50:32PM -0800, Andrew Morton wrote:

> diff -puN init/do_mounts.c~devfs-fix init/do_mounts.c
> --- 25/init/do_mounts.c~devfs-fix 2003-01-16 19:39:56.000000000 -0800
> +++ 25-akpm/init/do_mounts.c 2003-01-16 19:39:56.000000000 -0800
> @@ -853,11 +853,6 @@ void prepare_namespace(void)
> {
> int is_floppy;
>
> -#ifdef CONFIG_DEVFS_FS
> - sys_mount("devfs", "/dev", "devfs", 0, NULL);
> - do_devfs = 1;
> -#endif
> -
> md_run_setup();

Whoa. I thought that sucker made it into mainline.
This has been blocking closure of http://bugzilla.kernel.org/show_bug.cgi?id=110
for a while.

Dave

2003-02-26 02:37:35

by Milton Miller

[permalink] [raw]
Subject: Re: Patch: 2.5.62 devfs shrink

The real fix cset is below and was applied long ago (dated Jan 5), and indeed
reading carefully bugzilla #110

"2.5.55 boots ok with no workarounds needed, but 2.5.54 fails"


[email protected]|ChangeSet|20030106035042|11703


1.879.2.22 03/01/05 19:50:42-08:00 [email protected] 15796 15795 00003/00000/00001

[PATCH] devfs mount-time readdir fix and cleanup


milton

2003-02-27 23:04:07

by Adam J. Richter

[permalink] [raw]
Subject: Re: Patch: 2.5.62 devfs shrink

On Tue, 25 Feb 2003, Andrew Morton wrote, about my devfs code shrink:
>Adam, could you please provide a description of the incompatibilities between
>this implementation and the present one? For both kernel and userspace.

OK. Here is a first draft of what I plan to put in
linux/Documentation/filesystems/devfs/small-devfs. Corrections and
comments are welcome.

Adam J. Richter __ ______________ 575 Oroville Road
[email protected] \ / Milpitas, California 95035
+1 408 309-6081 | g g d r a s i l United States of America
"Free Software For The Rest Of Us."


---------------------------CUT HERE----------------------------------

This document describes the differences between Richard Gooch's
original devfs and my "small" devfs.

This new devfs replaces the internal devfs file system with one
derived from ramfs, a reduction of more than 2400 lines of source
code, although file systems based on ramfs rely on the 345 line
file fs/libfs.c.


User level differences:

1. devfsd replaced by devfs_helper

devfs_helper implements a subset of devfsd functionality.
devfsd is not a deamon. Instead, the new devfs invokes devfs_helper
with argument for each event. The new devfs currently only calls
devfs_helper for "LOOKUP" and "REGISTER" events. devfs_helper
uses the existing /etc/devfsd.conf file and supports devfsd's regular
expression matching. Like devfsd, devfs_helper is optional. It is
available from the following FTP directory.

ftp://ftp.yggdrasil.com/pub/dist/device_control/devfs/


2. Old device names not automatically installed.

Unlike devfsd, devfs_helper does not install old "compatible"
device names. This keeps devfs_helper small, which is particularly
important since devfs_helper is invoked repeatedly.

If you want to install a bunch of alternate device
names (such as /dev/hda1 for /dev/ide/host0/bus0/target0/lun0/part1),
you can do this at boot time after /dev has been mounted. For
example, you could maintain a tree of device nodes to overlay
on /dev in, say /dev.overlay, and then add something like the
following to a boot script:

( cd /dev.overlay && tar cf - ) | ( cd /dev && tar xfp - )

Note that you should not use "cp" or even "cp -a" for this
operation, as that "cp" will always try to open devices and
read from them.

If you want to save the current /dev every time you shut your
system down, you could add a line like the following to a
halt script:

( cd /dev && tar cf - ) | ( cd /dev.overlay && tar xfp - )

Note that if you want to support booting both with and without
devfs, a simpler approach might be to convert your non-devfs
system to use devfs-style names, at least for the devices that
are needed for booting (/dev/vc/0, /dev/vc/1... for virtual
consoles, /dev/discs/disc0/disc for the first whole hard disk,
/dev/discs/discs0/part1 for the first partition of the first
disk, /dev/floppy/0).


3. Future: DEVFS_MOUNT and "devfs=nomount" may disappear.

The option to have the kernel automatically mount /dev may
disappear in the future. As with old devfs, you can already
eliminate this feature by not defining DEVFS_MOUNT. If you
do this, the kernel will not be able to open /dev/console
before invoking /sbin/init. Eliminating DEVFS_MOUNT shrinks
the kernel, allowing this functionality to be provided by
user level programs (which don't necessarily remain resident
in memory and which may want to do something different anyhow).
The init program can do something like the following untested
code to mount /dev and open /dev/console:

mount("", "/dev", "devfs", 0, NULL);
close(0); close(1); close(2); /* Just to make sure. */
open("/dev/console", O_RDONLY); /* This will return fd 0. */
open("/dev/console", O_WRONLY); /* This will return fd 1. */
dup2(1, 2); /* stderr = stdout. */


4. Partition table support now matches non-devfs systems (i.e., no
automatic partition table rereading, which was causing problems).

The old devfs would automatically reread partition tables
at various times. This was a functional difference with non-devfs
systems, and made it nearly impossible to use drivers that returned
incorrect "media changed" information such as with CompactFlash cards
on systems that used user level partition reading programs like partx
to keep the kernel small. Basically, the old devfs would make the
kernel forget CompactFlash partition tables on nearly every operation.
This misfeature is removed in smalldevfs. smalldevfs systems now
handle partition tables just like non-devfs systems.


Kernel differences:

5. "ops" argument to devfs_register is temporarily ignored

If you are using devfs to register a character or block
device, you should not notice any difference. The difference is that
the ops argument to devfs_register is currently ignored. So, for the
time being, access to all devices still go through major and minor
device numbers. Eventually, I would like to restore the functionality
of potentially eliminating major and minor device numbers, but, for
now, this functionality is temporarily gone.

Because this functionality is gone, you can only register
character or block devices to get device-like behavior. The only
users of this functionality were a couple of interfaces that
duplicated /proc interfaces. They were removed from the kernel
recently anyhow.

In the future, I hope to restore this functionality in a way
that will allow even more device support code to removed (or
"configured out") as a result than under the old devfs. So, please
continue to pass the character or block device operations pointer to
devfs_register, even if devfs_register is currently not using it.


5a. devfs_only() always returns 0

devfs_only() is supposed to return 1 on systems that always
use the ops field in devfs_register and therefore do not need to
reference devices by number. Because of #2, devfs_only() currently
always return 0. This should change in the future, so please do not
delete code that tests devfs_only(). The compiler will optimize out
the unnecessary code in the meantime.


Adam J. Richter
[email protected]

2003-02-27 23:50:24

by Miquel van Smoorenburg

[permalink] [raw]
Subject: Re: Patch: 2.5.62 devfs shrink

In article <[email protected]>,
Adam J. Richter <[email protected]> wrote:
> devfs, a simpler approach might be to convert your non-devfs
> system to use devfs-style names, at least for the devices that
> are needed for booting (/dev/vc/0, /dev/vc/1... for virtual
> consoles, /dev/discs/disc0/disc for the first whole hard disk,
> /dev/discs/discs0/part1 for the first partition of the first
> disk, /dev/floppy/0).

If you're making it not 100% compatible anyway, now is the time
to do away with that horrible 'disc' spelling ;). 'disk' is a
harddisk or floppy disk, 'disc' is for compact disc (try Google
on both spellings and you'll see that the world agrees ..).
Just do s/disc/disk/g in devfs_register().

Mike.
--
Anyone who is capable of getting themselves made President should
on no account be allowed to do the job -- Douglas Adams.

2003-02-28 01:27:58

by Andrew Walrond

[permalink] [raw]
Subject: Re: Patch: 2.5.62 devfs shrink

I assume you meant devfs_helper here:

> devfsd is not a deamon. Instead, the new devfs invokes devfs_helper
------

Looks good to me. I want to give this another whirl, but your latest
patch doesn't apply cleanly against 2.5.63+ (fs/devfs/base.c fails). Any
chance of an update?

Thanks

Andrew Walrond

2003-02-28 02:38:59

by Adam J. Richter

[permalink] [raw]
Subject: Re: Patch: 2.5.62 devfs shrink

On Fri, 28 Feb 2003, Andrew Walrond wrote:
>I assume you meant devfs_helper here:

> > devfsd is not a deamon. Instead, the new devfs invokes devfs_helper
> ------

Right. I've checked in the fix. Thanks.


>Looks good to me. I want to give this another whirl, but your latest
>patch doesn't apply cleanly against 2.5.63+ (fs/devfs/base.c fails). Any
>chance of an update?

I've just come across a bug with in in 2.5.63 where
devfs_helper hangs while trying to down a semaphore. I think it is
doing down(&dir->i_sem) in some lookup routine in fs/namei.c.
I am trying to figure out what exactly inode->i_sem protects
so I can determine if it is OK for the routine that calls
defvs_helper to release it and reacquire it when devfs_helper
exits. Once I think I've fixed this, I'll post a new patch.

Adam J. Richter __ ______________ 575 Oroville Road
[email protected] \ / Milpitas, California 95035
+1 408 309-6081 | g g d r a s i l United States of America
"Free Software For The Rest Of Us."

2003-02-28 03:04:37

by Adam J. Richter

[permalink] [raw]
Subject: Re: Patch: 2.5.62 devfs shrink

[email protected] wrote:
>If you're making it not 100% compatible anyway, now is the time
>to do away with that horrible 'disc' spelling ;). 'disk' is a
>harddisk or floppy disk, 'disc' is for compact disc (try Google
>on both spellings and you'll see that the world agrees ..).
>Just do s/disc/disk/g in devfs_register().

The names of devices are not chosen by fs/devfs/*.[ch]. They
are chosen by the client code in device drivers and elsewhere that
call call devfs. In the case of the /dev/discs/ names, they are
chose by devfs_{create,remove}_partitions in fs/partitions/check.c,
which, from the comments, was apparently written by Linus Torvalds
and Russell King.

Tangential note:

For what it's worth, my preference would be to change from
/dev/discs/disc0/part1 to /dev/disk/0/part1, but I think it would
probably do more harm than good to try to coordinate such a change
with switching devfs. If you want to try to make a change where
people will eventually have to update their systems, I think it would
probably make more sense to survey existing devfs naming practices and
try to come up with some recommendations harmonize them a bit. For
example, should the directory names be singular or plural (/dev/loop
or /dev/loops, /dev/disk or /dev/disks)? I would recommend signular
because it is less English-centric. There are probably four or five
recommendations like these that could be put into a Documentation
file. More consistent naming schemes in anything tend to make
a system more readily usable.

Adam J. Richter __ ______________ 575 Oroville Road
[email protected] \ / Milpitas, California 95035
+1 408 309-6081 | g g d r a s i l United States of America
"Free Software For The Rest Of Us."

2003-02-28 03:53:53

by Miles Bader

[permalink] [raw]
Subject: Re: Patch: 2.5.62 devfs shrink

"Adam J. Richter" <[email protected]> writes:
> For example, should the directory names be singular or plural
> (/dev/loop or /dev/loops, /dev/disk or /dev/disks)? I would recommend
> signular because it is less English-centric.

I think singular is also far more common in existing [unix] practice.

-Miles
--
`Cars give people wonderful freedom and increase their opportunities.
But they also destroy the environment, to an extent so drastic that
they kill all social life' (from _A Pattern Language_)

2003-02-28 07:57:57

by Andreas Jellinghaus

[permalink] [raw]
Subject: Re: Patch: 2.5.62 devfs shrink

In case there is a cleanup of /dev/* names,
I'd like to also point out this (seen on 2.4.*):
/dev/printers/0
but
/dev/cdroms/cdrom0
./discs/disc0

If there are incompatible changes, it might
be good to cleanup all ugly parts, not only some.

Andreas

2003-02-28 12:38:54

by Helge Hafting

[permalink] [raw]
Subject: Re: Patch: 2.5.62 devfs shrink

Adam J. Richter wrote:

> Tangential note:
>
> For what it's worth, my preference would be to change from
> /dev/discs/disc0/part1 to /dev/disk/0/part1, but I think it would

Yes, that is nice and short. There is no need for the disc0 part,
we know it is a disk because it is in /dev/disk.

> probably do more harm than good to try to coordinate such a change
> with switching devfs. If you want to try to make a change where

Well, I wouldn't mind a disc->disk transition. It seems to mee there
aren't that many devfs users yet so I don't think it'll be that much of
a problem.

> people will eventually have to update their systems, I think it would
> probably make more sense to survey existing devfs naming practices and
> try to come up with some recommendations harmonize them a bit. For
> example, should the directory names be singular or plural (/dev/loop
> or /dev/loops, /dev/disk or /dev/disks)? I would recommend signular
> because it is less English-centric.

Singular is nice, because we think about /dev/disk/4 (one
particular disk) a lot more than we think about "the collection
/dev/disks"


Helge Hafting