Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/irix Added system calls: getdents64/ngetdents64
details: https://anonhg.NetBSD.org/src/rev/7224b656239d
branches: trunk
changeset: 521758:7224b656239d
user: manu <manu%NetBSD.org@localhost>
date: Mon Feb 04 20:26:34 2002 +0000
description:
Added system calls: getdents64/ngetdents64
diffstat:
sys/compat/irix/irix_dirent.c | 156 ++++++++++++++++++++++++++++++++++++-
sys/compat/irix/irix_syscall.h | 10 +-
sys/compat/irix/irix_syscallargs.h | 19 ++++-
sys/compat/irix/irix_syscalls.c | 10 +-
sys/compat/irix/irix_sysent.c | 14 +-
sys/compat/irix/irix_types.h | 9 +-
sys/compat/irix/syscalls.master | 9 +-
7 files changed, 205 insertions(+), 22 deletions(-)
diffs (truncated from 378 to 300 lines):
diff -r 0773d67febd2 -r 7224b656239d sys/compat/irix/irix_dirent.c
--- a/sys/compat/irix/irix_dirent.c Mon Feb 04 20:09:46 2002 +0000
+++ b/sys/compat/irix/irix_dirent.c Mon Feb 04 20:26:34 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: irix_dirent.c,v 1.4 2002/02/03 17:41:03 manu Exp $ */
+/* $NetBSD: irix_dirent.c,v 1.5 2002/02/04 20:26:34 manu Exp $ */
/*-
* Copyright (c) 1994, 2001 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irix_dirent.c,v 1.4 2002/02/03 17:41:03 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irix_dirent.c,v 1.5 2002/02/04 20:26:34 manu Exp $");
#include <sys/types.h>
#include <sys/signal.h>
@@ -220,3 +220,155 @@
return irix_sys_ngetdents(p, (void *)&cup, retval);
}
+
+
+/*
+ * The 64 versions are very close to the
+ * 32 bit versions (only 3 lines of diff
+ */
+int
+irix_sys_ngetdents64(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct irix_sys_ngetdents64_args /* {
+ syscallarg(int) fildes;
+ syscallarg(irix_dirent64_t *) buf;
+ syscallarg(unsigned short) nbyte;
+ syscallarg(int *) eof;
+ } */ *uap = v;
+ struct dirent *bdp;
+ struct vnode *vp;
+ caddr_t inp, buf; /* BSD-format */
+ int len, reclen; /* BSD-format */
+ caddr_t outp; /* SVR4-format */
+ int resid, svr4_reclen; /* SVR4-format */
+ struct file *fp;
+ struct uio auio;
+ struct iovec aiov;
+ struct irix_dirent idb;
+ off_t off; /* true file offset */
+ int buflen, error, eofflag;
+ off_t *cookiebuf = NULL, *cookie;
+ int ncookies;
+
+ /* getvnode() will use the descriptor for us */
+ if ((error = getvnode(p->p_fd, SCARG(uap, fildes), &fp)) != 0)
+ return (error);
+
+ if ((fp->f_flag & FREAD) == 0) {
+ error = EBADF;
+ goto out1;
+ }
+
+ vp = (struct vnode *)fp->f_data;
+ if (vp->v_type != VDIR) {
+ error = EINVAL;
+ goto out1;
+ }
+
+ buflen = min(MAXBSIZE, SCARG(uap, nbyte));
+ buf = malloc(buflen, M_TEMP, M_WAITOK);
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+ off = fp->f_offset;
+again:
+ aiov.iov_base = buf;
+ aiov.iov_len = buflen;
+ auio.uio_iov = &aiov;
+ auio.uio_iovcnt = 1;
+ auio.uio_rw = UIO_READ;
+ auio.uio_segflg = UIO_SYSSPACE;
+ auio.uio_procp = p;
+ auio.uio_resid = buflen;
+ auio.uio_offset = off;
+ /*
+ * First we read into the malloc'ed buffer, then
+ * we massage it into user space, one record at a time.
+ */
+ error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &cookiebuf,
+ &ncookies);
+ if (error)
+ goto out;
+
+ inp = buf;
+ outp = (char *)SCARG(uap, buf);
+ resid = SCARG(uap, nbyte);
+ if ((len = buflen - auio.uio_resid) == 0)
+ goto eof;
+
+ for (cookie = cookiebuf; len > 0; len -= reclen) {
+ bdp = (struct dirent *)inp;
+ reclen = bdp->d_reclen;
+ if (reclen & 3)
+ panic("irix_getdents64: bad reclen");
+ if (bdp->d_fileno == 0) {
+ inp += reclen; /* it is a hole; squish it out */
+ off = *cookie++;
+ continue;
+ }
+ svr4_reclen = SVR4_RECLEN(&idb, bdp->d_namlen);
+ if (reclen > len || resid < svr4_reclen) {
+ /* entry too big for buffer, so just stop */
+ outp++;
+ break;
+ }
+ off = *cookie++; /* each entry points to the next */
+ /*
+ * Massage in place to make a SVR4-shaped dirent (otherwise
+ * we have to worry about touching user memory outside of
+ * the copyout() call).
+ */
+ idb.d_ino = (irix_ino64_t)bdp->d_fileno;
+ idb.d_off = (irix_off64_t)off;
+ idb.d_reclen = (u_short)svr4_reclen;
+ strcpy(idb.d_name, bdp->d_name);
+ if ((error = copyout((caddr_t)&idb, outp, svr4_reclen)))
+ goto out;
+ /* advance past this real entry */
+ inp += reclen;
+ /* advance output past SVR4-shaped entry */
+ outp += svr4_reclen;
+ resid -= svr4_reclen;
+ }
+
+ /* if we squished out the whole block, try again */
+ if (outp == (char *)SCARG(uap, buf))
+ goto again;
+ fp->f_offset = off; /* update the vnode offset */
+
+eof:
+ *retval = SCARG(uap, nbyte) - resid;
+out:
+ VOP_UNLOCK(vp, 0);
+ if (cookiebuf)
+ free(cookiebuf, M_TEMP);
+ free(buf, M_TEMP);
+out1:
+ FILE_UNUSE(fp, p);
+ if (SCARG(uap, eof) != NULL)
+ error = copyout(&eofflag, SCARG(uap, eof), sizeof(int));
+ return error;
+}
+
+int
+irix_sys_getdents64(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct irix_sys_ngetdents64_args /* {
+ syscallarg(int) fildes;
+ syscallarg(irix_dirent64_t *) buf;
+ syscallarg(unsigned short) nbyte;
+ syscallarg(int *) eof;
+ } */ *uap = v;
+ struct irix_sys_ngetdents64_args cup;
+
+ SCARG(&cup, fildes) = SCARG(uap, fildes);
+ SCARG(&cup, buf) = SCARG(uap, buf);
+ SCARG(&cup, nbyte) = SCARG(uap, nbyte);
+ SCARG(&cup, eof) = NULL;
+
+ return irix_sys_ngetdents64(p, (void *)&cup, retval);
+}
diff -r 0773d67febd2 -r 7224b656239d sys/compat/irix/irix_syscall.h
--- a/sys/compat/irix/irix_syscall.h Mon Feb 04 20:09:46 2002 +0000
+++ b/sys/compat/irix/irix_syscall.h Mon Feb 04 20:26:34 2002 +0000
@@ -1,10 +1,10 @@
-/* $NetBSD: irix_syscall.h,v 1.20 2002/02/03 17:39:54 manu Exp $ */
+/* $NetBSD: irix_syscall.h,v 1.21 2002/02/04 20:26:34 manu Exp $ */
/*
* System call numbers.
*
* DO NOT EDIT-- this file is automatically generated.
- * created from NetBSD: syscalls.master,v 1.18 2002/02/03 01:21:48 manu Exp
+ * created from NetBSD: syscalls.master,v 1.19 2002/02/03 17:39:54 manu Exp
*/
/* syscall: "syscall" ret: "int" args: */
@@ -313,8 +313,14 @@
/* syscall: "getmountid" ret: "int" args: "const char *" "irix_mountid_t *" */
#define IRIX_SYS_getmountid 203
+/* syscall: "getdents64" ret: "int" args: "int" "irix_dirent64_t *" "int" */
+#define IRIX_SYS_getdents64 205
+
/* syscall: "ngetdents" ret: "int" args: "int" "irix_dirent_t *" "unsigned short" "int *" */
#define IRIX_SYS_ngetdents 207
+/* syscall: "ngetdents64" ret: "int" args: "int" "irix_dirent64_t *" "unsigned short" "int *" */
+#define IRIX_SYS_ngetdents64 208
+
#define IRIX_SYS_MAXSYSCALL 236
#define IRIX_SYS_NSYSENT 236
diff -r 0773d67febd2 -r 7224b656239d sys/compat/irix/irix_syscallargs.h
--- a/sys/compat/irix/irix_syscallargs.h Mon Feb 04 20:09:46 2002 +0000
+++ b/sys/compat/irix/irix_syscallargs.h Mon Feb 04 20:26:34 2002 +0000
@@ -1,10 +1,10 @@
-/* $NetBSD: irix_syscallargs.h,v 1.20 2002/02/03 17:39:54 manu Exp $ */
+/* $NetBSD: irix_syscallargs.h,v 1.21 2002/02/04 20:26:34 manu Exp $ */
/*
* System call argument lists.
*
* DO NOT EDIT-- this file is automatically generated.
- * created from NetBSD: syscalls.master,v 1.18 2002/02/03 01:21:48 manu Exp
+ * created from NetBSD: syscalls.master,v 1.19 2002/02/03 17:39:54 manu Exp
*/
#ifndef _IRIX_SYS__SYSCALLARGS_H_
@@ -281,6 +281,12 @@
syscallarg(irix_mountid_t *) buf;
};
+struct irix_sys_getdents64_args {
+ syscallarg(int) fildes;
+ syscallarg(irix_dirent64_t *) buf;
+ syscallarg(int) nbytes;
+};
+
struct irix_sys_ngetdents_args {
syscallarg(int) fildes;
syscallarg(irix_dirent_t *) buf;
@@ -288,6 +294,13 @@
syscallarg(int *) eof;
};
+struct irix_sys_ngetdents64_args {
+ syscallarg(int) fildes;
+ syscallarg(irix_dirent64_t *) buf;
+ syscallarg(unsigned short) nbyte;
+ syscallarg(int *) eof;
+};
+
/*
* System call prototypes.
*/
@@ -399,5 +412,7 @@
int sys_readv(struct proc *, void *, register_t *);
int sys_writev(struct proc *, void *, register_t *);
int irix_sys_getmountid(struct proc *, void *, register_t *);
+int irix_sys_getdents64(struct proc *, void *, register_t *);
int irix_sys_ngetdents(struct proc *, void *, register_t *);
+int irix_sys_ngetdents64(struct proc *, void *, register_t *);
#endif /* _IRIX_SYS__SYSCALLARGS_H_ */
diff -r 0773d67febd2 -r 7224b656239d sys/compat/irix/irix_syscalls.c
--- a/sys/compat/irix/irix_syscalls.c Mon Feb 04 20:09:46 2002 +0000
+++ b/sys/compat/irix/irix_syscalls.c Mon Feb 04 20:26:34 2002 +0000
@@ -1,14 +1,14 @@
-/* $NetBSD: irix_syscalls.c,v 1.20 2002/02/03 17:39:54 manu Exp $ */
+/* $NetBSD: irix_syscalls.c,v 1.21 2002/02/04 20:26:34 manu Exp $ */
/*
* System call names.
*
* DO NOT EDIT-- this file is automatically generated.
- * created from NetBSD: syscalls.master,v 1.18 2002/02/03 01:21:48 manu Exp
+ * created from NetBSD: syscalls.master,v 1.19 2002/02/03 17:39:54 manu Exp
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irix_syscalls.c,v 1.20 2002/02/03 17:39:54 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irix_syscalls.c,v 1.21 2002/02/04 20:26:34 manu Exp $");
#if defined(_KERNEL_OPT)
#if defined(_KERNEL_OPT)
@@ -247,10 +247,10 @@
"#202 (unimplemented fstatvfs64)", /* 202 = unimplemented fstatvfs64 */
"getmountid", /* 203 = getmountid */
"#204 (unimplemented nsproc)", /* 204 = unimplemented nsproc */
- "#205 (unimplemented getdents64)", /* 205 = unimplemented getdents64 */
+ "getdents64", /* 205 = getdents64 */
"#206 (unimplemented afs_syscall)", /* 206 = unimplemented afs_syscall */
"ngetdents", /* 207 = ngetdents */
- "#208 (unimplemented ngetdents64)", /* 208 = unimplemented ngetdents64 */
+ "ngetdents64", /* 208 = ngetdents64 */
"#209 (unimplemented sgi_sesmgr)", /* 209 = unimplemented sgi_sesmgr */
"#210 (unimplemented pidsprocsp)", /* 210 = unimplemented pidsprocsp */
"#211 (unimplemented rexec)", /* 211 = unimplemented rexec */
diff -r 0773d67febd2 -r 7224b656239d sys/compat/irix/irix_sysent.c
--- a/sys/compat/irix/irix_sysent.c Mon Feb 04 20:09:46 2002 +0000
+++ b/sys/compat/irix/irix_sysent.c Mon Feb 04 20:26:34 2002 +0000
@@ -1,14 +1,14 @@
-/* $NetBSD: irix_sysent.c,v 1.20 2002/02/03 17:39:54 manu Exp $ */
+/* $NetBSD: irix_sysent.c,v 1.21 2002/02/04 20:26:34 manu Exp $ */
/*
* System call switch table.
*
Home |
Main Index |
Thread Index |
Old Index