#endif
#include <errno.h>
+#include <stdarg.h>
#include <sys/syscall.h>
#include <unistd.h>
-#include <sys/uio.h>
+#include <fcntl.h>
#include <sys/types.h>
+#include <sys/stat.h>
#include <sys/queue.h>
#include "sysio.h"
+#include "xtio.h"
+#include "native.h"
#include "inode.h"
#include "dev.h"
#define dowrite(f, b, n) write_yod(f, b, n)
#define doread(f, b, n) read_yod(f, b, n)
#else
-#define dowrite(f, b, n) syscall(SYS_write, f, b, n)
-#define doread(f, b, n) syscall(SYS_read, f, b, n)
+#define dowrite(f, b, n) syscall(SYSIO_SYS_write, f, b, n)
+#define doread(f, b, n) syscall(SYSIO_SYS_read, f, b, n)
#endif
/*
static int stdfd_write(struct inode *ino, struct ioctx *ioctx);
static int stdfd_iodone(struct ioctx *ioctx);
static int stdfd_datasync(struct inode *ino);
+static int stdfd_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn);
static int stdfd_ioctl(struct inode *ino,
unsigned long int request,
va_list ap);
stdfd_operations.inop_read = stdfd_read;
stdfd_operations.inop_write = stdfd_write;
stdfd_operations.inop_iodone = stdfd_iodone;
+ stdfd_operations.inop_fcntl = stdfd_fcntl;
stdfd_operations.inop_datasync = stdfd_datasync;
stdfd_operations.inop_ioctl = stdfd_ioctl;
_SYSIO_OFF_T off __IS_UNUSED,
struct inode *ino)
{
+ int fd = SYSIO_MINOR_DEV(ino->i_stbuf.st_rdev);
+ int cc;
- int fd = SYSIO_MINOR_DEV(ino->i_rdev);
-
- return doread(fd, buf, nbytes);
+ cc = doread(fd, buf, nbytes);
+ if (cc < 0)
+ cc = -errno;
+ return cc;
}
static int
_SYSIO_OFF_T off __IS_UNUSED,
struct inode *ino)
{
- int fd = SYSIO_MINOR_DEV(ino->i_rdev);
+ int fd = SYSIO_MINOR_DEV(ino->i_stbuf.st_rdev);
+ int cc;
- return dowrite(fd, buf, nbytes);
+ cc = dowrite(fd, buf, nbytes);
+ if (cc < 0)
+ cc = -errno;
+ return cc;
}
static int
}
static int
+stdfd_fcntl(struct inode *ino,
+ int cmd,
+ va_list ap,
+ int *rtn)
+{
+ int err;
+ int fd = SYSIO_MINOR_DEV(ino->i_stbuf.st_rdev);
+ long arg;
+
+ err = 0;
+ switch (cmd) {
+ case F_GETFL:
+ *rtn = syscall(SYS_fcntl, fd, cmd);
+ if (*rtn == -1)
+ err = -errno;
+ break;
+ case F_SETFL:
+ arg = va_arg(ap, long);
+ *rtn = syscall(SYS_fcntl, fd, cmd, arg);
+ if (*rtn == -1)
+ err = -errno;
+ va_end(ap);
+ break;
+ default:
+ *rtn = -1;
+ err = -EINVAL;
+ }
+ return err;
+}
+
+static int
stdfd_datasync(struct inode *ino __IS_UNUSED)
{