--- file_not_specified_in_diff +++ file_not_specified_in_diff @@ -, +, @@ --- lib/getcwd.c +++ lib/getcwd.c @@ -101,10 +101,17 @@ #endif #if D_INO_IN_DIRENT -# define MATCHING_INO(dp, ino) ((dp)->d_ino == (ino)) +/*# define MATCHING_INO(dp, ino) ((dp)->d_ino == (ino))*/ #else -# define MATCHING_INO(dp, ino) true +/*# define MATCHING_INO(dp, ino) true*/ #endif +/* Patch: Always ignore dirent.d_ino entries, even if they exist, + although this slows down the getcwd algorithm. + The reason is that for some filesystem (e.g. combination squashfs/unionfs) + this gives a different value than stat() and thus confuses the algorithm. +*/ +# define MATCHING_INO(dp, ino) true + #if !_LIBC # define __getcwd getcwd @@ -153,7 +160,12 @@ size_t allocated = size; size_t used; -#if HAVE_PARTLY_WORKING_GETCWD && !defined AT_FDCWD +/*#if HAVE_PARTLY_WORKING_GETCWD && !defined AT_FDCWD */ +/* Patch: The above is commented out, because the system's getcwd should + be preferred even if AT_FDCWD is defined, i.e. even if the following + algorithm would be fast: The system's getcwd does not rely so much + about D_INO_IN_DIRENT (see the above patch why this is bad). */ +#if HAVE_PARTLY_WORKING_GETCWD /* The system getcwd works, except it sometimes fails when it shouldn't, setting errno to ERANGE, ENAMETOOLONG, or ENOENT. If AT_FDCWD is not defined, the algorithm below is O(N**2) and this