Changeset View
Changeset View
Standalone View
Standalone View
bin/sh/input.c
Show First 20 Lines • Show All 346 Lines • ▼ Show 20 Lines | /*out2fmt_flush("*** calling popstring: restoring to '%s'\n", parsenextc);*/ | ||||
if (sp != &(parsefile->basestrpush)) | if (sp != &(parsefile->basestrpush)) | ||||
ckfree(sp); | ckfree(sp); | ||||
INTON; | INTON; | ||||
} | } | ||||
/* | /* | ||||
* Set the input to take input from a file. If push is set, push the | * Set the input to take input from a file. If push is set, push the | ||||
* old input onto the stack first. | * old input onto the stack first. | ||||
* About verify: | |||||
* -1: Obey verifyflag | |||||
* 0: Do not verify | |||||
* 1: Do verify | |||||
*/ | */ | ||||
void | void | ||||
setinputfile(const char *fname, int push) | setinputfile(const char *fname, int push, int verify) | ||||
{ | { | ||||
int e; | int e; | ||||
int fd; | int fd; | ||||
int fd2; | int fd2; | ||||
int oflags = O_RDONLY | O_CLOEXEC; | |||||
if (verify == 1 || (verify == -1 && verifyflag)) | |||||
oflags |= O_VERIFY; | |||||
INTOFF; | INTOFF; | ||||
if ((fd = open(fname, O_RDONLY | O_CLOEXEC)) < 0) { | if ((fd = open(fname, oflags)) < 0) { | ||||
e = errno; | e = errno; | ||||
errorwithstatus(e == ENOENT || e == ENOTDIR ? 127 : 126, | errorwithstatus(e == ENOENT || e == ENOTDIR ? 127 : 126, | ||||
"cannot open %s: %s", fname, strerror(e)); | "cannot open %s: %s", fname, strerror(e)); | ||||
} | } | ||||
if (fd < 10) { | if (fd < 10) { | ||||
fd2 = fcntl(fd, F_DUPFD_CLOEXEC, 10); | fd2 = fcntl(fd, F_DUPFD_CLOEXEC, 10); | ||||
close(fd); | close(fd); | ||||
if (fd2 < 0) | if (fd2 < 0) | ||||
▲ Show 20 Lines • Show All 147 Lines • Show Last 20 Lines |