From owner-freebsd-emulation Sat Nov 27 4:35:40 1999 Delivered-To: freebsd-emulation@freebsd.org Received: from post.mail.nl.demon.net (post-11.mail.nl.demon.net [194.159.73.21]) by hub.freebsd.org (Postfix) with ESMTP id 1DE2E14CBA for ; Sat, 27 Nov 1999 04:35:35 -0800 (PST) (envelope-from marcel@scc.nl) Received: from [212.238.132.94] (helo=scones.sup.scc.nl) by post.mail.nl.demon.net with esmtp (Exim 2.12 #1) id 11rh4l-000MA3-00 for emulation@FreeBSD.org; Sat, 27 Nov 1999 12:35:39 +0000 Received: from scc.nl (scones.sup.scc.nl [192.168.2.4]) by scones.sup.scc.nl (8.9.3/8.9.3) with ESMTP id NAA59889 for ; Sat, 27 Nov 1999 13:35:31 +0100 (CET) (envelope-from marcel@scc.nl) Message-ID: <383FD013.703DD84D@scc.nl> Date: Sat, 27 Nov 1999 13:35:31 +0100 From: Marcel Moolenaar Organization: SCC vof X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.5 i386) X-Accept-Language: en MIME-Version: 1.0 To: emulation@FreeBSD.org Subject: PLEASE REVIEW: implementation of linux_ustat syscall Content-Type: multipart/mixed; boundary="------------29A391E6669B317013714B37" Sender: owner-freebsd-emulation@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org This is a multi-part message in MIME format. --------------29A391E6669B317013714B37 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, Please review the following implementation of the linux_ustat syscall. It will be committed shortly when noone objects. thanks, -- Marcel Moolenaar mailto:marcel@scc.nl SCC Internetworking & Databases http://www.scc.nl/ The FreeBSD project mailto:marcel@FreeBSD.org --------------29A391E6669B317013714B37 Content-Type: text/plain; charset=us-ascii; name="diff.out" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diff.out" Index: linux_stats.c =================================================================== RCS file: /home/ncvs/src/sys/i386/linux/linux_stats.c,v retrieving revision 1.16 diff -u -r1.16 linux_stats.c --- linux_stats.c 1999/11/08 03:33:21 1.16 +++ linux_stats.c 1999/11/27 12:25:59 @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -68,6 +69,14 @@ 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) { @@ -271,4 +280,57 @@ linux_statfs_buf.fnamelen = MAXNAMLEN; 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 + + /* Allow only root */ + error = suser(p); + if (error) + return (error); + + /* + * 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)) { + simple_lock(&mountlist_slock); + error = (vp->v_mount == NULL) ? EINVAL : 0; + if (!error) { + stat = &(vp->v_mount->mnt_stat); + error = VFS_STATFS(vp->v_mount, stat, p); + if (!error) { + lu.f_tfree = stat->f_bfree; + lu.f_tinode = stat->f_ffree; + } + } + simple_unlock(&mountlist_slock); + if (error) + return (error); + } + + return (copyout(&lu, uap->ubuf, sizeof(lu))); } --------------29A391E6669B317013714B37-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-emulation" in the body of the message