]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
mount: (old) remove hybrid libmount code
authorKarel Zak <kzak@redhat.com>
Wed, 30 May 2012 15:36:44 +0000 (17:36 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 26 Jun 2012 18:48:22 +0000 (20:48 +0200)
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>
configure.ac
mount-deprecated/Makemodule.am
mount-deprecated/fstab.c
mount-deprecated/fstab.h
mount-deprecated/mount.c
mount-deprecated/umount.c

index 24b30bf66ec716e76e5daec1afb9d4067e46fc0f..adb5758e535bcbc3de53d6fda511e224bc4141cd 100644 (file)
@@ -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
index 7e71a5f518749404d3f81f46e9713a99d8ecd87f..d3205f504ccbf72e3bf2ab20b41481cf4edb325c 100644 (file)
@@ -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
index 54b6ed132f3075149a52e03d7bad4e3f96f5b956..47159a3a9e8e55608f0984397e3f5d9f88ad7d1d 100644 (file)
@@ -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() {
index bbef33b51039ec55fcf0e25a6dab7d131cc8d42b..4c01fd41c2163d499fa5f1b67060d3c315d746e2 100644 (file)
@@ -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);
index 2e9b2a4e3c48a6fa993dec168f923cfa48b50b7b..e3e1bfe4660f200a51ef950c86b266845291fc2d 100644 (file)
@@ -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;
 
index d3375df83fda7b0d374577bbbdb442090fb3ba9c..3820c67f2a56fc3319bb9b44133c7155202ce7e9 100644 (file)
@@ -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)