Hi, this diff merges cmd.c files of sys/stand/boot and sys/arch/zaurus/stand/zboot. Back in time, that file was copied to add "clear" command for zaurus. Revision 1.2 of zaurus' file added some clean ups which could be merged back.
Otherwise, get the changes of stand/boot into stand/zboot, too. Greatly reduces diff-Output between these files: Just "clear" command, the same way it was back then. "cc -c" works for zaurus' cmd.c. I don't have a zaurus, so it would be nice if a zaurus owner can test these changes. Tobias Index: arch/zaurus/stand/zboot/boot.8 =================================================================== RCS file: /cvs/src/sys/arch/zaurus/stand/zboot/boot.8,v retrieving revision 1.10 diff -u -p -r1.10 boot.8 --- arch/zaurus/stand/zboot/boot.8 27 Sep 2012 12:26:28 -0000 1.10 +++ arch/zaurus/stand/zboot/boot.8 29 Jun 2014 18:35:44 -0000 @@ -103,6 +103,12 @@ This file may contain any commands .Nm accepts at the interactive prompt. Though default settings usually suffice, they can be changed here. +.\" XXX CHECK_SKIP_CONF is not defined... +.\" .Pp +.\" .Pa boot.conf +.\" processing can be skipped by holding down either Control key as +.\" .Nm +.\" starts. .It The header line .Pp Index: arch/zaurus/stand/zboot/cmd.c =================================================================== RCS file: /cvs/src/sys/arch/zaurus/stand/zboot/cmd.c,v retrieving revision 1.3 diff -u -p -r1.3 cmd.c --- arch/zaurus/stand/zboot/cmd.c 21 Mar 2007 03:29:05 -0000 1.3 +++ arch/zaurus/stand/zboot/cmd.c 29 Jun 2014 18:35:44 -0000 @@ -29,13 +29,8 @@ #include <sys/param.h> #include <sys/reboot.h> -#ifdef REGRESS -#include <sys/stat.h> -#include <errno.h> -#else #include <libsa.h> #include <lib/libkern/funcs.h> -#endif #include <stand/boot/cmd.h> @@ -57,6 +52,10 @@ extern const struct cmd_table MACHINE_CM extern int Xset(void); extern int Xenv(void); +#ifdef CHECK_SKIP_CONF +extern int CHECK_SKIP_CONF(void); +#endif + extern const struct cmd_table cmd_set[]; const struct cmd_table cmd_table[] = { {"#", CMDT_CMD, Xnop}, /* XXX must be first */ @@ -103,6 +102,14 @@ read_conf(void) #endif int fd, rc = 0; +#ifdef CHECK_SKIP_CONF + if (CHECK_SKIP_CONF()) { + printf("boot.conf processing skipped at operator request\n"); + cmd.timeout = 0; + return -1; /* Pretend file wasn't found */ + } +#endif + if ((fd = open(qualify(cmd.conf), 0)) < 0) { if (errno != ENOENT && errno != ENXIO) { printf("open(%s): %s\n", cmd.path, strerror(errno)); @@ -208,12 +215,7 @@ docmd(void) } cmd.argv[cmd.argc] = NULL; -#ifdef REGRESS - printf("%s %s\n", cmd.argv[0], - (cmd.argv[1] == NULL) ? "(null)" : cmd.argv[1]); -#else return (*cmd.cmd->cmd_exec)(); -#endif } static char * @@ -280,7 +282,7 @@ readline(char *buf, size_t n, int to) continue; case '\n': case '\r': - p[1] = *p = '\0'; + *p = '\0'; break; case '\b': case '\177': @@ -290,11 +292,13 @@ readline(char *buf, size_t n, int to) } continue; default: - if (p - buf < n-1) - *p++ = ch; - else { - putchar('\007'); - putchar('\177'); + if (ch >= ' ' && ch < '\177') { + if (p - buf < n-1) + *p++ = ch; + else { + putchar('\007'); + putchar('\177'); + } } continue; } @@ -358,8 +362,6 @@ Xmachine(void) static int Xclear(void) { - int i; - printf("\033[H\033[J"); return 0; } Index: stand/boot/cmd.c =================================================================== RCS file: /cvs/src/sys/stand/boot/cmd.c,v retrieving revision 1.62 diff -u -p -r1.62 cmd.c --- stand/boot/cmd.c 27 Jun 2014 20:35:37 -0000 1.62 +++ stand/boot/cmd.c 29 Jun 2014 18:35:46 -0000 @@ -129,7 +129,6 @@ read_conf(void) char *p = cmd_buf; cmd.cmd = NULL; - do { rc = read(fd, p, 1); } while (rc > 0 && *p++ != '\n' && @@ -155,10 +154,8 @@ read_conf(void) /* Don't want to run the truncated command */ rc = -1; } - *p = '\0'; } - } while (rc > 0 && !(rc = docmd())); close(fd); @@ -378,25 +375,25 @@ Xstty(void) char *cp; dev_t dev; - if (cmd.argc == 1) + if (cmd.argc == 1) { printf("%s speed is %d\n", ttyname(0), cnspeed(0, -1)); - else { - dev = ttydev(cmd.argv[1]); - if (dev == NODEV) - printf("%s not a console device\n", cmd.argv[1]); - else { - if (cmd.argc == 2) - printf("%s speed is %d\n", cmd.argv[1], - cnspeed(dev, -1)); - else { - sp = 0; - for (cp = cmd.argv[2]; *cp && isdigit(*cp); cp++) - sp = sp * 10 + (*cp - '0'); - cnspeed(dev, sp); - } - } + return 0; + } + dev = ttydev(cmd.argv[1]); + if (dev == NODEV) { + printf("%s not a console device\n", cmd.argv[1]); + return 0; } + if (cmd.argc == 2) + printf("%s speed is %d\n", cmd.argv[1], + cnspeed(dev, -1)); + else { + sp = 0; + for (cp = cmd.argv[2]; isdigit(*cp); cp++) + sp = sp * 10 + (*cp - '0'); + cnspeed(dev, sp); + } return 0; } @@ -407,8 +404,6 @@ Xtime(void) if (cmd.argc == 1) printf(ctime(&tt)); - else { - } return 0; } @@ -429,8 +424,8 @@ Xls(void) ls(cmd.path, &sb); else { if ((fd = opendir(cmd.path)) < 0) { - printf ("opendir(%s): %s\n", cmd.path, - strerror(errno)); + printf("opendir(%s): %s\n", cmd.path, + strerror(errno)); return 0; } @@ -440,10 +435,10 @@ Xls(void) *p++ = '/'; *p = '\0'; - while(readdir(fd, p) >= 0) { + while (readdir(fd, p) >= 0) { if (stat(cmd.path, &sb) < 0) printf("stat(%s): %s\n", cmd.path, - strerror(errno)); + strerror(errno)); else ls(p, &sb); }