diff -Nur util-linux-2.12pre/configure util-linux-2.12pre.org/configure --- util-linux-2.12pre/configure.fumount 2003-07-05 13:06:55.000000000 -0700 +++ util-linux-2.12pre/configure 2004-10-20 15:17:31.914627387 -0700 @@ -70,6 +70,13 @@ rm -f conftest.c conftest +for arg in "$@" +do + if [ "$arg" = "--with-fumount" ]; then + echo "#define HAVE_FUMOUNT" >> defines.h + fi +done + # # Old gcc wants options like -m486, but gcc 3.0 says # `-m486' is deprecated. Use `-march=i486' or `-mcpu=i486' instead. diff -Nur util-linux-2.12pre/mount/umount.c util-linux-2.12pre.org/mount/umount.c --- util-linux-2.12pre/mount/umount.c 2002-10-31 17:00:50.000000000 -0800 +++ util-linux-2.12pre.org/mount/umount.c 2004-08-12 22:59:38.967943624 -0700 @@ -45,6 +45,10 @@ #include "fstab.h" #include "env.h" #include "nls.h" +/* for vforce unmount */ +#ifdef HAVE_FUMOUNT +#define MNT_FFORCE 0x00000008 /* Really forcibily umount - no prisoners */ +#endif #ifdef HAVE_NFS #include @@ -94,6 +98,11 @@ /* Nonzero for force umount (-f). There is kernel support since 2.1.116. */ int force = 0; +#ifdef HAVE_FUMOUNT +/* Nonzero for vforce umount (-F). */ +int vforce = 0; +#endif + /* Nonzero for lazy umount (-l). There is kernel support since 2.4.11. */ int lazy = 0; @@ -275,8 +284,22 @@ umnt_err = errno; goto writemtab; } - - if (force) { /* only supported for NFS */ + + #ifdef HAVE_FUMOUNT + if (vforce) { + res = umount2 (node, MNT_FFORCE); + if (res == -1) { + perror("umount2"); + if (errno == ENOSYS) { + if (verbose) + printf(_("no umount2, trying umount...\n")); + res = umount (node); + } + } + } + else + #endif + if (force) { /* only supported for NFS */ res = umount2 (node, MNT_FORCE); if (res == -1) { perror("umount2"); @@ -441,6 +464,9 @@ { { "all", 0, 0, 'a' }, { "force", 0, 0, 'f' }, +#ifdef HAVE_FUMOUNT + { "vforce", 0, 0, 'F' }, +#endif { "help", 0, 0, 'h' }, { "no-mtab", 0, 0, 'n' }, { "test-opts", 1, 0, 'O' }, @@ -454,9 +480,15 @@ static void usage (FILE *fp, int n) { + #ifdef HAVE_FUMOUNT + fprintf (fp, _("Usage: umount [-hV]\n" + " umount -a [-f] [-F] [-r] [-n] [-v] [-t vfstypes] [-O opts]\n" + " umount [-f] [-F] [-r] [-n] [-v] special | node...\n")); + #else fprintf (fp, _("Usage: umount [-hV]\n" " umount -a [-f] [-r] [-n] [-v] [-t vfstypes] [-O opts]\n" " umount [-f] [-r] [-n] [-v] special | node...\n")); + #endif exit (n); } @@ -619,8 +651,13 @@ umask(033); + #ifdef HAVE_FUMOUNT + while ((c = getopt_long (argc, argv, "adfFhlnrt:O:vV", + longopts, NULL)) != -1) + #else while ((c = getopt_long (argc, argv, "adfhlnrt:O:vV", longopts, NULL)) != -1) + #endif switch (c) { case 'a': /* umount everything */ ++all; @@ -632,6 +669,11 @@ case 'f': /* force umount */ ++force; break; + #ifdef HAVE_FUMOUNT + case 'F': /* VFS level force umount */ + ++vforce; + break; + #endif case 'h': /* help */ usage (stdout, 0); break; @@ -665,8 +707,13 @@ if (getuid () != geteuid ()) { suid = 1; - if (all || types || nomtab || force) + #ifdef HAVE_FUMOUNT + if (all || types || nomtab || force || vforce) + die (2, _("umount: only root can do that")); + #else + if (all || types || nomtab || force ) die (2, _("umount: only root can do that")); + #endif } argc -= optind;