Ticket #3987: implement a workaround if readdir() system call returns with EINTR.

On Linux >= 5.1, MC sometimes shows empty directpries on mounted CIFS
shares. Rereading directory restores the directory content.

(local_opendir): reopen directory, if first readdir() returns NULL and
errno == EINTR.

Signed-off-by: Andrij Abyzov <aabyzov@slb.com>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrij Abyzov 2020-11-24 18:58:06 +01:00 committed by Andrew Borodin
parent 446a031350
commit 27de03754f
1 changed files with 21 additions and 4 deletions

View File

@ -87,13 +87,30 @@ static void *
local_opendir (const vfs_path_t * vpath)
{
DIR **local_info;
DIR *dir;
DIR *dir = NULL;
const vfs_path_element_t *path_element;
path_element = vfs_path_get_by_index (vpath, -1);
dir = opendir (path_element->path);
if (dir == NULL)
return 0;
/* On Linux >= 5.1, MC sometimes shows empty directpries on mounted CIFS shares.
* Rereading directory restores the directory content.
*
* Reopen directory, if first readdir() returns NULL and errno == EINTR.
*/
while (dir == NULL)
{
dir = opendir (path_element->path);
if (dir == NULL)
return NULL;
if (readdir (dir) == NULL && errno == EINTR)
{
closedir (dir);
dir = NULL;
}
else
rewinddir (dir);
}
local_info = (DIR **) g_new (DIR *, 1);
*local_info = dir;