diff options
author | Pedro Martelletto <pedro@cvs.openbsd.org> | 2005-12-07 01:43:40 +0000 |
---|---|---|
committer | Pedro Martelletto <pedro@cvs.openbsd.org> | 2005-12-07 01:43:40 +0000 |
commit | df66fdcb3f6680b2b175bd9b5c3073525f633010 (patch) | |
tree | 53e7f26308ef51361b95e07a676c448384fa409b | |
parent | fc667a26ab543e5920e851613b1243fc5f0c129a (diff) |
Move Art's fdescfs regress to a now more appropriate place
-rw-r--r-- | regress/sys/dev/Makefile | 3 | ||||
-rw-r--r-- | regress/sys/dev/fdesc/Makefile | 7 | ||||
-rw-r--r-- | regress/sys/dev/fdesc/confuse.c | 43 |
3 files changed, 52 insertions, 1 deletions
diff --git a/regress/sys/dev/Makefile b/regress/sys/dev/Makefile index 364bf9269dd..d84da9c709e 100644 --- a/regress/sys/dev/Makefile +++ b/regress/sys/dev/Makefile @@ -1,5 +1,6 @@ -# $OpenBSD: Makefile,v 1.2 2003/07/31 15:56:32 deraadt Exp $ +# $OpenBSD: Makefile,v 1.3 2005/12/07 01:43:39 pedro Exp $ SUBDIR+= audio +SUBDIR+= fdesc .include <bsd.subdir.mk> diff --git a/regress/sys/dev/fdesc/Makefile b/regress/sys/dev/fdesc/Makefile new file mode 100644 index 00000000000..dcb1da1a900 --- /dev/null +++ b/regress/sys/dev/fdesc/Makefile @@ -0,0 +1,7 @@ +# $OpenBSD: Makefile,v 1.1 2005/12/07 01:43:39 pedro Exp $ + +SUBDIR=confuse + +install: + +.include <bsd.subdir.mk> diff --git a/regress/sys/dev/fdesc/confuse.c b/regress/sys/dev/fdesc/confuse.c new file mode 100644 index 00000000000..e61b242a844 --- /dev/null +++ b/regress/sys/dev/fdesc/confuse.c @@ -0,0 +1,43 @@ +/* $OpenBSD: confuse.c,v 1.1 2005/12/07 01:43:39 pedro Exp $ */ + +/* + * Written by Artur Grabowski <art@openbsd.org> in 2002. Public Domain. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <err.h> +#include <fcntl.h> +#include <errno.h> + +int +main(int argc, char *argv[]) +{ + char fname[64]; + int fd, newfd; + + if ((fd = open("/dev/null", O_RDONLY)) < 0) + err(1, "open(/dev/null)"); + + /* Try to confuse fdescfs by making it open into itself. */ + close(fd); + + snprintf(fname, sizeof(fname), "/dev/fd/%d", fd); + + if ((newfd = open(fname, O_RDONLY)) == fd) + errx(1, "open of %s to %d succeeded, beware.", fname, fd); + + if (newfd >= 0) + errx(1, "open(%s) gave us the unexpected %d", fname, fd); + + if (errno == ENOENT) + err(1, "open(%s)", fname); + + if (errno == ENXIO) + errx(1, "no support for fdesc in kernel"); + + warn("errno was (%d)", errno); + + return 0; +} |