public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* Cluster Project branch, master, updated. cluster-2.99.06-73-ga54d8cb
@ 2008-07-25 19:35 rohara
  0 siblings, 0 replies; only message in thread
From: rohara @ 2008-07-25 19:35 UTC (permalink / raw)
  To: cluster-cvs, cluster-devel

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Cluster Project".

http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=a54d8cbe8a6fa83b647cdc6da57f15604d5f0f00

The branch, master has been updated
       via  a54d8cbe8a6fa83b647cdc6da57f15604d5f0f00 (commit)
      from  402bbded982537fcae1eaec968a03e434a37591d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a54d8cbe8a6fa83b647cdc6da57f15604d5f0f00
Author: Ryan O'Hara <rohara@redhat.com>
Date:   Fri Jul 25 14:33:47 2008 -0500

    gfs_mkfs: change the way we check to see if a device is mounted
    
    New method will attempt to open device with O_EXCL flag. If open()
    responds with EBUSY, mkfs will die. This indicates that the device
    is either mounted or part of a LVM volume. (BZ #426298)

-----------------------------------------------------------------------

Summary of changes:
 gfs/gfs_mkfs/main.c |   29 +++++++++++++++--------------
 1 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/gfs/gfs_mkfs/main.c b/gfs/gfs_mkfs/main.c
index 0dc75b4..87316c7 100644
--- a/gfs/gfs_mkfs/main.c
+++ b/gfs/gfs_mkfs/main.c
@@ -229,30 +229,31 @@ void are_you_sure(commandline_t *comline)
 
 
 /**
- * check_mount -
+ * check_mount - check to see if device is mounted/busy
  * @
  *
  */
 
 void check_mount(char *device)
 {
-	struct mntent *mnt;
-	FILE *fp;
+	struct stat st_buf;
+	int fd;
 
-	if ((fp = setmntent("/proc/mounts", "r")) == NULL) {
-		die("error opening /proc/mounts");
-	}
+	if (stat(device, &st_buf) < 0)
+		die("could not stat device %s\n", device);
+	if (!S_ISBLK(st_buf.st_mode))
+		die("%s is not a block device\n", device);
+
+	fd = open(device, O_RDONLY | O_NONBLOCK | O_EXCL);
 
-	while ((mnt = getmntent(fp)) != NULL) {
-		if (strcmp(device, mnt->mnt_fsname) == 0) {
-			printf("cannot create filesystem: ");
-			printf("%s appears to be mounted\n", device);
-			endmntent(fp);
-			exit(EXIT_FAILURE);
+	if (fd < 0) {
+		if (errno == EBUSY) {
+			die("device %s is busy\n", device);
 		}
 	}
-
-	endmntent(fp);
+	else {
+		close(fd);
+	}
 
 	return;
 }


hooks/post-receive
--
Cluster Project


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-07-25 19:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-25 19:35 Cluster Project branch, master, updated. cluster-2.99.06-73-ga54d8cb rohara

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 read-only IMAP folder(s) and NNTP newsgroup(s).