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 11-30-2011, 02:04 PM
Steven Whitehouse
 
Default libgfs2: Move generic_interrupt() into utils

First patch moving user interface code out of the library

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
---
gfs2/convert/gfs2_convert.c | 48 +++++++++++++++++++++++++++++++++++++++++++
gfs2/fsck/util.c | 48 +++++++++++++++++++++++++++++++++++++++++++
gfs2/fsck/util.h | 4 +++
gfs2/libgfs2/gfs2_log.c | 48 -------------------------------------------
gfs2/libgfs2/libgfs2.h | 3 --
5 files changed, 100 insertions(+), 51 deletions(-)

diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 396e899..f79b4a4 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -2057,6 +2057,54 @@ static void copy_quotas(struct gfs2_sbd *sdp)
inode_put(&oq_ip);
}

+
+static char generic_interrupt(const char *caller, const char *where,
+ const char *progress, const char *question,
+ const char *answers)
+{
+ fd_set rfds;
+ struct timeval tv;
+ char response;
+ int err, i;
+
+ FD_ZERO(&rfds);
+ FD_SET(STDIN_FILENO, &rfds);
+
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ /* Make sure there isn't extraneous input before asking the
+ * user the question */
+ while((err = select(STDIN_FILENO + 1, &rfds, NULL, NULL, &tv))) {
+ if(err < 0) {
+ log_debug("Error in select() on stdin
");
+ break;
+ }
+ if(read(STDIN_FILENO, &response, sizeof(char)) < 0) {
+ log_debug("Error in read() on stdin
");
+ break;
+ }
+ }
+ while (TRUE) {
+ printf("
%s interrupted during %s: ", caller, where);
+ if (progress)
+ printf("%s.
", progress);
+ printf("%s", question);
+
+ /* Make sure query is printed out */
+ fflush(NULL);
+ response = gfs2_getch();
+ printf("
");
+ fflush(NULL);
+ if (strchr(answers, response))
+ break;
+ printf("Bad response, please type ");
+ for (i = 0; i < strlen(answers) - 1; i++)
+ printf("'%c', ", answers[i]);
+ printf(" or '%c'.
", answers[i]);
+ }
+ return response;
+}
+
static int __attribute__((format(printf, 3, 4))) gfs2_query(int *setonabort,
struct gfs2_options *opts, const char *format, ...)
{
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index 0d243e0..ddbc757 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -87,6 +87,54 @@ void warm_fuzzy_stuff(uint64_t block)
}
}

+
+char generic_interrupt(const char *caller, const char *where,
+ const char *progress, const char *question,
+ const char *answers)
+{
+ fd_set rfds;
+ struct timeval tv;
+ char response;
+ int err, i;
+
+ FD_ZERO(&rfds);
+ FD_SET(STDIN_FILENO, &rfds);
+
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ /* Make sure there isn't extraneous input before asking the
+ * user the question */
+ while((err = select(STDIN_FILENO + 1, &rfds, NULL, NULL, &tv))) {
+ if(err < 0) {
+ log_debug("Error in select() on stdin
");
+ break;
+ }
+ if(read(STDIN_FILENO, &response, sizeof(char)) < 0) {
+ log_debug("Error in read() on stdin
");
+ break;
+ }
+ }
+ while (TRUE) {
+ printf("
%s interrupted during %s: ", caller, where);
+ if (progress)
+ printf("%s.
", progress);
+ printf("%s", question);
+
+ /* Make sure query is printed out */
+ fflush(NULL);
+ response = gfs2_getch();
+ printf("
");
+ fflush(NULL);
+ if (strchr(answers, response))
+ break;
+ printf("Bad response, please type ");
+ for (i = 0; i < strlen(answers) - 1; i++)
+ printf("'%c', ", answers[i]);
+ printf(" or '%c'.
", answers[i]);
+ }
+ return response;
+}
+
/* fsck_query: Same as gfs2_query except it adjusts errors_found and
errors_corrected. */
int fsck_query(const char *format, ...)
diff --git a/gfs2/fsck/util.h b/gfs2/fsck/util.h
index b56fe69..7c32404 100644
--- a/gfs2/fsck/util.h
+++ b/gfs2/fsck/util.h
@@ -180,4 +180,8 @@ extern void *gfs2_bmap_destroy(struct gfs2_sbd *sdp, struct gfs2_bmap *il);
extern int gfs2_blockmap_set(struct gfs2_bmap *il, uint64_t block,
enum gfs2_mark_block mark);
extern int set_ip_blockmap(struct gfs2_inode *ip, int instree);
+extern char generic_interrupt(const char *caller, const char *where,
+ const char *progress, const char *question,
+ const char *answers);
+
#endif /* __UTIL_H__ */
diff --git a/gfs2/libgfs2/gfs2_log.c b/gfs2/libgfs2/gfs2_log.c
index aa5ca73..39b09c7 100644
--- a/gfs2/libgfs2/gfs2_log.c
+++ b/gfs2/libgfs2/gfs2_log.c
@@ -84,51 +84,3 @@ char gfs2_getch(void)
tcsetattr (STDIN_FILENO, TCSANOW, &savetermattr);
return ch;
}
-
-char generic_interrupt(const char *caller, const char *where,
- const char *progress, const char *question,
- const char *answers)
-{
- fd_set rfds;
- struct timeval tv;
- char response;
- int err, i;
-
- FD_ZERO(&rfds);
- FD_SET(STDIN_FILENO, &rfds);
-
- tv.tv_sec = 0;
- tv.tv_usec = 0;
- /* Make sure there isn't extraneous input before asking the
- * user the question */
- while((err = select(STDIN_FILENO + 1, &rfds, NULL, NULL, &tv))) {
- if(err < 0) {
- log_debug("Error in select() on stdin
");
- break;
- }
- if(read(STDIN_FILENO, &response, sizeof(char)) < 0) {
- log_debug("Error in read() on stdin
");
- break;
- }
- }
- while (TRUE) {
- printf("
%s interrupted during %s: ", caller, where);
- if (progress)
- printf("%s.
", progress);
- printf("%s", question);
-
- /* Make sure query is printed out */
- fflush(NULL);
- response = gfs2_getch();
- printf("
");
- fflush(NULL);
- if (strchr(answers, response))
- break;
- printf("Bad response, please type ");
- for (i = 0; i < strlen(answers) - 1; i++)
- printf("'%c', ", answers[i]);
- printf(" or '%c'.
", answers[i]);
- }
- return response;
-}
-
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 95fd2b4..80c84fa 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -662,9 +662,6 @@ extern void decrease_verbosity(void);
extern void print_fsck_log(int priority, const char *file, int line,
const char *format, ...)
__attribute__((format(printf,4,5)));
-extern char generic_interrupt(const char *caller, const char *where,
- const char *progress, const char *question,
- const char *answers);
/* misc.c */

extern int compute_heightsize(struct gfs2_sbd *sdp, uint64_t *heightsize,
--
1.7.4.4
 

Thread Tools




All times are GMT. The time now is 12:28 AM.

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