[Cluster-devel] cluster/gfs2/mount mount.gfs2.c

teigland at sourceware.org teigland at sourceware.org
Mon Apr 23 19:18:18 UTC 2007


CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	teigland at sourceware.org	2007-04-23 20:18:18

Modified files:
	gfs2/mount     : mount.gfs2.c 

Log message:
	Use realpath(3) to canonicalize path names for device and mount point.
	bz 237544

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/mount/mount.gfs2.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.20&r2=1.20.2.1

--- cluster/gfs2/mount/mount.gfs2.c	2006/10/25 06:24:43	1.20
+++ cluster/gfs2/mount/mount.gfs2.c	2007/04/23 19:18:17	1.20.2.1
@@ -38,7 +38,7 @@
 {
 	int cont = 1;
 	int optchar;
-	int l;
+	char *real;
 
 	/* FIXME: check for "quiet" option and don't print in that case */
 
@@ -77,18 +77,22 @@
 		}
 	}
 
-	if (optind < argc && argv[optind])
-		strncpy(mo->dev, argv[optind], PATH_MAX);
+	if (optind < argc && argv[optind]) {
+		real = realpath(argv[optind], NULL);
+		if (!real)
+			die("invalid device path \"%s\"\n", argv[optind]);
+		strncpy(mo->dev, real, PATH_MAX);
+		free(real);
+	}
 
 	++optind;
 
 	if (optind < argc && argv[optind]) {
-		strncpy(mo->dir, argv[optind], PATH_MAX);
-		l = strlen(mo->dir) - 1;
-		while (l > 0 && mo->dir[l] == '/') {
-			mo->dir[l] = '\0';
-			l--;
-		};
+		real = realpath(argv[optind], NULL);
+		if (!real)
+			die("invalid mount point path \"%s\"\n", argv[optind]);
+		strncpy(mo->dir, real, PATH_MAX);
+		free(real);
 	}
 
 	log_debug("mount %s %s", mo->dev, mo->dir);




More information about the Cluster-devel mailing list