unix_convert() and amount of stat() calls
jra at samba.org
Tue Sep 7 14:01:56 MDT 2010
On Tue, Sep 07, 2010 at 09:40:17PM +0200, Stefan (metze) Metzmacher wrote:
> Hi Jeremy,
> what's the reason that we loop over the components
> from the root to the leaf, when checking them?
> Can't we start with the last component?
> At least if it's related to a wildcard search.
> Maybe we only need to check the last 2 components,
> unless the name is mangled?
> The problem I want to solve in this branch:
> is this:
> FindFirst with 'path\to\some\dir\with\files\*'
> triggers the following stat calls
> path\to\some\dir\with\files\* => ENOENT (this should be already solved
> with my patches)
> path\to\some\dir\with\files\* => ENOENT
Oh good catch Metze ! Your patch fixes the
issue with the last component being a wildcard
causing a traversal.
As I recall it was designed like this as only
the first traversal will cause this number of
stat calls as every stat will enter the looked
up path into the stat cache. Every subsequent
lookup should immediately hit the stat cache
and shortcut them.
It's hard to get the error messages correct
when there's an invalid component in the path
if you don't process them from root to leaf.
More information about the samba-technical