readdir is incorrectly implemented at Windows

Поиск
Список
Период
Сортировка
От Konstantin Knizhnik
Тема readdir is incorrectly implemented at Windows
Дата
Msg-id 2cad7829-8d66-e39c-b937-ac825db5203d@postgrespro.ru
обсуждение исходный текст
Ответы Re: readdir is incorrectly implemented at Windows  (Grigory Smolkin <g.smolkin@postgrespro.ru>)
Re: readdir is incorrectly implemented at Windows  (Michael Paquier <michael@paquier.xyz>)
Re: readdir is incorrectly implemented at Windows  (Andrew Dunstan <andrew.dunstan@2ndquadrant.com>)
Список pgsql-hackers
Hi hackers,

Small issue with readir implementation for Windows.
Right now it returns ENOENT in case of any error returned by FindFirstFile.
So all places in Postgres where opendir/listdir are used will assume 
that directory is empty and
do nothing without reporting any error.
It is not so good if directory is actually not empty but there are not 
enough permissions for accessing the directory and FindFirstFile
returns ERROR_ACCESS_DENIED:

struct dirent *
readdir(DIR *d)
{
     WIN32_FIND_DATA fd;

     if (d->handle == INVALID_HANDLE_VALUE)
     {
         d->handle = FindFirstFile(d->dirname, &fd);
         if (d->handle == INVALID_HANDLE_VALUE)
         {
             errno = ENOENT;
             return NULL;
         }
     }


Attached please find small patch fixing the problem.

-- 
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company


Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Stephen Frost
Дата:
Сообщение: Re: Remove Deprecated Exclusive Backup Mode
Следующее
От: Laurenz Albe
Дата:
Сообщение: Re: Should we increase the default vacuum_cost_limit?