diff -Naur busybox-1.13.3.orig/util-linux/umount.c busybox-1.13.3/util-linux/umount.c --- busybox-1.13.3.orig/util-linux/umount.c 2009-02-26 12:47:43.000000000 +0100 +++ busybox-1.13.3/util-linux/umount.c 2009-06-04 02:31:59.000000000 +0200 @@ -39,7 +39,10 @@ int umount_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int umount_main(int argc UNUSED_PARAM, char **argv) { +#if defined(__linux__) + // from the comment above, doForce is highly Linux specific int doForce; +#endif char *const path = xmalloc(PATH_MAX + 2); /* to save stack */ struct mntent me; FILE *fp; @@ -55,7 +58,9 @@ opt = getopt32(argv, OPTION_STRING, &fstype); //argc -= optind; argv += optind; +#if defined(__linux__) doForce = MAX((opt & OPT_FORCE), (opt & OPT_LAZY)); +#endif /* Get a list of mount points from mtab. We read them all in now mostly * for umount -a (so we don't have to worry about the list changing while @@ -118,11 +123,17 @@ if (m) zapit = m->dir; // Let's ask the thing nicely to unmount. +#if defined(__FreeBSD_kernel__) + curstat = unmount(zapit, 0); +#else curstat = umount(zapit); +#endif +#if defined(__linux__) // Force the unmount, if necessary. if (curstat && doForce) curstat = umount2(zapit, doForce); +#endif // If still can't umount, maybe remount read-only? if (curstat) { @@ -130,7 +141,11 @@ // Note! Even if we succeed here, later we should not // free loop device or erase mtab entry! const char *msg = "%s busy - remounted read-only"; +#if defined(__FreeBSD_kernel__) + curstat = verbose_mount(m->device, zapit, NULL, MS_REMOUNT|MS_RDONLY, NULL); +#else curstat = mount(m->device, zapit, NULL, MS_REMOUNT|MS_RDONLY, NULL); +#endif if (curstat) { msg = "can't remount %s read-only"; status = EXIT_FAILURE; @@ -138,7 +153,11 @@ bb_error_msg(msg, m->device); } else { status = EXIT_FAILURE; +#if defined(__linux__) bb_perror_msg("can't %sumount %s", (doForce ? "forcibly " : ""), zapit); +#else + bb_perror_msg("can't %sumount %s", "", zapit); +#endif } } else { // De-allocate the loop device. This ioctl should be ignored on