From owner-freebsd-emulation@FreeBSD.ORG Mon May 15 23:28:13 2006 Return-Path: X-Original-To: freebsd-emulation@freebsd.org Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E4C0916A4A7 for ; Mon, 15 May 2006 23:28:13 +0000 (UTC) (envelope-from bakul@bitblocks.com) Received: from mail.bitblocks.com (bitblocks.com [209.204.185.216]) by mx1.FreeBSD.org (Postfix) with ESMTP id A2F4743D46 for ; Mon, 15 May 2006 23:28:13 +0000 (GMT) (envelope-from bakul@bitblocks.com) Received: from bitblocks.com (localhost [127.0.0.1]) by mail.bitblocks.com (Postfix) with ESMTP id F1715294B9; Mon, 15 May 2006 16:28:12 -0700 (PDT) To: Alexander Leidinger In-reply-to: Your message of "Mon, 15 May 2006 21:46:38 +0200." <20060515214638.04ade411@Magellan.Leidinger.net> Date: Mon, 15 May 2006 16:28:12 -0700 From: Bakul Shah Message-Id: <20060515232812.F1715294B9@mail.bitblocks.com> Cc: freebsd-emulation@freebsd.org Subject: Re: linux emulation file descriptor leakage -current? 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: Mon, 15 May 2006 23:28:14 -0000 > > Ok, I'll file a PR. I did file a PR via send-pr but I don't see any email back. Looks like it disappeared into thin air -- will file again. Turns out the problem is not limited to skype or thunderbird. I discovered that linux-firefox ate over 8800 descriptors and linux-opera died a suspicious death (on exit it fails to write the state of open windows if it can't get a file descriptor and on restart it loses all the open windows) and I had to dig some more. The following code from linux_stats.c looked dodgy to me so I reverted /sys/{i386/linux,compat/{linux,linprocfs}} to about one month old state and the problem disappears. skype still opens about 296 files but no more. -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) - 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); - } - } - } - } - fdrop(fp, td); -} - -static void -translate_path_major_minor(struct thread *td, char *path, struct stat *buf) -{ - struct file *fp; - int fd; - int temp; - - temp = td->td_retval[0]; - if (kern_open(td, path, UIO_SYSSPACE, O_RDONLY, 0) != 0) - return; - fd = td->td_retval[0]; - td->td_retval[0] = temp; - translate_fd_major_minor(td, fd, buf); - fget(td, fd, &fp); - closef(fp, td); -}