From 7431d3f3470b46d6cbbcbdf6aeb712a446ae6fcc Mon Sep 17 00:00:00 2001 From: Takashi Yano Date: Fri, 19 Dec 2025 11:26:37 +0900 Subject: [PATCH 42/N] Cygwin: path: Implement path_conv::is_app_execution_alias() An app execution alias cannot be opened for read (CreateFile() with GENERIC_READ fails with ERROR_CANT_ACCESS_FILE) because it does not resolve the reparse point for app execution alias. Therefore, we need to know if the path is an app execution alias when opening it. This patch adds new api path_conv::is_app_execution_alias() for that purpose. Reviewed-by: Johannes Schindelin Signed-off-by: Takashi Yano Signed-off-by: Johannes Schindelin --- winsup/cygwin/local_includes/path.h | 5 +++++ winsup/cygwin/path.cc | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/local_includes/path.h b/winsup/cygwin/local_includes/path.h index a9ce2c7..ad142dd 100644 --- a/winsup/cygwin/local_includes/path.h +++ b/winsup/cygwin/local_includes/path.h @@ -79,6 +79,7 @@ enum path_types PATH_SOCKET = _BIT ( 5), /* AF_UNIX socket file */ PATH_RESOLVE_PROCFD = _BIT ( 6), /* fd symlink via /proc */ PATH_REP_NOAPI = _BIT ( 7), /* rep. point unknown to WinAPI */ + PATH_APPEXECLINK = _BIT ( 8), /* rep. point app execution alias */ PATH_DONT_USE = _BIT (31) /* conversion to signed happens. */ }; @@ -214,6 +215,10 @@ class path_conv { return (path_flags & (PATH_REP | PATH_REP_NOAPI)) == PATH_REP; } + int is_app_execution_alias () const + { + return path_flags & PATH_APPEXECLINK; + } int isfifo () const {return dev.is_device (FH_FIFO);} int iscygdrive () const {return dev.is_device (FH_CYGDRIVE);} diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index c1298a4..bcde89c 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -2921,7 +2921,7 @@ check_reparse_point_target (HANDLE h, bool remote, PREPARSE_DATA_BUFFER rp, if (i == 2 && n > 0 && n < size) { RtlInitCountedUnicodeString (psymbuf, buf, n * sizeof (WCHAR)); - return PATH_SYMLINK | PATH_REP; + return PATH_SYMLINK | PATH_REP | PATH_APPEXECLINK; } if (i == 2) break;