From 9ecd8becf46c32ed18e468fe647947b359d25cdb Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 20 Oct 1999 18:24:31 +0000 Subject: [PATCH] ChangeLog, unix.c, util.c: unix.c (PRS), util.c (ask_yn): Add #ifdef's to make e2fsprogs easier to port to non-Unix platforms. --- e2fsck/ChangeLog | 7 ++++++- e2fsck/unix.c | 11 ++++++++--- e2fsck/util.c | 17 ++++++++++++++++- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog index a75e47d..52a93ad 100644 --- a/e2fsck/ChangeLog +++ b/e2fsck/ChangeLog @@ -1,4 +1,9 @@ -1999-09-07 +1999-09-24 + + * unix.c (PRS), util.c (ask_yn): Add #ifdef's to make + e2fsprogs easier to port to non-Unix platforms. + +1999-09-07 * pass3.c (adjust_inode_count): Fix bug where we didn't keep the internal and external inode counts in sync when we diff --git a/e2fsck/unix.c b/e2fsck/unix.c index ba1aa6b..150bd51 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -16,9 +16,10 @@ #include #include #include -#include #include +#ifdef HAVE_SIGNAL_H #include +#endif #ifdef HAVE_GETOPT_H #include #endif @@ -37,8 +38,6 @@ #include "problem.h" #include "../version.h" -extern int isatty(int); - /* Command line options */ static int blocksize = 0; static int swapfs = 0; @@ -338,6 +337,7 @@ static void reserve_stdio_fds(NOARGS) close(fd); } +#ifdef HAVE_SIGNAL_H static e2fsck_t global_signal_ctx; static void signal_progress_on(int sig) @@ -361,6 +361,7 @@ static void signal_progress_off(int sig) e2fsck_clear_progbar(ctx); ctx->progress = 0; } +#endif static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) { @@ -372,7 +373,9 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) char *oldpath = getenv("PATH"); e2fsck_t ctx; errcode_t retval; +#ifdef HAVE_SIGNAL_H struct sigaction sa; +#endif retval = e2fsck_allocate_context(&ctx); if (retval) @@ -530,6 +533,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) exit(FSCK_ERROR); } } +#ifdef HAVE_SIGNAL_H /* * Set up signal action */ @@ -542,6 +546,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) sigaction(SIGUSR1, &sa, 0); sa.sa_handler = signal_progress_off; sigaction(SIGUSR2, &sa, 0); +#endif return 0; } diff --git a/e2fsck/util.c b/e2fsck/util.c index d48c769..a124a0f 100644 --- a/e2fsck/util.c +++ b/e2fsck/util.c @@ -13,7 +13,17 @@ #include #include #include + +#ifdef HAVE_CONIO_H +#undef HAVE_TERMIOS_H +#include +#define getchar() getch() +#else +#ifdef HAVE_TERMIOS_H #include +#endif +#endif + #ifdef HAVE_MALLOC_H #include #endif @@ -54,15 +64,18 @@ void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned int size, int ask_yn(const char * string, int def) { int c; - struct termios termios, tmp; const char *defstr; +#ifdef HAVE_TERMIOS_H + struct termios termios, tmp; + tcgetattr (0, &termios); tmp = termios; tmp.c_lflag &= ~(ICANON | ECHO); tmp.c_cc[VMIN] = 1; tmp.c_cc[VTIME] = 0; tcsetattr (0, TCSANOW, &tmp); +#endif if (def == 1) defstr = ""; @@ -91,7 +104,9 @@ int ask_yn(const char * string, int def) printf ("yes\n\n"); else printf ("no\n\n"); +#ifdef HAVE_TERMIOS_H tcsetattr (0, TCSANOW, &termios); +#endif return def; } -- 1.8.3.1