[petsc-dev] damn symlinks on windows

Chetan Jhurani chetan.jhurani at gmail.com
Wed Oct 9 14:56:26 CDT 2013


The whole shortcut business on windows/cygwin is a mess.
And you're right about mklink being a cmd.exe built-in.
I had not run it as an exe from bash.  However, in case
you decide to change things so that true symlinks are
created, mklink can still be called from bash.

$ cmd /c mklink symlinkBook1.xlsx Book1.xlsx
symbolic link created for symlinkBook1.xlsx <<===>> Book1.xlsx

$ wc symlinkBook1.xlsx Book1.xlsx
   26   136  8668 symlinkBook1.xlsx
   26   136  8668 Book1.xlsx
   52   272 17336 total

cygwin also understands it automatically, since it is a link at
NTFS level, as do other programs (say while mailing the
configure.log).

mklink requires Vista+, as you pointed out, and NTFS.  Vista and 7
don't install on FAT32 as the boot partition.  Windows versions
cannot even create FAT32 partitions of size > 32GB.  (Though
third-party utilities can do it and Windows understands them.)

The point is that someone who uses FAT partitions on today's
disks has to be too attached to FAT (except for USB flash drives
where NTFS is not ideal).

To ensure that mklink is used only on Vista or higher and only
for NTFS, you can check "cmd /c help mklink" output and fsutil.exe
to query file-system type.  fsutil is available since XP.

Chetan


> -----Original Message-----
> From: petsc-dev-bounces at mcs.anl.gov [mailto:petsc-dev-bounces at mcs.anl.gov] On Behalf Of Satish Balay
> Sent: Wednesday, October 09, 2013 9:12 AM
> To: Chetan Jhurani
> Cc: 'petsc-dev'
> Subject: Re: [petsc-dev] damn symlinks on windows
> 
> On Tue, 8 Oct 2013, Chetan Jhurani wrote:
> 
> > mklink on NTFS does it the right way - no .lnk business
> > or cygwin specific file format.
> > http://en.wikipedia.org/wiki/NTFS_symbolic_link
> 
> Hm..
> 
> >>>>
> Please note: For Windows 2000/XP, you would use an NTFS junction point.
> 
> The mklink command is used to create a symbolic link. It is natively available in the Command Prompt
> in Windows Vista/2008+ (not in PowerShell or as an executable).
> <<<<<<
> 
> Looks like its not really portable across all versions. And I wonder
> if anyone is still using FAT32 for local drives.
> 
> >>>>>>>>>
> 
> C:\Users\balay>mklink
> Creates a symbolic link.
> 
> MKLINK [[/D] | [/H] | [/J]] Link Target
> 
>         /D      Creates a directory symbolic link.  Default is a file
>                 symbolic link.
>         /H      Creates a hard link instead of a symbolic link.
>         /J      Creates a Directory Junction.
>         Link    specifies the new symbolic link name.
>         Target  specifies the path (relative or absolute) that the new link
>                 refers to.
> 
> C:\Users\balay>where mklink
> INFO: Could not find files for the given pattern(s).
> 
> C:\Users\balay>bash
> 
> balay at msnehalem2 /cygdrive/c/Users/balay
> $ mklink
> bash: mklink: command not found
> 
> balay at msnehalem2 /cygdrive/c/Users/balay
> $
> <<<<<<<<<<<
> 
> Hm - Looks like this is this a built in feature for 'cmd' - and not useable from bash.
> [Searching c: drive doesn't show anything]
> 
> Satish





More information about the petsc-dev mailing list