STABLE2 - Changes needed to stay compatible with libvolume_id.
Fabio M. Di Nitto
fabbione@fedoraproject.org
Wed Sep 24 09:39:00 GMT 2008
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=ac3aed5d029da9f62c4c574f341951c8d5040ec6
Commit: ac3aed5d029da9f62c4c574f341951c8d5040ec6
Parent: c0d298321776c1d468eef2658c258a699853a054
Author: Bob Peterson <rpeterso@redhat.com>
AuthorDate: Wed Sep 3 13:29:35 2008 -0500
Committer: Fabio M. Di Nitto <fdinitto@redhat.com>
CommitterDate: Wed Sep 24 09:32:05 2008 +0200
Changes needed to stay compatible with libvolume_id.
---
gfs/gfs_mkfs/main.c | 28 ++++++++++++++++++++++------
1 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/gfs/gfs_mkfs/main.c b/gfs/gfs_mkfs/main.c
index 87316c7..f216b5c 100644
--- a/gfs/gfs_mkfs/main.c
+++ b/gfs/gfs_mkfs/main.c
@@ -208,18 +208,34 @@ void are_you_sure(commandline_t *comline)
{
char input[32];
struct volume_id *vid = NULL;
+ int fd;
- vid = volume_id_open_node(comline->device);
- if (vid == NULL)
+ fd = open(comline->device, O_RDONLY);
+ if (fd < 0)
+ die("Error: device %s not found.\n", comline->device);
+ vid = volume_id_open_fd(fd);
+ if (vid == NULL) {
+ close(fd);
die("error identifying the contents of %s: %s\n",
comline->device, strerror(errno));
-
+ }
printf("This will destroy any data on %s.\n",
comline->device);
- if (volume_id_probe_all(vid, 0, MKFS_DEFAULT_BSIZE) == 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, MKFS_DEFAULT_BSIZE) == 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) == NULL || input[0] != 'y')
die("aborted\n");
More information about the Cluster-cvs
mailing list