Whamcloud - gitweb
LU-3319 procfs: move osp proc handling to seq_files
[fs/lustre-release.git] / libsysio / src / readdir.c
index af21c16..2633f96 100644 (file)
@@ -105,7 +105,12 @@ int
 _SCANDIR(const char *dirname, 
         _DIRENT_T ***namelist, 
         int (*filter) (const _DIRENT_T *), 
-        int (*cmp) (const void *, const void *))
+#ifdef HAVE_POSIX2008_SCANDIR
+        int(*compar)(const _DIRENT_T **, const  _DIRENT_T **)
+#else
+        int(*compar)(const void *, const void *)
+#endif
+       )
 {
        DIR *dir = NULL;
        _DIRENT_T *de     = NULL,
@@ -117,7 +122,7 @@ _SCANDIR(const char *dirname,
 
        SYSIO_INTERFACE_ENTER;
 
-       if ((dir = opendir(dirname)) == NULL)
+       if ((dir = SYSIO_INTERFACE_NAME(opendir)(dirname)) == NULL)
                SYSIO_INTERFACE_RETURN(-1, -errno);
 
        while ((de = _READDIR(dir)) != NULL) {
@@ -137,12 +142,15 @@ _SCANDIR(const char *dirname,
                        s[i++] = (_DIRENT_T *)memcpy(nextde, de, desize);
                }
        }
-       if (cmp)
-               qsort (s, i, sizeof (*s), cmp);
+       if (compar)
+               qsort (s,
+                      i,
+                      sizeof (*s),
+                      (int (*)(const void *, const void *))compar);
 
        *namelist = s;
 
-       closedir(dir);
+       SYSIO_INTERFACE_NAME(closedir)(dir);
 
        SYSIO_INTERFACE_RETURN(i, 0);
 }