summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util-linux/umount.c47
1 files changed, 7 insertions, 40 deletions
diff --git a/util-linux/umount.c b/util-linux/umount.c
index 78c6038..5597d9e 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -9,39 +9,10 @@
*/
#include <mntent.h>
#include <sys/mount.h>
-/* Make sure we have all the new mount flags we actually try to use. */
-#ifndef MS_BIND
-# define MS_BIND (1 << 12)
-#endif
-#ifndef MS_MOVE
-# define MS_MOVE (1 << 13)
-#endif
-#ifndef MS_RECURSIVE
-# define MS_RECURSIVE (1 << 14)
-#endif
-#ifndef MS_SILENT
-# define MS_SILENT (1 << 15)
-#endif
-/* The shared subtree stuff, which went in around 2.6.15. */
-#ifndef MS_UNBINDABLE
-# define MS_UNBINDABLE (1 << 17)
-#endif
-#ifndef MS_PRIVATE
-# define MS_PRIVATE (1 << 18)
-#endif
-#ifndef MS_SLAVE
-# define MS_SLAVE (1 << 19)
-#endif
-#ifndef MS_SHARED
-# define MS_SHARED (1 << 20)
-#endif
-#ifndef MS_RELATIME
-# define MS_RELATIME (1 << 21)
-#endif
#include "libbb.h"
-
#if defined(__dietlibc__)
+// TODO: This does not belong here.
/* 16.12.2006, Sampo Kellomaki (sampo@iki.fi)
* dietlibc-0.30 does not have implementation of getmntent_r() */
static struct mntent *getmntent_r(FILE* stream, struct mntent* result,
@@ -54,23 +25,17 @@ static struct mntent *getmntent_r(FILE* stream, struct mntent* result,
/* ignored: -v -d -t -i */
#define OPTION_STRING "fldnra" "vdt:i"
-#define OPT_FORCE (1 << 0)
-#define OPT_LAZY (1 << 1)
+#define OPT_FORCE (1 << 0) // Same as MNT_FORCE
+#define OPT_LAZY (1 << 1) // Same as MNT_DETACH
#define OPT_FREELOOP (1 << 2)
#define OPT_NO_MTAB (1 << 3)
#define OPT_REMOUNT (1 << 4)
#define OPT_ALL (ENABLE_FEATURE_UMOUNT_ALL ? (1 << 5) : 0)
-// These constants from linux/fs.h must match OPT_FORCE and OPT_LAZY,
-// otherwise "doForce" trick below won't work!
-//#define MNT_FORCE 0x00000001 /* Attempt to forcibly umount */
-//#define MNT_DETACH 0x00000002 /* Just detach from the tree */
-
int umount_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int umount_main(int argc UNUSED_PARAM, char **argv)
{
int doForce;
- char *const buf = xmalloc(4096); /* reducing stack usage */
struct mntent me;
FILE *fp;
char *fstype = NULL;
@@ -85,6 +50,9 @@ int umount_main(int argc UNUSED_PARAM, char **argv)
opt = getopt32(argv, OPTION_STRING, &fstype);
//argc -= optind;
argv += optind;
+
+ // MNT_FORCE and MNT_DETACH (from linux/fs.h) must match
+ // OPT_FORCE and OPT_LAZY, otherwise this trick won't work:
doForce = MAX((opt & OPT_FORCE), (opt & OPT_LAZY));
/* Get a list of mount points from mtab. We read them all in now mostly
@@ -101,7 +69,7 @@ int umount_main(int argc UNUSED_PARAM, char **argv)
if (opt & OPT_ALL)
bb_error_msg_and_die("can't open '%s'", bb_path_mtab_file);
} else {
- while (getmntent_r(fp, &me, buf, 4096)) {
+ while (getmntent_r(fp, &me, bb_common_bufsiz1, sizeof(bb_common_bufsiz1))) {
/* Match fstype if passed */
if (!match_fstype(&me, fstype))
continue;
@@ -203,7 +171,6 @@ int umount_main(int argc UNUSED_PARAM, char **argv)
free(mtl);
mtl = m;
}
- free(buf);
}
return status;