diff options
author | pjd <pjd@FreeBSD.org> | 2010-08-06 20:48:10 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2010-08-06 20:48:10 +0000 |
commit | 3898aedc01d53c7a74e3ee41c02fe7dc8f2a8184 (patch) | |
tree | 33bc0e26a4dfa5bc0156323880065df8754da810 /tools | |
parent | 9fed776db8174ec8269719eaa619e11ae1700f2d (diff) | |
download | FreeBSD-src-3898aedc01d53c7a74e3ee41c02fe7dc8f2a8184.zip FreeBSD-src-3898aedc01d53c7a74e3ee41c02fe7dc8f2a8184.tar.gz |
Add mknod(2) support.
Submitted by: Jan Senolt <senoltj@centrum.cz>
Submitted by: Milan Cermak <Milan.Cermak@Sun.COM>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/regression/fstest/fstest.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/regression/fstest/fstest.c b/tools/regression/fstest/fstest.c index 04ccbb3..976ad8b 100644 --- a/tools/regression/fstest/fstest.c +++ b/tools/regression/fstest/fstest.c @@ -27,9 +27,13 @@ */ #include <sys/param.h> +#include <sys/types.h> #include <sys/stat.h> #include <sys/socket.h> #include <sys/un.h> +#ifndef makedev +#include <sys/mkdev.h> +#endif #include <assert.h> #include <ctype.h> @@ -66,6 +70,7 @@ enum action { ACTION_SYMLINK, ACTION_RENAME, ACTION_MKFIFO, + ACTION_MKNOD, ACTION_BIND, ACTION_CONNECT, ACTION_CHMOD, @@ -115,6 +120,7 @@ static struct syscall_desc syscalls[] = { { "symlink", ACTION_SYMLINK, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, { "rename", ACTION_RENAME, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, { "mkfifo", ACTION_MKFIFO, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, + { "mknod", ACTION_MKNOD, { TYPE_STRING, TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE} }, { "bind", ACTION_BIND, { TYPE_STRING, TYPE_NONE } }, { "connect", ACTION_CONNECT, { TYPE_STRING, TYPE_NONE } }, { "chmod", ACTION_CHMOD, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, @@ -359,6 +365,10 @@ show_stat(struct stat64 *sp, const char *what) else if (strcmp(what, "flags") == 0) printf("%s", flags2str(chflags_flags, (long long)sp->st_flags)); #endif + else if (strcmp(what, "major") == 0) + printf("%u", (unsigned int)major(sp->st_rdev)); + else if (strcmp(what, "minor") == 0) + printf("%u", (unsigned int)minor(sp->st_rdev)); else if (strcmp(what, "type") == 0) { switch (sp->st_mode & S_IFMT) { case S_IFIFO: @@ -503,6 +513,29 @@ call_syscall(struct syscall_desc *scall, char *argv[]) case ACTION_MKFIFO: rval = mkfifo(STR(0), (mode_t)NUM(1)); break; + case ACTION_MKNOD: + { + mode_t ntype; + dev_t dev; + + dev = makedev(NUM(3), NUM(4)); + if (strcmp(STR(1), "c") == 0) /* character device */ + ntype = S_IFCHR; + else if (strcmp(STR(1), "b") == 0) /* block device */ + ntype = S_IFBLK; + else if (strcmp(STR(1), "f") == 0) /* fifo special */ + ntype = S_IFIFO; + else if (strcmp(STR(1), "d") == 0) /* directory */ + ntype = S_IFDIR; + else if (strcmp(STR(1), "o") == 0) /* regular file */ + ntype = S_IFREG; + else { + fprintf(stderr, "wrong argument 1\n"); + exit(1); + } + rval = mknod(STR(0), ntype | NUM(2), dev); + break; + } case ACTION_BIND: { struct sockaddr_un sun; |