FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Cluster Development

 
 
LinkBack Thread Tools
 
Old 09-27-2011, 04:08 PM
Carlos Maiolino
 
Default mkfs: Remove unneeded open/close fd test from are_you_sure()

are_you_sure() function should not make an open/close
test on the underlying device. The pourpose of this
function is just to ask a yes/no question to the user.
If we need a function to do this test, we should create
a new function with its specific pourpose.
This patch also fix a call to are_you_sure() function and
move the are_you_sure() function to the begining of the
file, allowing it to be used in another part of the code

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
gfs2/mkfs/main_mkfs.c | 75 ++++++++++++++++++++++--------------------------
1 files changed, 34 insertions(+), 41 deletions(-)

diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index cc678fe..8802ef7 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -289,6 +289,39 @@ static void test_locking(char *lockproto, char *locktable)
}
}

+/**
+ * are_you_sure - protect lusers from themselves
+ * @sdp: the command line
+ *
+ */
+
+static void are_you_sure(void)
+{
+ char *line = NULL;
+ size_t len = 0;
+ int ret = -1;
+ int res = 0;
+
+ do{
+ printf( _("Are you sure you want to proceed? [y/n]"));
+ ret = getline(&line, &len, stdin);
+ res = rpmatch(line);
+
+ if (res > 0){
+ free(line);
+ return;
+ }
+ if (!res){
+ printf("
");
+ die( _("aborted
"));
+ }
+
+ }while(ret >= 0);
+
+ if(line)
+ free(line);
+}
+
static void verify_bsize(struct gfs2_sbd *sdp)
{
unsigned int x;
@@ -448,46 +481,6 @@ fail:
exit(execv(args[0], args));
}

-/**
- * are_you_sure - protect lusers from themselves
- * @sdp: the command line
- *
- */
-
-static void are_you_sure(struct gfs2_sbd *sdp)
-{
- char *line = NULL;
- size_t len = 0;
- int fd;
- int ret = -1;
- int res = 0;
-
- fd = open(sdp->device_name, O_RDONLY|O_CLOEXEC);
- if (fd < 0)
- die( _("Error: device %s not found.
"), sdp->device_name);
- printf( _("This will destroy any data on %s.
"), sdp->device_name);
- check_dev_content(sdp->device_name);
- close(fd);
-
- do{
- printf( _("Are you sure you want to proceed? [y/n]"));
- ret = getline(&line, &len, stdin);
- res = rpmatch(line);
-
- if (res > 0){
- free(line);
- return;
- }
- if (!res){
- printf("
");
- die( _("aborted
"));
- }
-
- }while(ret >= 0);
-
- if(line)
- free(line);
-}

/**
* print_results - print out summary information
@@ -576,7 +569,7 @@ void main_mkfs(int argc, char *argv[])
}

if (!sdp->override)
- are_you_sure(sdp);
+ are_you_sure();

if (!S_ISREG(st_buf.st_mode) && device_topology(sdp)) {
fprintf(stderr, _("Device topology error
"));
--
1.7.6
 

Thread Tools




All times are GMT. The time now is 04:55 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org