[PATCH] size reduction and clean up swaponoff.c

Mike Frysinger vapier at gentoo.org
Fri Sep 16 20:10:55 UTC 2005


On Friday 16 September 2005 03:48 pm, Rob Landley wrote:
> On Friday 16 September 2005 08:13, Mike Frysinger wrote:
> > On Friday 16 September 2005 01:32 am, Rob Landley wrote:
> > > The patch you attached wasn't the "multiple paths" issue, but the
> > > "suppress error" issue.
> >
> > thats because i committed the 'multiple paths' fix to svn
>
> Cool.
>
> > > (And the patch gets it wrong: only the "already on" or
> > > "already off" errors are suppressed.  Something like file not found is
> > > not suppressed (by swapon, at least).)  Play with the util-linux
> > > version a bit...
> >
> > i did play with it, `swapon -a` and `swapoff -a` from util-linux will
> > error if fstab lists a path which doesnt exist ... the -a option doesnt
> > suppress all errors, just the ones that make sense to supress
>
> Yup.  Unless I'm misreading it, the patch you proposed suppressed all
> errors for the -a case.

you did read it slightly wrong ;)
it doesnt suppress the error from stat or the swapfile-has-holes check, but it 
does ignore all results from the swapon() call ... in order to fully match 
the behavior of util-linux, we'd have to check errno after the swapon() call, 
parse /proc/swaps, and compare with /etc/fstab ... but we could get pretty 
damn close if we just check the value of errno and warn when (verbose == 1 || 
errno == EBUSY) ...

the only corner case we'd have left is if you have say /dev/hda3 mounted as 
ext3 and have /dev/hda3 listed as swap space in /etc/fstab ... a 
swapon(/dev/hda3) call would too set errno to EBUSY ...

> > > Now admittedly we could skip both in the name of size.  What we might
> > > want to do is have a CONFIG option to enable these two extra features
> > > for people who want to replace util-linux with busybox in a real
> > > system. (Like me. :)
> >
> > that'd work for me too
>
> By the way, having looked at the multiple arguments fix, the ret=0 right
> before that isn't currently needed since the ret!=0 case from
> getopt_ulflags returns, so we can only get there right now if it is zero,
> correct?

indeed ... as long as we dont add anymore options like -v :)
-mike



More information about the busybox mailing list