From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14284 invoked by alias); 25 Jul 2008 19:38:50 -0000 Received: (qmail 14253 invoked by uid 9579); 25 Jul 2008 19:38:49 -0000 Date: Fri, 25 Jul 2008 19:38:00 -0000 Message-ID: <20080725193849.14234.qmail@sourceware.org> From: rohara@sourceware.org To: cluster-cvs@sources.redhat.com, cluster-devel@redhat.com Subject: Cluster Project branch, STABLE2, updated. cluster-2.03.05-24-gf6a63c9 X-Git-Refname: refs/heads/STABLE2 X-Git-Reftype: branch X-Git-Oldrev: 8ac81e012926ef4b9466f8b19cf161f0a7d04838 X-Git-Newrev: f6a63c92a24b867347491ba90fc1a80256efc08c Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2008-q3/txt/msg00146.txt.bz2 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=f6a63c92a24b867347491ba90fc1a80256efc08c The branch, STABLE2 has been updated via f6a63c92a24b867347491ba90fc1a80256efc08c (commit) from 8ac81e012926ef4b9466f8b19cf161f0a7d04838 (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 f6a63c92a24b867347491ba90fc1a80256efc08c Author: Ryan O'Hara Date: Fri Jul 25 14:38:13 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