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

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