[vlc-devel] [PATCH] Fix the problem that 'Open Directory...' does not work on OS/2

KO Myung-Hun komh78 at gmail.com
Sat May 12 16:16:00 CEST 2012


fpathconf (_PC_NAME_MAX) set errno to EBADF. This leads vlc_loaddir() to
misinterpret the result of vlc_readdir() if there are no more files.
---
 src/posix/filesystem.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/posix/filesystem.c b/src/posix/filesystem.c
index 7d9e723..49d07fc 100644
--- a/src/posix/filesystem.c
+++ b/src/posix/filesystem.c
@@ -190,8 +190,8 @@ char *vlc_readdir( DIR *dir )
     struct dirent *ent;
     char *path = NULL;

+#if !defined(__OS2__) || !defined(__KLIBC__)
     long len = fpathconf (dirfd (dir), _PC_NAME_MAX);
-#if !defined(__OS2__) || !defined(__INNOTEK_LIBC__)
 #ifdef NAME_MAX
     /* POSIX says there shall we room for NAME_MAX bytes at all times */
     if (/*len == -1 ||*/ len < NAME_MAX)
@@ -202,12 +202,12 @@ char *vlc_readdir( DIR *dir )
         return NULL;
 #endif
     len += offsetof (struct dirent, d_name) + 1;
-#else /* __OS2__ && __INNOTEK_LIBC__ */
+#else /* __OS2__ && __KLIBC__ */
     /* In the implementation of Innotek LIBC, aka kLIBC on OS/2,
-     * fpathconf (_PC_NAME_MAX) is broken, and d_name is not the last member
-     * of struct dirent.
+     * fpathconf (_PC_NAME_MAX) is broken, and errno is set to EBADF.
+     * Moreover, d_name is not the last member of struct dirent.
      * So just allocate as many as the size of struct dirent. */
-    len = sizeof (struct dirent);
+    long len = sizeof (struct dirent);
 #endif

     struct dirent *buf = malloc (len);
--
1.7.3.2




More information about the vlc-devel mailing list