[Cluster-devel] cluster/gfs2/mount mount.gfs2.c
teigland at sourceware.org
teigland at sourceware.org
Mon Apr 23 19:18:11 UTC 2007
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: teigland at sourceware.org 2007-04-23 20:18:09
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&r1=1.20&r2=1.21
--- 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:09 1.21
@@ -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