This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

master - gfs2: randomize debugfs mount point


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=18b24ae55c3e4abdc256a3b6c4f15ae0116a0f14
Commit:        18b24ae55c3e4abdc256a3b6c4f15ae0116a0f14
Parent:        10ca35e82781ca456d05e8701d27fb1f7a304f49
Author:        Fabio M. Di Nitto <fdinitto@redhat.com>
AuthorDate:    Wed Oct 22 08:13:33 2008 +0200
Committer:     Fabio M. Di Nitto <fdinitto@redhat.com>
CommitterDate: Wed Oct 22 08:13:33 2008 +0200

gfs2: randomize debugfs mount point

by using a static path to /tmp, the operation can fail in different
ways.

randomize the path a bit by using the invoking pid. This will also allow
multiple simultaneous invokation of lockdump operations.

There is still a small window for a race where one gfs2_tool invokation
has created the mount point, the second one finds the mount point, the
first one succeed in an umount and the second one will not be able to
access the data. This is a very unlikely condition to happen and it's
not mission critical so we can live with it.

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
 gfs2/tool/misc.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gfs2/tool/misc.c b/gfs2/tool/misc.c
index 0882b49..3e223d0 100644
--- a/gfs2/tool/misc.c
+++ b/gfs2/tool/misc.c
@@ -107,11 +107,11 @@ print_lockdump(int argc, char **argv)
 	/* See if debugfs is mounted, and if not, mount it. */
 	debugfs = find_debugfs_mount();
 	if (!debugfs) {
-		debugfs = malloc(20);
+		debugfs = malloc(PATH_MAX);
 		if (!debugfs)
 			die("Can't allocate memory for debugfs.\n");
-		memset(debugfs, 0, 20);
-		strcpy(debugfs, "/tmp/debugfs");
+		memset(debugfs, 0, PATH_MAX);
+		sprintf(debugfs, "/tmp/debugfs.%d", getpid());
 
 		if (access(debugfs, F_OK)) {
 			debug_dir_existed = mkdir(debugfs, 644);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]