Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Oct 1999 11:36:59 +0200
From:      Marcel Moolenaar <marcel@scc.nl>
To:        emulation@freebsd.org
Cc:        Mark Newton <newton@internode.com.au>
Subject:   Re: duplicate filenames under Linux emulation [FIX: please test]
Message-ID:  <380C3BBB.7BA26C30@scc.nl>
References:  <380A9278.638D7FC2@freenet.co.uk> <380B279E.D4786BEB@scc.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?380C3BBB.7BA26C30>