Author: pjd
Date: Fri Aug  6 20:48:10 2010
New Revision: 210965
URL: http://svn.freebsd.org/changeset/base/210965

Log:
  Add mknod(2) support.
  
  Submitted by: Jan Senolt <seno...@centrum.cz>
  Submitted by: Milan Cermak <milan.cer...@sun.com>

Modified:
  head/tools/regression/fstest/fstest.c

Modified: head/tools/regression/fstest/fstest.c
==============================================================================
--- head/tools/regression/fstest/fstest.c       Fri Aug  6 20:46:26 2010        
(r210964)
+++ head/tools/regression/fstest/fstest.c       Fri Aug  6 20:48:10 2010        
(r210965)
@@ -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 
        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,
        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;
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to