XFS and other filesystems that do not support d_type field in dirent
structure will get unexpected behavior when using eina_file_direct_ls()
- since it relies on d_type to determine file types.
Thus, an eina_file_statat() call is required in eina_file_direct_ls()
only if the file type had not been determined by using readdir_r().
I've just got such issue when using elementary_config to change current
profile - but it wasn't able to list the avaiable profiles since the
diretory entries in share/elementary/ were not recognized by
eina_file_direct_ls() function.
>From 5c19d6768567e31df2ef72aa450e377584d12c6b Mon Sep 17 00:00:00 2001
From: Paulo Alcantara <[email protected]>
Date: Fri, 1 Feb 2013 02:56:05 -0200
Subject: [PATCH] efl/eina: Fix directory listing in eina_file_direct_ls()
On XFS filesystems, for example, file types cannot be determined by using
readdir_r() function to list directory entries - since the d_type field
in dirent structure is not supported by XFS.
Thus, whether we got DT_UNKNOWN in d_type or dirent structure does not
have d_type (!_DIRENT_HAVE_D_TYPE), then we should try to get file type
with eina_file_statat() (which will work in a filesystem-independent
way) as the last try.
Signed-off-by: Paulo Alcantara <[email protected]>
---
src/lib/eina/eina_file.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/lib/eina/eina_file.c b/src/lib/eina/eina_file.c
index 98dff36..0116709 100644
--- a/src/lib/eina/eina_file.c
+++ b/src/lib/eina/eina_file.c
@@ -269,6 +269,7 @@ _eina_file_direct_ls_iterator_next(Eina_File_Direct_Iterator *it, void **data)
{
struct dirent *dp;
size_t length;
+ Eina_Stat st;
dp = alloca(_eina_dirent_buffer_size(it->dirp));
@@ -330,6 +331,11 @@ _eina_file_direct_ls_iterator_next(Eina_File_Direct_Iterator *it, void **data)
#else
it->info.type = EINA_FILE_UNKNOWN;
#endif
+ if (it->info.type == EINA_FILE_UNKNOWN)
+ {
+ if (eina_file_statat(it->dirp, &it->info, &st) != 0)
+ it->info.type = EINA_FILE_UNKNOWN;
+ }
*data = &it->info;
return EINA_TRUE;
--
1.7.10.4
--
Paulo Alcantara, ProFUSION Embedded Systems
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_jan
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel