enumerator: Fall back to lstat() if stat() fails when enumerating dirs/files
This happens e.g. if the path is for an invalid symlink.
This commit is contained in:
@@ -129,9 +129,10 @@ METHOD(enumerator_t, enumerate_dir_enum, bool,
|
|||||||
{
|
{
|
||||||
*absolute = this->full;
|
*absolute = this->full;
|
||||||
}
|
}
|
||||||
if (st)
|
if (st && stat(this->full, st))
|
||||||
{
|
{
|
||||||
if (stat(this->full, st))
|
/* try lstat() e.g. if a symlink is not valid anymore */
|
||||||
|
if ((errno != ENOENT && errno != ENOTDIR) || lstat(this->full, st))
|
||||||
{
|
{
|
||||||
DBG1(DBG_LIB, "stat() on '%s' failed: %s", this->full,
|
DBG1(DBG_LIB, "stat() on '%s' failed: %s", this->full,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
|||||||
@@ -222,6 +222,11 @@ static inline int setenv(const char *name, const char *value, int overwrite)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* stat(2) behaves like lstat(2) for symbolic links on Windows
|
||||||
|
*/
|
||||||
|
#define lstat stat
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lazy binding, ignored on Windows
|
* Lazy binding, ignored on Windows
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user