summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2012-05-30 17:36:44 +0200
committerKarel Zak2012-06-26 20:48:22 +0200
commit14a0cafb928e4292a750e9dc69b10072c79d84c1 (patch)
tree26c9f947d8365278ec588375c86e483cb7dbdb27
parentbuild-sys: default to new sys-utils/mount.c, add --enable-deprecated-mount (diff)
downloadkernel-qcow2-util-linux-14a0cafb928e4292a750e9dc69b10072c79d84c1.tar.gz
kernel-qcow2-util-linux-14a0cafb928e4292a750e9dc69b10072c79d84c1.tar.xz
kernel-qcow2-util-linux-14a0cafb928e4292a750e9dc69b10072c79d84c1.zip
mount: (old) remove hybrid libmount code
The hybrid version with old mount and new mtab management from libmount is not more supported. Only two versions are supported: 1/ old mount in mount-deprecated/, --enable-deprecated-mount 2/ new sys-utils/mount.c, enabled by default Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--configure.ac13
-rw-r--r--mount-deprecated/Makemodule.am17
-rw-r--r--mount-deprecated/fstab.c47
-rw-r--r--mount-deprecated/fstab.h5
-rw-r--r--mount-deprecated/mount.c151
-rw-r--r--mount-deprecated/umount.c11
6 files changed, 2 insertions, 242 deletions
diff --git a/configure.ac b/configure.ac
index 24b30bf66..adb5758e5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -739,19 +739,6 @@ UL_REQUIRES_LINUX([losetup])
AM_CONDITIONAL(BUILD_LOSETUP, test "x$build_losetup" = xyes)
-AC_ARG_ENABLE([libmount-mount],
- AS_HELP_STRING([--enable-libmount-mount], [link old mount(8) with libmount]),
- [], enable_libmount_mount=no
-)
-UL_BUILD_INIT([libmount_mount])
-UL_REQUIRES_BUILD([libmount_mount], [mount])
-UL_REQUIRES_BUILD([libmount_mount], [libmount])
-if test "x$build_libmount_mount" = xyes; then
- AC_DEFINE(HAVE_LIBMOUNT_MOUNT, 1, [use libmount for mount(8)])
-fi
-AM_CONDITIONAL(BUILD_LIBMOUNT_MOUNT, test "x$build_libmount_mount" = xyes)
-
-
AC_ARG_ENABLE([mount],
AS_HELP_STRING([--disable-mount], [do not build mount(8) and umount(8)]),
[], enable_mount=check
diff --git a/mount-deprecated/Makemodule.am b/mount-deprecated/Makemodule.am
index 7e71a5f51..d3205f504 100644
--- a/mount-deprecated/Makemodule.am
+++ b/mount-deprecated/Makemodule.am
@@ -71,23 +71,6 @@ mount_LDADD += $(SELINUX_LIBS)
mount_static_LDADD += $(SELINUX_LIBS_STATIC)
endif
-# hybrid mount -- old mount + new code from libmount for mtab management
-#
-if BUILD_LIBMOUNT_MOUNT
-mount_LDADD += libmount.la
-mount_CFLAGS += $(AM_CFLAGS) -I$(ul_libmount_incdir)
-umount_LDADD += libmount.la
-umount_CFLAGS += $(AM_CFLAGS) -I$(ul_libmount_incdir)
-if HAVE_STATIC_MOUNT
-mount_static_LDADD += libmount.la
-mount_static_CFLAGS += -I$(ul_libmount_incdir)
-endif
-if HAVE_STATIC_UMOUNT
-umount_static_LDADD += libmount.la
-umount_static_CFLAGS += -I$(ul_libmount_incdir)
-endif
-endif
-
if MAKEINSTALL_DO_SETUID
install-exec-hook-mount:
chmod 4755 $(DESTDIR)$(bindir)/mount
diff --git a/mount-deprecated/fstab.c b/mount-deprecated/fstab.c
index 54b6ed132..47159a3a9 100644
--- a/mount-deprecated/fstab.c
+++ b/mount-deprecated/fstab.c
@@ -149,52 +149,6 @@ read_mntentchn(mntFILE *mfp, const char *fnam, struct mntentchn *mc0) {
my_endmntent(mfp);
}
-#ifdef HAVE_LIBMOUNT_MOUNT
-
-#define USE_UNSTABLE_LIBMOUNT_API
-#include <libmount.h> /* libmount */
-
-static void read_mounttable()
-{
- struct mntentchn *mc0 = &mounttable, *mc = mc0;
- struct libmnt_table *tb = mnt_new_table();
- struct libmnt_iter *itr = mnt_new_iter(MNT_ITER_FORWARD);
- struct libmnt_fs *fs;
-
- got_mtab = 1;
- mc->nxt = mc->prev = NULL;
-
- if (!tb || !itr)
- goto err;
- if (mnt_table_parse_mtab(tb, NULL))
- goto err;
-
- while(mnt_table_next_fs(tb, itr, &fs) == 0) {
- const char *type = mnt_fs_get_fstype(fs);
- struct my_mntent *mnt = NULL;
-
- if (type && strcmp(type, MNTTYPE_IGNORE) == 0)
- continue;
- if (mnt_fs_to_mntent(fs, (struct mntent **) &mnt))
- goto err;
- mc->nxt = xmalloc(sizeof(*mc));
- mc->nxt->prev = mc;
- mc = mc->nxt;
- mc->m = *mnt;
- mc->nxt = mc0;
- }
-
- mc0->prev = mc;
- return;
-err:
- error(_("warning: failed to read mtab"));
- mnt_free_table(tb);
- mnt_free_iter(itr);
- mc->nxt = mc->prev = NULL;
-}
-
-#else /* !HAVE_LIBMOUNT_MOUNT */
-
/*
* Read /etc/mtab. If that fails, try /proc/mounts.
* This produces a linked list. The list head mounttable is a dummy.
@@ -226,7 +180,6 @@ read_mounttable() {
}
read_mntentchn(mfp, fnam, mc);
}
-#endif /* HAVE_LIBMOUNT_MOUNT */
static void
read_fstab() {
diff --git a/mount-deprecated/fstab.h b/mount-deprecated/fstab.h
index bbef33b51..4c01fd41c 100644
--- a/mount-deprecated/fstab.h
+++ b/mount-deprecated/fstab.h
@@ -3,11 +3,6 @@
#include "mount_mntent.h"
-#ifdef HAVE_LIBMOUNT_MOUNT
-#define USE_UNSTABLE_LIBMOUNT_API
-#include <libmount.h>
-#endif
-
int mtab_is_writable(void);
int mtab_is_a_symlink(void);
int mtab_does_not_exist(void);
diff --git a/mount-deprecated/mount.c b/mount-deprecated/mount.c
index 2e9b2a4e3..e3e1bfe46 100644
--- a/mount-deprecated/mount.c
+++ b/mount-deprecated/mount.c
@@ -88,15 +88,6 @@ static int restricted = 1;
/* Contains the fd to read the passphrase from, if any. */
static int pfd = -1;
-#ifdef HAVE_LIBMOUNT_MOUNT
-static struct libmnt_update *mtab_update;
-static char *mtab_opts;
-static unsigned long mtab_flags;
-
-static void prepare_mtab_entry(const char *spec, const char *node,
- const char *type, const char *opts, unsigned long flags);
-#endif
-
/* mount(2) options */
struct mountargs {
const char *spec;
@@ -761,10 +752,6 @@ do_mount (struct mountargs *args, int *special, int *status) {
*special = 1;
ret = 0;
} else {
-#ifdef HAVE_LIBMOUNT_MOUNT
- prepare_mtab_entry(args->spec, args->node, args->type,
- mtab_opts, mtab_flags);
-#endif
ret = do_mount_syscall(args);
}
if (ret == 0)
@@ -1426,87 +1413,6 @@ err:
}
-#ifdef HAVE_LIBMOUNT_MOUNT
-static void
-verbose_mount_info(const char *spec, const char *node, const char *type,
- const char *opts)
-{
- struct my_mntent mnt;
-
- mnt.mnt_fsname = is_pseudo_fs(type) ? spec : canonicalize(spec);
- mnt.mnt_dir = canonicalize (node);
- mnt.mnt_type = type;
- mnt.mnt_opts = opts;
-
- print_one (&mnt);
-
- if (spec != mnt.mnt_fsname)
- my_free(mnt.mnt_fsname);
- my_free(mnt.mnt_dir);
-}
-
-static void
-prepare_mtab_entry(const char *spec, const char *node, const char *type,
- const char *opts, unsigned long flags)
-{
- struct libmnt_fs *fs = mnt_new_fs();
- int rc = -1;
-
- if (!mtab_update)
- mtab_update = mnt_new_update();
-
- if (mtab_update && fs) {
- const char *cn_spec = is_pseudo_fs(type) ? spec : canonicalize(spec);
- const char *cn_node = canonicalize(node);
-
- mnt_fs_set_source(fs, cn_spec);
- mnt_fs_set_target(fs, cn_node);
- mnt_fs_set_fstype(fs, type);
- mnt_fs_set_options(fs, opts);
-
- rc = mnt_update_set_fs(mtab_update, flags, NULL, fs);
-
- if (spec != cn_spec)
- my_free(cn_spec);
- my_free(cn_node);
- }
-
- mnt_free_fs(fs);
-
- if (rc) {
- mnt_free_update(mtab_update);
- mtab_update = NULL;
- }
-}
-
-static void update_mtab_entry(int flags)
-{
- unsigned long fl;
-
- if (!mtab_update)
- return;
-
- fl = mnt_update_get_mflags(mtab_update);
-
- if ((flags & MS_RDONLY) != (fl & MS_RDONLY))
- mnt_update_force_rdonly(mtab_update, flags & MS_RDONLY);
-
- if (!nomtab) {
- if (mtab_does_not_exist()) {
- if (verbose > 1)
- printf(_("mount: no %s found - creating it..\n"),
- _PATH_MOUNTED);
- create_mtab ();
- }
-
- mnt_update_table(mtab_update, NULL);
- }
-
- mnt_free_update(mtab_update);
- mtab_update = NULL;
-}
-
-#else /*!HAVE_LIBMOUNT_MOUNT */
static void
update_mtab_entry(const char *spec, const char *node, const char *type,
const char *opts, int flags, int freq, int pass) {
@@ -1543,7 +1449,6 @@ update_mtab_entry(const char *spec, const char *node, const char *type,
my_free(mnt.mnt_fsname);
my_free(mnt.mnt_dir);
}
-#endif /* !HAVE_LIBMOUNT_MOUNT */
static void
set_pfd(char *s) {
@@ -1715,14 +1620,6 @@ try_mount_one (const char *spec0, const char *node0, const char *types0,
goto out;
}
-#ifdef HAVE_LIBMOUNT_MOUNT
- mtab_opts = fix_opts_string(flags & ~MS_NOMTAB, extra_opts, user, 0);
- mtab_flags = flags;
-
- if (fake)
- prepare_mtab_entry(spec, node, types, mtab_opts, mtab_flags);
-#endif
-
block_signals (SIG_BLOCK);
if (!fake) {
@@ -1764,11 +1661,6 @@ try_mount_one (const char *spec0, const char *node0, const char *types0,
const char *tp = types ? types : "unknown";
/* Mount succeeded, report this (if verbose) and write mtab entry. */
-#ifdef HAVE_LIBMOUNT_MOUNT
- update_mtab_entry(flags);
- if (verbose)
- verbose_mount_info(loop ? loopfile : spec, node, tp, mo);
-#else
if (!(mounttype & MS_PROPAGATION))
update_mtab_entry(loop ? loopfile : spec,
node,
@@ -1777,7 +1669,7 @@ try_mount_one (const char *spec0, const char *node0, const char *types0,
flags,
freq,
pass);
-#endif
+
block_signals (SIG_UNBLOCK);
free(mo);
@@ -2112,50 +2004,14 @@ mount_one (const char *spec, const char *node, const char *types,
return try_mount_one (spec, node, types, opts, freq, pass, 0);
}
-#ifdef HAVE_LIBMOUNT_MOUNT
-static struct libmnt_table *minfo; /* parsed mountinfo file */
-
-/* Check if an fsname/dir pair was already in the old mtab. */
-static int
-mounted (const char *spec0, const char *node0, struct mntentchn *fstab_mc) {
-#else
static int
mounted (const char *spec0, const char *node0,
struct mntentchn *fstab_mc __attribute__((__unused__))) {
-#endif
+
struct mntentchn *mc, *mc0;
const char *spec, *node;
int ret = 0;
-#ifdef HAVE_LIBMOUNT_MOUNT
- /*
- * Use libmount to check for already mounted bind mounts on systems
- * without mtab.
- */
- if (fstab_mc && fstab_mc->m.mnt_opts &&
- mtab_is_a_symlink() && strstr(fstab_mc->m.mnt_opts, "bind")) {
-
- struct libmnt_fs *fs = mnt_new_fs();
- int rc = fs ? 0 : -1;
-
- if (!rc)
- rc = mnt_fs_set_fstype(fs, fstab_mc->m.mnt_type);
- if (!rc)
- rc = mnt_fs_set_source(fs, fstab_mc->m.mnt_fsname);
- if (!rc)
- rc = mnt_fs_set_target(fs, fstab_mc->m.mnt_dir);
- if (!rc)
- rc = mnt_fs_set_options(fs, fstab_mc->m.mnt_opts);
- if (!rc && !minfo)
- minfo = mnt_new_table_from_file("/proc/self/mountinfo");
- if (!rc && minfo)
- rc = mnt_table_is_fs_mounted(minfo, fs);
-
- mnt_free_fs(fs);
- if (rc == 1)
- return 1;
- }
-#endif
/* Handle possible UUID= and LABEL= in spec */
spec = spec_to_devname(spec0);
if (!spec)
@@ -2693,9 +2549,6 @@ main(int argc, char *argv[]) {
printf("mount: eUID: %u\n", geteuid());
}
-#ifdef HAVE_LIBMOUNT_MOUNT
- mnt_init_debug(0);
-#endif
argc -= optind;
argv += optind;
diff --git a/mount-deprecated/umount.c b/mount-deprecated/umount.c
index d3375df83..3820c67f2 100644
--- a/mount-deprecated/umount.c
+++ b/mount-deprecated/umount.c
@@ -422,16 +422,8 @@ umount_one (const char *spec, const char *node, const char *type,
writemtab:
if (!nomtab &&
(umnt_err == 0 || umnt_err == EINVAL || umnt_err == ENOENT)) {
-#ifdef HAVE_LIBMOUNT_MOUNT
- struct libmnt_update *upd = mnt_new_update();
- if (upd && !mnt_update_set_fs(upd, 0, node, NULL))
- mnt_update_table(upd, NULL);
-
- mnt_free_update(upd);
-#else
update_mtab (node, NULL);
-#endif
}
block_signals(SIG_UNBLOCK);
@@ -861,9 +853,6 @@ main (int argc, char *argv[]) {
atexit(unlock_mtab);
-#ifdef HAVE_LIBMOUNT_MOUNT
- mnt_init_debug(0);
-#endif
if (all) {
/* nodev stuff: sysfs, usbfs, oprofilefs, ... */
if (types == NULL)