cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: teigland@sourceware.org <teigland@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/gfs2/mount mtab.c util.c
Date: 2 Jan 2007 20:18:04 -0000	[thread overview]
Message-ID: <20070102201804.24524.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	teigland at sourceware.org	2007-01-02 20:18:03

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&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/mount/util.c.diff?cvsroot=cluster&r1=1.20&r2=1.21

--- cluster/gfs2/mount/mtab.c	2005/11/10 20:37:18	1.3
+++ cluster/gfs2/mount/mtab.c	2007/01/02 20:18:03	1.4
@@ -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:13:35	1.20
+++ cluster/gfs2/mount/util.c	2007/01/02 20:18:03	1.21
@@ -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);
 }



             reply	other threads:[~2007-01-02 20:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-02 20:18 teigland [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-01-02 20:18 [Cluster-devel] cluster/gfs2/mount mtab.c util.c teigland
2007-01-02 20:49 teigland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070102201804.24524.qmail@sourceware.org \
    --to=teigland@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).