exceeding PATH_MAX
Eric Blake
ebb9@byu.net
Mon Mar 28 16:21:00 GMT 2005
Christopher Faylor <cgf-no-personal-reply-please <at> cygwin.com> writes:
> >2005-03-26 Eric Blake <ebb9 <at> byu.net>
> >
> > * errno.cc (FILENAME_EXCED_RANGE): Map to ENAMETOOLONG.
>
> This is apparently fixing the symptom rather than the problem. Cygwin
> is supposed to be detecting if the name is too long before it gets to
> the windows api.
Well, cygwin did not detect it, as proved by this portion of the strace from
the test program I attached:
66 1661823 [main] getcwd 6048 cwdstuff::get: (C:\cygwin\tmp\getcwd.test\confd
ir3\confdir3\confdir3\confdir3\confdir3\confdir3\confdir3\confdir3\confdir3\conf
dir3\confdir3\confdir3\confdir3\confdir3\confdir3\confdir3\confdir3\confdir3\con
fdir3\confdir3\confdir3\confdir3\confdir3\confdir3) = cwdstuff::get (0x22E280, 2
60, 0, 0), errno 0
129 1661952 [main] getcwd 6048 alloc_sd: uid 22382, gid 10513, attribute 41C0
69 1662021 [main] getcwd 6048 cygpsid::debug_print: alloc_sd: owner SID = S-1
-5-21-2062245864-1860583678-1057817870-12382
64 1662085 [main] getcwd 6048 cygpsid::debug_print: alloc_sd: group SID = S-1
-5-21-2062245864-1860583678-1057817870-513
67 1662152 [main] getcwd 6048 alloc_sd: ACL-Size: 160
172 1662324 [main] getcwd 6048 alloc_sd: Created SD-Size: 236
111 1662435 [main] getcwd 6048 seterrno_from_win_error: /netrel/src/cygwin-1.5
.13-1/winsup/cygwin/dir.cc:262 windows error 206
75 1662510 [main] getcwd 6048 geterrno_from_win_error: windows error 206 == e
rrno 22
61 1662571 [main] getcwd 6048 geterrno_from_win_error: windows error 206 == e
rrno 22
61 1662632 [main] getcwd 6048 mkdir: -1 = mkdir (confdir3, 448)
It looks like the failure comes when the current working directory has length
241, and the program requests a mkdir of an 8 character relative path. mkdir
defers to Windows CreateDirectory, which notices that the new directory would
have length 250; CreateDirectory is documented with a maximum of 248 (MAX_PATH
minus an 8.3 filename), so it returns an error. From there, cygwin is mapping
the windows error into EINVAL even though POSIX specifies ENAMETOOLONG.
I don't see any reason why this mapping should not be applied, even if you also
patch mkdir to error out early rather than calling CreateDirectory.
More information about the Cygwin-patches
mailing list