Convert 67 namei call sites to use namei_simple, in these functions:
check_console, veriexecclose, veriexec_delete, veriexec_file_add,
emul_find_root, coff_load_shlib (sh3 version), coff_load_shlib,
compat_20_sys_statfs, compat_20_netbsd32_statfs,
ELFNAME2(netbsd32,probe_noteless), darwin_sys_statfs,
ibcs2_sys_statfs, ibcs2_sys_statvfs, linux_sys_uselib,
osf1_sys_statfs, sunos_sys_statfs, sunos32_sys_statfs,
ultrix_sys_statfs, do_sys_mount, fss_create_files (3 of 4),
adosfs_mount, cd9660_mount, coda_ioctl, coda_mount, ext2fs_mount,
ffs_mount, filecore_mount, hfs_mount, lfs_mount, msdosfs_mount,
ntfs_mount, sysvbfs_mount, udf_mount, union_mount, sys_chflags,
sys_lchflags, sys_chmod, sys_lchmod, sys_chown, sys_lchown,
sys___posix_chown, sys___posix_lchown, sys_link, do_sys_pstatvfs,
sys_quotactl, sys_revoke, sys_truncate, do_sys_utimes, sys_extattrctl,
sys_extattr_set_file, sys_extattr_set_link, sys_extattr_get_file,
sys_extattr_get_link, sys_extattr_delete_file,
sys_extattr_delete_link, sys_extattr_list_file, sys_extattr_list_link,
sys_setxattr, sys_lsetxattr, sys_getxattr, sys_lgetxattr,
sys_listxattr, sys_llistxattr, sys_removexattr, sys_lremovexattr
All have been scrutinized (several times, in fact) and compile-tested,
but not all have been explicitly tested in action.
XXX: While I haven't (intentionally) changed the use or nonuse of
XXX: TRYEMULROOT in any of these places, I'm not convinced all the
XXX: uses are correct; an audit might be desirable.
2009-06-29 09:08:15 +04:00
|
|
|
/* $NetBSD: netbsd32_compat_20.c,v 1.27 2009/06/29 05:08:16 dholland Exp $ */
|
2004-06-17 22:29:40 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1998, 2001 Matthew R. Green
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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>
|
Convert 67 namei call sites to use namei_simple, in these functions:
check_console, veriexecclose, veriexec_delete, veriexec_file_add,
emul_find_root, coff_load_shlib (sh3 version), coff_load_shlib,
compat_20_sys_statfs, compat_20_netbsd32_statfs,
ELFNAME2(netbsd32,probe_noteless), darwin_sys_statfs,
ibcs2_sys_statfs, ibcs2_sys_statvfs, linux_sys_uselib,
osf1_sys_statfs, sunos_sys_statfs, sunos32_sys_statfs,
ultrix_sys_statfs, do_sys_mount, fss_create_files (3 of 4),
adosfs_mount, cd9660_mount, coda_ioctl, coda_mount, ext2fs_mount,
ffs_mount, filecore_mount, hfs_mount, lfs_mount, msdosfs_mount,
ntfs_mount, sysvbfs_mount, udf_mount, union_mount, sys_chflags,
sys_lchflags, sys_chmod, sys_lchmod, sys_chown, sys_lchown,
sys___posix_chown, sys___posix_lchown, sys_link, do_sys_pstatvfs,
sys_quotactl, sys_revoke, sys_truncate, do_sys_utimes, sys_extattrctl,
sys_extattr_set_file, sys_extattr_set_link, sys_extattr_get_file,
sys_extattr_get_link, sys_extattr_delete_file,
sys_extattr_delete_link, sys_extattr_list_file, sys_extattr_list_link,
sys_setxattr, sys_lsetxattr, sys_getxattr, sys_lgetxattr,
sys_listxattr, sys_llistxattr, sys_removexattr, sys_lremovexattr
All have been scrutinized (several times, in fact) and compile-tested,
but not all have been explicitly tested in action.
XXX: While I haven't (intentionally) changed the use or nonuse of
XXX: TRYEMULROOT in any of these places, I'm not convinced all the
XXX: uses are correct; an audit might be desirable.
2009-06-29 09:08:15 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_20.c,v 1.27 2009/06/29 05:08:16 dholland Exp $");
|
2004-06-17 22:29:40 +04:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/ktrace.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/filedesc.h>
|
|
|
|
#include <sys/namei.h>
|
|
|
|
#include <sys/syscallargs.h>
|
|
|
|
#include <sys/proc.h>
|
2005-08-19 08:24:38 +04:00
|
|
|
#include <sys/dirent.h>
|
2004-06-17 22:29:40 +04:00
|
|
|
|
|
|
|
#include <compat/netbsd32/netbsd32.h>
|
|
|
|
#include <compat/netbsd32/netbsd32_syscallargs.h>
|
|
|
|
#include <compat/netbsd32/netbsd32_conv.h>
|
|
|
|
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void compat_20_netbsd32_from_statvfs(struct statvfs *,
|
2004-06-17 22:29:40 +04:00
|
|
|
struct netbsd32_statfs *);
|
|
|
|
|
2005-12-24 23:45:08 +03:00
|
|
|
static inline void
|
2007-12-08 21:35:53 +03:00
|
|
|
compat_20_netbsd32_from_statvfs(struct statvfs *sbp, struct netbsd32_statfs *sb32p)
|
2004-06-17 22:29:40 +04:00
|
|
|
{
|
|
|
|
sb32p->f_flags = sbp->f_flag;
|
|
|
|
sb32p->f_bsize = (netbsd32_long)sbp->f_bsize;
|
|
|
|
sb32p->f_iosize = (netbsd32_long)sbp->f_iosize;
|
|
|
|
sb32p->f_blocks = (netbsd32_long)sbp->f_blocks;
|
|
|
|
sb32p->f_bfree = (netbsd32_long)sbp->f_bfree;
|
|
|
|
sb32p->f_bavail = (netbsd32_long)sbp->f_bavail;
|
|
|
|
sb32p->f_files = (netbsd32_long)sbp->f_files;
|
|
|
|
sb32p->f_ffree = (netbsd32_long)sbp->f_ffree;
|
|
|
|
sb32p->f_fsid = sbp->f_fsidx;
|
|
|
|
sb32p->f_owner = sbp->f_owner;
|
|
|
|
sb32p->f_spare[0] = 0;
|
|
|
|
sb32p->f_spare[1] = 0;
|
|
|
|
sb32p->f_spare[2] = 0;
|
|
|
|
sb32p->f_spare[3] = 0;
|
|
|
|
#if 1
|
|
|
|
/* May as well do the whole batch in one go */
|
2007-07-18 00:39:42 +04:00
|
|
|
(void)memcpy(sb32p->f_fstypename, sbp->f_fstypename,
|
|
|
|
sizeof(sb32p->f_fstypename) +
|
|
|
|
sizeof(sb32p->f_mntonname) +
|
2007-07-18 17:53:34 +04:00
|
|
|
sizeof(sb32p->f_mntfromname));
|
2004-06-17 22:29:40 +04:00
|
|
|
#else
|
|
|
|
/* If we want to be careful */
|
2007-07-18 00:39:42 +04:00
|
|
|
(void)memcpy(sb32p->f_fstypename, sbp->f_fstypename,
|
|
|
|
sizeof(sb32p->f_fstypename));
|
|
|
|
(void)memcpy(sb32p->f_mntonname, sbp->f_mntonname,
|
|
|
|
sizeof(sb32p->f_mntonname));
|
|
|
|
(void)memcpy(sb32p->f_mntfromname, sbp->f_mntfromname,
|
|
|
|
sizeof(sb32p->f_mntfromname));
|
2004-06-17 22:29:40 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_20_netbsd32_getfsstat(struct lwp *l, const struct compat_20_netbsd32_getfsstat_args *uap, register_t *retval)
|
2004-06-17 22:29:40 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
2004-06-17 22:29:40 +04:00
|
|
|
syscallarg(netbsd32_statfsp_t) buf;
|
|
|
|
syscallarg(netbsd32_long) bufsize;
|
|
|
|
syscallarg(int) flags;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
2004-06-17 22:29:40 +04:00
|
|
|
struct mount *mp, *nmp;
|
|
|
|
struct statvfs *sp;
|
|
|
|
struct netbsd32_statfs sb32;
|
2007-03-04 08:59:00 +03:00
|
|
|
void *sfsp;
|
2004-06-17 22:29:40 +04:00
|
|
|
long count, maxcount, error;
|
|
|
|
|
|
|
|
maxcount = SCARG(uap, bufsize) / sizeof(struct netbsd32_statfs);
|
2007-03-19 00:38:32 +03:00
|
|
|
sfsp = SCARG_P32(uap, buf);
|
2007-10-11 02:00:53 +04:00
|
|
|
mutex_enter(&mountlist_lock);
|
2004-06-17 22:29:40 +04:00
|
|
|
count = 0;
|
|
|
|
for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = nmp) {
|
PR kern/38141 lookup/vfs_busy acquire rwlock recursively
Simplify the mount locking. Remove all the crud to deal with recursion on
the mount lock, and crud to deal with unmount as another weirdo lock.
Hopefully this will once and for all fix the deadlocks with this. With this
commit there are two locks on each mount:
- krwlock_t mnt_unmounting. This is used to prevent unmount across critical
sections like getnewvnode(). It's only ever read locked with rw_tryenter(),
and is only ever write locked in dounmount(). A write hold can't be taken
on this lock if the current LWP could hold a vnode lock.
- kmutex_t mnt_updating. This is taken by threads updating the mount, for
example when going r/o -> r/w, and is only present to serialize updates.
In order to take this lock, a read hold must first be taken on
mnt_unmounting, and the two need to be held across the operation.
One effect of this change: previously if an unmount failed, we would make a
half hearted attempt to back out of it gracefully, but that was unlikely to
work in a lot of cases. Now while an unmount that will be aborted is in
progress, new file operations within the mount will fail instead of being
delayed. That is unlikely to be a problem though, because if the admin
requests unmount of a file system then s(he) has made a decision to deny
access to the resource.
2008-05-06 22:43:44 +04:00
|
|
|
if (vfs_busy(mp, &nmp)) {
|
2004-06-17 22:29:40 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (sfsp && count < maxcount) {
|
|
|
|
sp = &mp->mnt_stat;
|
|
|
|
/*
|
|
|
|
* If MNT_NOWAIT or MNT_LAZY is specified, do not
|
2007-04-16 22:33:39 +04:00
|
|
|
* refresh the fsstat cache. MNT_WAIT or MNT_LAZY
|
2004-06-17 22:29:40 +04:00
|
|
|
* overrides MNT_NOWAIT.
|
|
|
|
*/
|
|
|
|
if (SCARG(uap, flags) != MNT_NOWAIT &&
|
|
|
|
SCARG(uap, flags) != MNT_LAZY &&
|
|
|
|
(SCARG(uap, flags) == MNT_WAIT ||
|
|
|
|
SCARG(uap, flags) == 0) &&
|
2007-11-27 12:47:15 +03:00
|
|
|
(error = VFS_STATVFS(mp, sp)) != 0) {
|
2007-10-11 02:00:53 +04:00
|
|
|
mutex_enter(&mountlist_lock);
|
2008-04-30 16:49:16 +04:00
|
|
|
vfs_unbusy(mp, false, &nmp);
|
2004-06-17 22:29:40 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK;
|
|
|
|
compat_20_netbsd32_from_statvfs(sp, &sb32);
|
|
|
|
error = copyout(&sb32, sfsp, sizeof(sb32));
|
|
|
|
if (error) {
|
2008-04-30 16:49:16 +04:00
|
|
|
vfs_unbusy(mp, false, NULL);
|
2004-06-17 22:29:40 +04:00
|
|
|
return (error);
|
|
|
|
}
|
2007-03-04 10:54:07 +03:00
|
|
|
sfsp = (char *)sfsp + sizeof(sb32);
|
2004-06-17 22:29:40 +04:00
|
|
|
}
|
|
|
|
count++;
|
2007-10-11 02:00:53 +04:00
|
|
|
mutex_enter(&mountlist_lock);
|
2008-04-30 16:49:16 +04:00
|
|
|
vfs_unbusy(mp, false, &nmp);
|
2004-06-17 22:29:40 +04:00
|
|
|
}
|
2007-10-11 02:00:53 +04:00
|
|
|
mutex_exit(&mountlist_lock);
|
2004-06-17 22:29:40 +04:00
|
|
|
if (sfsp && count > maxcount)
|
|
|
|
*retval = maxcount;
|
|
|
|
else
|
|
|
|
*retval = count;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_20_netbsd32_statfs(struct lwp *l, const struct compat_20_netbsd32_statfs_args *uap, register_t *retval)
|
2004-06-17 22:29:40 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
2004-06-17 22:29:40 +04:00
|
|
|
syscallarg(const netbsd32_charp) path;
|
|
|
|
syscallarg(netbsd32_statfsp_t) buf;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
2004-06-17 22:29:40 +04:00
|
|
|
struct mount *mp;
|
|
|
|
struct statvfs *sp;
|
|
|
|
struct netbsd32_statfs s32;
|
|
|
|
int error;
|
Convert 67 namei call sites to use namei_simple, in these functions:
check_console, veriexecclose, veriexec_delete, veriexec_file_add,
emul_find_root, coff_load_shlib (sh3 version), coff_load_shlib,
compat_20_sys_statfs, compat_20_netbsd32_statfs,
ELFNAME2(netbsd32,probe_noteless), darwin_sys_statfs,
ibcs2_sys_statfs, ibcs2_sys_statvfs, linux_sys_uselib,
osf1_sys_statfs, sunos_sys_statfs, sunos32_sys_statfs,
ultrix_sys_statfs, do_sys_mount, fss_create_files (3 of 4),
adosfs_mount, cd9660_mount, coda_ioctl, coda_mount, ext2fs_mount,
ffs_mount, filecore_mount, hfs_mount, lfs_mount, msdosfs_mount,
ntfs_mount, sysvbfs_mount, udf_mount, union_mount, sys_chflags,
sys_lchflags, sys_chmod, sys_lchmod, sys_chown, sys_lchown,
sys___posix_chown, sys___posix_lchown, sys_link, do_sys_pstatvfs,
sys_quotactl, sys_revoke, sys_truncate, do_sys_utimes, sys_extattrctl,
sys_extattr_set_file, sys_extattr_set_link, sys_extattr_get_file,
sys_extattr_get_link, sys_extattr_delete_file,
sys_extattr_delete_link, sys_extattr_list_file, sys_extattr_list_link,
sys_setxattr, sys_lsetxattr, sys_getxattr, sys_lgetxattr,
sys_listxattr, sys_llistxattr, sys_removexattr, sys_lremovexattr
All have been scrutinized (several times, in fact) and compile-tested,
but not all have been explicitly tested in action.
XXX: While I haven't (intentionally) changed the use or nonuse of
XXX: TRYEMULROOT in any of these places, I'm not convinced all the
XXX: uses are correct; an audit might be desirable.
2009-06-29 09:08:15 +04:00
|
|
|
struct vnode *vp;
|
2004-06-17 22:29:40 +04:00
|
|
|
|
Convert 67 namei call sites to use namei_simple, in these functions:
check_console, veriexecclose, veriexec_delete, veriexec_file_add,
emul_find_root, coff_load_shlib (sh3 version), coff_load_shlib,
compat_20_sys_statfs, compat_20_netbsd32_statfs,
ELFNAME2(netbsd32,probe_noteless), darwin_sys_statfs,
ibcs2_sys_statfs, ibcs2_sys_statvfs, linux_sys_uselib,
osf1_sys_statfs, sunos_sys_statfs, sunos32_sys_statfs,
ultrix_sys_statfs, do_sys_mount, fss_create_files (3 of 4),
adosfs_mount, cd9660_mount, coda_ioctl, coda_mount, ext2fs_mount,
ffs_mount, filecore_mount, hfs_mount, lfs_mount, msdosfs_mount,
ntfs_mount, sysvbfs_mount, udf_mount, union_mount, sys_chflags,
sys_lchflags, sys_chmod, sys_lchmod, sys_chown, sys_lchown,
sys___posix_chown, sys___posix_lchown, sys_link, do_sys_pstatvfs,
sys_quotactl, sys_revoke, sys_truncate, do_sys_utimes, sys_extattrctl,
sys_extattr_set_file, sys_extattr_set_link, sys_extattr_get_file,
sys_extattr_get_link, sys_extattr_delete_file,
sys_extattr_delete_link, sys_extattr_list_file, sys_extattr_list_link,
sys_setxattr, sys_lsetxattr, sys_getxattr, sys_lgetxattr,
sys_listxattr, sys_llistxattr, sys_removexattr, sys_lremovexattr
All have been scrutinized (several times, in fact) and compile-tested,
but not all have been explicitly tested in action.
XXX: While I haven't (intentionally) changed the use or nonuse of
XXX: TRYEMULROOT in any of these places, I'm not convinced all the
XXX: uses are correct; an audit might be desirable.
2009-06-29 09:08:15 +04:00
|
|
|
error = namei_simple_user(SCARG_P32(uap, path),
|
|
|
|
NSM_FOLLOW_TRYEMULROOT, &vp);
|
|
|
|
if (error != 0)
|
2004-06-17 22:29:40 +04:00
|
|
|
return (error);
|
Convert 67 namei call sites to use namei_simple, in these functions:
check_console, veriexecclose, veriexec_delete, veriexec_file_add,
emul_find_root, coff_load_shlib (sh3 version), coff_load_shlib,
compat_20_sys_statfs, compat_20_netbsd32_statfs,
ELFNAME2(netbsd32,probe_noteless), darwin_sys_statfs,
ibcs2_sys_statfs, ibcs2_sys_statvfs, linux_sys_uselib,
osf1_sys_statfs, sunos_sys_statfs, sunos32_sys_statfs,
ultrix_sys_statfs, do_sys_mount, fss_create_files (3 of 4),
adosfs_mount, cd9660_mount, coda_ioctl, coda_mount, ext2fs_mount,
ffs_mount, filecore_mount, hfs_mount, lfs_mount, msdosfs_mount,
ntfs_mount, sysvbfs_mount, udf_mount, union_mount, sys_chflags,
sys_lchflags, sys_chmod, sys_lchmod, sys_chown, sys_lchown,
sys___posix_chown, sys___posix_lchown, sys_link, do_sys_pstatvfs,
sys_quotactl, sys_revoke, sys_truncate, do_sys_utimes, sys_extattrctl,
sys_extattr_set_file, sys_extattr_set_link, sys_extattr_get_file,
sys_extattr_get_link, sys_extattr_delete_file,
sys_extattr_delete_link, sys_extattr_list_file, sys_extattr_list_link,
sys_setxattr, sys_lsetxattr, sys_getxattr, sys_lgetxattr,
sys_listxattr, sys_llistxattr, sys_removexattr, sys_lremovexattr
All have been scrutinized (several times, in fact) and compile-tested,
but not all have been explicitly tested in action.
XXX: While I haven't (intentionally) changed the use or nonuse of
XXX: TRYEMULROOT in any of these places, I'm not convinced all the
XXX: uses are correct; an audit might be desirable.
2009-06-29 09:08:15 +04:00
|
|
|
mp = vp->v_mount;
|
2004-06-17 22:29:40 +04:00
|
|
|
sp = &mp->mnt_stat;
|
Convert 67 namei call sites to use namei_simple, in these functions:
check_console, veriexecclose, veriexec_delete, veriexec_file_add,
emul_find_root, coff_load_shlib (sh3 version), coff_load_shlib,
compat_20_sys_statfs, compat_20_netbsd32_statfs,
ELFNAME2(netbsd32,probe_noteless), darwin_sys_statfs,
ibcs2_sys_statfs, ibcs2_sys_statvfs, linux_sys_uselib,
osf1_sys_statfs, sunos_sys_statfs, sunos32_sys_statfs,
ultrix_sys_statfs, do_sys_mount, fss_create_files (3 of 4),
adosfs_mount, cd9660_mount, coda_ioctl, coda_mount, ext2fs_mount,
ffs_mount, filecore_mount, hfs_mount, lfs_mount, msdosfs_mount,
ntfs_mount, sysvbfs_mount, udf_mount, union_mount, sys_chflags,
sys_lchflags, sys_chmod, sys_lchmod, sys_chown, sys_lchown,
sys___posix_chown, sys___posix_lchown, sys_link, do_sys_pstatvfs,
sys_quotactl, sys_revoke, sys_truncate, do_sys_utimes, sys_extattrctl,
sys_extattr_set_file, sys_extattr_set_link, sys_extattr_get_file,
sys_extattr_get_link, sys_extattr_delete_file,
sys_extattr_delete_link, sys_extattr_list_file, sys_extattr_list_link,
sys_setxattr, sys_lsetxattr, sys_getxattr, sys_lgetxattr,
sys_listxattr, sys_llistxattr, sys_removexattr, sys_lremovexattr
All have been scrutinized (several times, in fact) and compile-tested,
but not all have been explicitly tested in action.
XXX: While I haven't (intentionally) changed the use or nonuse of
XXX: TRYEMULROOT in any of these places, I'm not convinced all the
XXX: uses are correct; an audit might be desirable.
2009-06-29 09:08:15 +04:00
|
|
|
vrele(vp);
|
2007-11-27 12:47:15 +03:00
|
|
|
if ((error = VFS_STATVFS(mp, sp)) != 0)
|
2004-06-17 22:29:40 +04:00
|
|
|
return (error);
|
|
|
|
sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK;
|
|
|
|
compat_20_netbsd32_from_statvfs(sp, &s32);
|
2007-03-19 00:38:32 +03:00
|
|
|
return copyout(&s32, SCARG_P32(uap, buf), sizeof(s32));
|
2004-06-17 22:29:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_20_netbsd32_fstatfs(struct lwp *l, const struct compat_20_netbsd32_fstatfs_args *uap, register_t *retval)
|
2004-06-17 22:29:40 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
2004-06-17 22:29:40 +04:00
|
|
|
syscallarg(int) fd;
|
|
|
|
syscallarg(netbsd32_statfsp_t) buf;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
2008-03-22 00:54:58 +03:00
|
|
|
file_t *fp;
|
2004-06-17 22:29:40 +04:00
|
|
|
struct mount *mp;
|
|
|
|
struct statvfs *sp;
|
|
|
|
struct netbsd32_statfs s32;
|
|
|
|
int error;
|
|
|
|
|
2008-06-24 15:18:14 +04:00
|
|
|
/* fd_getvnode() will use the descriptor for us */
|
2008-03-22 00:54:58 +03:00
|
|
|
if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
|
2004-06-17 22:29:40 +04:00
|
|
|
return (error);
|
|
|
|
mp = ((struct vnode *)fp->f_data)->v_mount;
|
|
|
|
sp = &mp->mnt_stat;
|
2007-11-27 12:47:15 +03:00
|
|
|
if ((error = VFS_STATVFS(mp, sp)) != 0)
|
2004-06-17 22:29:40 +04:00
|
|
|
goto out;
|
|
|
|
sp->f_flag = mp->mnt_flag & MNT_VISFLAGMASK;
|
|
|
|
compat_20_netbsd32_from_statvfs(sp, &s32);
|
2007-03-19 00:38:32 +03:00
|
|
|
error = copyout(&s32, SCARG_P32(uap, buf), sizeof(s32));
|
2004-06-17 22:29:40 +04:00
|
|
|
out:
|
2008-03-22 00:54:58 +03:00
|
|
|
fd_putfile(SCARG(uap, fd));
|
2004-06-17 22:29:40 +04:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_20_netbsd32_fhstatfs(struct lwp *l, const struct compat_20_netbsd32_fhstatfs_args *uap, register_t *retval)
|
2004-06-17 22:29:40 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
2004-06-17 22:29:40 +04:00
|
|
|
syscallarg(const netbsd32_fhandlep_t) fhp;
|
|
|
|
syscallarg(struct statvfs *) buf;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
2006-07-31 20:34:42 +04:00
|
|
|
struct compat_30_sys_fhstatvfs1_args ua;
|
2004-06-17 22:29:40 +04:00
|
|
|
|
2006-07-31 20:34:42 +04:00
|
|
|
NETBSD32TOP_UAP(fhp, const struct compat_30_fhandle);
|
2004-06-17 22:29:40 +04:00
|
|
|
NETBSD32TOP_UAP(buf, struct statvfs);
|
|
|
|
#ifdef notyet
|
|
|
|
NETBSD32TOP_UAP(flags, int);
|
|
|
|
#endif
|
2006-07-31 20:34:42 +04:00
|
|
|
return (compat_30_sys_fhstatvfs1(l, &ua, retval));
|
2004-06-17 22:29:40 +04:00
|
|
|
}
|