]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: add fallbacks for old systems without umount2() syscall
authorKarel Zak <kzak@redhat.com>
Fri, 11 Feb 2011 09:45:09 +0000 (10:45 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 11 Feb 2011 09:45:09 +0000 (10:45 +0100)
Reported-by: Peter Breitenlohner <peb@mppmu.mpg.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
shlibs/mount/src/context_umount.c

index bd9be695601d935e37fa1c997dd7037bc6aa72b9..1187a87cd71246d5d4f22df9f1ee05a4fb65ffea 100644 (file)
 #include "strutils.h"
 #include "mountP.h"
 
+#if defined(MNT_FORCE)
+/* Interesting ... it seems libc knows about MNT_FORCE and presumably
+   about umount2 as well -- need not do anything */
+#else /* MNT_FORCE */
+/* Does the present kernel source know about umount2? */
+# include <linux/unistd.h>
+# ifdef __NR_umount2
+static int umount2(const char *path, int flags);
+_syscall2(int, umount2, const char *, path, int, flags);
+# else /* __NR_umount2 */
+static int
+umount2(const char *path, int flags) {
+       fprintf(stderr, _("umount: compiled without support for -f\n"));
+       errno = ENOSYS;
+       return -1;
+}
+#endif /* __NR_umount2 */
+# if !defined(MNT_FORCE)
+# define MNT_FORCE 1
+#endif
+
+#endif /* MNT_FORCE */
+
+#if !defined(MNT_DETACH)
+#define MNT_DETACH 2
+#endif
+
+
 static int lookup_umount_fs(struct libmnt_context *cxt)
 {
        int rc;