* lib/canonicalize.c (canonicalize_filename_mode):
Avoid calling l?stat() when both CAN_MISSING,
and CAN_NOLINKS are set, as then we neither need
to resolve symlinks or test component existence.
+2011-12-31 Pádraig Brady <P@draigBrady.com>
+
+ canonicalize: only stat() if required
+ * lib/canonicalize.c (canonicalize_filename_mode):
+ Avoid calling l?stat() when both CAN_MISSING,
+ and CAN_NOLINKS are set, as we neither need
+ to resolve symlinks or test component existence.
+
2011-12-31 Paul Eggert <eggert@cs.ucla.edu>
doc: cover st_ino issues once; add OpenVMS etc.
dest += end - start;
*dest = '\0';
- if ((logical ? stat (rname, &st) : lstat (rname, &st)) != 0)
+ if (logical && (can_mode == CAN_MISSING))
+ {
+ /* Avoid the stat in this case as it's inconsequential.
+ i.e. we're neither resolving symlinks or testing
+ component existence. */
+ st.st_mode = 0;
+ }
+ else if ((logical ? stat (rname, &st) : lstat (rname, &st)) != 0)
{
saved_errno = errno;
if (can_mode == CAN_EXISTING)