List Info

Thread: linux32 statfs/statfs64




linux32 statfs/statfs64
country flaguser name
Germany
2007-03-07 13:54:26
I'm wondering why statfs and even statfs64 are unimplemented
in the  
linux32
emulation.
Is it just that no-one needed them up to now or is there
some  
specific problem
I'm not aware of?
The tivoli client seems to need at least one of them.


Re: linux32 statfs/statfs64
country flaguser name
Germany
2007-03-08 10:54:46
> Emulations are implemented opportunistically.
OK, let's be opportunistic.
How does this look (is builds and pretends to work):

---
sys/compat/linux32/arch/amd64/syscalls.master.orig	2006-09-1
3 21:55:49.000000000 +0200
+++ sys/compat/linux32/arch/amd64/syscalls.master	2007-03-08
17:03:19.000000000 +0100
 -191,7
+191,8 
 96	STD	{ int linux32_sys_getpriority(int which, int who);
}
 97	STD	{ int linux32_sys_setpriority(int which, int who,
int prio); }
 98	UNIMPL	profil
-99	UNIMPL	statfs
+99	STD	{ int linux32_sys_statfs(const netbsd32_charp path,

+		    linux32_statfsp sp); }
 100	UNIMPL	fstatfs
 101	UNIMPL	ioperm
 102	STD	{ int linux32_sys_socketcall(int what,
netbsd32_voidp args); }
--- sys/compat/linux32/files.linux32.orig	2006-09-13
21:55:49.000000000 +0200
+++ sys/compat/linux32/files.linux32	2007-03-08
14:57:12.000000000 +0100
 -11,6
+11,7 
 file	compat/linux32/common/linux32_exec_elf32.c
compat_linux32 & exec_elf32
 file	compat/linux32/common/linux32_fcntl.c	compat_linux32
 file	compat/linux32/common/linux32_ioctl.c	compat_linux32
+file	compat/linux32/common/linux32_misc.c	compat_linux32
 file	compat/linux32/common/linux32_mman.c	compat_linux32
 file	compat/linux32/common/linux32_resource.c	compat_linux3
2
 file	compat/linux32/common/linux32_sched.c	compat_linux32
--- sys/compat/linux/common/linux_misc.c.orig	2006-11-16
02:32:42.000000000 +0100
+++ sys/compat/linux/common/linux_misc.c	2007-03-08
15:42:01.000000000 +0100
 -177,11
+177,10 
 #define DPRINTF(a)
 # endif
 
-/* Local linux_misc.c functions: */
-# ifndef __amd64__
-static void bsd_to_linux_statfs __P((const struct statvfs
*,
+/* needed by linux32_sys_statfs */
+void bsd_to_linux_statfs __P((const struct statvfs *,
     struct linux_statfs *));
-# endif
+/* Local linux_misc.c functions: */
 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 *,
 -313,13
+312,12 
 	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
  * to glibc statvfs() bug (see below).
  */
-static void
+void
 bsd_to_linux_statfs(bsp, lsp)
 	const struct statvfs *bsp;
 	struct linux_statfs *lsp;
 -365,6
+363,7 
 	(void)memset(lsp->l_fspare, 0,
sizeof(lsp->l_fspare));
 }
 
+# ifndef __amd64__
 /*
  * Implement the fs stat functions. Straightforward.
  */
---
sys/compat/linux32/common/linux32_types.h.orig	2006-11-16
02:32:44.000000000 +0100
+++ sys/compat/linux32/common/linux32_types.h	2007-03-08
16:59:51.000000000 +0100
 -1,4
+1,4 
-/*	$NetBSD: linux32_types.h,v 1.3 2006/11/16 01:32:44
christos Exp $ */
+/*	$NetBSD: linux32_types.h,v  $ */
 
 /*-
  * Copyright (c) 2006 Emmanuel Dreyfus, all rights
reserved.
 -42,6
+42,8 
 typedef netbsd32_pointer_t linux32_utsnamep;
 typedef netbsd32_pointer_t linux32_stat64p;
 typedef netbsd32_pointer_t linux32_statp;
+typedef netbsd32_pointer_t linux32_statfs64p;
+typedef netbsd32_pointer_t linux32_statfsp;
 typedef netbsd32_pointer_t linux32_sigactionp_t;
 typedef netbsd32_pointer_t linux32_sigsetp_t;
 typedef netbsd32_pointer_t linux32___sysctlp_t;
--- /dev/null	2007-03-08 17:45:23.000000000 +0100
+++ sys/compat/linux32/common/linux32_misc.c	2007-03-08
17:47:22.000000000 +0100
 -0,0
+1,144 
+/*	$NetBSD: linux32_misc.c,v $	*/
+
+/*-
+ * Copyright (c) 1995, 1998, 1999 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; by Jason
R. Thorpe
+ * of the Numerical Aerospace Simulation Facility, NASA
Ames Research Center;
+ * by Edgar Fuss, Mathematisches Institut der Uni Bonn.
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: linux32_misc.c,v
$");
+
+#if defined(_KERNEL_OPT)
+#include "opt_ptrace.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/namei.h>
+#include <sys/proc.h>
+#include <sys/dirent.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/vnode.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+#include <sys/utsname.h>
+#include <sys/unistd.h>
+
+#include <sys/sa.h>
+#include <sys/syscall.h>
+#include <sys/syscallargs.h>
+
+#include <compat/netbsd32/netbsd32.h>
+#include <compat/netbsd32/netbsd32_conv.h>
+#include <compat/netbsd32/netbsd32_syscallargs.h>
+
+#include <compat/linux32/common/linux32_machdep.h>
+#include <compat/linux32/common/linux32_types.h>
+#include <compat/linux32/common/linux32_signal.h>
+#include <compat/linux32/common/linux32_sysctl.h>
+#include <compat/linux32/linux32_syscallargs.h>
+
+#include <compat/linux/common/linux_machdep.h>
+#include <compat/linux/common/linux_types.h>
+#include <compat/linux/common/linux_util.h>
+#include <compat/linux/common/linux_misc.h>
+#include <compat/linux/common/linux_emuldata.h>
+#include <compat/linux/linux_syscallargs.h>
+
+
+extern const struct linux_mnttypes linux_fstypes[];
+extern const int linux_fstypes_cnt;
+
+# ifdef DEBUG_LINUX
+#define DPRINTF(a)	uprintf a
+# else
+#define DPRINTF(a)
+# endif
+
+void bsd_to_linux_statfs __P((const struct statvfs *,
+    struct linux_statfs *));
+
+/*
+ * Implement the fs stat functions. Straightforward.
+ */
+int
+linux32_sys_statfs(l, v, retval)
+	struct lwp *l;
+	void *v;
+	register_t *retval;
+{
+	struct linux32_sys_statfs_args /* {
+		syscallarg(const netbsd32_charp char) path;
+		syscallarg(struct linux_statfs *) sp;
+	} */ *uap = v;
+	struct proc *p = l->l_proc;
+	struct statvfs *btmp, *bsp;
+	struct linux_statfs ltmp;
+	struct sys_statvfs1_args bsa;
+	caddr_t sg;
+	int error;
+
+	sg = stackgap_init(p, 0);
+	bsp = stackgap_alloc(p, &sg, sizeof (struct
statvfs));
+
+	NETBSD32TOP(uap, &bsa, path, const char);
+	CHECK_ALT_EXIST(l, &sg, SCARG(&bsa, path));
+
+	SCARG(&bsa, buf) = bsp;
+	SCARG(&bsa, flags) = ST_WAIT;
+
+	if ((error = sys_statvfs1(l, &bsa, retval)))
+		return error;
+
+	btmp = STATVFSBUF_GET();
+	error = copyin(bsp, btmp, sizeof(*btmp));
+	if (error) {
+		goto out;
+	}
+	bsd_to_linux_statfs(btmp, &ltmp);
+	error = copyout(&ltmp, NETBSD32PTR64(SCARG(uap, sp)),
sizeof ltmp);
+out:
+	STATVFSBUF_PUT(btmp);
+	return error;
+}


Re: linux32 statfs/statfs64
country flaguser name
Germany
2007-03-16 11:02:22
> Looks ok.
Could we pull this up to 4.0?

With the statfs and sched_yield calls added and Nicolas
Joly's patch
applied, I've finally managed to make dsmc (the Tivoli
client) work.
If we could have select() fixed, it would probably work even
better.

> But you should trim the unused stuff (variables and
headers)
> from linux32_misc.c
I trimmed headers, but I can't find any variables to trim.

BTW, in sys/compat/linux32/Makefile.inc, we have:

OBJS=	linux_sysent.c linux_syscalls.c linux_syscall.h
linux_syscallargs.h

and I suppose this should s/linux_/linux32_/g

  
Re: linux32 statfs/statfs64
country flaguser name
Germany
2007-03-30 12:17:56
May I humbly ask what the state of affairs is regarding my
proposed  
integration of statfs and sched_yield?

Is there any further work that should be done by me before
these may  
become ready to be integrated?

I just ask because I need both syscalls in order for dsmc to
work  
properly and I would like to reduce the number of my local
kernel  
patches as much as possible.

I'd also be glad if someone could comment on the alleged
select()  
timeout misbehaviour (in compat/linux32) for the same
reason.


Re: linux32 statfs/statfs64
country flaguser name
France
2007-03-30 15:25:54
On Fri, Mar 30, 2007 at 07:17:56PM +0200, Edgar Fuß wrote:
> May I humbly ask what the state of affairs is regarding
my proposed  
> integration of statfs and sched_yield?

I'm working on it. I already requested 2 pullups for
netbsd-4 for your
PR.

<URL:http://releng.netbsd.org/cgi-bin/req-4.cgi?show=543>
<URL:http://releng.netbsd.org/cgi-bin/req-4.cgi?show=544>

> Is there any further work that should be done by me
before these may  
> become ready to be integrated?

For the statfs port, it is not as simple as it looks; but
not too
complicated. The main problem is that `struct statfs' have
different
sizes between compat linux and linux32 ... We can then share
the
bsd_to_linux_statfs() source code, but not the compiled
form. I'll
plan to move the function from linux_misc.c to linux_misc.h
for easier
integration in compat linux32.
I just need a little more time 

> I just ask because I need both syscalls in order for
dsmc to work  
> properly and I would like to reduce the number of my
local kernel  
> patches as much as possible.
> 
> I'd also be glad if someone could comment on the
alleged select()  
> timeout misbehaviour (in compat/linux32) for the same
reason.

I have the fix in my tree. To be sure, i'm stressing it ...
will then
commit.

-- 
Nicolas Joly

Biological Software and Databanks.
Institut Pasteur, Paris.

Re: linux32 statfs/statfs64
country flaguser name
Germany
2007-03-30 15:46:28
> The main problem is that `struct statfs'
> have different sizes between compat linux and linux32
Oops?! But my patch pretended to work. As I read, the
structure is  
declared as

struct linux_statfs {
	u_int32_t	l_ftype;
	u_int32_t	l_fbsize;
	u_int32_t	l_fblocks;
	u_int32_t	l_fbfree;
	u_int32_t	l_fbavail;
	u_int32_t	l_ffiles;
	u_int32_t	l_fffree;
	linux_fsid_t	l_ffsid;
	u_int32_t	l_fnamelen;
	u_int32_t	l_ffrsize;
	u_int32_t	l_fspare[5];
};

I must be missing something. Which field width differs
between 32 bit Linux and 64 bit Linux?


Re: linux32 statfs/statfs64
country flaguser name
France
2007-03-30 15:55:23
On Fri, Mar 30, 2007 at 10:46:28PM +0200, Edgar Fuß wrote:
> >The main problem is that `struct statfs'
> >have different sizes between compat linux and
linux32
> Oops?! But my patch pretended to work.

Yes. But you have a broken compat linux statfs syscall 

With your report, i generated a small testcase that showed a
problem
for compat linux too. I always prefer to fix native compat
linux
before, because it often require some unexpected changes !
And without
fixing it first, i would surely have broken the compat
linux32 statfs,
without noticing, a little later :-(

> As I read, the structure is declared as
> 
> struct linux_statfs {
> 	u_int32_t	l_ftype;
> 	u_int32_t	l_fbsize;
> 	u_int32_t	l_fblocks;
> 	u_int32_t	l_fbfree;
> 	u_int32_t	l_fbavail;
> 	u_int32_t	l_ffiles;
> 	u_int32_t	l_fffree;
> 	linux_fsid_t	l_ffsid;
> 	u_int32_t	l_fnamelen;
> 	u_int32_t	l_ffrsize;
> 	u_int32_t	l_fspare[5];
> };
> 
> I must be missing something. Which field width differs
> between 32 bit Linux and 64 bit Linux?

All except one  This is
a full 64bit struct.

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];
};

-- 
Nicolas Joly

Biological Software and Databanks.
Institut Pasteur, Paris.

[1-7]

about | contact  Other archives ( Real Estate discussion Medical topics )