cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: rohara@sourceware.org <rohara@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] Cluster Project branch, RHEL5, updated. cmirror_1_1_15-178-g50203b1
Date: 25 Jul 2008 19:29:24 -0000	[thread overview]
Message-ID: <20080725192924.2519.qmail@sourceware.org> (raw)

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=50203b164f9d122b3d2312534587e1dcef9e3bb8

The branch, RHEL5 has been updated
       via  50203b164f9d122b3d2312534587e1dcef9e3bb8 (commit)
      from  e0ff895e257924ddba53244b01445f6665a2e163 (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 50203b164f9d122b3d2312534587e1dcef9e3bb8
Author: Ryan O'Hara <rohara@redhat.com>
Date:   Fri Jul 25 14:27:56 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 |   30 +++++++++++++++---------------
 1 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/gfs/gfs_mkfs/main.c b/gfs/gfs_mkfs/main.c
index 4f3920a..09315a5 100644
--- a/gfs/gfs_mkfs/main.c
+++ b/gfs/gfs_mkfs/main.c
@@ -244,31 +244,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);
 
-	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);
-			break;
+	fd = open(device, O_RDONLY | O_NONBLOCK | O_EXCL);
+
+	if (fd < 0) {
+		if (errno == EBUSY) {
+			die("device %s is busy\n", device);
 		}
 	}
-
-	endmntent(fp);
+	else {
+		close(fd);
+	}
 
 	return;
 }


hooks/post-receive
--
Cluster Project



                 reply	other threads:[~2008-07-25 19:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20080725192924.2519.qmail@sourceware.org \
    --to=rohara@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).