autofs-5.0.6 - remove move mount code and configure option From: Ian Kent The code to construct a multi-mount tree in a temporary location and then move it into place is obsolete when using a kernel which includes the vfs-automount infrastructure. It is incompatible with systemd and cannot be used if systemd is being used. So it's being removed. --- autofs.spec | 2 - configure | 18 ----- configure.in | 10 --- daemon/automount.c | 5 - include/config.h.in | 3 - modules/parse_sun.c | 195 ++------------------------------------------------- 6 files changed, 7 insertions(+), 226 deletions(-) diff --git a/autofs.spec b/autofs.spec index a73fefb..0441b44 100644 --- a/autofs.spec +++ b/autofs.spec @@ -74,7 +74,7 @@ echo %{version}-%{release} > .version %endif %build -CFLAGS="$RPM_OPT_FLAGS -Wall" ./configure --libdir=%{_libdir} --disable-mount-locking --enable-ignore-busy --with-libtirpc --disable-mount-move %{?systemd_configure_arg:} +CFLAGS="$RPM_OPT_FLAGS -Wall" ./configure --libdir=%{_libdir} --disable-mount-locking --enable-ignore-busy --with-libtirpc %{?systemd_configure_arg:} CFLAGS="$RPM_OPT_FLAGS -Wall" make initdir=/etc/rc.d/init.d DONTSTRIP=1 %install diff --git a/configure b/configure index 9844a59..fbd9967 100755 --- a/configure +++ b/configure @@ -719,7 +719,6 @@ with_openldap with_sasl enable_ext_env enable_mount_locking -enable_mount_move enable_forced_shutdown enable_ignore_busy ' @@ -1343,7 +1342,6 @@ Optional Features: --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-ext-env disable search in environment for substitution variable --disable-mount-locking disable use of locking when spawning mount command - --disable-mount-move disable use of mount move when when preparing tree of mounts --enable-force-shutdown enable USR1 signal to force unlink umount of any busy mounts during shutdown --enable-ignore-busy enable exit without umounting busy mounts during @@ -5448,22 +5446,6 @@ $as_echo "#define ENABLE_MOUNT_LOCKING 1" >>confdefs.h fi # -# Disable use of mount move -# -# Check whether --enable-mount-move was given. -if test "${enable_mount_move+set}" = set; then : - enableval=$enable_mount_move; -else - enableval=yes -fi - -if test x$enable_mount_move = xyes -o x$enableval = xyes; then - -$as_echo "#define ENABLE_MOUNT_MOVE 1" >>confdefs.h - -fi - -# # Enable forced shutdown on USR1 signal (unlink umounts all mounts). # # Check whether --enable-forced-shutdown was given. diff --git a/configure.in b/configure.in index 5477508..5740b0d 100644 --- a/configure.in +++ b/configure.in @@ -338,16 +338,6 @@ if test x$enable_mount_locking = xyes -o x$enableval = xyes; then fi # -# Disable use of mount move -# -AC_ARG_ENABLE(mount-move, -[ --disable-mount-move disable use of mount move when when preparing tree of mounts],, - enableval=yes) -if test x$enable_mount_move = xyes -o x$enableval = xyes; then - AC_DEFINE(ENABLE_MOUNT_MOVE, 1, [Disable use of mount move when preparing tree of mounts]) -fi - -# # Enable forced shutdown on USR1 signal (unlink umounts all mounts). # AC_ARG_ENABLE(forced-shutdown, diff --git a/daemon/automount.c b/daemon/automount.c index 7dea73b..e56f9e1 100644 --- a/daemon/automount.c +++ b/daemon/automount.c @@ -1753,11 +1753,6 @@ static void show_build_info(void) count = 22; #endif -#ifndef ENABLE_MOUNT_MOVE - printf("DISABLE_MOUNT_MOVE "); - count = count + 19; -#endif - #ifdef ENABLE_FORCED_SHUTDOWN printf("ENABLE_FORCED_SHUTDOWN "); count = count + 23; diff --git a/include/config.h.in b/include/config.h.in index f79d579..9bdf98a 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -12,9 +12,6 @@ /* Disable use of locking when spawning mount command */ #undef ENABLE_MOUNT_LOCKING -/* Disable use of mount move when preparing tree of mounts */ -#undef ENABLE_MOUNT_MOVE - /* define if you have E2FSCK */ #undef HAVE_E2FSCK diff --git a/modules/parse_sun.c b/modules/parse_sun.c index 8b0f8b6..e2c36ad 100644 --- a/modules/parse_sun.c +++ b/modules/parse_sun.c @@ -37,10 +37,6 @@ #define MODPREFIX "parse(sun): " -#define MOUNT_MOVE_NONE 0x00 -#define MOUNT_MOVE_AUTOFS 0x01 -#define MOUNT_MOVE_OTHER 0x02 - int parse_version = AUTOFS_PARSE_VERSION; /* Required by protocol */ static struct mount_mod *mount_nfs = NULL; @@ -1047,86 +1043,6 @@ static int parse_mapent(const char *ent, char *g_options, char **options, char * return (p - ent); } -#ifdef ENABLE_MOUNT_MOVE -static int move_mount(struct autofs_point *ap, - const char *mm_tmp_root, const char *mm_root, - unsigned int move) -{ - char buf[MAX_ERR_BUF]; - int err; - - if (move == MOUNT_MOVE_NONE) - return 1; - - err = mkdir_path(mm_root, 0555); - if (err < 0 && errno != EEXIST) { - error(ap->logopt, - "failed to create move target mount point %s", mm_root); - return 0; - } - - if (move == MOUNT_MOVE_AUTOFS) - err = mount(mm_tmp_root, mm_root, NULL, MS_MOVE, NULL); - else - err = spawn_mount(ap->logopt, - "--move", mm_tmp_root, mm_root, NULL); - if (err) { - char *estr = strerror_r(errno, buf, MAX_ERR_BUF); - error(ap->logopt, - "failed to move mount from %s to %s: %s", - mm_tmp_root, mm_root, estr); - return 0; - } - - debug(ap->logopt, - "moved mount tree from %s to %s", mm_tmp_root, mm_root); - - return 1; -} -#endif - -static void cleanup_multi_root(struct autofs_point *ap, const char *root, - const char *path, unsigned int move) -{ - if (move == MOUNT_MOVE_NONE) - return; - - if (move == MOUNT_MOVE_OTHER) - spawn_umount(ap->logopt, root, NULL); - else { - struct ioctl_ops *ops = get_ioctl_ops(); - struct autofs_point *submount; - - mounts_mutex_lock(ap); - submount = __master_find_submount(ap, path); - if (!submount) { - mounts_mutex_unlock(ap); - return; - } - - alarm_delete(submount); - st_remove_tasks(submount); - st_wait_state(submount, ST_READY); - - submount->parent->submnt_count--; - list_del_init(&submount->mounts); - - ops->catatonic(submount->logopt, submount->ioctlfd); - - mounts_mutex_unlock(ap); - - if (submount->thid) { - pthread_cancel(submount->thid); - close_mount_fds(submount); - umount(root); - destroy_logpri_fifo(submount); - master_free_mapent_sources(submount->entry, 1); - master_free_mapent(ap->entry); - } - } - return; -} - static void cleanup_multi_triggers(struct autofs_point *ap, struct mapent *me, const char *root, int start, const char *base) @@ -1166,49 +1082,15 @@ static void cleanup_multi_triggers(struct autofs_point *ap, return; } -#ifdef ENABLE_MOUNT_MOVE -static int check_fstype_autofs_option(const char *options) -{ - char *tok, *tokbuf; - int found; - - /* - * Look for fstype= in options and return true if - * the last occurrence is fstype=autofs. - */ - found = 0; - tokbuf = alloca(strlen(options) + 2); - strcpy(tokbuf, options); - tok = strtok_r(tokbuf, ",", &tokbuf); - if (tok) { - do { - if (strstr(tok, "fstype=")) { - if (strstr(tok, "autofs")) - found = 1; - else - found = 0; - } - } while ((tok = strtok_r(NULL, ",", &tokbuf))); - } - - return found; -} -#endif - static int mount_subtree(struct autofs_point *ap, struct mapent *me, const char *name, char *loc, char *options, void *ctxt) { struct mapent *mm; struct mapent *ro; char *mm_root, *mm_base, *mm_key; - const char *mnt_root, *target; + const char *mnt_root; unsigned int mm_root_len, mnt_root_len; int start, ret = 0, rv; - unsigned int move = MOUNT_MOVE_NONE; -#ifdef ENABLE_MOUNT_MOVE - char t_dir[] = "/tmp/autoXXXXXX"; - char *mnt_tmp_root = NULL; -#endif rv = 0; @@ -1227,26 +1109,12 @@ static int mount_subtree(struct autofs_point *ap, struct mapent *me, } mm_root_len = strlen(mm_root); -#ifndef ENABLE_MOUNT_MOVE mnt_root = mm_root; mnt_root_len = mm_root_len; -#else - if (ap->flags & MOUNT_FLAG_REMOUNT) { - mnt_root = mm_root; - mnt_root_len = mm_root_len; - } else { - mnt_root = mkdtemp(t_dir); - if (!mnt_root) - return 1; - mnt_root_len = strlen(mnt_root); - mnt_tmp_root = (char *) mnt_root; - } -#endif if (me == me->multi) { /* name = NULL */ /* destination = mm_root */ - target = mm_root; mm_base = "/"; /* Mount root offset if it exists */ @@ -1263,18 +1131,10 @@ static int mount_subtree(struct autofs_point *ap, struct mapent *me, warn(ap->logopt, MODPREFIX "failed to parse root offset"); cache_delete_offset_list(me->mc, name); - goto error_out; + return 1; } ro_len = strlen(ro_loc); -#ifdef ENABLE_MOUNT_MOVE - if (!(ap->flags & MOUNT_FLAG_REMOUNT)) { - move = MOUNT_MOVE_OTHER; - if (check_fstype_autofs_option(myoptions)) - move = MOUNT_MOVE_AUTOFS; - } -#endif - tmp = alloca(mnt_root_len + 1); strcpy(tmp, mnt_root); tmp[mnt_root_len] = '/'; @@ -1293,44 +1153,25 @@ static int mount_subtree(struct autofs_point *ap, struct mapent *me, error(ap->logopt, MODPREFIX "failed to mount offset triggers"); cleanup_multi_triggers(ap, me, mnt_root, start, mm_base); - cleanup_multi_root(ap, mnt_root, mm_root, move); - goto error_out; + return 1; } } else if (rv <= 0) { -#ifdef ENABLE_MOUNT_MOVE - move = MOUNT_MOVE_NONE; -#endif ret = mount_multi_triggers(ap, me, mm_root, start, mm_base); if (ret == -1) { error(ap->logopt, MODPREFIX "failed to mount offset triggers"); cleanup_multi_triggers(ap, me, mm_root, start, mm_base); - goto error_out; + return 1; } } } else { int loclen = strlen(loc); int namelen = strlen(name); -#ifndef ENABLE_MOUNT_MOVE - /* - * When using move mount to mount offsets or direct mounts - * the base of the tree can be the base of the temporary - * mount point it needs to be the full path when not moving - * the mount after construction. - */ mnt_root = name; -#else - if (!(ap->flags & MOUNT_FLAG_REMOUNT)) { - move = MOUNT_MOVE_OTHER; - if (check_fstype_autofs_option(options)) - move = MOUNT_MOVE_AUTOFS; - } -#endif /* name = mm_root + mm_base */ /* destination = mm_root + mm_base = name */ - target = name; mm_base = &me->key[start]; rv = sun_mount(ap, mnt_root, name, namelen, loc, loclen, options, ctxt); @@ -1340,16 +1181,11 @@ static int mount_subtree(struct autofs_point *ap, struct mapent *me, error(ap->logopt, MODPREFIX "failed to mount offset triggers"); cleanup_multi_triggers(ap, me, mnt_root, start, mm_base); - cleanup_multi_root(ap, mnt_root, mm_root, move); - goto error_out; + return 1; } } else if (rv < 0) { char *mm_root_base = alloca(strlen(mm_root) + strlen(mm_base) + 1); -#ifdef ENABLE_MOUNT_MOVE - move = MOUNT_MOVE_NONE; -#endif - strcpy(mm_root_base, mm_root); strcat(mm_root_base, mm_base); @@ -1358,22 +1194,11 @@ static int mount_subtree(struct autofs_point *ap, struct mapent *me, error(ap->logopt, MODPREFIX "failed to mount offset triggers"); cleanup_multi_triggers(ap, me, mm_root, start, mm_base); - goto error_out; + return 1; } } } -#ifdef ENABLE_MOUNT_MOVE - if (!move_mount(ap, mnt_root, target, move)) { - cleanup_multi_triggers(ap, me, mnt_root, start, mm_base); - cleanup_multi_root(ap, mnt_root, mm_root, move); - goto error_out; - } - - if (mnt_tmp_root) - rmdir(mnt_tmp_root); -#endif - /* Mount for base of tree failed */ if (rv > 0) return rv; @@ -1386,14 +1211,6 @@ static int mount_subtree(struct autofs_point *ap, struct mapent *me, rv = 0; return rv; - -error_out: -#ifdef ENABLE_MOUNT_MOVE - if (mnt_tmp_root) - rmdir(mnt_tmp_root); -#endif - - return 1; } /*