diff --git a/qa/kern/build.json b/qa/kern/build.json index 8d9b9a3..5072cae 100644 --- a/qa/kern/build.json +++ b/qa/kern/build.json @@ -16,6 +16,7 @@ "awake_note1.c", "brk.c", "broken.c", + "dup.c", "execl.c", "float.c", "fork.c", diff --git a/qa/kern/dup.c b/qa/kern/dup.c new file mode 100644 index 0000000..d464c22 --- /dev/null +++ b/qa/kern/dup.c @@ -0,0 +1,70 @@ +/* + * This file is part of Jehanne. + * + * Copyright (C) 2015 Giacomo Tesio + * + * Jehanne is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * Jehanne is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jehanne. If not, see . + */ +#include +#include + +/* check devdup Nctl format */ + + +void +main(void) +{ + char buf[256]; + int fd, r; + + fd = open("/fd/0ctl", OREAD|OCEXEC); + if(fd < 0) + goto Fail; + r = read(fd, buf, sizeof(buf)); + if(r < 0) + goto Fail; + close(fd); + print("Got 0ctl: %s\n", buf); + + fd = open("/fd/1ctl", OREAD|OCEXEC); + if(fd < 0) + goto Fail; + r = read(fd, buf, sizeof(buf)); + if(r < 0) + goto Fail; + close(fd); + print("Got 1ctl: %s\n", buf); + + fd = open("/fd/2ctl", OREAD|OCEXEC); + if(fd < 0) + goto Fail; + r = read(fd, buf, sizeof(buf)); + if(r < 0) + goto Fail; + print("Got 2ctl: %s\n", buf); + + snprint(buf, sizeof(buf), "/fd/%dctl", fd); + fd = open(buf, OREAD); + if(fd < 0) + goto Fail; + r = read(fd, buf, sizeof(buf)); + if(r < 0) + goto Fail; + print("Got: %s\n", buf); + close(fd); + exits(nil); + +Fail: + print("FAIL\n"); + exits("FAIL"); +} diff --git a/qa/kern/dup.runner b/qa/kern/dup.runner new file mode 100755 index 0000000..369bbab --- /dev/null +++ b/qa/kern/dup.runner @@ -0,0 +1,37 @@ +#!/cmd/rc + +runner=$0 +test = `{echo $runner|sed 's/.runner//'} +test_output = /tmp/output-`{basename $test} + +if ( test -e $test_output) rm $test_output + +$test > $test_output +testpid=$apid + +wait $testpid + +if ( ! cat $test_output | grep 'Got 0ctl: 0 r ' > /dev/null ) { + cat $test_output + echo FAIL + exit FAIL +} +if ( ! cat $test_output | grep 'Got 1ctl: 1 w ' > /dev/null ) { + cat $test_output + echo FAIL + exit FAIL +} +if ( ! cat $test_output | grep 'Got 2ctl: 2 w ' > /dev/null ) { + cat $test_output + echo FAIL + exit FAIL +} +if ( ! cat $test_output | grep 'Got: 3 rE ' > /dev/null ) { + cat $test_output + echo FAIL + exit FAIL +} + +rm $test_output +echo PASS +exit PASS diff --git a/sys/src/kern/port/devproc.c b/sys/src/kern/port/devproc.c index bf019cf..5588c04 100644 --- a/sys/src/kern/port/devproc.c +++ b/sys/src/kern/port/devproc.c @@ -564,11 +564,11 @@ _procfdprint(Chan *c, int fd, int w, char *s, int ns, char *modestr) { int n; char *flags; - if((c->mode&(OCEXEC|ORCLOSE)) == (OCEXEC|ORCLOSE)) + if((c->flag&(OCEXEC|ORCLOSE)) == (OCEXEC|ORCLOSE)) flags = "ED"; - else if(c->mode&OCEXEC) + else if(c->flag&OCEXEC) flags = "E "; - else if(c->mode&ORCLOSE) + else if(c->flag&ORCLOSE) flags = "D "; else flags = " ";