Fix compat linux statfs/fstatfs syscalls on amd64.

- Do not use statfs64/fstatfs64 as they have an extra size argument.
- Add full 64bit linux struct statfs support.

ok by manu
This commit is contained in:
njoly 2007-03-14 12:44:39 +00:00
parent ab07e481e4
commit 4e3a8d7d1d
5 changed files with 48 additions and 23 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_machdep.h,v 1.5 2005/11/23 16:14:57 manu Exp $ */
/* $NetBSD: linux_machdep.h,v 1.6 2007/03/14 12:44:39 njoly Exp $ */
/*-
* Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved.
@ -34,6 +34,8 @@
#ifndef _AMD64_LINUX_MACHDEP_H
#define _AMD64_LINUX_MACHDEP_H
#define LINUX_STATFS_64BIT /* Needed for full 64bit struct statfs */
#include <compat/linux/common/linux_types.h>
#include <compat/linux/common/linux_signal.h>
#include <compat/linux/common/linux_siginfo.h>

View File

@ -1,4 +1,4 @@
$NetBSD: syscalls.master,v 1.17 2007/03/04 06:01:19 christos Exp $
$NetBSD: syscalls.master,v 1.18 2007/03/14 12:44:39 njoly Exp $
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@ -298,10 +298,10 @@
#endif
135 STD { int linux_sys_personality(int per); }
136 UNIMPL ustat
137 STD { int linux_sys_statfs64(const char *path, \
size_t sz, struct linux_statfs64 *sp); }
138 STD { int linux_sys_fstatfs64(int fd, \
size_t sz, struct linux_statfs64 *sp); }
137 STD { int linux_sys_statfs(const char *path, \
struct linux_statfs *sp); }
138 STD { int linux_sys_fstatfs(int fd, \
struct linux_statfs *sp); }
139 UNIMPL sysfs
140 STD { int linux_sys_getpriority(int which, int who); }
141 NOARGS { int sys_setpriority(int which, int who, int prio); }

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_misc.c,v 1.167 2007/03/04 06:01:24 christos Exp $ */
/* $NetBSD: linux_misc.c,v 1.168 2007/03/14 12:44:39 njoly Exp $ */
/*-
* Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.167 2007/03/04 06:01:24 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.168 2007/03/14 12:44:39 njoly Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ptrace.h"
@ -177,10 +177,8 @@ const int linux_fstypes_cnt = sizeof(linux_fstypes) / sizeof(linux_fstypes[0]);
# endif
/* Local linux_misc.c functions: */
# ifndef __amd64__
static void bsd_to_linux_statfs __P((const struct statvfs *,
struct linux_statfs *));
# endif
static void linux_to_bsd_mmap_args __P((struct sys_mmap_args *,
const struct linux_sys_mmap_args *));
static int linux_mmap __P((struct lwp *, struct linux_sys_mmap_args *,
@ -312,7 +310,6 @@ linux_sys_brk(l, v, retval)
return 0;
}
# ifndef __amd64__
/*
* Convert NetBSD statvfs structure to Linux statfs structure.
* Linux doesn't have f_flag, and we can't set f_frsize due
@ -446,7 +443,6 @@ out:
STATVFSBUF_PUT(btmp);
return error;
}
# endif /* !__amd64__ */
/*
* uname(). Just copy the info from the various strings stored in the

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_misc_notalpha.c,v 1.86 2007/03/04 06:01:24 christos Exp $ */
/* $NetBSD: linux_misc_notalpha.c,v 1.87 2007/03/14 12:44:40 njoly Exp $ */
/*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_misc_notalpha.c,v 1.86 2007/03/04 06:01:24 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_misc_notalpha.c,v 1.87 2007/03/14 12:44:40 njoly Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -82,7 +82,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_misc_notalpha.c,v 1.86 2007/03/04 06:01:24 chr
#endif
#ifndef COMPAT_LINUX32
#if !defined(__m68k__)
#if !defined(__m68k__) && !defined(__amd64__)
static void bsd_to_linux_statfs64(const struct statvfs *,
struct linux_statfs64 *);
#endif
@ -410,7 +410,7 @@ linux_sys_stime(struct lwp *l, void *v, register_t *retval)
}
#endif /* !amd64 */
#if !defined(__m68k__)
#if !defined(__m68k__) && !defined(__amd64__)
/*
* Convert NetBSD statvfs structure to Linux statfs64 structure.
* See comments in bsd_to_linux_statfs() for further background.
@ -542,5 +542,5 @@ out:
STATVFSBUF_PUT(btmp);
return error;
}
#endif /* !__m68k__ */
#endif /* !__m68k__ && !__amd64__ */
#endif /* !COMPAT_LINUX32 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_types.h,v 1.24 2006/11/16 01:32:42 christos Exp $ */
/* $NetBSD: linux_types.h,v 1.25 2007/03/14 12:44:40 njoly Exp $ */
/*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@ -106,11 +106,38 @@ struct linux___sysctl {
#include <compat/linux/common/linux_siginfo.h>
/*
* From Linux include/asm-generic/statfs.h
* This is _almost_ generic - Linux/sparc64 uses different (fully 64bit)
* struct statfs. However, we don't support Linux/sparc64 ATM.
* Generic statfs structure from Linux include/asm-generic/statfs.h
* Linux/x86_64 uses different (fully 64bit) struct statfs.
*/
#ifndef __sparc64__
#ifdef LINUX_STATFS_64BIT
struct linux_statfs {
long l_ftype;
long l_fbsize;
long l_fblocks;
long l_fbfree;
long l_fbavail;
long l_ffiles;
long l_fffree;
linux_fsid_t l_ffsid;
long l_fnamelen;
long l_ffrsize;
long l_fspare[5];
};
struct linux_statfs64 {
long l_ftype;
long l_fbsize;
long l_fblocks;
long l_fbfree;
long l_fbavail;
long l_ffiles;
long l_fffree;
linux_fsid_t l_ffsid;
long l_fnamelen;
long l_ffrsize;
long l_fspare[5];
};
#else /* !LINUX_STATFS_64BIT */
struct linux_statfs {
u_int32_t l_ftype;
u_int32_t l_fbsize;
@ -138,6 +165,6 @@ struct linux_statfs64 {
u_int32_t l_ffrsize;
u_int32_t l_fspare[5];
};
#endif /* !__sparc64__ */
#endif /* !LINUX_STATFS_64BIT */
#endif /* !_LINUX_TYPES_H */