|
From: | Christian Franke |
Subject: | Re: [BUGFIX] Don't use DT_DIR: It doesn't work on non-ext* filesystems |
Date: | Fri, 24 Jul 2009 23:02:29 +0200 |
User-agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20090403 SeaMonkey/1.1.16 |
Pavel Roskin wrote:
On Thu, 2009-07-23 at 11:29 +0200, Vladimir 'phcoder' Serbinenko wrote:-#ifdef DT_DIR - info.dir = (de->d_type == DT_DIR); -#else info.dir = !! is_dir (path, de->d_name); -#endifFine with me. Finally a patch that reduces the number of preprocessor directives :-)
:-)Grub hostfs has no performance requirement like e.g. find. The optimization with d_type can simply be ignored - patch is OK.
The idea behind d_type is that it should only be set != DT_UNKNOWN if the type info is available for free or at low cost. It is safe for a filesystem implementation to return DT_UNKNOWN always.
A correct performance-aware solution would look like: #ifdef DT_DIR if (de->d_type == DT_DIR) info.dir = 1; else if (de->type == DT_FILE) info.dir = 0; else #endif info.dir = !! is_dir (path, de->d_name);This was actually wrong in my original patch (svn 1353) that was necessary because of missing d_type on Cygwin - Sorry! Meantime I added d_type support to Cygwin itself and therefore learned how this is supposed to work :-)
-- Regards, Christian Franke
[Prev in Thread] | Current Thread | [Next in Thread] |