1*433d6423SLionel Sambuc #include <sys/cdefs.h> 2*433d6423SLionel Sambuc #include "namespace.h" 3*433d6423SLionel Sambuc #include <lib.h> 4*433d6423SLionel Sambuc 5*433d6423SLionel Sambuc #include <string.h> 6*433d6423SLionel Sambuc #include <fcntl.h> 7*433d6423SLionel Sambuc #include <stdarg.h> 8*433d6423SLionel Sambuc 9*433d6423SLionel Sambuc int fcntl(int fd, int cmd, ...) 10*433d6423SLionel Sambuc { 11*433d6423SLionel Sambuc va_list argp; 12*433d6423SLionel Sambuc message m; 13*433d6423SLionel Sambuc 14*433d6423SLionel Sambuc va_start(argp, cmd); 15*433d6423SLionel Sambuc 16*433d6423SLionel Sambuc /* Set up for the sensible case where there is no variable parameter. This 17*433d6423SLionel Sambuc * covers F_GETFD, F_GETFL and invalid commands. 18*433d6423SLionel Sambuc */ 19*433d6423SLionel Sambuc memset(&m, 0, sizeof(m)); 20*433d6423SLionel Sambuc 21*433d6423SLionel Sambuc /* Adjust for the stupid cases. */ 22*433d6423SLionel Sambuc switch(cmd) { 23*433d6423SLionel Sambuc case F_DUPFD: 24*433d6423SLionel Sambuc case F_SETFD: 25*433d6423SLionel Sambuc case F_SETFL: 26*433d6423SLionel Sambuc m.m_lc_vfs_fcntl.arg_int = va_arg(argp, int); 27*433d6423SLionel Sambuc break; 28*433d6423SLionel Sambuc case F_GETLK: 29*433d6423SLionel Sambuc case F_SETLK: 30*433d6423SLionel Sambuc case F_SETLKW: 31*433d6423SLionel Sambuc case F_FREESP: 32*433d6423SLionel Sambuc m.m_lc_vfs_fcntl.arg_ptr = va_arg(argp, struct flock *); 33*433d6423SLionel Sambuc break; 34*433d6423SLionel Sambuc } 35*433d6423SLionel Sambuc 36*433d6423SLionel Sambuc /* Clean up and make the system call. */ 37*433d6423SLionel Sambuc va_end(argp); 38*433d6423SLionel Sambuc m.m_lc_vfs_fcntl.fd = fd; 39*433d6423SLionel Sambuc m.m_lc_vfs_fcntl.cmd = cmd; 40*433d6423SLionel Sambuc return(_syscall(VFS_PROC_NR, VFS_FCNTL, &m)); 41*433d6423SLionel Sambuc } 42