Subject: fsck_ffs/mount_ffs problems on boot disks?
To: None <current-users@NetBSD.ORG>
From: Brian C. Grayson <email@example.com>
Date: 10/27/1997 15:26:40
Recently, whenever I use a floppy to recover from some mistake
on my hard drive, and it tries to run fsck_ffs to clean wd0a
etc., it dies with a message like:
mount_ffs: no option '-y'
Basically, when mount/fsck execs mount_ffs/fsck_ffs, they use
execv, and use the proper arg for the execname, but pass a
slightly bogus argv -- the argv that the process sees is
just "ffs", and not "mount_ffs" or "fsck_ffs". Now, when we make
crunched binaries, the crunchgen main program uses argv to
decide what program to run. We run a crunched fsck, which then
runs the crunched /sbin/fsck_ffs with an argv of "ffs",
which is really running the crunched main(), which then looks
down its list of crunched programs, sees the alias "ffs" for
"mount_ffs", and happily calls the mount_ffs main().
Obviously, parts of this problem have surfaced in the past,
because someone went to the trouble of adding the ``aliases''
of ffs for mount_ffs, etc. to the ramdiskbin.conf file in
/usr/src/distrib/i386/floppies/ramdisk. But has no one noticed
that this solution prevents fsck_ffs from doing the right thing?
Is there a good reason why mount and fsck don't specify the
full argv, besides saving a call to sprintf? :)
This situation was discussed (along with several others) w.r.t.
mount in PR 2974 "mount lies to child about argv0, which causes
crunch to lose" from nearly a year ago, which is still open, and
specifically in PR 2975 "fsck lies about argv0 to child, so
crunch loses". 2975 was closed but unfortunately the patch in
the PR was wrong: it still had "argv = vfstype" instead of
"argv = execbase". From inspection of the source code (and
experience), fsck.c still does the wrong thing.
It would be nice if this were fixed (for both mount and fsck)
If it would expedite the process, I'll send in a PR with
patches, probably later tonight.
Brian Grayson (firstname.lastname@example.org)
Graduate Student, Electrical and Computer Engineering
The University of Texas at Austin
Office: ENS 406 (512) 471-8011
Finger email@example.com for PGP key.