delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/04/06/04:26:26

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_MK,TW_NL,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
In-Reply-To: <4D9A2A5B.7060502@gmail.com>
References: <4D9A2A5B DOT 7060502 AT gmail DOT com>
Date: Wed, 6 Apr 2011 09:26:07 +0100
Message-ID: <BANLkTimqik9dE2rN-k=e3-OJ_a0PZRH59Q@mail.gmail.com>
Subject: Re: Utility: winln, a drop-in replacement for ln(1)
From: Andy Koppe <andy DOT koppe AT gmail DOT com>
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On 4 April 2011 21:30, Daniel Colascione wrote:
> Attached is a small program that behaves very similarly to ln(1), but that
> works with Windows hard and symbolic links instead of Cygwin ones.
> =C2=A0Successful use of this program requires Vista or newer, a user with
> SeCreateSymbolicLinkPrivilege, and a symlink evaluation policy that allows
> the kind of symbolic link you'd like to create. =C2=A0If these conditions=
 are
> met, however, this program becomes useful because it can create symbolic
> links that work equally well for Cygwin and non-Cygwin programs. =C2=A0Be=
cause
> its argument handling is practically identical to that of coreutils ln,
> winln can be used via a simple shell alias (or PATH prefixing, if you're
> feeling bold).

Very nice, and much better than faffing about with 'cmd /c mklink' and cygp=
ath.

A few points of note:

- Coretools ln also creates native Windows hard links, via Cygwin's
link() function.
- Cygwin link() directly invokes the NT API, which I think avoids some
filename restrictions at the Win32 level.
- winln doesn't have the .exe magic where links to .exes automatically
have .exe appended if it's not already present.
- Native symbolic links require administrator privileges and aren't
available at all before Vista.
- 'cmd /c mklink /j' allows to create directory junction points
without administrator privileges. Junction points are more or less
equivalent with symbolic links, and the 'linkd' utility from the
Windows Reource Kit Tools even allows to create them on XP. Hence it
might be useful for winln to fall back to junction points when
symbolic links aren't available.
- Native symbolic links obviously point at Windows paths, which means
they end up pointing at the wrong thing if the meaning of their
original POSIX path changes, in particular due to changing mount
points or Cygwin symlinks in the original path.
- 'winln' always creates a link to the absolute Windows path when
given a relative path. This means the link will point at the wrong
thing if it's moved about. I don't know whether native relative links
are possible.

(Some of these points rule out the use of native symbolic links as
Cygwin symbolic links.)

Andy

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019