lots of work on determinism in the linux driver.

This commit is contained in:
2022-02-18 03:59:21 -05:00
parent 6a6d2c7f75
commit ba1e923b5a
10 changed files with 175 additions and 110 deletions

View File

@@ -225,7 +225,25 @@ static int console_read(char *bytes, int nbytes) {
return read(0, bytes, nbytes);
}
static std::string_view read_file(const char *fn, char *buf, int bufsize, UmmString &err) {
int nread;
int fd = open(fn, O_RDONLY);
if (fd < 0) goto error_errno;
nread = read(fd, buf, bufsize);
if (nread < 0) goto error_errno;
if (nread == bufsize) {
err = "file too large";
goto error;
}
buf[nread] = 0;
err = "";
return std::string_view(buf, nread);
error_errno:
err = strerror_str(errno);
error:
buf[0] = 0;
return std::string_view(buf, 0);
}
static void disable_randomization(int argc, char *argv[]) {
const int old_personality = personality(ADDR_NO_RANDOMIZE);