On Tue, Nov 01, 2005 at 10:08:11PM +0100, Jonas Smedegaard wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Tue, 1 Nov 2005 17:37:19 +0100 > Sven Luther <[EMAIL PROTECTED]> wrote: > > > BTW, i just had an idea, but is maybe the way yaird does this not > > broken, and it should use the mount output instead : > > The output of mount shows what is currently mounted. > > /etc/fstab shows what is intended to be mounted. > > So switching to using a different rootfs for the next mount would not > be possible if relying on what's mounted now.
Please find attached a patch to do * absent options in fstab * multiple fstypes: ext2,ext3 * auto fstype. We could use blkid to verify the fstype even if it's given explicitly in /etc/fstab, then do an error message if there's no match so the image would not boot. Somehow I get the impression that's an improvement that would not be much appreciated today ... Regards, Erik This is the test set used to make the patch: # # This is true; works # /dev/mapper/vg0-tst /b ext3 defaults,noauto 0 2 # This is a lie, its ext3 -- mount complains 'wrong fstype or superblock'. # Expect yaird to fail at boot time. # /dev/mapper/vg0-tst /b vfat defaults,noauto 0 2 # this is successful -- do two mount system calls, both fs types. # /dev/mapper/vg0-tst /b vfat,ext3 defaults,noauto 0 2 # Works, but complains about unknown fstype '' if it was already mounted # deviant repeat errors not tested for other variants. # /dev/mapper/vg0-tst /b vfat,ext3, defaults,noauto 0 2 # Works # /dev/mapper/vg0-tst /b ,vfat,ext3 defaults,noauto 0 2 # Works # /dev/mapper/vg0-tst /b vfat,,ext3 defaults,noauto 0 2 # Fails # /dev/mapper/vg0-tst /b ,, defaults,noauto 0 2 # this works -- courtesy of blkid libaries # /dev/mapper/vg0-tst /b auto defaults,noauto 0 2 # this works - fsck stuff is optional # /dev/mapper/vg0-tst /b ext3 defaults,noauto # this also works # /dev/mapper/vg0-tst /b ext3 # this breaks -- mount complains unknown fstype '' # /dev/mapper/vg0-tst /b # diff -urN -x {arch} -x .arch-ids -x configure -x aclocal.m4 -x depcomp -x missing -x Makefile -x Makefile.in -x install-sh -x INSTALL p79/ChangeLog p83/ChangeLog --- p79/ChangeLog 2005-11-01 22:55:04.000000000 +0100 +++ p83/ChangeLog 2005-11-01 22:55:16.000000000 +0100 @@ -2,6 +2,62 @@ # arch-tag: [EMAIL PROTECTED]/yaird--devo--0.1 # +2005-11-01 21:54:21 GMT Erik van Konijnenburg <[EMAIL PROTECTED]> patch-83 + + Summary: + support fstype == auto + Revision: + yaird--devo--0.1--patch-83 + + support fstype == auto + + + modified files: + ChangeLog perl/Plan.pm + + +2005-11-01 21:29:30 GMT Erik van Konijnenburg <[EMAIL PROTECTED]> patch-82 + + Summary: + merge optGetOutput from evms branch + Revision: + yaird--devo--0.1--patch-82 + + merge optGetOutput from evms branch + + + modified files: + ChangeLog perl/Base.pm + + +2005-11-01 21:15:27 GMT Erik van Konijnenburg <[EMAIL PROTECTED]> patch-81 + + Summary: + allow absent fs options + Revision: + yaird--devo--0.1--patch-81 + + allow absent fs options + + + modified files: + ChangeLog perl/FsTab.pm + + +2005-11-01 21:04:52 GMT Erik van Konijnenburg <[EMAIL PROTECTED]> patch-80 + + Summary: + allow fstype ext3,vfat + Revision: + yaird--devo--0.1--patch-80 + + allow fstype ext3,vfat + + + modified files: + ChangeLog perl/Plan.pm + + 2005-11-01 20:28:10 GMT Erik van Konijnenburg <[EMAIL PROTECTED]> patch-79 Summary: diff -urN -x {arch} -x .arch-ids -x configure -x aclocal.m4 -x depcomp -x missing -x Makefile -x Makefile.in -x install-sh -x INSTALL p79/perl/Base.pm p83/perl/Base.pm --- p79/perl/Base.pm 2005-11-01 22:55:04.000000000 +0100 +++ p83/perl/Base.pm 2005-11-01 22:55:16.000000000 +0100 @@ -35,6 +35,7 @@ # # Also routines to # - read content of one-line files +# - read content of multi-line files # - get device number from block or character device files # - interpret symbolic links # - interpret pathnames @@ -151,6 +152,69 @@ # +# optGetOutput -- all chomped lines of output for a given command. +# The twist is that a non-existent command is acceptable, +# and results in returning undef. +# Errors in invoking the cmd are fatal. +# Discard stderr. +# +sub optGetOutput { + my ($cmd, @args) = @_; + my $cmdLine = join (' ', $cmd, @args); + + my $in; + my $result; + if (! -e $cmd) { + Base::debug ("No command $cmd, returning undef"); + return undef; + } + + my $rc = open ($in, "-|"); + + if (! defined ($rc)) { + Base::fatal ("Can't start command $cmdLine"); + } + elsif ($rc == 0) { + # Child - setup stderr and exec or fatal. + $rc = open (STDERR, '>', '/dev/null'); + if (! $rc) { + exit (1); + } + + # Do the exec like so to make shell escapes + # impossible. + exec { $cmd } $cmd, @args; + + # Let parent do the error message. + exit (1); + } + else { + # parent + my @lines = <$in>; + if (! close ($in)) { + Base::fatal ("Could not read output for $cmdLine"); + } + chomp @lines; + $result = [ @lines ]; + } + return $result; +} + + +# getOutput -- the same, except that command must exist. +sub getOutput { + my ($cmd, @args) = @_; + + my $result = optGetOutput ($cmd, @args); + if (! defined ($result)) { + my $cmdLine = join (' ', $cmd, @args); + Base::fatal ("Could not execute $cmdLine"); + } + return $result; +} + + +# # devno -- given pathname to a device, return "maj:min" or undef. # symlinks are resolved implicitly. # diff -urN -x {arch} -x .arch-ids -x configure -x aclocal.m4 -x depcomp -x missing -x Makefile -x Makefile.in -x install-sh -x INSTALL p79/perl/FsTab.pm p83/perl/FsTab.pm --- p79/perl/FsTab.pm 2005-11-01 22:55:04.000000000 +0100 +++ p83/perl/FsTab.pm 2005-11-01 22:55:16.000000000 +0100 @@ -45,10 +45,14 @@ next if $line =~ /^#/; # comment line next if $line eq ""; # empty line my @fields = split (/\s+/, $line, 999); - if ($#fields < 4) { - # no test for extra fields; + if ($#fields < 3) { + # No test for extra fields; # the mount command allows that. - # note that field 5,6 (fsck stuff) is optional + # Note that field 5,6 (fsck stuff) is optional. + # Note that mount(8) does not explicitly handle + # absence of field 4 (options) in fstab line, + # but effect is that no special options are + # passed to mount system call. Base::fatal ("malformed line in $name:$lineNo"); } if ($fields[2] eq "swap") { diff -urN -x {arch} -x .arch-ids -x configure -x aclocal.m4 -x depcomp -x missing -x Makefile -x Makefile.in -x install-sh -x INSTALL p79/perl/Plan.pm p83/perl/Plan.pm --- p79/perl/Plan.pm 2005-11-01 22:55:04.000000000 +0100 +++ p83/perl/Plan.pm 2005-11-01 22:55:16.000000000 +0100 @@ -543,7 +543,39 @@ addDevicePlan ($actions, $abd, []); my $fsType = $root->type; - ModProbe::addModules ($actions, [ $fsType ]); + + if ($fsType eq "auto") { + # + # Let's guess the fstype using /sbin/blkid. + # + my $guess = Base::optGetOutput ('/sbin/blkid', $rootDevName); + if (!defined ($guess)) { + my $origin = $root->origin; + Base::fatal ("the command /sbin/blkid is not found, so file system type 'auto' for '$rootDevName' is not supported; use an explicit file system type ($origin)"); + } + if (@{$guess} != 1) { + my $origin = $root->origin; + Base::fatal ("the command /sbin/blkid $rootDevName did not give exactly one line of output, so file system type 'auto' for '$rootDevName' is not supported; use an explicit file system type ($origin)"); + } + + if (${$guess}[0] !~ /\sTYPE="([a-zA-Z0-9]+)"/) { + my $origin = $root->origin; + Base::fatal ("the command /sbin/blkid $rootDevName did not have TYPE=\"fstype\" in the output, so file system type 'auto' for '$rootDevName' is not supported; use an explicit file system type ($origin)"); + } + $fsType = $1; + Base::debug ("blkid $rootDevName => $fsType"); + } + + # + # Actually, fsType may be a comma-separated list of types, + # to be tried in turn + # + my @types = grep {$_ ne ''} split (',', $fsType); + if (@types == 0) { + my $origin = $root->origin; + Base::fatal ("no file system type given for '$rootDevName'; use an explicit file system type ($origin)"); + } + ModProbe::addModules ($actions, [ @types ]); my $yspecial = $abd->yspecial(); my $opts = $root->opts->cmdLineVersion(); -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]