2002-08-07 02:50:37 +04:00
|
|
|
/* $NetBSD: ibcs2_stat.c,v 1.21 2002/08/06 22:50:37 itojun Exp $ */
|
1995-03-14 18:12:17 +03:00
|
|
|
/*
|
1998-02-09 05:30:42 +03:00
|
|
|
* Copyright (c) 1995, 1998 Scott Bartram
|
1995-03-14 18:12:17 +03:00
|
|
|
* 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.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2001-11-13 05:07:52 +03:00
|
|
|
#include <sys/cdefs.h>
|
2002-08-07 02:50:37 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: ibcs2_stat.c,v 1.21 2002/08/06 22:50:37 itojun Exp $");
|
2001-11-13 05:07:52 +03:00
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/namei.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/filedesc.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/syscallargs.h>
|
|
|
|
|
|
|
|
#include <compat/ibcs2/ibcs2_types.h>
|
|
|
|
#include <compat/ibcs2/ibcs2_fcntl.h>
|
|
|
|
#include <compat/ibcs2/ibcs2_signal.h>
|
|
|
|
#include <compat/ibcs2/ibcs2_stat.h>
|
|
|
|
#include <compat/ibcs2/ibcs2_statfs.h>
|
|
|
|
#include <compat/ibcs2/ibcs2_syscallargs.h>
|
|
|
|
#include <compat/ibcs2/ibcs2_ustat.h>
|
|
|
|
#include <compat/ibcs2/ibcs2_util.h>
|
|
|
|
#include <compat/ibcs2/ibcs2_utsname.h>
|
|
|
|
|
1997-10-17 03:52:20 +04:00
|
|
|
static void bsd_stat2ibcs_stat __P((struct stat *, struct ibcs2_stat *));
|
1996-05-03 21:05:16 +04:00
|
|
|
static int cvt_statfs __P((struct statfs *, caddr_t, int));
|
1998-03-05 07:36:07 +03:00
|
|
|
static int cvt_statvfs __P((struct statfs *, caddr_t, int));
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
static void
|
|
|
|
bsd_stat2ibcs_stat(st, st4)
|
1997-10-17 03:52:20 +04:00
|
|
|
struct stat *st;
|
1995-03-14 18:12:17 +03:00
|
|
|
struct ibcs2_stat *st4;
|
|
|
|
{
|
1998-08-10 00:36:58 +04:00
|
|
|
memset(st4, 0, sizeof(*st4));
|
1995-03-14 18:12:17 +03:00
|
|
|
st4->st_dev = (ibcs2_dev_t)st->st_dev;
|
|
|
|
st4->st_ino = (ibcs2_ino_t)st->st_ino;
|
|
|
|
st4->st_mode = (ibcs2_mode_t)st->st_mode;
|
1997-10-17 03:52:20 +04:00
|
|
|
if (st->st_nlink >= (1 << 15))
|
|
|
|
st4->st_nlink = (1 << 15) - 1;
|
|
|
|
else
|
|
|
|
st4->st_nlink = (ibcs2_nlink_t)st->st_nlink;
|
1995-03-14 18:12:17 +03:00
|
|
|
st4->st_uid = (ibcs2_uid_t)st->st_uid;
|
|
|
|
st4->st_gid = (ibcs2_gid_t)st->st_gid;
|
|
|
|
st4->st_rdev = (ibcs2_dev_t)st->st_rdev;
|
|
|
|
st4->st_size = (ibcs2_off_t)st->st_size;
|
|
|
|
st4->st_atim = (ibcs2_time_t)st->st_atime;
|
|
|
|
st4->st_mtim = (ibcs2_time_t)st->st_mtime;
|
|
|
|
st4->st_ctim = (ibcs2_time_t)st->st_ctime;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
cvt_statfs(sp, buf, len)
|
|
|
|
struct statfs *sp;
|
|
|
|
caddr_t buf;
|
|
|
|
int len;
|
|
|
|
{
|
|
|
|
struct ibcs2_statfs ssfs;
|
|
|
|
|
2002-08-03 04:12:48 +04:00
|
|
|
if (len < 0)
|
|
|
|
return (EINVAL);
|
|
|
|
if (len > sizeof(ssfs));
|
|
|
|
len = sizeof(ssfs);
|
|
|
|
|
1998-08-10 00:36:58 +04:00
|
|
|
memset(&ssfs, 0, sizeof ssfs);
|
1995-03-14 18:12:17 +03:00
|
|
|
ssfs.f_fstyp = 0;
|
|
|
|
ssfs.f_bsize = sp->f_bsize;
|
|
|
|
ssfs.f_frsize = 0;
|
|
|
|
ssfs.f_blocks = sp->f_blocks;
|
|
|
|
ssfs.f_bfree = sp->f_bfree;
|
|
|
|
ssfs.f_files = sp->f_files;
|
|
|
|
ssfs.f_ffree = sp->f_ffree;
|
|
|
|
ssfs.f_fname[0] = 0;
|
|
|
|
ssfs.f_fpack[0] = 0;
|
|
|
|
return copyout((caddr_t)&ssfs, buf, len);
|
|
|
|
}
|
|
|
|
|
1998-03-05 07:36:07 +03:00
|
|
|
static int
|
|
|
|
cvt_statvfs(sp, buf, len)
|
|
|
|
struct statfs *sp;
|
|
|
|
caddr_t buf;
|
|
|
|
int len;
|
|
|
|
{
|
|
|
|
struct ibcs2_statvfs ssvfs;
|
|
|
|
|
2002-08-07 02:50:37 +04:00
|
|
|
if (len < 0)
|
|
|
|
return (EINVAL);
|
|
|
|
if (len > sizeof(ssfs));
|
|
|
|
len = sizeof(ssfs);
|
|
|
|
|
1998-08-10 00:36:58 +04:00
|
|
|
memset(&ssvfs, 0, sizeof ssvfs);
|
1998-03-05 07:36:07 +03:00
|
|
|
ssvfs.f_frsize = ssvfs.f_bsize = sp->f_bsize;
|
|
|
|
ssvfs.f_blocks = sp->f_blocks;
|
|
|
|
ssvfs.f_bfree = sp->f_bfree;
|
|
|
|
ssvfs.f_bavail = sp->f_bavail;
|
|
|
|
ssvfs.f_files = sp->f_files;
|
|
|
|
ssvfs.f_ffree = sp->f_ffree;
|
|
|
|
ssvfs.f_favail = sp->f_ffree;
|
|
|
|
ssvfs.f_fsid = sp->f_fsid.val[0];
|
|
|
|
strncpy(ssvfs.f_basetype, sp->f_fstypename, 15);
|
|
|
|
ssvfs.f_flag = 0;
|
|
|
|
ssvfs.f_namemax = PATH_MAX;
|
|
|
|
ssvfs.f_fstr[0] = 0;
|
|
|
|
return copyout((caddr_t)&ssvfs, buf, len);
|
2002-08-07 02:50:37 +04:00
|
|
|
}
|
1998-03-05 07:36:07 +03:00
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_statfs(p, v, retval)
|
1995-03-14 18:12:17 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_statfs_args /* {
|
1999-02-09 23:48:20 +03:00
|
|
|
syscallarg(const char *) path;
|
1995-10-07 09:25:19 +03:00
|
|
|
syscallarg(struct ibcs2_statfs *) buf;
|
|
|
|
syscallarg(int) len;
|
|
|
|
syscallarg(int) fstype;
|
|
|
|
} */ *uap = v;
|
2000-03-30 15:24:16 +04:00
|
|
|
struct mount *mp;
|
|
|
|
struct statfs *sp;
|
1995-03-14 18:12:17 +03:00
|
|
|
int error;
|
|
|
|
struct nameidata nd;
|
2002-03-16 23:43:48 +03:00
|
|
|
caddr_t sg = stackgap_init(p, 0);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
2000-12-01 15:28:30 +03:00
|
|
|
CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
|
1995-03-14 18:12:17 +03:00
|
|
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
|
1996-05-03 21:05:16 +04:00
|
|
|
if ((error = namei(&nd)) != 0)
|
1995-03-14 18:12:17 +03:00
|
|
|
return (error);
|
|
|
|
mp = nd.ni_vp->v_mount;
|
|
|
|
sp = &mp->mnt_stat;
|
|
|
|
vrele(nd.ni_vp);
|
1996-05-03 21:05:16 +04:00
|
|
|
if ((error = VFS_STATFS(mp, sp, p)) != 0)
|
1995-03-14 18:12:17 +03:00
|
|
|
return (error);
|
|
|
|
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
|
|
|
return cvt_statfs(sp, (caddr_t)SCARG(uap, buf), SCARG(uap, len));
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_fstatfs(p, v, retval)
|
1995-03-14 18:12:17 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_fstatfs_args /* {
|
|
|
|
syscallarg(int) fd;
|
|
|
|
syscallarg(struct ibcs2_statfs *) buf;
|
|
|
|
syscallarg(int) len;
|
|
|
|
syscallarg(int) fstype;
|
|
|
|
} */ *uap = v;
|
1995-03-14 18:12:17 +03:00
|
|
|
struct file *fp;
|
|
|
|
struct mount *mp;
|
2000-03-30 15:24:16 +04:00
|
|
|
struct statfs *sp;
|
1995-03-14 18:12:17 +03:00
|
|
|
int error;
|
|
|
|
|
1999-05-06 00:01:01 +04:00
|
|
|
/* getvnode() will use the descriptor for us */
|
1996-05-03 21:05:16 +04:00
|
|
|
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
|
1995-03-14 18:12:17 +03:00
|
|
|
return (error);
|
|
|
|
mp = ((struct vnode *)fp->f_data)->v_mount;
|
|
|
|
sp = &mp->mnt_stat;
|
1996-05-03 21:05:16 +04:00
|
|
|
if ((error = VFS_STATFS(mp, sp, p)) != 0)
|
1999-05-06 00:01:01 +04:00
|
|
|
goto out;
|
1995-03-14 18:12:17 +03:00
|
|
|
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
1999-05-06 00:01:01 +04:00
|
|
|
error = cvt_statfs(sp, (caddr_t)SCARG(uap, buf), SCARG(uap, len));
|
|
|
|
out:
|
|
|
|
FILE_UNUSE(fp, p);
|
|
|
|
return (error);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
|
1998-03-05 07:36:07 +03:00
|
|
|
int
|
|
|
|
ibcs2_sys_statvfs(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct ibcs2_sys_statvfs_args /* {
|
1999-02-09 23:48:20 +03:00
|
|
|
syscallarg(const char *) path;
|
1998-03-05 07:36:07 +03:00
|
|
|
syscallarg(struct ibcs2_statvfs *) buf;
|
|
|
|
} */ *uap = v;
|
2000-03-30 15:24:16 +04:00
|
|
|
struct mount *mp;
|
|
|
|
struct statfs *sp;
|
1998-03-05 07:36:07 +03:00
|
|
|
int error;
|
|
|
|
struct nameidata nd;
|
2002-03-16 23:43:48 +03:00
|
|
|
caddr_t sg = stackgap_init(p, 0);
|
1998-03-05 07:36:07 +03:00
|
|
|
|
2000-12-01 15:28:30 +03:00
|
|
|
CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
|
1998-03-05 07:36:07 +03:00
|
|
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
|
|
|
|
if ((error = namei(&nd)) != 0)
|
|
|
|
return (error);
|
|
|
|
mp = nd.ni_vp->v_mount;
|
|
|
|
sp = &mp->mnt_stat;
|
|
|
|
vrele(nd.ni_vp);
|
|
|
|
if ((error = VFS_STATFS(mp, sp, p)) != 0)
|
|
|
|
return (error);
|
|
|
|
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
|
|
|
return cvt_statvfs(sp, (caddr_t)SCARG(uap, buf),
|
|
|
|
sizeof(struct ibcs2_statvfs));
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ibcs2_sys_fstatvfs(p, v, retval)
|
|
|
|
struct proc *p;
|
|
|
|
void *v;
|
|
|
|
register_t *retval;
|
|
|
|
{
|
|
|
|
struct ibcs2_sys_fstatvfs_args /* {
|
|
|
|
syscallarg(int) fd;
|
|
|
|
syscallarg(struct ibcs2_statvfs *) buf;
|
|
|
|
} */ *uap = v;
|
|
|
|
struct file *fp;
|
|
|
|
struct mount *mp;
|
2000-03-30 15:24:16 +04:00
|
|
|
struct statfs *sp;
|
1998-03-05 07:36:07 +03:00
|
|
|
int error;
|
|
|
|
|
1999-05-06 00:01:01 +04:00
|
|
|
/* getvnode() will use the descriptor for us */
|
1998-03-05 07:36:07 +03:00
|
|
|
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
|
|
|
|
return (error);
|
|
|
|
mp = ((struct vnode *)fp->f_data)->v_mount;
|
|
|
|
sp = &mp->mnt_stat;
|
|
|
|
if ((error = VFS_STATFS(mp, sp, p)) != 0)
|
1999-05-06 00:01:01 +04:00
|
|
|
goto out;
|
1998-03-05 07:36:07 +03:00
|
|
|
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
1999-05-06 00:01:01 +04:00
|
|
|
error = cvt_statvfs(sp, (caddr_t)SCARG(uap, buf),
|
1998-03-05 07:36:07 +03:00
|
|
|
sizeof(struct ibcs2_statvfs));
|
1999-05-06 00:01:01 +04:00
|
|
|
out:
|
|
|
|
FILE_UNUSE(fp, p);
|
|
|
|
return (error);
|
1998-03-05 07:36:07 +03:00
|
|
|
}
|
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_stat(p, v, retval)
|
1995-03-14 18:12:17 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_stat_args /* {
|
1999-02-09 23:48:20 +03:00
|
|
|
syscallarg(const char *) path;
|
1995-10-07 09:25:19 +03:00
|
|
|
syscallarg(struct ibcs2_stat *) st;
|
|
|
|
} */ *uap = v;
|
1997-10-17 03:52:20 +04:00
|
|
|
struct stat st;
|
1995-03-14 18:12:17 +03:00
|
|
|
struct ibcs2_stat ibcs2_st;
|
1997-10-21 02:05:06 +04:00
|
|
|
struct sys___stat13_args cup;
|
1995-03-14 18:12:17 +03:00
|
|
|
int error;
|
2002-03-16 23:43:48 +03:00
|
|
|
caddr_t sg = stackgap_init(p, 0);
|
|
|
|
SCARG(&cup, ub) = stackgap_alloc(p, &sg, sizeof(st));
|
2000-12-01 15:28:30 +03:00
|
|
|
CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(&cup, path) = SCARG(uap, path);
|
2000-08-29 18:33:25 +04:00
|
|
|
|
1997-10-21 02:05:06 +04:00
|
|
|
if ((error = sys___stat13(p, &cup, retval)) != 0)
|
1995-03-14 18:12:17 +03:00
|
|
|
return error;
|
1996-05-03 21:05:16 +04:00
|
|
|
if ((error = copyin(SCARG(&cup, ub), &st, sizeof(st))) != 0)
|
1995-03-14 18:12:17 +03:00
|
|
|
return error;
|
|
|
|
bsd_stat2ibcs_stat(&st, &ibcs2_st);
|
|
|
|
return copyout((caddr_t)&ibcs2_st, (caddr_t)SCARG(uap, st),
|
|
|
|
ibcs2_stat_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_lstat(p, v, retval)
|
1995-03-14 18:12:17 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_lstat_args /* {
|
1999-02-09 23:48:20 +03:00
|
|
|
syscallarg(const char *) path;
|
1995-10-07 09:25:19 +03:00
|
|
|
syscallarg(struct ibcs2_stat *) st;
|
|
|
|
} */ *uap = v;
|
1997-10-17 03:52:20 +04:00
|
|
|
struct stat st;
|
1995-03-14 18:12:17 +03:00
|
|
|
struct ibcs2_stat ibcs2_st;
|
1997-10-21 02:05:06 +04:00
|
|
|
struct sys___lstat13_args cup;
|
1995-03-14 18:12:17 +03:00
|
|
|
int error;
|
2002-03-16 23:43:48 +03:00
|
|
|
caddr_t sg = stackgap_init(p, 0);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
2002-03-16 23:43:48 +03:00
|
|
|
SCARG(&cup, ub) = stackgap_alloc(p, &sg, sizeof(st));
|
2000-12-01 15:28:30 +03:00
|
|
|
CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
|
1995-03-14 18:12:17 +03:00
|
|
|
SCARG(&cup, path) = SCARG(uap, path);
|
2000-08-29 18:33:25 +04:00
|
|
|
|
1997-10-21 02:05:06 +04:00
|
|
|
if ((error = sys___lstat13(p, &cup, retval)) != 0)
|
1995-03-14 18:12:17 +03:00
|
|
|
return error;
|
1996-05-03 21:05:16 +04:00
|
|
|
if ((error = copyin(SCARG(&cup, ub), &st, sizeof(st))) != 0)
|
1995-03-14 18:12:17 +03:00
|
|
|
return error;
|
|
|
|
bsd_stat2ibcs_stat(&st, &ibcs2_st);
|
|
|
|
return copyout((caddr_t)&ibcs2_st, (caddr_t)SCARG(uap, st),
|
|
|
|
ibcs2_stat_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_fstat(p, v, retval)
|
1995-03-14 18:12:17 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_fstat_args /* {
|
|
|
|
syscallarg(int) fd;
|
|
|
|
syscallarg(struct ibcs2_stat *) st;
|
|
|
|
} */ *uap = v;
|
1997-10-17 03:52:20 +04:00
|
|
|
struct stat st;
|
1995-03-14 18:12:17 +03:00
|
|
|
struct ibcs2_stat ibcs2_st;
|
1997-10-21 02:05:06 +04:00
|
|
|
struct sys___fstat13_args cup;
|
1995-03-14 18:12:17 +03:00
|
|
|
int error;
|
2002-03-16 23:43:48 +03:00
|
|
|
caddr_t sg = stackgap_init(p, 0);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
SCARG(&cup, fd) = SCARG(uap, fd);
|
2002-03-16 23:43:48 +03:00
|
|
|
SCARG(&cup, sb) = stackgap_alloc(p, &sg, sizeof(st));
|
1997-10-21 02:05:06 +04:00
|
|
|
if ((error = sys___fstat13(p, &cup, retval)) != 0)
|
1995-03-14 18:12:17 +03:00
|
|
|
return error;
|
1996-05-03 21:05:16 +04:00
|
|
|
if ((error = copyin(SCARG(&cup, sb), &st, sizeof(st))) != 0)
|
1995-03-14 18:12:17 +03:00
|
|
|
return error;
|
|
|
|
bsd_stat2ibcs_stat(&st, &ibcs2_st);
|
|
|
|
return copyout((caddr_t)&ibcs2_st, (caddr_t)SCARG(uap, st),
|
|
|
|
ibcs2_stat_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-10-07 09:25:19 +03:00
|
|
|
ibcs2_sys_utssys(p, v, retval)
|
1995-03-14 18:12:17 +03:00
|
|
|
struct proc *p;
|
1995-09-20 02:19:01 +04:00
|
|
|
void *v;
|
1995-10-07 09:25:19 +03:00
|
|
|
register_t *retval;
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1995-10-07 09:25:19 +03:00
|
|
|
struct ibcs2_sys_utssys_args /* {
|
|
|
|
syscallarg(int) a1;
|
|
|
|
syscallarg(int) a2;
|
|
|
|
syscallarg(int) flag;
|
|
|
|
} */ *uap = v;
|
1995-09-20 02:19:01 +04:00
|
|
|
|
1995-03-14 18:12:17 +03:00
|
|
|
switch (SCARG(uap, flag)) {
|
1998-02-09 05:30:42 +03:00
|
|
|
case 0: /* uname(struct utsname *) */
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
|
|
|
struct ibcs2_utsname sut;
|
|
|
|
|
1998-08-10 00:36:58 +04:00
|
|
|
memset(&sut, 0, ibcs2_utsname_len);
|
|
|
|
memcpy(sut.sysname, ostype, sizeof(sut.sysname) - 1);
|
|
|
|
memcpy(sut.nodename, hostname, sizeof(sut.nodename));
|
1995-03-14 18:12:17 +03:00
|
|
|
sut.nodename[sizeof(sut.nodename)-1] = '\0';
|
1998-08-10 00:36:58 +04:00
|
|
|
memcpy(sut.release, osrelease, sizeof(sut.release) - 1);
|
|
|
|
memcpy(sut.version, "1", sizeof(sut.version) - 1);
|
|
|
|
memcpy(sut.machine, machine, sizeof(sut.machine) - 1);
|
1995-03-14 18:12:17 +03:00
|
|
|
|
|
|
|
return copyout((caddr_t)&sut, (caddr_t)SCARG(uap, a1),
|
|
|
|
ibcs2_utsname_len);
|
|
|
|
}
|
|
|
|
|
1998-02-09 05:30:42 +03:00
|
|
|
case 2: /* ustat(dev_t, struct ustat *) */
|
1995-03-14 18:12:17 +03:00
|
|
|
{
|
1998-02-09 05:30:42 +03:00
|
|
|
struct ibcs2_ustat xu;
|
|
|
|
|
1998-03-05 07:36:07 +03:00
|
|
|
xu.f_tfree = 20000; /* XXX fixme */
|
1998-02-09 05:30:42 +03:00
|
|
|
xu.f_tinode = 32000;
|
|
|
|
xu.f_fname[0] = 0;
|
|
|
|
xu.f_fpack[0] = 0;
|
|
|
|
return copyout((caddr_t)&xu, (caddr_t)SCARG(uap, a2),
|
|
|
|
ibcs2_ustat_len);
|
1995-03-14 18:12:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return ENOSYS;
|
|
|
|
}
|
|
|
|
}
|