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.
This commit is contained in:
Theodore Ts'o 1999-10-20 18:24:31 +00:00
parent c03bc4e8f2
commit 9ecd8becf4
3 changed files with 30 additions and 5 deletions

View File

@ -1,4 +1,9 @@
1999-09-07 <tytso@rsts-11.mit.edu>
1999-09-24 <tytso@valinux.com>
* unix.c (PRS), util.c (ask_yn): Add #ifdef's to make
e2fsprogs easier to port to non-Unix platforms.
1999-09-07 <tytso@valinux.com>
* pass3.c (adjust_inode_count): Fix bug where we didn't keep the
internal and external inode counts in sync when we

View File

@ -16,9 +16,10 @@
#include <string.h>
#include <fcntl.h>
#include <ctype.h>
#include <termios.h>
#include <time.h>
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#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;
}

View File

@ -13,7 +13,17 @@
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#ifdef HAVE_CONIO_H
#undef HAVE_TERMIOS_H
#include <conio.h>
#define getchar() getch()
#else
#ifdef HAVE_TERMIOS_H
#include <termios.h>
#endif
#endif
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#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 = "<y>";
@ -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;
}