This is the mail archive of the
mailing list for the Cygwin project.
Re: `CYGWIN=winsymlinks:nativestrict`, `ln -s target link` fails if target doesn't exist
- From: Gene Pavlovsky <gene dot pavlovsky at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Fri, 29 Apr 2016 03:09:16 +0300
- Subject: Re: `CYGWIN=winsymlinks:nativestrict`, `ln -s target link` fails if target doesn't exist
- Authentication-results: sourceware.org; auth=none
- References: <CAPTiy3NUXprQL6V0+Njc2L7XfhpqtC7oWFwNMhOEFZ2OZmddoQ at mail dot gmail dot com> <1606116423 dot 20160429020650 at yandex dot ru> <CAPTiy3OZC7acPvJRN0QtqjzfcFpnoxJkud3MTKQQVTCRr6vJVg at mail dot gmail dot com>
The list of errors that might be returned by symlink(2) mention target
only 3 times:
EFAULT target or linkpath points outside your accessible address space.
target or linkpath was too long.
ENOENT A directory component in linkpath does not exist or is a
dangling symbolic link, or target or linkpath is an empty string.
So my understanding is: target must be non-empty, not too long, and
don't point outside the accessible address space. Nothing about
On 29 April 2016 at 03:05, Gene Pavlovsky <email@example.com> wrote:
> I don't know if POSIX standard has something to say about that, but
> here's a reference from GNU libc:
> `man 2 symlink`:
>> A symbolic link (also known as a soft link) may point to an existing file or to a nonexistent one; the latter case is known as a dangling link.
> On 29 April 2016 at 02:06, Andrey Repin <firstname.lastname@example.org> wrote:
>> Greetings, Gene Pavlovsky!
>>> I have an issue to report:
>>> Introduction: On a UNIX system, `ln -s target link` creates a link
>>> regardless of target's existence.
>>> This is used in some scripts, e.g. Gentoo's `run-crons` (which I also
>>> use on Cygwin) uses a symlink pointing to the running process PID as
>>> Issue: if `CYGWIN=winsymlinks:nativestrict` env var is set, running
>>> `ln -s target link` completely fails (even though running `mklink link
>>> target` in `cmd.exe` succeeds, same as `ln -s` does on UNIX). If
>>> `CYGWIN=winsymlinks:native`, a non-native link is created.
>>> So, `nativestrict` might break some (admittedly unorthodox) scripts.
>>> With `native` these script work, but still a native link would be
>>> preferrable and it is possible to create, but a non-native link is
>>> created instead.
>>> Bottom line, I think the native symlink creation code should be
>>> checked and a possibility should be added to create links to
>>> non-existent targets, rather than the current behavior of failing.
>> This is actually an arguable behavior, even in Linux. I can imagine the
>> behavior is "undefined" in such a case.
>> But I'll leave final say to the more experienced members of the list.
>> With best regards,
>> Andrey Repin
>> Friday, April 29, 2016 01:55:21
>> Sorry for my terrible english...
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple