Add getdirentries backward compat syscall. Provide common function to
signal cookie overflow during emulated getdents and friends.
This commit is contained in:
parent
49d58c7d89
commit
811fbe17b5
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.17 1997/06/12 17:35:18 mrg Exp $
|
||||
# $NetBSD: Makefile,v 1.18 1997/10/10 01:46:59 fvdl Exp $
|
||||
|
||||
LIB= compat
|
||||
NOPIC=
|
||||
|
@ -7,7 +7,8 @@ CPPFLAGS= ${COMPATCPPFLAGS}
|
|||
|
||||
SRCS= compat_exec.c compat_util.c kern_exit_43.c kern_info_09.c \
|
||||
kern_info_43.c kern_resource_43.c kern_sig_43.c kern_xxx_12.c \
|
||||
tty_43.c uipc_syscalls_43.c vfs_syscalls_43.c vm_43.c vm_swap_12.c
|
||||
tty_43.c uipc_syscalls_43.c vfs_syscalls_43.c vm_43.c vm_swap_12.c \
|
||||
vfs_syscalls_12.c
|
||||
|
||||
# really, all machines where sizeof(int) != sizeof(long)
|
||||
.if (${MACHINE_ARCH} != "alpha")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: compat_util.c,v 1.6 1996/10/25 23:14:00 cgd Exp $ */
|
||||
/* $NetBSD: compat_util.c,v 1.7 1997/10/10 01:47:00 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christos Zoulas
|
||||
|
@ -41,6 +41,8 @@
|
|||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/mount.h>
|
||||
|
||||
#include <vm/vm_param.h>
|
||||
|
||||
|
@ -192,3 +194,17 @@ stackgap_alloc(sgp, sz)
|
|||
*sgp += ALIGN(sz);
|
||||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
compat_offseterr(vp, msg)
|
||||
struct vnode *vp;
|
||||
char *msg;
|
||||
{
|
||||
struct mount *mp;
|
||||
|
||||
mp = vp->v_mount;
|
||||
|
||||
log(LOG_ERR, "%s: dir offset too large on fs %s (mounted from %s)\n",
|
||||
msg, mp->mnt_stat.f_mntonname, mp->mnt_stat.f_mntfromname);
|
||||
uprintf("%s: dir offset too large for emulated program\n", msg);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: compat_util.h,v 1.2 1996/10/12 02:12:55 thorpej Exp $ */
|
||||
/* $NetBSD: compat_util.h,v 1.3 1997/10/10 01:47:01 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christos Zoulas
|
||||
|
@ -41,6 +41,8 @@ void *stackgap_alloc __P((caddr_t *, size_t));
|
|||
int emul_find __P((struct proc *, caddr_t *, const char *, char *,
|
||||
char **, int));
|
||||
|
||||
void compat_offseterr __P((struct vnode *, char *msg));
|
||||
|
||||
#define CHECK_ALT_EXIST(p, sgp, root, path) \
|
||||
emul_find(p, sgp, root, path, &(path), 0)
|
||||
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
/* $NetBSD: vfs_syscalls_12.c,v 1.1 1997/10/10 01:47:02 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* (c) UNIX System Laboratories, Inc.
|
||||
* All or some portions of this file are derived from material licensed
|
||||
* to the University of California by American Telephone and Telegraph
|
||||
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
||||
* the permission of UNIX System Laboratories, Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* From: @(#)vfs_syscalls.c 8.28 (Berkeley) 12/10/94
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/namei.h>
|
||||
#include <sys/filedesc.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/dirent.h>
|
||||
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
/*
|
||||
* Read a block of directory entries in a file system independent format.
|
||||
*/
|
||||
int
|
||||
compat_12_sys_getdirentries(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
register_t *retval;
|
||||
{
|
||||
register struct compat_12_sys_getdirentries_args /* {
|
||||
syscallarg(int) fd;
|
||||
syscallarg(char *) buf;
|
||||
syscallarg(u_int) count;
|
||||
syscallarg(long *) basep;
|
||||
} */ *uap = v;
|
||||
struct file *fp;
|
||||
int error, done;
|
||||
long loff;
|
||||
|
||||
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
|
||||
return error;
|
||||
if ((fp->f_flag & FREAD) == 0)
|
||||
return (EBADF);
|
||||
|
||||
loff = fp->f_offset;
|
||||
|
||||
error = vn_readdir(fp, SCARG(uap, buf), UIO_USERSPACE,
|
||||
SCARG(uap, count), &done, p, 0, 0);
|
||||
|
||||
error = copyout(&loff, SCARG(uap, basep), sizeof(long));
|
||||
*retval = done;
|
||||
return error;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vfs_syscalls_43.c,v 1.5 1997/06/06 19:36:31 christos Exp $ */
|
||||
/* $NetBSD: vfs_syscalls_43.c,v 1.6 1997/10/10 01:47:04 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
|
@ -382,7 +382,7 @@ unionread:
|
|||
MALLOC(dirbuf, caddr_t, SCARG(uap, count), M_TEMP, M_WAITOK);
|
||||
kiov.iov_base = dirbuf;
|
||||
error = VOP_READDIR(vp, &kuio, fp->f_cred, &eofflag,
|
||||
(u_long *)0, 0);
|
||||
(off_t *)0, 0);
|
||||
fp->f_offset = kuio.uio_offset;
|
||||
if (error == 0) {
|
||||
readcnt = SCARG(uap, count) - kuio.uio_resid;
|
||||
|
|
Loading…
Reference in New Issue