* fhandler.cc (fhandler_base::fpathconf): Fix _PC_NAME_MAX and

_PC_PATH_MAX cases.
This commit is contained in:
Corinna Vinschen 2008-02-16 09:43:19 +00:00
parent 9d342d561e
commit e2108ce092
2 changed files with 15 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2008-02-16 Corinna Vinschen <corinna@vinschen.de>
* fhandler.cc (fhandler_base::fpathconf): Fix _PC_NAME_MAX and
_PC_PATH_MAX cases.
2008-02-15 Corinna Vinschen <corinna@vinschen.de>
* include/sys/cygwin.h (__INT_MAX_PATH): Remove.

View File

@ -1541,6 +1541,8 @@ fhandler_base::fsync ()
int
fhandler_base::fpathconf (int v)
{
int ret;
switch (v)
{
case _PC_LINK_MAX:
@ -1558,10 +1560,16 @@ fhandler_base::fpathconf (int v)
break;
case _PC_NAME_MAX:
/* NAME_MAX is without trailing \0 */
return pc.isdir () ? PATH_MAX - strlen (get_name ()) - 2 : NAME_MAX;
if (!pc.isdir ())
return NAME_MAX;
ret = NT_MAX_PATH - strlen (get_name ()) - 2;
return ret < 0 ? 0 : ret > NAME_MAX ? NAME_MAX : ret;
case _PC_PATH_MAX:
/* PATH_MAX is with trailing \0 */
return pc.isdir () ? PATH_MAX - strlen (get_name ()) - 1 : PATH_MAX;
if (!pc.isdir ())
return PATH_MAX;
ret = NT_MAX_PATH - strlen (get_name ()) - 1;
return ret < 0 ? 0 : ret > PATH_MAX ? PATH_MAX : ret;
case _PC_PIPE_BUF:
if (pc.isdir ()
|| get_device () == FH_FIFO || get_device () == FH_PIPE