From owner-freebsd-emulation@FreeBSD.ORG Tue Jun 3 19:21:23 2008 Return-Path: Delivered-To: emulation@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D0DB41065679 for ; Tue, 3 Jun 2008 19:21:23 +0000 (UTC) (envelope-from jhein@timing.com) Received: from Daffy.timing.com (mail.timing.com [206.168.13.218]) by mx1.freebsd.org (Postfix) with ESMTP id 8F70A8FC14 for ; Tue, 3 Jun 2008 19:21:23 +0000 (UTC) (envelope-from jhein@timing.com) Received: from gromit.timing.com (gromit.timing.com [206.168.13.209]) by Daffy.timing.com (8.13.1/8.13.1) with ESMTP id m53JLMTU045013; Tue, 3 Jun 2008 13:21:22 -0600 (MDT) (envelope-from jhein@timing.com) Received: from gromit.timing.com (localhost [127.0.0.1]) by gromit.timing.com (8.14.2/8.14.2) with ESMTP id m53JLLTF066124; Tue, 3 Jun 2008 13:21:21 -0600 (MDT) (envelope-from jhein@gromit.timing.com) Received: (from jhein@localhost) by gromit.timing.com (8.14.2/8.14.2/Submit) id m53JLLIm066121; Tue, 3 Jun 2008 13:21:21 -0600 (MDT) (envelope-from jhein) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18501.39345.276357.941733@gromit.timing.com> Date: Tue, 3 Jun 2008 13:21:21 -0600 From: John E Hein To: emulation@freebsd.org X-Mailer: VM 7.19 under Emacs 22.1.1 X-Virus-Scanned: ClamAV version 0.91.2, clamav-milter version 0.91.2 on Daffy.timing.com X-Virus-Status: Clean Cc: Subject: mfc linux_stats.c:1.86 to releng_6 - fifoor fix X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jun 2008 19:21:23 -0000 Can someone MFC to 6.x Junk-uk Kim's fix for the linux block-on-a-fifo problem (rev 1.86 of linux_stats.c)? I've been running with it for nearly two years now without a problem. It's already in RELENG_7. I prepared a patch against RELENG_6 to make it easier... Index: sys/compat/linux/linux_stats.c =================================================================== RCS file: /base/FreeBSD-CVS/src/sys/compat/linux/linux_stats.c,v retrieving revision 1.72.2.8 diff -u -p -r1.72.2.8 linux_stats.c --- sys/compat/linux/linux_stats.c 9 Jan 2008 16:07:32 -0000 1.72.2.8 +++ sys/compat/linux/linux_stats.c 3 Jun 2008 15:57:55 -0000 @@ -99,23 +99,16 @@ static void translate_fd_major_minor(struct thread *td, int fd, struct stat *buf) { struct file *fp; - int error; int major, minor; - if ((error = fget(td, fd, &fp)) != 0) + if ((!S_ISCHR(buf->st_mode) && !S_ISBLK(buf->st_mode)) || + fget(td, fd, &fp) != 0) return; - if (fp->f_vnode) { - if (fp->f_vnode->v_type == VCHR - || fp->f_vnode->v_type == VBLK) { - if (fp->f_vnode->v_un.vu_cdev) { - if (linux_driver_get_major_minor( - fp->f_vnode->v_un.vu_cdev->si_name, - &major, &minor) == 0) { - buf->st_rdev = (major << 8 | minor); - } - } - } - } + if (fp->f_vnode != NULL && + fp->f_vnode->v_un.vu_cdev != NULL && + linux_driver_get_major_minor(fp->f_vnode->v_un.vu_cdev->si_name, + &major, &minor) == 0) + buf->st_rdev = (major << 8 | minor); fdrop(fp, td); } @@ -128,6 +121,8 @@ translate_path_major_minor(struct thread int fd; int temp; + if (!S_ISCHR(buf->st_mode) && !S_ISBLK(buf->st_mode)) + return; temp = td->td_retval[0]; if (kern_open(td, path, UIO_SYSSPACE, O_RDONLY, 0) != 0) return; @@ -178,18 +173,19 @@ linux_newstat(struct thread *td, struct #endif error = kern_stat(td, path, UIO_SYSSPACE, &buf); - if (!error && strlen(path) > strlen("/dev/pts/") && - !strncmp(path, "/dev/pts/", strlen("/dev/pts/")) - && path[9] >= '0' && path[9] <= '9') { - /* - * Linux checks major and minors of the slave device to make - * sure it's a pty device, so let's make him believe it is. - */ - buf.st_rdev = (136 << 8); - } - - translate_path_major_minor(td, path, &buf); - + if (!error) { + if (strlen(path) > strlen("/dev/pts/") && + !strncmp(path, "/dev/pts/", strlen("/dev/pts/")) && + path[9] >= '0' && path[9] <= '9') { + /* + * Linux checks major and minors of the slave device + * to make sure it's a pty device, so let's make him + * believe it is. + */ + buf.st_rdev = (136 << 8); + } else + translate_path_major_minor(td, path, &buf); + } LFREEPATH(path); if (error) return (error);