Secret printing in libraries and shell and silencing randcall.

This commit is contained in:
Geoffrey Challen 2016-01-01 11:47:43 -05:00
parent a2b15b77aa
commit 036cae3982
5 changed files with 44 additions and 4 deletions

View File

@ -534,7 +534,7 @@ interactive(void)
struct exitinfo ei;
while (1) {
printf("OS/161$ ");
printsf("OS/161$ ");
getcmd(buf, sizeof(buf));
docommand(buf, &ei);
printstatus(&ei, 0);

View File

@ -56,6 +56,11 @@ int vprintf(const char *fmt, __va_list ap);
int snprintf(char *buf, size_t len, const char *fmt, ...);
int vsnprintf(char *buf, size_t len, const char *fmt, __va_list ap);
/* Automated testing extensions. */
int tprintf(const char *fmt, ...);
int printsf(const char *fmt, ...);
/* Print the argument string and then a newline. Returns 0 or -1 on error. */
int puts(const char *);

View File

@ -31,6 +31,8 @@
#include <stdarg.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <kern/secret.h>
/*
* printf - C standard I/O function.
@ -76,3 +78,36 @@ vprintf(const char *fmt, va_list ap)
}
return chars;
}
/* printf variant that is quiet during automated testing */
int
tprintf(const char *fmt, ...)
{
int chars;
va_list ap;
if (strcmp(KERNEL_SECRET, "") != 0) {
return 0;
}
va_start(ap, fmt);
chars = vprintf(fmt, ap);
va_end(ap);
return chars;
}
/* printf variant that prepends the kernel secret */
int
printsf(const char *fmt, ...)
{
int chars;
va_list ap;
printf("%s: ", KERNEL_SECRET);
va_start(ap, fmt);
chars = vprintf(fmt, ap);
va_end(ap);
return chars;
}

View File

@ -67,7 +67,7 @@ awk < $1 '
if (i<NF) printf ", ";
}
printf ");\n";
printf"\tprintf(\"%%-47s\", buf);\n";
printf"\ttprintf(\"%%-47s\", buf);\n";
#printf "\tfflush(stdout);\n";
printf "\n";
@ -88,7 +88,7 @@ awk < $1 '
}
printf ");\n";
printf "\tprintf(\" result %%d, errno %%d\\n\", result, errno);\n";
printf "\ttprintf(\" result %%d, errno %%d\\n\", result, errno);\n";
printf "\tif (dofork) {\n";
printf "\t\texit(0);\n";
printf "\t}\n";

View File

@ -157,7 +157,7 @@ main(int argc, char *argv[])
}
}
printf("Seed: %d Count: %d\n", seed, count);
tprintf("Seed: %d Count: %d\n", seed, count);
srandom(seed);
trycalls(an, dofork, count);