This is the mail archive of the
cluster-cvs@sourceware.org
mailing list for the cluster.
master - Changes needed to stay current with libvolume_id.
- From: Bob Peterson <rpeterso at fedoraproject dot org>
- To: cluster-cvs-relay at redhat dot com
- Date: Wed, 3 Sep 2008 18:53:30 +0000 (UTC)
- Subject: master - Changes needed to stay current with libvolume_id.
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=f00e7639798652daf6cce0dc7f9d8d3be0dae194
Commit: f00e7639798652daf6cce0dc7f9d8d3be0dae194
Parent: 1e00b980fb2531de1272229f9900b8bf94caae56
Author: Bob Peterson <rpeterso@redhat.com>
AuthorDate: Wed Sep 3 13:49:41 2008 -0500
Committer: Bob Peterson <rpeterso@redhat.com>
CommitterDate: Wed Sep 3 13:49:41 2008 -0500
Changes needed to stay current with libvolume_id.
---
gfs2/mkfs/main_mkfs.c | 30 +++++++++++++++++++++++-------
1 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 381380c..9b57f5a 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -260,17 +260,33 @@ static void are_you_sure(struct gfs2_sbd *sdp)
{
char input[32];
struct volume_id *vid = NULL;
-
- vid = volume_id_open_node(sdp->device_name);
- if (vid == NULL)
+ int fd;
+
+ fd = open(sdp->device_name, O_RDONLY);
+ if (fd < 0)
+ die("Error: device %s not found.\n", sdp->device_name);
+ vid = volume_id_open_fd(fd);
+ if (vid == NULL) {
+ close(fd);
die("error identifying the contents of %s: %s\n",
sdp->device_name, strerror(errno));
-
+ }
printf("This will destroy any data on %s.\n", sdp->device_name);
- if (volume_id_probe_all(vid, 0, sdp->device_size) == 0)
- printf(" It appears to contain a %s %s.\n", vid->type,
- vid->usage_id == VOLUME_ID_OTHER? "partition" : vid->usage);
+ if (volume_id_probe_all(vid, 0, sdp->device_size) == 0) {
+ const char *fstype, *fsusage;
+ int rc;
+
+ rc = volume_id_get_type(vid, &fstype);
+ if (rc) {
+ rc = volume_id_get_usage(vid, &fsusage);
+ if (!rc || strncmp(fsusage, "other", 5) == 0)
+ fsusage = "partition";
+ printf(" It appears to contain a %s %s.\n", fstype,
+ fsusage);
+ }
+ }
volume_id_close(vid);
+ close(fd);
printf("\nAre you sure you want to proceed? [y/n] ");
if(!fgets(input, 32, stdin))
die("unable to read from stdin\n");