_fcntl.c

Go to the documentation of this file.
00001 #include <lib.h>
00002 #define fcntl _fcntl
00003 #include <fcntl.h>
00004 #include <stdarg.h>
00005 
00006 #if _ANSI
00007 PUBLIC int fcntl(int fd, int cmd, ...)
00008 #else
00009 PUBLIC int fcntl(fd, cmd)
00010 int fd;
00011 int cmd;
00012 #endif
00013 {
00014   va_list argp;
00015   message m;
00016 
00017   va_start(argp, cmd);
00018 
00019   /* Set up for the sensible case where there is no variable parameter.  This
00020    * covers F_GETFD, F_GETFL and invalid commands.
00021    */
00022   m.m1_i3 = 0;
00023   m.m1_p1 = NIL_PTR;
00024 
00025   /* Adjust for the stupid cases. */
00026   switch(cmd) {
00027      case F_DUPFD:
00028      case F_SETFD:
00029      case F_SETFL:
00030         m.m1_i3 = va_arg(argp, int);
00031         break;
00032      case F_GETLK:
00033      case F_SETLK:
00034      case F_SETLKW:
00035      case F_FREESP:
00036         m.m1_p1 = (char *) va_arg(argp, struct flock *);
00037         break;
00038   }
00039 
00040   /* Clean up and make the system call. */
00041   va_end(argp);
00042   m.m1_i1 = fd;
00043   m.m1_i2 = cmd;
00044   return(_syscall(FS, FCNTL, &m));
00045 }

Generated on Fri Apr 14 22:57:27 2006 for minix by  doxygen 1.4.6