From owner-freebsd-emulation Tue Oct 19 2:37:18 1999 Delivered-To: freebsd-emulation@freebsd.org Received: from post.mail.nl.demon.net (post-10.mail.nl.demon.net [194.159.73.20]) by hub.freebsd.org (Postfix) with ESMTP id 1EEC31649E for ; Tue, 19 Oct 1999 02:37:12 -0700 (PDT) (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.02 #1) id 11dVha-0006sK-00; Tue, 19 Oct 1999 09:37:06 +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 LAA80541; Tue, 19 Oct 1999 11:36:59 +0200 (CEST) (envelope-from marcel@scc.nl) Message-ID: <380C3BBB.7BA26C30@scc.nl> Date: Tue, 19 Oct 1999 11:36:59 +0200 From: Marcel Moolenaar Organization: SCC vof X-Mailer: Mozilla 4.61 [en] (X11; I; Linux 2.2.5 i386) X-Accept-Language: en MIME-Version: 1.0 To: emulation@freebsd.org Cc: Mark Newton Subject: Re: duplicate filenames under Linux emulation [FIX: please test] References: <380A9278.638D7FC2@freenet.co.uk> <380B279E.D4786BEB@scc.nl> Content-Type: multipart/mixed; boundary="------------6B4845DA128D933D209112D6" Sender: owner-freebsd-emulation@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org This is a multi-part message in MIME format. --------------6B4845DA128D933D209112D6 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Marcel Moolenaar wrote: > > Mark Newton wrote: > > > > Alex wrote: > > > > > 444964 -rw-r--r-- 1 ak users 102042 Oct 17 20:23 > > > bxutils-c.c > > > 444964 -rw-r--r-- 1 ak users 102042 Oct 17 20:23 > > > bxutils-c.c > > > > For what it's worth, I have this bug in the to-do list for the > > SVR4 emulator too. > > The Linuxulator doesn't have that problem. Linux binaries suffer from > the duplicate name because glibc (libc5 too?) explicitly calls lseek on > the fd of the open directory: A more simple fix than the one attached is probably not possible, but before I commit this, I want to be somewhat sure I don't break anything. Please apply the patch (it also works for -stable [offset -3 lines]) and tell me if it solves the problem (it does for me :-) and if it doesn't break anything else. Without negative feedback, this patch is going to be committed in a couple of days. \begin{background} The dirent used in the Linux kernel is different from the dirent used by glibc2 (libc5?). To handle this, glibc2 (libc5?) uses a heuristic to determine how many kernel-dirents to read in order to fill the buffer, supplied by the application, with glibc-dirents. It is possible for glibc2 to read more kernel-dirents than it can pass on the the application. In that case, the surplus kernel-dirents are ignored and the file pointer set to the value of the offset field in the last dirent written to the application buffer. If offset is what it means, you get that dirent on a second call again. The patch changes the value of offset to be the offset of the *next* dirent. Et voila! \end{background} -- Marcel Moolenaar mailto:marcel@scc.nl SCC Internetworking & Databases http://www.scc.nl/ The FreeBSD project mailto:marcel@FreeBSD.org --------------6B4845DA128D933D209112D6 Content-Type: text/plain; charset=us-ascii; name="getdents.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="getdents.diff" Index: linux_file.c =================================================================== RCS file: /home/ncvs/src/sys/i386/linux/linux_file.c,v retrieving revision 1.35 diff -u -r1.35 linux_file.c --- linux_file.c 1999/09/25 16:21:24 1.35 +++ linux_file.c 1999/10/19 09:11:07 @@ -540,7 +540,7 @@ linux_dirent.doff = (linux_off_t) linuxreclen; linux_dirent.dreclen = (u_short) bdp->d_namlen; } else { - linux_dirent.doff = (linux_off_t) off; + linux_dirent.doff = (linux_off_t)(off + reclen); linux_dirent.dreclen = (u_short) linuxreclen; } strcpy(linux_dirent.dname, bdp->d_name); --------------6B4845DA128D933D209112D6-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-emulation" in the body of the message