Added system calls: getdents64/ngetdents64
This commit is contained in:
parent
d4e99a46ec
commit
b778bba3d3
|
@ -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 @@ irix_sys_getdents(p, v, retval)
|
|||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 @@ struct irix_sys_getmountid_args {
|
|||
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 @@ struct irix_sys_ngetdents_args {
|
|||
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 irix_sys_waitsys(struct proc *, void *, register_t *);
|
|||
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_ */
|
||||
|
|
|
@ -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 @@ const char *const irix_syscallnames[] = {
|
|||
"#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 */
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* 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_sysent.c,v 1.20 2002/02/03 17:39:54 manu Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: irix_sysent.c,v 1.21 2002/02/04 20:26:34 manu Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_ntp.h"
|
||||
|
@ -455,14 +455,14 @@ struct sysent irix_sysent[] = {
|
|||
irix_sys_getmountid }, /* 203 = getmountid */
|
||||
{ 0, 0, 0,
|
||||
sys_nosys }, /* 204 = unimplemented nsproc */
|
||||
{ 0, 0, 0,
|
||||
sys_nosys }, /* 205 = unimplemented getdents64 */
|
||||
{ 3, s(struct irix_sys_getdents64_args), 0,
|
||||
irix_sys_getdents64 }, /* 205 = getdents64 */
|
||||
{ 0, 0, 0,
|
||||
sys_nosys }, /* 206 = unimplemented afs_syscall */
|
||||
{ 4, s(struct irix_sys_ngetdents_args), 0,
|
||||
irix_sys_ngetdents }, /* 207 = ngetdents */
|
||||
{ 0, 0, 0,
|
||||
sys_nosys }, /* 208 = unimplemented ngetdents64 */
|
||||
{ 4, s(struct irix_sys_ngetdents64_args), 0,
|
||||
irix_sys_ngetdents64 }, /* 208 = ngetdents64 */
|
||||
{ 0, 0, 0,
|
||||
sys_nosys }, /* 209 = unimplemented sgi_sesmgr */
|
||||
{ 0, 0, 0,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: irix_types.h,v 1.9 2001/12/26 11:04:20 manu Exp $ */
|
||||
/* $NetBSD: irix_types.h,v 1.10 2002/02/04 20:26:34 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -164,4 +164,11 @@ typedef struct irix_dirent {
|
|||
char d_name[1];
|
||||
} irix_dirent_t;
|
||||
|
||||
typedef struct irix_dirent64 {
|
||||
irix_ino64_t d_ino;
|
||||
irix_off64_t d_off;
|
||||
unsigned short d_reclen;
|
||||
char d_name[1];
|
||||
} irix_dirent64_t;
|
||||
|
||||
#endif /* _IRIX_TYPES_H_ */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$NetBSD: syscalls.master,v 1.19 2002/02/03 17:39:54 manu Exp $
|
||||
$NetBSD: syscalls.master,v 1.20 2002/02/04 20:26:34 manu Exp $
|
||||
|
||||
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
|
||||
|
||||
|
@ -330,12 +330,15 @@
|
|||
203 STD { int irix_sys_getmountid(const char *path, \
|
||||
irix_mountid_t *buf); }
|
||||
204 UNIMPL nsproc
|
||||
205 UNIMPL getdents64
|
||||
205 STD { int irix_sys_getdents64(int fildes, \
|
||||
irix_dirent64_t *buf, int nbytes); }
|
||||
206 UNIMPL afs_syscall
|
||||
207 STD { int irix_sys_ngetdents(int fildes, \
|
||||
irix_dirent_t *buf, unsigned short nbyte, \
|
||||
int *eof); }
|
||||
208 UNIMPL ngetdents64
|
||||
208 STD { int irix_sys_ngetdents64(int fildes, \
|
||||
irix_dirent64_t *buf, unsigned short nbyte, \
|
||||
int *eof); }
|
||||
209 UNIMPL sgi_sesmgr
|
||||
210 UNIMPL pidsprocsp
|
||||
211 UNIMPL rexec
|
||||
|
|
Loading…
Reference in New Issue