libs/libc/dirent/lib_scandir.c: Do not build in PROTECTED or KERNEL mode builds. Add FAR to some pointers. Minor comment updates.
This commit is contained in:
parent
ded8711261
commit
534acb8281
@ -44,6 +44,13 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
/* The scandir() function is not appropriate for use within the kernel in its
|
||||||
|
* current form because it uses user space memory allocators and modifies
|
||||||
|
* the errno value.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __KERNEL__
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -61,10 +68,12 @@
|
|||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* path - Pathname of the directory to scan
|
* path - Pathname of the directory to scan
|
||||||
* namelist - An array of pointers to directory entries, which is allocated
|
* namelist - An array of pointers to directory entries, which is allocated
|
||||||
* by scandir via malloc. Each directory entry is allocated via malloc as
|
* by scandir via malloc. Each directory entry is allocated via
|
||||||
* well. The caller is responsible to free said objects.
|
* malloc as well. The caller is responsible to free said
|
||||||
|
objects.
|
||||||
* filter - Directory entries for which filter returns zero are not
|
* filter - Directory entries for which filter returns zero are not
|
||||||
* included in the namelist. If filter is NULL, all entries are included.
|
* included in the namelist. If filter is NULL, all entries are
|
||||||
|
* included.
|
||||||
* compar - Comparison function used with qsort() to sort the namelist.
|
* compar - Comparison function used with qsort() to sort the namelist.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
@ -79,14 +88,14 @@ int scandir(FAR const char *path, FAR struct dirent ***namelist,
|
|||||||
CODE int (*compar)(FAR const struct dirent **,
|
CODE int (*compar)(FAR const struct dirent **,
|
||||||
FAR const struct dirent **))
|
FAR const struct dirent **))
|
||||||
{
|
{
|
||||||
struct dirent *d;
|
FAR struct dirent *d;
|
||||||
struct dirent *dnew;
|
FAR struct dirent *dnew;
|
||||||
struct dirent **list = NULL;
|
FAR struct dirent **list = NULL;
|
||||||
size_t listsize = 0;
|
size_t listsize = 0;
|
||||||
size_t cnt = 0;
|
size_t cnt = 0;
|
||||||
int errsv;
|
int errsv;
|
||||||
int result;
|
int result;
|
||||||
DIR *dirp;
|
FAR DIR *dirp;
|
||||||
|
|
||||||
/* This scandir implementation relies on errno being set by other service
|
/* This scandir implementation relies on errno being set by other service
|
||||||
* functions that it is calling to figure if it was successful. We save
|
* functions that it is calling to figure if it was successful. We save
|
||||||
@ -230,3 +239,5 @@ int scandir(FAR const char *path, FAR struct dirent ***namelist,
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* __KERNEL__ */
|
||||||
|
@ -180,4 +180,4 @@ void lib_stream_release(FAR struct task_group_s *group)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_NFILE_STREAMS > 0 */
|
#endif /* CONFIG_NFILE_STREAMS > 0 */
|
||||||
#endif /* (!CONFIG_BUILD_PROTECTED &&7 !CONFIG_BUILD_KERNEL) || __KERNEL__ */
|
#endif /* (!CONFIG_BUILD_PROTECTED && !CONFIG_BUILD_KERNEL) || __KERNEL__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user