add emulation of Linux truncate64(2), ftruncate64(2), *stat64(2)
This commit is contained in:
parent
4944313b38
commit
daff00c255
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux_commons.c,v 1.1 1999/01/03 05:29:31 erh Exp $ */
|
||||
/* $NetBSD: linux_commons.c,v 1.2 2000/12/12 19:01:59 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* This file includes C files from the common
|
||||
|
@ -25,6 +25,7 @@
|
|||
#include <sys/syscallargs.h>
|
||||
|
||||
#include "../../common/linux_pipe.c"
|
||||
#include "../../common/linux_file64.c"
|
||||
#include "../../common/linux_ipccall.c"
|
||||
#include "../../common/linux_misc_notalpha.c"
|
||||
#include "../../common/linux_sig_notalpha.c"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$NetBSD: syscalls.master,v 1.47 2000/12/09 12:23:36 jdolecek Exp $
|
||||
$NetBSD: syscalls.master,v 1.48 2000/12/12 19:01:59 jdolecek Exp $
|
||||
|
||||
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
|
||||
|
||||
|
@ -319,11 +319,16 @@
|
|||
190 NOARGS { int sys___vfork14(void); }
|
||||
191 UNIMPL getrlimit
|
||||
192 UNIMPL mmap2
|
||||
193 UNIMPL truncate64
|
||||
194 UNIMPL ftruncate64
|
||||
195 UNIMPL stat64
|
||||
196 UNIMPL lstat64
|
||||
197 UNIMPL fstat64
|
||||
193 NOARGS truncate64 { int sys_truncate(const char *path, \
|
||||
off_t length); }
|
||||
194 NOARGS ftruncate64 { int sys_ftruncate(const char *path, \
|
||||
off_t length); }
|
||||
195 STD { int linux_sys_stat64(const char *path, \
|
||||
struct linux_stat64 *sp); }
|
||||
196 STD { int linux_sys_lstat64(const char *path, \
|
||||
struct linux_stat64 *sp); }
|
||||
197 STD { int linux_sys_fstat64(int fd, \
|
||||
struct linux_stat64 *sp); }
|
||||
198 UNIMPL lchown
|
||||
199 UNIMPL getuid
|
||||
200 UNIMPL getgid
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.linux_m68k,v 1.1 1998/12/15 19:25:40 itohy Exp $
|
||||
# $NetBSD: files.linux_m68k,v 1.2 2000/12/12 19:02:00 jdolecek Exp $
|
||||
#
|
||||
# Config file description for m68k-dependent Linux compat code.
|
||||
|
||||
|
@ -9,6 +9,7 @@ file compat/linux/arch/m68k/linux_sysent.c compat_linux
|
|||
file compat/linux/arch/m68k/linux_sigarray.c compat_linux
|
||||
|
||||
file compat/linux/common/linux_pipe.c compat_linux
|
||||
file compat/linux/common/linux_file64.c compat_linux
|
||||
file compat/linux/common/linux_ipccall.c compat_linux
|
||||
file compat/linux/common/linux_misc_notalpha.c compat_linux
|
||||
file compat/linux/common/linux_sig_notalpha.c compat_linux
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$NetBSD: syscalls.master,v 1.21 2000/12/09 12:23:36 jdolecek Exp $
|
||||
$NetBSD: syscalls.master,v 1.22 2000/12/12 19:02:00 jdolecek Exp $
|
||||
|
||||
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
|
||||
|
||||
|
@ -337,11 +337,16 @@
|
|||
190 NOARGS { int sys___vfork14(void); }
|
||||
191 UNIMPL getrlimit
|
||||
192 UNIMPL mmap2
|
||||
193 UNIMPL truncate64
|
||||
194 UNIMPL ftruncate64
|
||||
195 UNIMPL stat64
|
||||
196 UNIMPL lstat64
|
||||
197 UNIMPL fstat64
|
||||
193 NOARGS truncate64 { int sys_truncate(const char *path, \
|
||||
off_t length); }
|
||||
194 NOARGS ftruncate64 { int sys_ftruncate(const char *path, \
|
||||
off_t length); }
|
||||
195 STD { int linux_sys_stat64(const char *path, \
|
||||
struct linux_stat64 *sp); }
|
||||
196 STD { int linux_sys_lstat64(const char *path, \
|
||||
struct linux_stat64 *sp); }
|
||||
197 STD { int linux_sys_fstat64(int fd, \
|
||||
struct linux_stat64 *sp); }
|
||||
198 UNIMPL lchown
|
||||
199 UNIMPL getuid
|
||||
200 UNIMPL getgid
|
||||
|
|
|
@ -0,0 +1,205 @@
|
|||
/* $NetBSD: linux_file64.c,v 1.1 2000/12/12 19:02:00 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995, 1998, 2000 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Frank van der Linden and Eric Haszlakiewicz.
|
||||
*
|
||||
* 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 NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Linux 64bit filesystem calls. Used on 32bit archs, not used on 64bit ones.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/namei.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/filedesc.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/tty.h>
|
||||
#include <sys/conf.h>
|
||||
|
||||
#include <sys/syscallargs.h>
|
||||
|
||||
#include <compat/linux/common/linux_types.h>
|
||||
#include <compat/linux/common/linux_signal.h>
|
||||
#include <compat/linux/common/linux_fcntl.h>
|
||||
#include <compat/linux/common/linux_util.h>
|
||||
#include <compat/linux/common/linux_machdep.h>
|
||||
|
||||
#include <compat/linux/linux_syscallargs.h>
|
||||
|
||||
static void bsd_to_linux_stat __P((struct stat *, struct linux_stat64 *));
|
||||
static int linux_do_stat64 __P((struct proc *, void *, register_t *, int));
|
||||
|
||||
/*
|
||||
* Convert a NetBSD stat structure to a Linux stat structure.
|
||||
* Only the order of the fields and the padding in the structure
|
||||
* is different. linux_fakedev is a machine-dependent function
|
||||
* which optionally converts device driver major/minor numbers
|
||||
* (XXX horrible, but what can you do against code that compares
|
||||
* things against constant major device numbers? sigh)
|
||||
*/
|
||||
static void
|
||||
bsd_to_linux_stat(bsp, lsp)
|
||||
struct stat *bsp;
|
||||
struct linux_stat64 *lsp;
|
||||
{
|
||||
lsp->lst_dev = bsp->st_dev;
|
||||
lsp->lst_ino = bsp->st_ino;
|
||||
lsp->lst_mode = (linux_mode_t)bsp->st_mode;
|
||||
if (bsp->st_nlink >= (1 << 15))
|
||||
lsp->lst_nlink = (1 << 15) - 1;
|
||||
else
|
||||
lsp->lst_nlink = (linux_nlink_t)bsp->st_nlink;
|
||||
lsp->lst_uid = bsp->st_uid;
|
||||
lsp->lst_gid = bsp->st_gid;
|
||||
lsp->lst_rdev = linux_fakedev(bsp->st_rdev);
|
||||
lsp->lst_size = bsp->st_size;
|
||||
lsp->lst_blksize = bsp->st_blksize;
|
||||
lsp->lst_blocks = bsp->st_blocks;
|
||||
lsp->lst_atime = bsp->st_atime;
|
||||
lsp->lst_mtime = bsp->st_mtime;
|
||||
lsp->lst_ctime = bsp->st_ctime;
|
||||
}
|
||||
|
||||
/*
|
||||
* The stat functions below are plain sailing. stat and lstat are handled
|
||||
* by one function to avoid code duplication.
|
||||
*/
|
||||
int
|
||||
linux_sys_fstat64(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
register_t *retval;
|
||||
{
|
||||
struct linux_sys_fstat64_args /* {
|
||||
syscallarg(int) fd;
|
||||
syscallarg(linux_stat64 *) sp;
|
||||
} */ *uap = v;
|
||||
struct sys___fstat13_args fsa;
|
||||
struct linux_stat64 tmplst;
|
||||
struct stat *st,tmpst;
|
||||
caddr_t sg;
|
||||
int error;
|
||||
|
||||
sg = stackgap_init(p->p_emul);
|
||||
|
||||
st = stackgap_alloc(&sg, sizeof (struct stat));
|
||||
|
||||
SCARG(&fsa, fd) = SCARG(uap, fd);
|
||||
SCARG(&fsa, sb) = st;
|
||||
|
||||
if ((error = sys___fstat13(p, &fsa, retval)))
|
||||
return error;
|
||||
|
||||
if ((error = copyin(st, &tmpst, sizeof tmpst)))
|
||||
return error;
|
||||
|
||||
bsd_to_linux_stat(&tmpst, &tmplst);
|
||||
|
||||
if ((error = copyout(&tmplst, SCARG(uap, sp), sizeof tmplst)))
|
||||
return error;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
linux_do_stat64(p, v, retval, dolstat)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
register_t *retval;
|
||||
int dolstat;
|
||||
{
|
||||
struct sys___stat13_args sa;
|
||||
struct linux_stat64 tmplst;
|
||||
struct stat *st, tmpst;
|
||||
caddr_t sg;
|
||||
int error;
|
||||
struct linux_sys_stat64_args *uap = v;
|
||||
|
||||
sg = stackgap_init(p->p_emul);
|
||||
st = stackgap_alloc(&sg, sizeof (struct stat));
|
||||
CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
|
||||
|
||||
SCARG(&sa, ub) = st;
|
||||
SCARG(&sa, path) = SCARG(uap, path);
|
||||
|
||||
if ((error = (dolstat ? sys___lstat13(p, &sa, retval) :
|
||||
sys___stat13(p, &sa, retval))))
|
||||
return error;
|
||||
|
||||
if ((error = copyin(st, &tmpst, sizeof tmpst)))
|
||||
return error;
|
||||
|
||||
bsd_to_linux_stat(&tmpst, &tmplst);
|
||||
|
||||
if ((error = copyout(&tmplst, SCARG(uap, sp), sizeof tmplst)))
|
||||
return error;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
linux_sys_stat64(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
register_t *retval;
|
||||
{
|
||||
struct linux_sys_stat64_args /* {
|
||||
syscallarg(const char *) path;
|
||||
syscallarg(struct linux_stat64 *) sp;
|
||||
} */ *uap = v;
|
||||
|
||||
return linux_do_stat64(p, uap, retval, 0);
|
||||
}
|
||||
|
||||
int
|
||||
linux_sys_lstat64(p, v, retval)
|
||||
struct proc *p;
|
||||
void *v;
|
||||
register_t *retval;
|
||||
{
|
||||
struct linux_sys_lstat64_args /* {
|
||||
syscallarg(const char *) path;
|
||||
syscallarg(struct linux_stat64 *) sp;
|
||||
} */ *uap = v;
|
||||
|
||||
return linux_do_stat64(p, uap, retval, 1);
|
||||
}
|
Loading…
Reference in New Issue