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

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