[BusyBox] Joy and Compatibility

busybox at rich-paul.net busybox at rich-paul.net
Wed Jul 27 18:04:16 UTC 2005


I think the current behavior is correct, and should remain the default.
But there are times, e.g. going from multiuser to single user and back
where it would be nice to be able to just say 'hey mount, make sure this
partition is mounted' rather than 'hey mount, mount the partition and
cry like a baby if it's already mounted'.  or 'gimme another tmpfs on
dev, even if there's already one there.

The option would probably only be useful for partitions that are
specified in /etc/fstab 

It's like rm vs. rm -f:  if rm returns true, you not only know that the
file doesn't exist now, but you also know that the file did exist when
you ran rm.  With rm -f, OTOH, a true result tells you that the file
isn't there now, but doesn't complain if the file never existed.

This could, of course, be simulated with 
	test ! -e $file || rm $file
but in the case of mount, it 's more difficult to simulate, you'd have
to do something like
chkmount() {
	local mntpt="$1"	
	if [ $mntpt == /proc && test ! -e /proc/mounts]; then
		mount /proc
	elsif awk '{print $2}' /proc/mounts | grep $mntpt >/dev/null; then
		# say nothing, act natural
	else
		mount $mntpt
	fi
};

And even that would probably fail at times, if you're using chroot,
pivotroot, mount --bind, mount --move, or some combination thereof.
It's also racy, but that's probably not an issue during boot.

I think that mount -c would prove clearer and more reliable.

Anyway, I think this might be one of those things that's easier to grok
from code then from prose, so I'll try to kick out a quick patch, and if
it's not useful, just recycle the bits.

On Tue, Jul 26, 2005 at 11:56:46PM -0500, Jason Schoon wrote:
> Totally lost here.  Are you saying a device and/or mountpoint should
> not be allowed to be mounted multiple times?  That is very much
> allowed and desired in many cases.
> 
> 
> On 7/26/05, busybox at rich-paul.net <busybox at rich-paul.net> wrote:
> > 
> > I use Gentoo Linux, and have been playing with the bootstrap process a
> > bit ... several times, when I've been experimenting or tweaking, I've
> > accidentally left proc mounted and exec'd init.  When Gentoo's boot
> > scripts fail to mount proc, it results in an unceremonious reboot.  None
> > of this, of course is your problem.
> > 
> > But then today, I noticed that I had a tmpfs mounted on /dev, and a
> > second tmpfs mounted on top of it.
> > 
> > This made me wonder if there would be any value to adding a switch
> > that would request an idempotent semantic from mount, e.g.
> >         if (already_mounted())
> >                 exit(0);
> >         else if (then_mount_the_silly_thing())
> >                 exit(0);
> >         else
> >                 exit(1);
> > 
> > It seems much cleaner to me than either adding logic to the init scripts
> > to test before running mount or grepping mount's error message to try to
> > determine why it failed.
> > 
> > But there is one drawback to the scheme:  util-linux doesn't have it.
> > Not a problem for me, I haven't found any situation that busy-mount
> > can't handle, but I figured I should check before submitting an
> > incompatable feature.
> > 
> > In a similar vein, I've noticed that busy-mount doesn't grok --move or
> > --bind, and util-mount doesn't grok -omove or -obind.  So I thought I
> > might clean up my Kompatablity Karma by explaining --move and --bind to
> > busy-mount.
> > 
> > Anyway, let me know what you think.
> > 
> > Regards,
> > Rich
> > 
> > 
> > 
> > 
> > --
> > Don't blame me, I voted libertarian.
> > http://radical-centrist.blogspot.com
> > 
> > 
> > _______________________________________________
> > busybox mailing list
> > busybox at mail.busybox.net
> > http://busybox.net/mailman/listinfo/busybox
> > 
> > 
> >

-- 
Don't blame me, I voted libertarian.
http://radical-centrist.blogspot.com



More information about the busybox mailing list