X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f X-Recipient: djgpp-workers AT delorie DOT com X-Authenticated: #27081556 X-Provags-ID: V01U2FsdGVkX1+AHaR0NY6AUWqKuvCHLKxCeIpQA0U465Gw3VaJD7 FnqEXojpZtTmME Message-ID: <000e01c91827$34a54f90$2202a8c0@computername> From: "Juan Manuel Guerrero" To: Subject: realpath/_fixpath and _use_lfn generated errno Date: Tue, 16 Sep 2008 20:08:21 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Y-GMX-Trusted: 0 X-FuHaFi: 0.55 Reply-To: djgpp-workers AT delorie DOT com While I was trying to fix the port of Which I have noticed that realpath and _fixpath set errno to ENOSYS if the OS used does not provide the LFN API. This happens because both functions use __canonicalize_path that calls _use_lfn to check if the OS provides a LFN API. If the OS does not, then _use_lfn returns zero and sets errno to ENOSYS (happens in _get_volume_info). But __canonicalize_path does not evalute errno at all and only uses the return value of _use_lfn to decide if function 0x7147 or 0x47 will be used to get the current directory. If the canonicalization of the path can be successfully performed, realpath and _fixpath do not set errno and the value of errno continues to be the one given by _use_lfn, that is errno = ENOSYS and that value is returned to the calling function. I assume that this is not intentional, so I suggest the patch below. Regards, Juan M. Guerrero 2008-09-16 Juan Manuell Guerrero * src/libc/posix/sys/stat/fixpath.c: Discard ENOSYS from the _use_lfn call. diff -aprNU3 djgpp.orig/src/libc/posix/sys/stat/fixpath.c djgpp/src/libc/posix/sys/stat/fixpath.c --- djgpp.orig/src/libc/posix/sys/stat/fixpath.c 2002-09-25 23:45:20 +0000 +++ djgpp/src/libc/posix/sys/stat/fixpath.c 2008-09-16 19:11:24 +0000 @@ -140,8 +140,11 @@ __canonicalize_path(const char *in, char char *name_start; int mbsize; char *op_limit; + int previous_errno; + previous_errno = errno; use_lfn = _use_lfn(in); + errno = previous_errno; /* Do not signal that LFN API is not available (ENOSYS). */ if (path_max > FILENAME_MAX) path_max = FILENAME_MAX;