diff options
author | marcel <marcel@FreeBSD.org> | 1999-11-27 16:55:14 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 1999-11-27 16:55:14 +0000 |
commit | 8d58d1e492460f5a77506779c5e20510785a09c3 (patch) | |
tree | e0be730b0efe0ec68ceddee9befd20233f041230 /sys | |
parent | 2a61f0e7a878e59f7e6c76beb5d3def98cc00ae8 (diff) | |
download | FreeBSD-src-8d58d1e492460f5a77506779c5e20510785a09c3.zip FreeBSD-src-8d58d1e492460f5a77506779c5e20510785a09c3.tar.gz |
Implement linux_ustat.
Reviewed by: bde
Diffstat (limited to 'sys')
-rw-r--r-- | sys/alpha/linux/linux_dummy.c | 1 | ||||
-rw-r--r-- | sys/compat/linux/linux_stats.c | 59 | ||||
-rw-r--r-- | sys/i386/linux/linux_dummy.c | 1 | ||||
-rw-r--r-- | sys/i386/linux/linux_proto.h | 5 | ||||
-rw-r--r-- | sys/i386/linux/linux_stats.c | 59 | ||||
-rw-r--r-- | sys/i386/linux/linux_syscall.h | 2 | ||||
-rw-r--r-- | sys/i386/linux/linux_sysent.c | 4 |
7 files changed, 118 insertions, 13 deletions
diff --git a/sys/alpha/linux/linux_dummy.c b/sys/alpha/linux/linux_dummy.c index ce5586b..518e781 100644 --- a/sys/alpha/linux/linux_dummy.c +++ b/sys/alpha/linux/linux_dummy.c @@ -68,7 +68,6 @@ DUMMY(lock); DUMMY(mpx); DUMMY(ulimit); DUMMY(olduname); -DUMMY(ustat); DUMMY(ksyslog); DUMMY(uname); DUMMY(vhangup); diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c index 6f42ba0..d48abc5 100644 --- a/sys/compat/linux/linux_stats.c +++ b/sys/compat/linux/linux_stats.c @@ -29,17 +29,18 @@ */ #include <sys/param.h> -#include <sys/systm.h> +#include <sys/conf.h> #include <sys/dirent.h> #include <sys/file.h> #include <sys/filedesc.h> +#include <sys/socketvar.h> +#include <sys/pipe.h> #include <sys/proc.h> #include <sys/mount.h> #include <sys/namei.h> -#include <sys/socketvar.h> #include <sys/stat.h> +#include <sys/systm.h> #include <sys/vnode.h> -#include <sys/pipe.h> #include <i386/linux/linux.h> #include <i386/linux/linux_proto.h> @@ -68,6 +69,14 @@ struct linux_newstat { u_long __unused5; }; +struct linux_ustat +{ + int f_tfree; + u_long f_tinode; + char f_fname[6]; + char f_fpack[6]; +}; + static int newstat_copyout(struct stat *buf, void *ubuf) { @@ -272,3 +281,47 @@ linux_fstatfs(struct proc *p, struct linux_fstatfs_args *args) return copyout((caddr_t)&linux_statfs_buf, (caddr_t)args->buf, sizeof(struct linux_statfs_buf)); } + +int +linux_ustat(p, uap) + struct proc *p; + struct linux_ustat_args *uap; +{ + struct linux_ustat lu; + dev_t dev; + struct vnode *vp; + struct statfs *stat; + int error; + +#ifdef DEBUG + printf("Linux-emul(%ld): ustat(%d, *)\n", (long)p->p_pid, uap->dev); +#endif + + /* + * lu.f_fname and lu.f_fpack are not used. They are always zeroed. + * lu.f_tinode and lu.f_tfree are set from the device's super block. + */ + bzero(&lu, sizeof(lu)); + + /* + * XXX - Don't return an error if we can't find a vnode for the + * device. Our dev_t is 32-bits whereas Linux only has a 16-bits + * dev_t. The dev_t that is used now may as well be a truncated + * dev_t returned from previous syscalls. Just return a bzeroed + * ustat in that case. + */ + dev = makebdev(uap->dev >> 8, uap->dev & 0xFF); + if (vfinddev(dev, VBLK, &vp)) { + if (vp->v_mount == NULL) + return (EINVAL); + stat = &(vp->v_mount->mnt_stat); + error = VFS_STATFS(vp->v_mount, stat, p); + if (error) + return (error); + + lu.f_tfree = stat->f_bfree; + lu.f_tinode = stat->f_ffree; + } + + return (copyout(&lu, uap->ubuf, sizeof(lu))); +} diff --git a/sys/i386/linux/linux_dummy.c b/sys/i386/linux/linux_dummy.c index ce5586b..518e781 100644 --- a/sys/i386/linux/linux_dummy.c +++ b/sys/i386/linux/linux_dummy.c @@ -68,7 +68,6 @@ DUMMY(lock); DUMMY(mpx); DUMMY(ulimit); DUMMY(olduname); -DUMMY(ustat); DUMMY(ksyslog); DUMMY(uname); DUMMY(vhangup); diff --git a/sys/i386/linux/linux_proto.h b/sys/i386/linux/linux_proto.h index e0bfa3d..0b2f86c 100644 --- a/sys/i386/linux/linux_proto.h +++ b/sys/i386/linux/linux_proto.h @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.26 1999/09/29 15:12:14 marcel Exp + * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.27 1999/11/27 16:50:54 marcel Exp */ #ifndef _LINUX_SYSPROTO_H_ @@ -179,7 +179,8 @@ struct linux_olduname_args { register_t dummy; }; struct linux_ustat_args { - register_t dummy; + linux_dev_t dev; char dev_[PAD_(linux_dev_t)]; + struct linux_ustat * ubuf; char ubuf_[PAD_(struct linux_ustat *)]; }; struct linux_sigaction_args { int sig; char sig_[PAD_(int)]; diff --git a/sys/i386/linux/linux_stats.c b/sys/i386/linux/linux_stats.c index 6f42ba0..d48abc5 100644 --- a/sys/i386/linux/linux_stats.c +++ b/sys/i386/linux/linux_stats.c @@ -29,17 +29,18 @@ */ #include <sys/param.h> -#include <sys/systm.h> +#include <sys/conf.h> #include <sys/dirent.h> #include <sys/file.h> #include <sys/filedesc.h> +#include <sys/socketvar.h> +#include <sys/pipe.h> #include <sys/proc.h> #include <sys/mount.h> #include <sys/namei.h> -#include <sys/socketvar.h> #include <sys/stat.h> +#include <sys/systm.h> #include <sys/vnode.h> -#include <sys/pipe.h> #include <i386/linux/linux.h> #include <i386/linux/linux_proto.h> @@ -68,6 +69,14 @@ struct linux_newstat { u_long __unused5; }; +struct linux_ustat +{ + int f_tfree; + u_long f_tinode; + char f_fname[6]; + char f_fpack[6]; +}; + static int newstat_copyout(struct stat *buf, void *ubuf) { @@ -272,3 +281,47 @@ linux_fstatfs(struct proc *p, struct linux_fstatfs_args *args) return copyout((caddr_t)&linux_statfs_buf, (caddr_t)args->buf, sizeof(struct linux_statfs_buf)); } + +int +linux_ustat(p, uap) + struct proc *p; + struct linux_ustat_args *uap; +{ + struct linux_ustat lu; + dev_t dev; + struct vnode *vp; + struct statfs *stat; + int error; + +#ifdef DEBUG + printf("Linux-emul(%ld): ustat(%d, *)\n", (long)p->p_pid, uap->dev); +#endif + + /* + * lu.f_fname and lu.f_fpack are not used. They are always zeroed. + * lu.f_tinode and lu.f_tfree are set from the device's super block. + */ + bzero(&lu, sizeof(lu)); + + /* + * XXX - Don't return an error if we can't find a vnode for the + * device. Our dev_t is 32-bits whereas Linux only has a 16-bits + * dev_t. The dev_t that is used now may as well be a truncated + * dev_t returned from previous syscalls. Just return a bzeroed + * ustat in that case. + */ + dev = makebdev(uap->dev >> 8, uap->dev & 0xFF); + if (vfinddev(dev, VBLK, &vp)) { + if (vp->v_mount == NULL) + return (EINVAL); + stat = &(vp->v_mount->mnt_stat); + error = VFS_STATFS(vp->v_mount, stat, p); + if (error) + return (error); + + lu.f_tfree = stat->f_bfree; + lu.f_tinode = stat->f_ffree; + } + + return (copyout(&lu, uap->ubuf, sizeof(lu))); +} diff --git a/sys/i386/linux/linux_syscall.h b/sys/i386/linux/linux_syscall.h index 437aa9e..4db0368 100644 --- a/sys/i386/linux/linux_syscall.h +++ b/sys/i386/linux/linux_syscall.h @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.26 1999/09/29 15:12:14 marcel Exp + * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.27 1999/11/27 16:50:54 marcel Exp */ #define LINUX_SYS_linux_setup 0 diff --git a/sys/i386/linux/linux_sysent.c b/sys/i386/linux/linux_sysent.c index 1c00aad..fe014ac 100644 --- a/sys/i386/linux/linux_sysent.c +++ b/sys/i386/linux/linux_sysent.c @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.26 1999/09/29 15:12:14 marcel Exp + * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.27 1999/11/27 16:50:54 marcel Exp */ #include "opt_compat.h" @@ -77,7 +77,7 @@ struct sysent linux_sysent[] = { { 0, (sy_call_t *)linux_olduname }, /* 59 = linux_olduname */ { 1, (sy_call_t *)umask }, /* 60 = umask */ { 1, (sy_call_t *)chroot }, /* 61 = chroot */ - { 0, (sy_call_t *)linux_ustat }, /* 62 = linux_ustat */ + { 2, (sy_call_t *)linux_ustat }, /* 62 = linux_ustat */ { 2, (sy_call_t *)dup2 }, /* 63 = dup2 */ { 0, (sy_call_t *)getppid }, /* 64 = getppid */ { 0, (sy_call_t *)getpgrp }, /* 65 = getpgrp */ |