--- linux-2.6.x/fs/hostfs/hostfs_user.c 2006-04-12 15:12:52.000000000 +0800
+++ linux-2.6.10-src/fs/hostfs/hostfs_user.c 2006-08-14 18:36:24.276305632 +0800
@@ -122,7 +122,6 @@
DIR *dir = stream;
struct dirent *ent;
- seekdir(dir, *pos);
ent = readdir(dir);
if(ent == NULL) return(NULL);
*len_out = strlen(ent->d_name);
On Thursday 10 August 2006 17:42, wang lianwei wrote:
> Hi all,
> There is a bug with UML kernel, some host directory can not be read, for
> example "ls /mnt/host/usr/lib", this command is dead until you press
> CTRL+c. I test it with Redhat Enterprise Linux 4.
Yes, this has been reported various times but difficult to reproduce, so we're
very happy somebody diagnosed it, and I'd be interested in understanding it
On which filesystem (ext3, reiserfs, what else) lays /usr/lib on the host?
> This is because the UML read host directory through opendir, seekdir,
> readdir and telldir. When get the dir stream offset through telldir, it
> always return 0 on some directory, for example".",
Can you elaborate on this? (And if possible post some details, like a strace)
What I've understood is:
position 0 -> you read "." -> you call telldir -> it _again_ says you're at 0?
I can maybe understand why it could happen. I'd be more interested in checking
if a simple sequence of readdir() calls (without seekdir()) would work
(probably write a standalone test program, it will be easier to use and
debug) and why read_dir needs to do seekdir (I think it's done to handle
calls to seekdir by the underlying process, but there should be different
ways to do it).
> I don't know why? But
> we can fix it as follows although the next dir entry offset is not exact:
> Modify the fs/hostfs/hostfs_user.c file, update the read_dir function,
> char *read_dir(void *stream, unsigned long long *pos,
> unsigned long long *ino_out, int *len_out)
> DIR *dir = stream;
> struct dirent *ent;
> unsigned long long oldpos;
> oldpos = *pos;
> seekdir(dir, *pos);
> ent = readdir(dir);
> if(ent == NULL)
> *len_out = strlen(ent->d_name);
> *ino_out = ent->d_ino;
> *pos = telldir(dir);
> /* Fix the telldir return 0 error */
> if (*pos == 0)
> *pos = oldpos + *len_out;
> although the next offset is not exact, but the readdir can get the next
> entry correct.
This probably depends heavily on the underlying filesystem...
> Can anyone give a better solution?
I can't yet, but maybe with your help we'll be able.
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade
Chiacchiera con i tuoi amici in tempo reale!