[Cluster-devel] cluster/gfs2/mount mtab.c util.c
teigland at sourceware.org
teigland at sourceware.org
Tue Jan 2 20:49:26 UTC 2007
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL50
Changes by: teigland at sourceware.org 2007-01-02 20:49:26
Modified files:
gfs2/mount : mtab.c util.c
Log message:
mount/umount modifications of /etc/mtab weren't smart enough
to get straight two different fs's mounted on the same mountpoint
bz 218560
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/mount/mtab.c.diff?cvsroot=cluster&only_with_tag=RHEL50&r1=1.3&r2=1.3.4.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/mount/util.c.diff?cvsroot=cluster&only_with_tag=RHEL50&r1=1.18.4.2&r2=1.18.4.3
--- cluster/gfs2/mount/mtab.c 2005/11/10 20:37:18 1.3
+++ cluster/gfs2/mount/mtab.c 2007/01/02 20:49:26 1.3.4.1
@@ -143,7 +143,8 @@
if ((sscanf(line, "%s %s %s", device, path, type) == 3) &&
(strncmp(type, "gfs", 3) == 0) &&
- (strcmp(path, mo->dir) == 0)) {
+ (strcmp(path, mo->dir) == 0) &&
+ (strcmp(device, mo->dev) == 0)) {
found = 1;
continue;
}
--- cluster/gfs2/mount/util.c 2006/12/20 19:16:49 1.18.4.2
+++ cluster/gfs2/mount/util.c 2007/01/02 20:49:26 1.18.4.3
@@ -157,6 +157,12 @@
log_debug("parse_opts: locktable = \"%s\"", mo->locktable);
}
+/* - when unmounting, we don't know the dev and need this function to set it;
+ we also want to select the _last_ line with a matching dir since it will
+ be the top-most fs that the umount(2) will unmount
+ - when mounting, we do know the dev and need this function to use it in the
+ comparison (for multiple fs's with the same mountpoint) */
+
void read_proc_mounts(struct mount_options *mo)
{
FILE *file;
@@ -165,6 +171,9 @@
char type[PATH_MAX];
char opts[PATH_MAX];
char device[PATH_MAX];
+ char save_line[PATH_MAX];
+ char save_opts[PATH_MAX];
+ char save_device[PATH_MAX];
int found = 0;
file = fopen("/proc/mounts", "r");
@@ -176,20 +185,31 @@
continue;
if (strcmp(path, mo->dir))
continue;
+ if (mo->dev[0] && strcmp(device, mo->dev))
+ continue;
if (strcmp(type, fsname))
die("%s is not a %s filesystem\n", mo->dir, fsname);
- strncpy(mo->dev, device, PATH_MAX);
- strncpy(mo->opts, opts, PATH_MAX);
- strncpy(mo->proc_entry, line, PATH_MAX);
+ /* when there is an input dev specified (mount), we should get
+ only one matching line; when there is no input dev specified
+ (umount), we want the _last_ matching line */
+
+ strncpy(save_device, device, PATH_MAX);
+ strncpy(save_opts, opts, PATH_MAX);
+ strncpy(save_line, line, PATH_MAX);
found = 1;
- break;
}
fclose(file);
if (!found)
die("can't find /proc/mounts entry for directory %s\n", mo->dir);
+ else {
+ strncpy(mo->dev, save_device, PATH_MAX);
+ strncpy(mo->opts, save_opts, PATH_MAX);
+ strncpy(mo->proc_entry, save_line, PATH_MAX);
+ }
+
log_debug("read_proc_mounts: device = \"%s\"", mo->dev);
log_debug("read_proc_mounts: opts = \"%s\"", mo->opts);
}
More information about the Cluster-devel
mailing list