Home | History | Annotate | Line # | Download | only in common
linux32_misc.c revision 1.4.4.1
      1  1.4.4.1  yamt /*	$NetBSD: linux32_misc.c,v 1.4.4.1 2007/04/15 16:03:15 yamt Exp $	*/
      2      1.1  manu 
      3      1.1  manu /*-
      4  1.4.4.1  yamt  * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
      5  1.4.4.1  yamt  * All rights reserved.
      6  1.4.4.1  yamt  *
      7  1.4.4.1  yamt  * This code is derived from software contributed to The NetBSD Foundation
      8  1.4.4.1  yamt  * by Frank van der Linden and Eric Haszlakiewicz; by Jason R. Thorpe
      9  1.4.4.1  yamt  * of the Numerical Aerospace Simulation Facility, NASA Ames Research Center;
     10  1.4.4.1  yamt  * by Edgar Fu\ss, Mathematisches Institut der Uni Bonn.
     11      1.1  manu  *
     12      1.1  manu  * Redistribution and use in source and binary forms, with or without
     13      1.1  manu  * modification, are permitted provided that the following conditions
     14      1.1  manu  * are met:
     15      1.1  manu  * 1. Redistributions of source code must retain the above copyright
     16      1.1  manu  *    notice, this list of conditions and the following disclaimer.
     17      1.1  manu  * 2. Redistributions in binary form must reproduce the above copyright
     18      1.1  manu  *    notice, this list of conditions and the following disclaimer in the
     19      1.1  manu  *    documentation and/or other materials provided with the distribution.
     20      1.1  manu  * 3. All advertising materials mentioning features or use of this software
     21      1.1  manu  *    must display the following acknowledgement:
     22  1.4.4.1  yamt  *	This product includes software developed by the NetBSD
     23  1.4.4.1  yamt  *	Foundation, Inc. and its contributors.
     24  1.4.4.1  yamt  * 4. Neither the name of The NetBSD Foundation nor the names of its
     25  1.4.4.1  yamt  *    contributors may be used to endorse or promote products derived
     26  1.4.4.1  yamt  *    from this software without specific prior written permission.
     27      1.1  manu  *
     28  1.4.4.1  yamt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     29  1.4.4.1  yamt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     30  1.4.4.1  yamt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     31  1.4.4.1  yamt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     32      1.1  manu  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     33      1.1  manu  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     34      1.1  manu  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     35      1.1  manu  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     36      1.1  manu  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     37      1.1  manu  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     38      1.1  manu  * POSSIBILITY OF SUCH DAMAGE.
     39      1.1  manu  */
     40      1.1  manu 
     41      1.1  manu #include <sys/cdefs.h>
     42  1.4.4.1  yamt __KERNEL_RCSID(0, "$NetBSD: linux32_misc.c,v 1.4.4.1 2007/04/15 16:03:15 yamt Exp $");
     43      1.1  manu 
     44      1.1  manu #include <sys/param.h>
     45      1.1  manu #include <sys/proc.h>
     46  1.4.4.1  yamt #include <sys/time.h>
     47  1.4.4.1  yamt #include <sys/types.h>
     48  1.4.4.1  yamt #include <sys/malloc.h>
     49      1.1  manu 
     50      1.1  manu #include <compat/netbsd32/netbsd32.h>
     51      1.1  manu #include <compat/netbsd32/netbsd32_syscallargs.h>
     52      1.1  manu 
     53      1.1  manu #include <compat/linux32/common/linux32_types.h>
     54      1.1  manu #include <compat/linux32/common/linux32_signal.h>
     55      1.1  manu #include <compat/linux32/linux32_syscallargs.h>
     56      1.1  manu 
     57  1.4.4.1  yamt #include <compat/linux/common/linux_types.h>
     58  1.4.4.1  yamt #include <compat/linux/common/linux_signal.h>
     59  1.4.4.1  yamt #include <compat/linux/common/linux_misc.h>
     60  1.4.4.1  yamt #include <compat/linux/common/linux_statfs.h>
     61  1.4.4.1  yamt #include <compat/linux/linux_syscallargs.h>
     62      1.1  manu 
     63  1.4.4.1  yamt extern const struct linux_mnttypes linux_fstypes[];
     64  1.4.4.1  yamt extern const int linux_fstypes_cnt;
     65      1.1  manu 
     66      1.1  manu 
     67  1.4.4.1  yamt /*
     68  1.4.4.1  yamt  * Implement the fs stat functions. Straightforward.
     69  1.4.4.1  yamt  */
     70      1.1  manu int
     71  1.4.4.1  yamt linux32_sys_statfs(l, v, retval)
     72      1.1  manu 	struct lwp *l;
     73      1.1  manu 	void *v;
     74      1.1  manu 	register_t *retval;
     75      1.1  manu {
     76  1.4.4.1  yamt 	struct linux32_sys_statfs_args /* {
     77  1.4.4.1  yamt 		syscallarg(const netbsd32_charp char) path;
     78  1.4.4.1  yamt 		syscallarg(linux32_statfsp) sp;
     79      1.1  manu 	} */ *uap = v;
     80      1.1  manu 	struct proc *p = l->l_proc;
     81  1.4.4.1  yamt 	struct statvfs *btmp, *bsp;
     82  1.4.4.1  yamt 	struct linux_statfs ltmp;
     83  1.4.4.1  yamt 	struct sys_statvfs1_args bsa;
     84  1.4.4.1  yamt 	void *sg;
     85      1.1  manu 	int error;
     86      1.1  manu 
     87  1.4.4.1  yamt 	sg = stackgap_init(p, 0);
     88  1.4.4.1  yamt 	bsp = stackgap_alloc(p, &sg, sizeof (struct statvfs));
     89      1.1  manu 
     90  1.4.4.1  yamt 	NETBSD32TOP(uap, &bsa, path, const char);
     91  1.4.4.1  yamt 	CHECK_ALT_EXIST(l, &sg, SCARG(&bsa, path));
     92      1.1  manu 
     93  1.4.4.1  yamt 	SCARG(&bsa, buf) = bsp;
     94  1.4.4.1  yamt 	SCARG(&bsa, flags) = ST_WAIT;
     95      1.1  manu 
     96  1.4.4.1  yamt 	if ((error = sys_statvfs1(l, &bsa, retval)))
     97      1.1  manu 		return error;
     98      1.1  manu 
     99  1.4.4.1  yamt 	btmp = STATVFSBUF_GET();
    100  1.4.4.1  yamt 	error = copyin(bsp, btmp, sizeof(*btmp));
    101  1.4.4.1  yamt 	if (error) {
    102  1.4.4.1  yamt 		goto out;
    103      1.1  manu 	}
    104  1.4.4.1  yamt 	bsd_to_linux_statfs(btmp, &ltmp);
    105  1.4.4.1  yamt 	error = copyout(&ltmp, SCARG_P32(uap, sp), sizeof ltmp);
    106  1.4.4.1  yamt out:
    107  1.4.4.1  yamt 	STATVFSBUF_PUT(btmp);
    108  1.4.4.1  yamt 	return error;
    109      1.1  manu }
    110