Home | History | Annotate | Line # | Download | only in common
linux_misc_notalpha.c revision 1.109
      1  1.109      maxv /*	$NetBSD: linux_misc_notalpha.c,v 1.109 2014/11/09 17:48:08 maxv Exp $	*/
      2   1.47       erh 
      3   1.47       erh /*-
      4  1.101        ad  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
      5   1.47       erh  * All rights reserved.
      6   1.47       erh  *
      7   1.47       erh  * This code is derived from software contributed to The NetBSD Foundation
      8   1.51   thorpej  * by Frank van der Linden and Eric Haszlakiewicz; by Jason R. Thorpe
      9   1.51   thorpej  * of the Numerical Aerospace Simulation Facility, NASA Ames Research Center.
     10   1.47       erh  *
     11   1.47       erh  * Redistribution and use in source and binary forms, with or without
     12   1.47       erh  * modification, are permitted provided that the following conditions
     13   1.47       erh  * are met:
     14   1.47       erh  * 1. Redistributions of source code must retain the above copyright
     15   1.47       erh  *    notice, this list of conditions and the following disclaimer.
     16   1.47       erh  * 2. Redistributions in binary form must reproduce the above copyright
     17   1.47       erh  *    notice, this list of conditions and the following disclaimer in the
     18   1.47       erh  *    documentation and/or other materials provided with the distribution.
     19   1.47       erh  *
     20   1.47       erh  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21   1.47       erh  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22   1.47       erh  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23   1.47       erh  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24   1.47       erh  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25   1.47       erh  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26   1.47       erh  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27   1.47       erh  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28   1.47       erh  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29   1.47       erh  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30   1.47       erh  * POSSIBILITY OF SUCH DAMAGE.
     31    1.1      fvdl  */
     32   1.61     lukem 
     33   1.61     lukem #include <sys/cdefs.h>
     34  1.109      maxv __KERNEL_RCSID(0, "$NetBSD: linux_misc_notalpha.c,v 1.109 2014/11/09 17:48:08 maxv Exp $");
     35  1.108       chs 
     36  1.108       chs /*
     37  1.108       chs  * Note that we must NOT include "opt_compat_linux32.h" here,
     38  1.108       chs  * the maze of ifdefs below relies on COMPAT_LINUX32 only being
     39  1.108       chs  * defined when this file is built for linux32.
     40  1.108       chs  */
     41    1.1      fvdl 
     42    1.1      fvdl #include <sys/param.h>
     43    1.1      fvdl #include <sys/systm.h>
     44    1.1      fvdl #include <sys/kernel.h>
     45   1.47       erh #include <sys/mman.h>
     46   1.47       erh #include <sys/mount.h>
     47    1.1      fvdl #include <sys/mbuf.h>
     48   1.47       erh #include <sys/namei.h>
     49   1.57     itohy #include <sys/proc.h>
     50   1.93       dsl #include <sys/prot.h>
     51    1.1      fvdl #include <sys/ptrace.h>
     52    1.1      fvdl #include <sys/resource.h>
     53    1.1      fvdl #include <sys/resourcevar.h>
     54   1.64   thorpej #include <sys/time.h>
     55   1.91       dsl #include <sys/vfs_syscalls.h>
     56    1.1      fvdl #include <sys/wait.h>
     57   1.79      elad #include <sys/kauth.h>
     58    1.1      fvdl 
     59    1.1      fvdl #include <sys/syscallargs.h>
     60    1.1      fvdl 
     61   1.48  christos #include <compat/linux/common/linux_types.h>
     62   1.48  christos #include <compat/linux/common/linux_fcntl.h>
     63   1.48  christos #include <compat/linux/common/linux_misc.h>
     64   1.48  christos #include <compat/linux/common/linux_mmap.h>
     65   1.48  christos #include <compat/linux/common/linux_signal.h>
     66   1.48  christos #include <compat/linux/common/linux_util.h>
     67   1.95     njoly #include <compat/linux/common/linux_ipc.h>
     68   1.95     njoly #include <compat/linux/common/linux_sem.h>
     69  1.108       chs #include <compat/linux/common/linux_statfs.h>
     70   1.48  christos 
     71    1.1      fvdl #include <compat/linux/linux_syscallargs.h>
     72   1.26  christos 
     73    1.1      fvdl /*
     74   1.47       erh  * This file contains routines which are used
     75   1.47       erh  * on every linux architechture except the Alpha.
     76    1.1      fvdl  */
     77   1.21   mycroft 
     78   1.47       erh /* Used on: arm, i386, m68k, mips, ppc, sparc, sparc64 */
     79   1.47       erh /* Not used on: alpha */
     80    1.1      fvdl 
     81   1.70  jdolecek #ifdef DEBUG_LINUX
     82   1.70  jdolecek #define DPRINTF(a)	uprintf a
     83   1.70  jdolecek #else
     84   1.70  jdolecek #define DPRINTF(a)
     85   1.70  jdolecek #endif
     86   1.70  jdolecek 
     87   1.77      manu #ifndef COMPAT_LINUX32
     88   1.70  jdolecek 
     89    1.1      fvdl /*
     90   1.47       erh  * Alarm. This is a libc call which uses setitimer(2) in NetBSD.
     91   1.47       erh  * Fiddle with the timers to make it work.
     92  1.101        ad  *
     93  1.101        ad  * XXX This shouldn't be dicking about with the ptimer stuff directly.
     94    1.1      fvdl  */
     95    1.1      fvdl int
     96   1.99       dsl linux_sys_alarm(struct lwp *l, const struct linux_sys_alarm_args *uap, register_t *retval)
     97   1.20   thorpej {
     98   1.99       dsl 	/* {
     99   1.47       erh 		syscallarg(unsigned int) secs;
    100   1.99       dsl 	} */
    101   1.64   thorpej 	struct proc *p = l->l_proc;
    102  1.103  christos 	struct timespec now;
    103  1.103  christos 	struct itimerspec *itp, it;
    104  1.101        ad 	struct ptimer *ptp, *spare;
    105  1.101        ad 	extern kmutex_t timer_lock;
    106  1.101        ad 	struct ptimers *pts;
    107  1.101        ad 
    108  1.101        ad 	if ((pts = p->p_timers) == NULL)
    109  1.101        ad 		pts = timers_alloc(p);
    110  1.101        ad 	spare = NULL;
    111  1.101        ad 
    112  1.101        ad  retry:
    113  1.101        ad 	mutex_spin_enter(&timer_lock);
    114  1.101        ad 	if (pts && pts->pts_timers[ITIMER_REAL])
    115  1.101        ad 		itp = &pts->pts_timers[ITIMER_REAL]->pt_time;
    116   1.64   thorpej 	else
    117   1.64   thorpej 		itp = NULL;
    118   1.47       erh 	/*
    119   1.47       erh 	 * Clear any pending timer alarms.
    120   1.47       erh 	 */
    121   1.64   thorpej 	if (itp) {
    122  1.101        ad 		callout_stop(&pts->pts_timers[ITIMER_REAL]->pt_ch);
    123  1.103  christos 		timespecclear(&itp->it_interval);
    124  1.103  christos 		getnanotime(&now);
    125  1.103  christos 		if (timespecisset(&itp->it_value) &&
    126  1.103  christos 		    timespeccmp(&itp->it_value, &now, >))
    127  1.103  christos 			timespecsub(&itp->it_value, &now, &itp->it_value);
    128   1.64   thorpej 		/*
    129   1.64   thorpej 		 * Return how many seconds were left (rounded up)
    130   1.64   thorpej 		 */
    131   1.64   thorpej 		retval[0] = itp->it_value.tv_sec;
    132  1.103  christos 		if (itp->it_value.tv_nsec)
    133   1.64   thorpej 			retval[0]++;
    134   1.64   thorpej 	} else {
    135   1.64   thorpej 		retval[0] = 0;
    136   1.73     perry 	}
    137    1.1      fvdl 
    138   1.47       erh 	/*
    139   1.47       erh 	 * alarm(0) just resets the timer.
    140   1.47       erh 	 */
    141   1.47       erh 	if (SCARG(uap, secs) == 0) {
    142   1.64   thorpej 		if (itp)
    143  1.103  christos 			timespecclear(&itp->it_value);
    144  1.101        ad 		mutex_spin_exit(&timer_lock);
    145   1.47       erh 		return 0;
    146   1.47       erh 	}
    147    1.1      fvdl 
    148   1.47       erh 	/*
    149   1.47       erh 	 * Check the new alarm time for sanity, and set it.
    150   1.47       erh 	 */
    151  1.103  christos 	timespecclear(&it.it_interval);
    152   1.47       erh 	it.it_value.tv_sec = SCARG(uap, secs);
    153  1.103  christos 	it.it_value.tv_nsec = 0;
    154  1.103  christos 	if (itimespecfix(&it.it_value) || itimespecfix(&it.it_interval)) {
    155  1.101        ad 		mutex_spin_exit(&timer_lock);
    156   1.47       erh 		return (EINVAL);
    157   1.16      fvdl 	}
    158    1.1      fvdl 
    159  1.101        ad 	ptp = pts->pts_timers[ITIMER_REAL];
    160   1.64   thorpej 	if (ptp == NULL) {
    161  1.101        ad 		if (spare == NULL) {
    162  1.101        ad 			mutex_spin_exit(&timer_lock);
    163  1.101        ad 			spare = pool_get(&ptimer_pool, PR_WAITOK);
    164  1.101        ad 			goto retry;
    165  1.101        ad 		}
    166  1.101        ad 		ptp = spare;
    167  1.101        ad 		spare = NULL;
    168   1.64   thorpej 		ptp->pt_ev.sigev_notify = SIGEV_SIGNAL;
    169   1.64   thorpej 		ptp->pt_ev.sigev_signo = SIGALRM;
    170   1.65  jdolecek 		ptp->pt_overruns = 0;
    171   1.65  jdolecek 		ptp->pt_proc = p;
    172   1.64   thorpej 		ptp->pt_type = CLOCK_REALTIME;
    173   1.65  jdolecek 		ptp->pt_entry = CLOCK_REALTIME;
    174  1.101        ad 		ptp->pt_active = 0;
    175  1.101        ad 		ptp->pt_queued = 0;
    176  1.101        ad 		callout_init(&ptp->pt_ch, CALLOUT_MPSAFE);
    177  1.101        ad 		pts->pts_timers[ITIMER_REAL] = ptp;
    178   1.64   thorpej 	}
    179   1.64   thorpej 
    180  1.103  christos 	if (timespecisset(&it.it_value)) {
    181   1.56   thorpej 		/*
    182  1.103  christos 		 * Don't need to check tvhzto() return value, here.
    183   1.56   thorpej 		 * callout_reset() does it for us.
    184   1.56   thorpej 		 */
    185  1.103  christos 		getnanotime(&now);
    186  1.103  christos 		timespecadd(&it.it_value, &now, &it.it_value);
    187  1.103  christos 		callout_reset(&ptp->pt_ch, tshzto(&it.it_value),
    188   1.64   thorpej 		    realtimerexpire, ptp);
    189   1.16      fvdl 	}
    190   1.64   thorpej 	ptp->pt_time = it;
    191  1.101        ad 	mutex_spin_exit(&timer_lock);
    192    1.1      fvdl 
    193   1.16      fvdl 	return 0;
    194    1.1      fvdl }
    195   1.77      manu #endif /* !COMPAT_LINUX32 */
    196    1.1      fvdl 
    197   1.96     njoly #if !defined(__amd64__)
    198    1.1      fvdl int
    199   1.99       dsl linux_sys_nice(struct lwp *l, const struct linux_sys_nice_args *uap, register_t *retval)
    200   1.20   thorpej {
    201   1.99       dsl 	/* {
    202   1.47       erh 		syscallarg(int) incr;
    203   1.99       dsl 	} */
    204  1.104     njoly 	struct proc *p = l->l_proc;
    205  1.106     njoly 	struct sys_setpriority_args bsa;
    206  1.106     njoly 	int error;
    207   1.20   thorpej 
    208  1.106     njoly 	SCARG(&bsa, which) = PRIO_PROCESS;
    209  1.106     njoly 	SCARG(&bsa, who) = 0;
    210  1.104     njoly 	SCARG(&bsa, prio) = p->p_nice - NZERO + SCARG(uap, incr);
    211  1.104     njoly 
    212  1.106     njoly 	error = sys_setpriority(l, &bsa, retval);
    213  1.106     njoly 	return (error) ? EPERM : 0;
    214    1.1      fvdl }
    215   1.96     njoly #endif /* !__amd64__ */
    216    1.1      fvdl 
    217   1.77      manu #ifndef COMPAT_LINUX32
    218   1.74      manu #ifndef __amd64__
    219    1.1      fvdl /*
    220   1.47       erh  * The old Linux readdir was only able to read one entry at a time,
    221   1.47       erh  * even though it had a 'count' argument. In fact, the emulation
    222   1.47       erh  * of the old call was better than the original, because it did handle
    223   1.47       erh  * the count arg properly. Don't bother with it anymore now, and use
    224   1.47       erh  * it to distinguish between old and new. The difference is that the
    225   1.47       erh  * newer one actually does multiple entries, and the reclen field
    226   1.47       erh  * really is the reclen, not the namelength.
    227    1.1      fvdl  */
    228    1.1      fvdl int
    229   1.99       dsl linux_sys_readdir(struct lwp *l, const struct linux_sys_readdir_args *uap, register_t *retval)
    230   1.20   thorpej {
    231   1.99       dsl 	/* {
    232   1.47       erh 		syscallarg(int) fd;
    233   1.47       erh 		syscallarg(struct linux_dirent *) dent;
    234   1.47       erh 		syscallarg(unsigned int) count;
    235   1.99       dsl 	} */
    236  1.100     njoly 	int error;
    237   1.99       dsl 	struct linux_sys_getdents_args da;
    238    1.1      fvdl 
    239   1.99       dsl 	SCARG(&da, fd) = SCARG(uap, fd);
    240   1.99       dsl 	SCARG(&da, dent) = SCARG(uap, dent);
    241   1.99       dsl 	SCARG(&da, count) = 1;
    242  1.100     njoly 
    243  1.100     njoly 	error = linux_sys_getdents(l, &da, retval);
    244  1.100     njoly 	if (error == 0 && *retval > 1)
    245  1.100     njoly 		*retval = 1;
    246  1.100     njoly 
    247  1.100     njoly 	return error;
    248    1.1      fvdl }
    249   1.74      manu #endif /* !amd64 */
    250    1.1      fvdl 
    251    1.1      fvdl /*
    252    1.1      fvdl  * I wonder why Linux has gettimeofday() _and_ time().. Still, we
    253    1.1      fvdl  * need to deal with it.
    254    1.1      fvdl  */
    255    1.1      fvdl int
    256   1.99       dsl linux_sys_time(struct lwp *l, const struct linux_sys_time_args *uap, register_t *retval)
    257   1.20   thorpej {
    258   1.99       dsl 	/* {
    259   1.99       dsl 		syscallarg(linux_time_t) *t;
    260   1.99       dsl 	} */
    261    1.1      fvdl 	struct timeval atv;
    262    1.1      fvdl 	linux_time_t tt;
    263    1.1      fvdl 	int error;
    264    1.1      fvdl 
    265    1.1      fvdl 	microtime(&atv);
    266    1.1      fvdl 
    267    1.1      fvdl 	tt = atv.tv_sec;
    268    1.1      fvdl 	if (SCARG(uap, t) && (error = copyout(&tt, SCARG(uap, t), sizeof tt)))
    269    1.1      fvdl 		return error;
    270    1.1      fvdl 
    271    1.1      fvdl 	retval[0] = tt;
    272    1.1      fvdl 	return 0;
    273    1.1      fvdl }
    274    1.1      fvdl 
    275    1.1      fvdl /*
    276   1.73     perry  * utime(). Do conversion to things that utimes() understands,
    277   1.47       erh  * and pass it on.
    278    1.1      fvdl  */
    279    1.1      fvdl int
    280   1.99       dsl linux_sys_utime(struct lwp *l, const struct linux_sys_utime_args *uap, register_t *retval)
    281   1.20   thorpej {
    282   1.99       dsl 	/* {
    283   1.50  christos 		syscallarg(const char *) path;
    284   1.47       erh 		syscallarg(struct linux_utimbuf *)times;
    285   1.99       dsl 	} */
    286    1.2      fvdl 	int error;
    287   1.47       erh 	struct timeval tv[2], *tvp;
    288   1.47       erh 	struct linux_utimbuf lut;
    289    1.2      fvdl 
    290   1.47       erh 	if (SCARG(uap, times) != NULL) {
    291   1.47       erh 		if ((error = copyin(SCARG(uap, times), &lut, sizeof lut)))
    292   1.47       erh 			return error;
    293   1.47       erh 		tv[0].tv_usec = tv[1].tv_usec = 0;
    294   1.47       erh 		tv[0].tv_sec = lut.l_actime;
    295   1.47       erh 		tv[1].tv_sec = lut.l_modtime;
    296   1.92       dsl 		tvp = tv;
    297   1.92       dsl 	} else
    298   1.92       dsl 		tvp = NULL;
    299    1.2      fvdl 
    300   1.92       dsl 	return do_sys_utimes(l, NULL, SCARG(uap, path), FOLLOW,
    301   1.92       dsl 			   tvp,  UIO_SYSSPACE);
    302    1.1      fvdl }
    303    1.1      fvdl 
    304   1.74      manu #ifndef __amd64__
    305   1.47       erh /*
    306   1.72       erh  * waitpid(2).  Just forward on to linux_sys_wait4 with a NULL rusage.
    307   1.47       erh  */
    308    1.1      fvdl int
    309   1.99       dsl linux_sys_waitpid(struct lwp *l, const struct linux_sys_waitpid_args *uap, register_t *retval)
    310   1.20   thorpej {
    311   1.99       dsl 	/* {
    312   1.47       erh 		syscallarg(int) pid;
    313   1.47       erh 		syscallarg(int *) status;
    314   1.47       erh 		syscallarg(int) options;
    315   1.99       dsl 	} */
    316   1.72       erh 	struct linux_sys_wait4_args linux_w4a;
    317    1.2      fvdl 
    318   1.72       erh 	SCARG(&linux_w4a, pid) = SCARG(uap, pid);
    319   1.72       erh 	SCARG(&linux_w4a, status) = SCARG(uap, status);
    320   1.72       erh 	SCARG(&linux_w4a, options) = SCARG(uap, options);
    321   1.72       erh 	SCARG(&linux_w4a, rusage) = NULL;
    322    1.2      fvdl 
    323   1.72       erh 	return linux_sys_wait4(l, &linux_w4a, retval);
    324   1.51   thorpej }
    325   1.74      manu #endif /* !amd64 */
    326   1.51   thorpej 
    327   1.51   thorpej int
    328   1.99       dsl linux_sys_setresgid(struct lwp *l, const struct linux_sys_setresgid_args *uap, register_t *retval)
    329   1.51   thorpej {
    330   1.99       dsl 	/* {
    331   1.51   thorpej 		syscallarg(gid_t) rgid;
    332   1.51   thorpej 		syscallarg(gid_t) egid;
    333   1.51   thorpej 		syscallarg(gid_t) sgid;
    334   1.99       dsl 	} */
    335   1.51   thorpej 
    336   1.51   thorpej 	/*
    337   1.51   thorpej 	 * Note: These checks are a little different than the NetBSD
    338   1.51   thorpej 	 * setregid(2) call performs.  This precisely follows the
    339   1.51   thorpej 	 * behavior of the Linux kernel.
    340   1.51   thorpej 	 */
    341   1.67       dsl 	return do_setresgid(l, SCARG(uap,rgid), SCARG(uap, egid),
    342   1.67       dsl 			    SCARG(uap, sgid),
    343   1.67       dsl 			    ID_R_EQ_R | ID_R_EQ_E | ID_R_EQ_S |
    344   1.67       dsl 			    ID_E_EQ_R | ID_E_EQ_E | ID_E_EQ_S |
    345   1.67       dsl 			    ID_S_EQ_R | ID_S_EQ_E | ID_S_EQ_S );
    346   1.51   thorpej }
    347   1.51   thorpej 
    348   1.51   thorpej int
    349   1.99       dsl linux_sys_getresgid(struct lwp *l, const struct linux_sys_getresgid_args *uap, register_t *retval)
    350   1.51   thorpej {
    351   1.99       dsl 	/* {
    352   1.51   thorpej 		syscallarg(gid_t *) rgid;
    353   1.51   thorpej 		syscallarg(gid_t *) egid;
    354   1.51   thorpej 		syscallarg(gid_t *) sgid;
    355   1.99       dsl 	} */
    356   1.81        ad 	kauth_cred_t pc = l->l_cred;
    357   1.51   thorpej 	int error;
    358   1.79      elad 	gid_t gid;
    359   1.51   thorpej 
    360   1.51   thorpej 	/*
    361   1.51   thorpej 	 * Linux copies these values out to userspace like so:
    362   1.51   thorpej 	 *
    363   1.51   thorpej 	 *	1. Copy out rgid.
    364   1.51   thorpej 	 *	2. If that succeeds, copy out egid.
    365   1.51   thorpej 	 *	3. If both of those succeed, copy out sgid.
    366   1.51   thorpej 	 */
    367   1.79      elad 	gid = kauth_cred_getgid(pc);
    368   1.79      elad 	if ((error = copyout(&gid, SCARG(uap, rgid), sizeof(gid_t))) != 0)
    369   1.51   thorpej 		return (error);
    370   1.51   thorpej 
    371   1.79      elad 	gid = kauth_cred_getegid(pc);
    372   1.79      elad 	if ((error = copyout(&gid, SCARG(uap, egid), sizeof(gid_t))) != 0)
    373   1.51   thorpej 		return (error);
    374   1.51   thorpej 
    375   1.79      elad 	gid = kauth_cred_getsvgid(pc);
    376   1.79      elad 
    377   1.79      elad 	return (copyout(&gid, SCARG(uap, sgid), sizeof(gid_t)));
    378   1.52      tron }
    379   1.52      tron 
    380   1.74      manu #ifndef __amd64__
    381   1.52      tron /*
    382   1.52      tron  * I wonder why Linux has settimeofday() _and_ stime().. Still, we
    383   1.52      tron  * need to deal with it.
    384   1.52      tron  */
    385   1.52      tron int
    386   1.99       dsl linux_sys_stime(struct lwp *l, const struct linux_sys_stime_args *uap, register_t *retval)
    387   1.52      tron {
    388   1.99       dsl 	/* {
    389   1.99       dsl 		syscallarg(linux_time_t) *t;
    390   1.99       dsl 	} */
    391   1.75  christos 	struct timespec ats;
    392   1.52      tron 	linux_time_t tt;
    393   1.52      tron 	int error;
    394   1.52      tron 
    395  1.105     njoly 	if ((error = copyin(SCARG(uap, t), &tt, sizeof tt)) != 0)
    396   1.52      tron 		return error;
    397   1.52      tron 
    398   1.75  christos 	ats.tv_sec = tt;
    399   1.75  christos 	ats.tv_nsec = 0;
    400   1.52      tron 
    401   1.81        ad 	if ((error = settime(l->l_proc, &ats)))
    402   1.52      tron 		return (error);
    403   1.52      tron 
    404   1.52      tron 	return 0;
    405    1.1      fvdl }
    406   1.70  jdolecek 
    407   1.70  jdolecek /*
    408   1.70  jdolecek  * Implement the fs stat functions. Straightforward.
    409   1.70  jdolecek  */
    410   1.70  jdolecek int
    411   1.99       dsl linux_sys_statfs64(struct lwp *l, const struct linux_sys_statfs64_args *uap, register_t *retval)
    412   1.70  jdolecek {
    413   1.99       dsl 	/* {
    414   1.70  jdolecek 		syscallarg(const char *) path;
    415   1.70  jdolecek 		syscallarg(size_t) sz;
    416   1.70  jdolecek 		syscallarg(struct linux_statfs64 *) sp;
    417   1.99       dsl 	} */
    418   1.90       dsl 	struct statvfs *sb;
    419   1.70  jdolecek 	struct linux_statfs64 ltmp;
    420   1.70  jdolecek 	int error;
    421   1.70  jdolecek 
    422   1.70  jdolecek 	if (SCARG(uap, sz) != sizeof ltmp)
    423   1.70  jdolecek 		return (EINVAL);
    424   1.70  jdolecek 
    425   1.90       dsl 	sb = STATVFSBUF_GET();
    426   1.90       dsl 	error = do_sys_pstatvfs(l, SCARG(uap, path), ST_WAIT, sb);
    427   1.90       dsl 	if (error == 0) {
    428   1.90       dsl 		bsd_to_linux_statfs64(sb, &ltmp);
    429   1.90       dsl 		error = copyout(&ltmp, SCARG(uap, sp), sizeof ltmp);
    430   1.78      yamt 	}
    431   1.90       dsl 	STATVFSBUF_PUT(sb);
    432   1.78      yamt 	return error;
    433   1.70  jdolecek }
    434   1.70  jdolecek 
    435   1.70  jdolecek int
    436   1.99       dsl linux_sys_fstatfs64(struct lwp *l, const struct linux_sys_fstatfs64_args *uap, register_t *retval)
    437   1.70  jdolecek {
    438   1.99       dsl 	/* {
    439   1.70  jdolecek 		syscallarg(int) fd;
    440   1.70  jdolecek 		syscallarg(size_t) sz;
    441   1.70  jdolecek 		syscallarg(struct linux_statfs64 *) sp;
    442   1.99       dsl 	} */
    443   1.90       dsl 	struct statvfs *sb;
    444   1.70  jdolecek 	struct linux_statfs64 ltmp;
    445   1.70  jdolecek 	int error;
    446   1.70  jdolecek 
    447   1.70  jdolecek 	if (SCARG(uap, sz) != sizeof ltmp)
    448   1.70  jdolecek 		return (EINVAL);
    449   1.70  jdolecek 
    450   1.90       dsl 	sb = STATVFSBUF_GET();
    451   1.90       dsl 	error = do_sys_fstatvfs(l, SCARG(uap, fd), ST_WAIT, sb);
    452   1.90       dsl 	if (error == 0) {
    453   1.90       dsl 		bsd_to_linux_statfs64(sb, &ltmp);
    454   1.90       dsl 		error = copyout(&ltmp, SCARG(uap, sp), sizeof ltmp);
    455   1.78      yamt 	}
    456   1.90       dsl 	STATVFSBUF_PUT(sb);
    457   1.78      yamt 	return error;
    458   1.70  jdolecek }
    459  1.108       chs #endif /* !__amd64__ */
    460   1.77      manu #endif /* !COMPAT_LINUX32 */
    461