2011-02-17 18:11:09 +01:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#include "namespace.h"
|
|
|
|
#include <lib.h>
|
|
|
|
|
2013-11-04 22:48:08 +01:00
|
|
|
#include <string.h>
|
2011-02-17 18:11:09 +01:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#ifdef __weak_alias
|
|
|
|
__weak_alias(fcntl, _fcntl)
|
|
|
|
#endif
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
int fcntl(int fd, int cmd, ...)
|
2011-02-17 18:11:09 +01:00
|
|
|
{
|
2013-08-31 23:11:34 +02:00
|
|
|
va_list argp;
|
2011-02-17 18:11:09 +01:00
|
|
|
message m;
|
|
|
|
|
|
|
|
va_start(argp, cmd);
|
|
|
|
|
|
|
|
/* Set up for the sensible case where there is no variable parameter. This
|
|
|
|
* covers F_GETFD, F_GETFL and invalid commands.
|
|
|
|
*/
|
2013-11-04 22:48:08 +01:00
|
|
|
memset(&m, 0, sizeof(m));
|
2011-02-17 18:11:09 +01:00
|
|
|
|
|
|
|
/* Adjust for the stupid cases. */
|
|
|
|
switch(cmd) {
|
|
|
|
case F_DUPFD:
|
|
|
|
case F_SETFD:
|
|
|
|
case F_SETFL:
|
2013-11-04 22:48:08 +01:00
|
|
|
m.VFS_FCNTL_ARG_INT = va_arg(argp, int);
|
2011-02-17 18:11:09 +01:00
|
|
|
break;
|
|
|
|
case F_GETLK:
|
|
|
|
case F_SETLK:
|
|
|
|
case F_SETLKW:
|
|
|
|
case F_FREESP:
|
2013-11-04 22:48:08 +01:00
|
|
|
m.VFS_FCNTL_ARG_PTR = (char *) va_arg(argp, struct flock *);
|
2011-02-17 18:11:09 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clean up and make the system call. */
|
|
|
|
va_end(argp);
|
2013-11-04 22:48:08 +01:00
|
|
|
m.VFS_FCNTL_FD = fd;
|
|
|
|
m.VFS_FCNTL_CMD = cmd;
|
|
|
|
return(_syscall(VFS_PROC_NR, VFS_FCNTL, &m));
|
2011-02-17 18:11:09 +01:00
|
|
|
}
|