diff options
Diffstat (limited to '')
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | flx/ChangeLog | 2 | ||||
-rw-r--r-- | flx/Makefile | 6 | ||||
-rw-r--r-- | flx/arg.c | 2 | ||||
-rw-r--r-- | flx/main.c | 15 | ||||
-rw-r--r-- | flx/utils.h | 6 | ||||
-rw-r--r-- | init/README.2 | 3 | ||||
-rw-r--r-- | init/init.c | 60 | ||||
-rw-r--r-- | init/test.cfg | 12 | ||||
-rw-r--r-- | wd/wdd.8 | 4 | ||||
-rw-r--r-- | wd/wdd.c | 5 |
11 files changed, 101 insertions, 22 deletions
@@ -67,3 +67,11 @@ - now 'wdd' supports checks of arbitrary file lists and gets a man page. - lcdwrite and lcdtee sources have been brought back +2004/09/25 + - init : new 'wk' (waitkey) command. + +2004/10/11 + - wdd : add support for /dev/misc/watchdog as presented by devfs + +2004/11/21 + - flx : fix build with gcc-3.3 diff --git a/flx/ChangeLog b/flx/ChangeLog index 5397930..0e71676 100644 --- a/flx/ChangeLog +++ b/flx/ChangeLog @@ -1,3 +1,5 @@ +2004/11/21 : Version 0.6.8 +- now compiles with gcc-3.3 2003/06/05 : Version 0.6.7 - segfault on /proc directory : size_t -> ssize_t 2003/01/04 : Version 0.6.6c diff --git a/flx/Makefile b/flx/Makefile index 0da663e..0a92cdc 100644 --- a/flx/Makefile +++ b/flx/Makefile @@ -26,15 +26,17 @@ NAME=flx -VERSION=0.6.7 +VERSION=0.6.8 SRC=main.c arg.c utils.c md5.c flx.c fct1.c check.c sign.c \ input.c input_fs.c input_file.c \ output.c output_file.c OBJ=$(SRC:.c=.o) -COPTS="-O2" +COPTS=-O2 CFLAGS= -Wall $(COPTS) -DMEM_OPTIM -DPROGRAM_NAME=\"$(NAME)\" -DPROGRAM_VERSION=\"$(VERSION)\" LDFLAGS=-L. +all: $(NAME) + $(NAME): $(OBJ) $(CC) -o $(NAME) $(OBJ) $(LDFLAGS) # strip -R .note -R .comment signfs @@ -30,7 +30,7 @@ void arg_usage(t_param *p, char *message, ...) { fprintf(stderr, "%s %s, %s\n", PROGRAM_NAME, PROGRAM_VERSION, COPYRIGHT); fprintf(stderr, "usage: %s [options] [...]\n", Progname); while(p && p->optnum) { - fprintf(stderr, " %s\n", p->help); + fprintf(stderr, "\t%s\n", p->help); p++; } exit(1); @@ -36,12 +36,15 @@ char *Progname = NULL; t_param FLX_poptions[] = { - { 0, NULL, 0xFFFF, 0, "sign -h|<options> input [...] - sign data" }, - { 0, NULL, 0xFFFF, 0, "check -h|<options> src1 src2 - check difference between src1 and src2" }, - { 0, NULL, 0xFFFF, 0, "check -h|<options> src1 [...] , src2 [...] - check difference between srcs1 and srcs2" }, + { 0, NULL, 0xFFFF, 0, + "sign\t-h|<options> input [...]\n" + "\t\tsign data" }, + { 0, NULL, 0xFFFF, 0, + "check\t-h|<options> src1 src2\n" + "\t\tcheck difference between src1 and src2" }, + { 0, NULL, 0xFFFF, 0, + "check\t-h|<options> src1 [...] , src2 [...]\n" + "\t\tcheck difference between srcs1 and srcs2" }, { 0, NULL, 0, 0} }; diff --git a/flx/utils.h b/flx/utils.h index 5c47333..17c1991 100644 --- a/flx/utils.h +++ b/flx/utils.h @@ -56,7 +56,7 @@ typedef unsigned char u_char; #define BUFFLEN BUFFER_LENGTH -#define PFERROR(str...) PFERROR2(##str, 0) +#define PFERROR(str...) PFERROR2(str, 0) #define PFERROR2(str, p...) pferror("%s:%d: " str, __FILE__, __LINE__, ##p) #define HEXTODEC(a) (('0'<=(a) && (a)<='9')?(a)-'0':(a)-'a'+10) @@ -71,7 +71,7 @@ typedef unsigned char u_char; #define POOL_ALLOC(type) ({ \ void *p; \ if ((p = pool_##type) == NULL) \ - p = malloc(sizeof(##type)); \ + p = malloc(sizeof(type)); \ else { \ pool_##type = *(void **)pool_##type; \ } \ @@ -94,7 +94,7 @@ typedef unsigned char u_char; #define POOL_INIT_PROTO(type) extern type *pool_##type #else -#define POOL_ALLOC(type) (calloc(1,sizeof(##type))); +#define POOL_ALLOC(type) (calloc(1,sizeof(type))); #define POOL_FREE(type, ptr) (free(ptr)); #define POOL_INIT #endif /* MEM_OPTIM */ diff --git a/init/README.2 b/init/README.2 index f148d98..32fb071 100644 --- a/init/README.2 +++ b/init/README.2 @@ -12,6 +12,9 @@ Résumé rapide des commandes les plus courantes : - rd : passe en mode prompt clavier, en affichant le message. Ne retourne jamais d'erreur. Le prompt compte les niveaux pour s'y retrouver avec les {} :-) + - wk : affiche le message (premier param) et attend au maximum le + second param en nombre de secondes pour l'appui sur une touche. + Retourne une erreur si on atteint le time-out, OK sinon. - mt : mount ; re : remount ; um : umount - mv : mount --move ; bi : mount --bind - ex : exécute dans un sous-process (system()) diff --git a/init/init.c b/init/init.c index 6541774..0f6cf8b 100644 --- a/init/init.c +++ b/init/init.c @@ -306,6 +306,7 @@ enum { TOK_RD, /* rd : read a command from the console */ TOK_RM, /* rm : remove files */ TOK_ST, /* st : stat file existence */ + TOK_WK, /* wk : wait key */ TOK_OB, /* { : begin a command block */ TOK_CB, /* } : end a command block */ TOK_DOT, /* . : end of config */ @@ -318,7 +319,7 @@ enum { }; /* counts from TOK_LN to TOK_DOT */ -#define NB_TOKENS 24 +#define NB_TOKENS 25 /* this contains all two-chars command, 1-char commands, followed by a token * number. @@ -349,6 +350,7 @@ static const __attribute__ ((__section__(STR_SECT),__aligned__(1))) struct { "rd", 0, 0, /* TOK_RD */ "rm", 0, 1, /* TOK_RM */ "st", 0, 1, /* TOK_ST */ + "wk", 0, 2, /* TOK_WK */ "{", '{', 0, /* TOK_OB */ "}", '}', 0, /* TOK_CB */ ".", '.', 0, /* TOK_DOT : put every command before this one */ @@ -1027,6 +1029,39 @@ static mode_t a2mode(char *ascii) { return m; } +void flush_stdin() { + int ret; + fd_set in; + struct timeval tv; + + while (1) { + FD_ZERO(&in); + FD_SET(0, &in); + tv.tv_sec = tv.tv_usec = 0; + ret = select(1, &in, NULL, NULL, &tv); + if (ret <= 0) + break; + read(0, &ret, sizeof(ret)); + } +} + +/* waits <delay> seconds for a character to be entered from stdin. It returns + * zero if the timeout expires, otherwise it flushes stdin and returns 1 + */ +int keypressed(int delay) { + int ret; + fd_set in; + struct timeval tv; + FD_ZERO(&in); + FD_SET(0, &in); + tv.tv_sec = delay; tv.tv_usec=0; + ret = select(1, &in, NULL, NULL, &tv); + if (ret <= 0) + return 0; + flush_stdin(); + return 1; +} + int main(int argc, char **argv, char **envp) { int old_umask; int pid1, err; @@ -1119,6 +1154,7 @@ int main(int argc, char **argv, char **envp) { * can safely ignore and overwrite /dev in case of linuxrc, reason why * we don't test the presence of /dev/console. */ +#if 0 if (linuxrc || stat(dev_console, &statf) == -1) { print("init/info: /dev/console not found, rebuilding /dev.\n"); if (mount(dev_name, dev_name, tmpfs_fs, MS_MGC_VAL, dev_options) == -1) @@ -1150,7 +1186,7 @@ int main(int argc, char **argv, char **envp) { #endif return 0; } - +#endif /* if /dev/root is non-existent, we'll try to make it now */ if (stat(dev_root, &statf) == -1) { @@ -1222,7 +1258,7 @@ int main(int argc, char **argv, char **envp) { /* don't report prompt errors to the rest of the config ! */ error = 0; } - } + } /* end of kbd */ if (cmd_input == INPUT_FILE) { token = parse_cfg(&cfg_line); @@ -1238,7 +1274,7 @@ int main(int argc, char **argv, char **envp) { cond = token & TOK_COND; token &= ~TOK_COND; - if (cfg_args[tokens[token].minargs] == NULL) { + if (cfg_args[(int)tokens[token].minargs] == NULL) { print("Missing args\n"); continue; } @@ -1356,9 +1392,12 @@ int main(int argc, char **argv, char **envp) { error = context[brace_level].error; continue; - } else if (token == TOK_RD || token == TOK_EC) { - /* ec <string> : echo a string */ - /* rd <string> : display message then read commands from the console instead of the file */ + } else if (token == TOK_RD || token == TOK_EC || token == TOK_WK) { + /* ec <string> : echo a string + rd <string> : display message then read commands from the console instead of the file + wk <string> <delay> : display message and wait for a key for at most <delay> seconds. + returns TRUE if a key is pressed, FALSE otherwise. + */ char *msg; int len; @@ -1367,6 +1406,12 @@ int main(int argc, char **argv, char **envp) { cfg_args[1][len] = '\n'; write(1, cfg_args[1], len + 1); } + + if (token == TOK_WK) { + error = !keypressed(ATOL(cfg_args[2])); + goto finish_cmd; + } + if (token != TOK_RD) goto finish_cmd; @@ -1678,7 +1723,6 @@ int main(int argc, char **argv, char **envp) { if (mount(var_dir, var_dir, tmpfs_fs, MS_MGC_VAL, NULL) == -1) print("init/err: cannot mount /var.\n"); else { - int i; print("init/info: /var has been mounted.\n"); mkdir(var_dir, 0755); mkdir(var_tmp, 01777); diff --git a/init/test.cfg b/init/test.cfg new file mode 100644 index 0000000..c2b9e85 --- /dev/null +++ b/init/test.cfg @@ -0,0 +1,12 @@ +ec "salut" + +wk "Appuyer sur entrée dans les 2 secondes..." 2 +&{ + ec "vous avez appuyé sur entrée" +} +|{ + ec "vous n'avez pas appuyé sur entrée" +} + +rd "shell" + @@ -32,6 +32,8 @@ System checks are performed in this order : .TP \- Opening of \fB/dev/watchdog\fP if it was not previously open ; .TP +\- Opening of \fB/dev/misc/watchdog\fP if \fB/dev/watchdog\fP failed ; +.TP \- Allocation then release of 4 kB of memory to check that the VM subsystem is still operating, and to give the daemon a chance to die under Out-of-Memory conditions (OOM) ; @@ -64,7 +66,7 @@ accessibility of the root directory every second. Launching it with bombs because it soon will not get enough time slices to ping the driver. .TP -\fBwdd / /dev/watchdog /proc/version /var/run /tmp/. +\fBwdd / /dev/watchdog /proc/self/root /var/run /tmp/. .br Periodically checks all of these existing entries. This ensures that \fB/\fP is always reachable, that \fB/dev\fP has not been wiped out @@ -7,7 +7,8 @@ #include <sys/stat.h> #include <fcntl.h> -const char dev_wd_str[] = "/dev/watchdog"; +const char dev_wd_str[] = "/dev/watchdog"; /* standard entry */ +const char dev_misc_str[] = "/dev/misc/watchdog"; /* devfs entry */ const char root_str[] = "/"; /* @@ -103,6 +104,8 @@ int main (int argc, char **argv) { while (1) { if (dev == -1) dev = open(dev_wd_str, O_RDWR); + if (dev == -1) + dev = open(dev_misc_str, O_RDWR); if ((dev != -1) && (write(dev, dev_wd_str, 1) != 1)) { /* write error, we'll restart */ close(dev); |