diff -ru cygwin-1.7.7-1/winsup/cygwin/environ.cc cygwin-1.7.7-1_bjk/winsup/cygwin/environ.cc --- cygwin-1.7.7-1/winsup/cygwin/environ.cc 2010-08-16 14:55:07.000000000 +0100 +++ cygwin-1.7.7-1_bjk/winsup/cygwin/environ.cc 2011-01-17 02:20:15.136331600 +0000 @@ -32,6 +32,7 @@ #include "ntdll.h" extern bool dos_file_warning; +extern bool recognize_junctions; extern bool ignore_case_with_glob; extern bool allow_winsymlinks; bool reset_com = false; @@ -598,6 +599,7 @@ {"export", {&export_settings}, justset, NULL, {{false}, {true}}}, {"forkchunk", {func: set_chunksize}, isfunc, NULL, {{0}, {0}}}, {"glob", {func: &glob_init}, isfunc, NULL, {{0}, {s: "normal"}}}, + {"junctionlinks", {&recognize_junctions}, justset, NULL, {{false}, {true}}}, {"proc_retry", {func: set_proc_retry}, isfunc, NULL, {{0}, {5}}}, {"reset_com", {&reset_com}, justset, NULL, {{false}, {true}}}, {"strip_title", {&strip_title_path}, justset, NULL, {{false}, {true}}}, diff -ru cygwin-1.7.7-1/winsup/cygwin/fhandler_disk_file.cc cygwin-1.7.7-1_bjk/winsup/cygwin/fhandler_disk_file.cc --- cygwin-1.7.7-1/winsup/cygwin/fhandler_disk_file.cc 2010-08-23 17:20:43.000000000 +0100 +++ cygwin-1.7.7-1_bjk/winsup/cygwin/fhandler_disk_file.cc 2011-01-17 02:22:09.878894500 +0000 @@ -30,6 +30,8 @@ #define _COMPILING_NEWLIB #include +extern bool recognize_junctions; + class __DIR_mounts { int count; @@ -161,6 +163,9 @@ HANDLE reph; UNICODE_STRING subst; + if (!recognize_junctions) + return DT_DIR; + if (NT_SUCCESS (NtOpenFile (&reph, READ_CONTROL, attr, &io, FILE_SHARE_VALID_FLAGS, FILE_OPEN_FOR_BACKUP_INTENT diff -ru cygwin-1.7.7-1/winsup/cygwin/path.cc cygwin-1.7.7-1_bjk/winsup/cygwin/path.cc --- cygwin-1.7.7-1/winsup/cygwin/path.cc 2010-08-30 16:08:18.000000000 +0100 +++ cygwin-1.7.7-1_bjk/winsup/cygwin/path.cc 2011-01-17 02:21:34.542873400 +0000 @@ -74,6 +74,7 @@ #include bool dos_file_warning = true; +bool recognize_junctions = true; suffix_info stat_suffixes[] = { @@ -1869,23 +1870,43 @@ return 0; } if (rp->ReparseTag == IO_REPARSE_TAG_SYMLINK) - RtlInitCountedUnicodeString (&subst, + { + if (!recognize_junctions) + { + /* Pretend we don't know what a junction is, just like the + unrecognize case. */ + fileattr &= ~FILE_ATTRIBUTE_REPARSE_POINT; + return 0; + } + else + RtlInitCountedUnicodeString (&subst, (WCHAR *)((char *)rp->SymbolicLinkReparseBuffer.PathBuffer + rp->SymbolicLinkReparseBuffer.SubstituteNameOffset), rp->SymbolicLinkReparseBuffer.SubstituteNameLength); + } else if (rp->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) { - RtlInitCountedUnicodeString (&subst, + if (!recognize_junctions) + { + /* Pretend we don't know what a junction is, just like the + unrecognize case. */ + fileattr &= ~FILE_ATTRIBUTE_REPARSE_POINT; + return 0; + } + else + { + RtlInitCountedUnicodeString (&subst, (WCHAR *)((char *)rp->MountPointReparseBuffer.PathBuffer + rp->MountPointReparseBuffer.SubstituteNameOffset), rp->MountPointReparseBuffer.SubstituteNameLength); - if (RtlEqualUnicodePathPrefix (&subst, &ro_u_volume, TRUE)) - { - /* Volume mount point. Not treated as symlink. The return - value of -1 is a hint for the caller to treat this as a - volume mount point. */ - return -1; - } + if (RtlEqualUnicodePathPrefix (&subst, &ro_u_volume, TRUE)) + { + /* Volume mount point. Not treated as symlink. The return + value of -1 is a hint for the caller to treat this as a + volume mount point. */ + return -1; + } + } } else {