From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: cygwin@cygwin.com
Subject: Re: Unable to execute Cygwin application within UDF format
Date: Fri, 27 May 2022 19:51:23 +0900 [thread overview]
Message-ID: <20220527195123.abd2d66a17e28b51f1a745a3@nifty.ne.jp> (raw)
In-Reply-To: <20220527181849.6baaa5d9e8446f3e7d23cbee@nifty.ne.jp>
On Fri, 27 May 2022 18:18:49 +0900
Takashi Yano wrote:
> On Fri, 27 May 2022 16:47:09 +0800
> Sam Lin wrote:
> > I have also successfully executed that is to move cygwin1.dll to the root
> > directory to execute.
> >
> > Will cygwin1.dll be supported to execute in UDF format in the future?
>
> As I wrote earlier, it doesn't matter that the file system
> is UDF. cygwin1.dll 3.2.0 and later seems to cause problems
> if it is placed in the root directory.
>
> Even with UDF format, the problem does not occur if hello.exe
> and cygwin1.dll are placed in any directory other than root
> directory.
I looked into this problem and found the problem occurs after
the commit:
commit 6d898f43fc87a7bf3ab100d75538e381bd86f657
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Fri Feb 19 18:15:58 2021 +0100
Cygwin: realpath: fix cygwin installation dir being access via junction
Consider this case:
- Cygwin installed in C:\cygwin64
- mklink /j D:\cygwin64 C:\cygwin64
- create testcase calling
realpath("/", result);
printf ("%s\n", result);
- start cmd
>C:\cygwin64\bin\bash -lc <path-to-testcase>
/
>D\cygwin64\bin\bash -lc <path-to-testcase>
/cygdrive/c/cygwin64
This scenario circumventing the mount point handling which is automated
in terms of /, depending on the path returned from GetModuleFileNameW
for the Cygwin DLL. When calling D:\cygwin64\bin\bash the dir returned
from GetModuleFileNameW is D:\cygwin64\bin, thus root is D:\cygwin64.
However, junctions are treated as symlinks in Cygwin which explains why
the path gets converted to a cygdrive path.
Fix this by calling GetFinalPathNameByHandleW on the result from
GetModuleFileNameW to get the correct root path, even if accessed via
a junction point.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
And also found the following patch fixes the issue.
diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc
index 01b49468e..c4031b919 100644
--- a/winsup/cygwin/cygheap.cc
+++ b/winsup/cygwin/cygheap.cc
@@ -183,6 +183,8 @@ init_cygheap::init_installation_root ()
if (p)
p = wcschr (p + 1, L'\\'); /* Skip share name */
}
+ else
+ p = installation_root_buf + 4; /* 4 is the length of "\\\\?\\" */
}
installation_root_buf[1] = L'?';
RtlInitEmptyUnicodeString (&installation_key, installation_key_buf,
--
Takashi Yano <takashi.yano@nifty.ne.jp>
next prev parent reply other threads:[~2022-05-27 10:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-27 3:36 Sam Lin
2022-05-27 4:31 ` Takashi Yano
2022-05-27 8:43 ` Takashi Yano
2022-05-27 8:47 ` Sam Lin
2022-05-27 9:18 ` Takashi Yano
2022-05-27 10:51 ` Takashi Yano [this message]
2022-05-27 12:28 ` Takashi Yano
2022-05-27 12:36 ` Takashi Yano
2022-05-28 13:22 ` Ken Brown
2022-05-28 14:25 ` Takashi Yano
2022-05-27 17:41 ` Sam Edge
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220527195123.abd2d66a17e28b51f1a745a3@nifty.ne.jp \
--to=takashi.yano@nifty.ne.jp \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).