umount hangs with initramfs as root

Chuck Meade chuckmeade at mindspring.com
Wed Mar 22 22:51:13 UTC 2006


> Inability to umount is is a feature.  The hang when attempting to umount it is 
> a bug.  (The attempt should be ignored by the kernel, and is in current 
> kernels.  Just like an attempt to send a kill signal to init.)

Thanks for the info, Rob.  I know this is Busybox 1.0.0 we are talking
about here, but for the sake of the archives, and anyone else who may
stumble across this, I found a bug in util-linux/umount.c, function
mtab_getinfo().  Again, this is an *old version* of Busybox.  The
latest snapshot has different umount logic.

Take a look at this function.  Consider the line I marked with the
arrow.  If you ever reach this line, you are in an infinite loop.
The "continue" skips past the "cur = cur->next" at the bottom, so
cur never changes, and the while loop becomes infinite.  When I rebooted,
which umounted the rootfs, I hit this line and spun forever.

static char *mtab_getinfo(const char *match, const char which)
{
	struct _mtab_entry_t *cur = mtab_cache;

	while (cur) {
		if (strcmp(cur->mountpt, match) == 0 ||
			strcmp(cur->device, match) == 0) {
			if (which == MTAB_GETMOUNTPT) {
				return cur->mountpt;
			} else {
#if !defined CONFIG_FEATURE_MTAB_SUPPORT
				if (strcmp(cur->device, "rootfs") == 0) {
--------------->			continue;
				} else if (strcmp(cur->device, "/dev/root") == 0) {
					/* Adjusts device to be the real root device,
					 * or leaves device alone if it can't find it */
					cur->device = find_real_root_device_name();
				}
#endif
				return cur->device;
			}
		}
		cur = cur->next;
	}
	return NULL;
}

The patch I added advances the cur pointer before calling continue:

                        .....
                        if (strcmp(cur->device, "rootfs") == 0) {
                            cur = cur->next;
                            continue;
                        ....

This works fine.  I know this patch could also be accomplished with a 'goto'
to get down to the existing "cur = cur-> next" statement, or by recoding the
loop conditional logic.

I have not tested the functionality of umounting an initramfs with the
latest Busybox snapshot, or a 2.6.16 kernel, yet.

Just want to thank you again for your help in finding this, especially as
busy as you are right now.

Best Regards,
Chuck





More information about the busybox mailing list