Blame SOURCES/autofs-5.1.7-remove-redundant-variables-from-mount_autofs_offset.patch

96dc52
autofs-5.1.7 - remove redundant variables from mount_autofs_offset()
96dc52
96dc52
From: Ian Kent <raven@themaw.net>
96dc52
96dc52
The path to be mounted is the key in the passed in mapent.
96dc52
96dc52
Signed-off-by: Ian Kent <raven@themaw.net>
96dc52
---
96dc52
 CHANGELOG           |    1 +
96dc52
 daemon/direct.c     |   42 +++++++++++++++++++-----------------------
96dc52
 include/automount.h |    2 +-
96dc52
 lib/mounts.c        |    2 +-
96dc52
 4 files changed, 22 insertions(+), 25 deletions(-)
96dc52
96dc52
diff --git a/CHANGELOG b/CHANGELOG
96dc52
index c4ebb52f..45be4783 100644
96dc52
--- a/CHANGELOG
96dc52
+++ b/CHANGELOG
96dc52
@@ -9,6 +9,7 @@
96dc52
 - fix is mounted check on non existent path.
96dc52
 - simplify cache_get_parent().
96dc52
 - set offset parent in update_offset_entry().
96dc52
+- remove redundant variables from mount_autofs_offset().
96dc52
 
96dc52
 25/01/2021 autofs-5.1.7
96dc52
 - make bind mounts propagation slave by default.
96dc52
diff --git a/daemon/direct.c b/daemon/direct.c
96dc52
index 9fe4903a..c41c680f 100644
96dc52
--- a/daemon/direct.c
96dc52
+++ b/daemon/direct.c
96dc52
@@ -611,7 +611,7 @@ force_umount:
96dc52
 	return rv;
96dc52
 }
96dc52
 
96dc52
-int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, const char *root, const char *offset)
96dc52
+int mount_autofs_offset(struct autofs_point *ap, struct mapent *me)
96dc52
 {
96dc52
 	const char *str_offset = mount_type_str(t_offset);
96dc52
 	struct ioctl_ops *ops = get_ioctl_ops();
96dc52
@@ -623,7 +623,6 @@ int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, const char *
96dc52
 	const char *hosts_map_name = "-hosts";
96dc52
 	const char *map_name = hosts_map_name;
96dc52
 	const char *type;
96dc52
-	char mountpoint[PATH_MAX];
96dc52
 	struct mnt_list *mnt;
96dc52
 
96dc52
 	if (ops->version && ap->flags & MOUNT_FLAG_REMOUNT) {
96dc52
@@ -681,11 +680,8 @@ int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, const char *
96dc52
 			return MOUNT_OFFSET_OK;
96dc52
 	}
96dc52
 
96dc52
-	strcpy(mountpoint, root);
96dc52
-	strcat(mountpoint, offset);
96dc52
-
96dc52
 	/* In case the directory doesn't exist, try to mkdir it */
96dc52
-	if (mkdir_path(mountpoint, mp_mode) < 0) {
96dc52
+	if (mkdir_path(me->key, mp_mode) < 0) {
96dc52
 		if (errno == EEXIST) {
96dc52
 			/*
96dc52
 			 * If the mount point directory is a real mount
96dc52
@@ -694,7 +690,7 @@ int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, const char *
96dc52
 			 * the kernel NFS client.
96dc52
 			 */
96dc52
 			if (me->multi != me &&
96dc52
-			    is_mounted(mountpoint, MNTS_REAL))
96dc52
+			    is_mounted(me->key, MNTS_REAL))
96dc52
 				return MOUNT_OFFSET_IGNORE;
96dc52
 
96dc52
 			/* 
96dc52
@@ -714,13 +710,13 @@ int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, const char *
96dc52
 			char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
96dc52
 			debug(ap->logopt,
96dc52
 			     "can't create mount directory: %s, %s",
96dc52
-			     mountpoint, estr);
96dc52
+			     me->key, estr);
96dc52
 			return MOUNT_OFFSET_FAIL;
96dc52
 		} else {
96dc52
 			char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
96dc52
 			crit(ap->logopt,
96dc52
 			     "failed to create mount directory: %s, %s",
96dc52
-			     mountpoint, estr);
96dc52
+			     me->key, estr);
96dc52
 			return MOUNT_OFFSET_FAIL;
96dc52
 		}
96dc52
 	} else {
96dc52
@@ -730,56 +726,56 @@ int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, const char *
96dc52
 
96dc52
 	debug(ap->logopt,
96dc52
 	      "calling mount -t autofs " SLOPPY " -o %s automount %s",
96dc52
-	      mp->options, mountpoint);
96dc52
+	      mp->options, me->key);
96dc52
 
96dc52
 	type = ap->entry->maps->type;
96dc52
 	if (!type || strcmp(ap->entry->maps->type, "hosts"))
96dc52
 		map_name = me->mc->map->argv[0];
96dc52
 
96dc52
-	ret = mount(map_name, mountpoint, "autofs", MS_MGC_VAL, mp->options);
96dc52
+	ret = mount(map_name, me->key, "autofs", MS_MGC_VAL, mp->options);
96dc52
 	if (ret) {
96dc52
 		crit(ap->logopt,
96dc52
 		     "failed to mount offset trigger %s at %s",
96dc52
-		     me->key, mountpoint);
96dc52
+		     me->key, me->key);
96dc52
 		goto out_err;
96dc52
 	}
96dc52
 
96dc52
-	ret = stat(mountpoint, &st);
96dc52
+	ret = stat(me->key, &st);
96dc52
 	if (ret == -1) {
96dc52
 		error(ap->logopt,
96dc52
-		     "failed to stat direct mount trigger %s", mountpoint);
96dc52
+		     "failed to stat direct mount trigger %s", me->key);
96dc52
 		goto out_umount;
96dc52
 	}
96dc52
 
96dc52
-	ops->open(ap->logopt, &ioctlfd, st.st_dev, mountpoint);
96dc52
+	ops->open(ap->logopt, &ioctlfd, st.st_dev, me->key);
96dc52
 	if (ioctlfd < 0) {
96dc52
-		crit(ap->logopt, "failed to create ioctl fd for %s", mountpoint);
96dc52
+		crit(ap->logopt, "failed to create ioctl fd for %s", me->key);
96dc52
 		goto out_umount;
96dc52
 	}
96dc52
 
96dc52
 	ops->timeout(ap->logopt, ioctlfd, timeout);
96dc52
 	cache_set_ino_index(me->mc, me->key, st.st_dev, st.st_ino);
96dc52
 	if (ap->logopt & LOGOPT_DEBUG)
96dc52
-		notify_mount_result(ap, mountpoint, timeout, str_offset);
96dc52
+		notify_mount_result(ap, me->key, timeout, str_offset);
96dc52
 	else
96dc52
 		notify_mount_result(ap, me->key, timeout, str_offset);
96dc52
 	ops->close(ap->logopt, ioctlfd);
96dc52
 
96dc52
-	mnt = mnts_add_mount(ap, mountpoint, MNTS_OFFSET);
96dc52
+	mnt = mnts_add_mount(ap, me->key, MNTS_OFFSET);
96dc52
 	if (!mnt)
96dc52
 		error(ap->logopt,
96dc52
 		      "failed to add offset mount %s to mounted list",
96dc52
-		      mountpoint);
96dc52
+		      me->key);
96dc52
 
96dc52
-	debug(ap->logopt, "mounted trigger %s at %s", me->key, mountpoint);
96dc52
+	debug(ap->logopt, "mounted trigger %s", me->key);
96dc52
 
96dc52
 	return MOUNT_OFFSET_OK;
96dc52
 
96dc52
 out_umount:
96dc52
-	umount(mountpoint);
96dc52
+	umount(me->key);
96dc52
 out_err:
96dc52
-	if (stat(mountpoint, &st) == 0 && me->flags & MOUNT_FLAG_DIR_CREATED)
96dc52
-		 rmdir_path(ap, mountpoint, st.st_dev);
96dc52
+	if (stat(me->key, &st) == 0 && me->flags & MOUNT_FLAG_DIR_CREATED)
96dc52
+		 rmdir_path(ap, me->key, st.st_dev);
96dc52
 
96dc52
 	return MOUNT_OFFSET_FAIL;
96dc52
 }
96dc52
diff --git a/include/automount.h b/include/automount.h
96dc52
index 730be19a..09d84f05 100644
96dc52
--- a/include/automount.h
96dc52
+++ b/include/automount.h
96dc52
@@ -596,7 +596,7 @@ int expire_offsets_direct(struct autofs_point *ap, struct mapent *me, int now);
96dc52
 int mount_autofs_indirect(struct autofs_point *ap, const char *root);
96dc52
 int do_mount_autofs_direct(struct autofs_point *ap, struct mapent *me, time_t timeout);
96dc52
 int mount_autofs_direct(struct autofs_point *ap);
96dc52
-int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, const char *root, const char *offset);
96dc52
+int mount_autofs_offset(struct autofs_point *ap, struct mapent *me);
96dc52
 void submount_signal_parent(struct autofs_point *ap, unsigned int success);
96dc52
 void close_mount_fds(struct autofs_point *ap);
96dc52
 int umount_autofs_indirect(struct autofs_point *ap, const char *root);
96dc52
diff --git a/lib/mounts.c b/lib/mounts.c
96dc52
index fe931b20..12d22023 100644
96dc52
--- a/lib/mounts.c
96dc52
+++ b/lib/mounts.c
96dc52
@@ -2481,7 +2481,7 @@ static int do_mount_autofs_offset(struct autofs_point *ap,
96dc52
 
96dc52
 	debug(ap->logopt, "mount offset %s at %s", oe->key, root);
96dc52
 
96dc52
-	ret = mount_autofs_offset(ap, oe, root, offset);
96dc52
+	ret = mount_autofs_offset(ap, oe);
96dc52
 	if (ret >= MOUNT_OFFSET_OK)
96dc52
 		mounted++;
96dc52
 	else {