From 883413faf6e5797e703c7c81b481f621a51eba37 Mon Sep 17 00:00:00 2001 From: Francois Gouget Date: Mon, 30 May 2005 11:33:42 +0000 Subject: [PATCH] On some systems (linux 2.6.8) AFS fails to set d_reclen to 0 or does not support VFAT_IOCTL_READDIR_BOTH but returns 0 (success) anyway. So set d_reclen to 65535 (an impossible value) before the ioctl() and check it afterwards to work around this bug. --- dlls/ntdll/directory.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c index f3476573c3b..4405ef77b51 100644 --- a/dlls/ntdll/directory.c +++ b/dlls/ntdll/directory.c @@ -831,8 +831,11 @@ static int read_directory_vfat( int fd, IO_STATUS_BLOCK *io, void *buffer, ULONG { off_t old_pos = lseek( fd, 0, SEEK_CUR ); + /* Set d_reclen to 65535 to work around an AFS kernel bug */ + de[0].d_reclen = 65535; res = ioctl( fd, VFAT_IOCTL_READDIR_BOTH, (long)de ); if (res == -1 && errno != ENOENT) return -1; /* VFAT ioctl probably not supported */ + if (!res && de[0].d_reclen == 65535) return -1; /* AFS bug */ while (res != -1) { @@ -859,8 +862,11 @@ static int read_directory_vfat( int fd, IO_STATUS_BLOCK *io, void *buffer, ULONG } else /* we'll only return full entries, no need to worry about overflow */ { + /* Set d_reclen to 65535 to work around an AFS kernel bug */ + de[0].d_reclen = 65535; res = ioctl( fd, VFAT_IOCTL_READDIR_BOTH, (long)de ); if (res == -1 && errno != ENOENT) return -1; /* VFAT ioctl probably not supported */ + if (!res && de[0].d_reclen == 65535) return -1; /* AFS bug */ while (res != -1) { @@ -1161,7 +1167,10 @@ static NTSTATUS find_file_in_dir( char *unix_name, int pos, const WCHAR *name, i { KERNEL_DIRENT de[2]; - if (ioctl( fd, VFAT_IOCTL_READDIR_BOTH, (long)de ) != -1) + /* Set d_reclen to 65535 to work around an AFS kernel bug */ + de[0].d_reclen = 65535; + if (ioctl( fd, VFAT_IOCTL_READDIR_BOTH, (long)de ) != -1 && + de[0].d_reclen != 65535) { unix_name[pos - 1] = '/'; for (;;)