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.
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".", 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;
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.
Can anyone give a better solution?