delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2020/03/26/07:01:45

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 83656385E024
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1585220466;
bh=mYp24XqML0r8+fkwiRVJ0OR7DCzMGluxU3iFyjOsnqY=;
h=Date:From:To:Subject:References:In-Reply-To:List-Id:
List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:
Reply-To:From;
b=pjSDkBB2YkRznq0gvfL3XyzwbezVaDpdI/bu/6kCkuj3u9AF4cdvxdxVLAvE5QbCe
Ackm7/49twy1YNv3W0vAbasxLiXZhP3V5G3QODG/qjespCqHVW9pw1F0n/UYF1Yo7Y
sMeFApevwxAlNqymed8BIGZO0dn9r2AD/DYDpaos=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 26011385E01E
Authentication-Results: sourceware.org;
dmarc=none (p=none dis=none) header.from=cygwin.com
Authentication-Results: sourceware.org;
spf=fail smtp.mailfrom=corinna-cygwin AT cygwin DOT com
Date: Thu, 26 Mar 2020 12:00:59 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: WSL symbolic links
Message-ID: <20200326110059.GG3261@calimero.vinschen.de>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <294944bd-757e-4bb8-6bcc-ceb8d9190ef9 AT towo DOT net>
MIME-Version: 1.0
In-Reply-To: <294944bd-757e-4bb8-6bcc-ceb8d9190ef9@towo.net>
X-Provags-ID: V03:K1:rylL2MRCRRtfWef7EKnks0AIgKwgdSSJDYE9Nbx4+6eUqqDozyA
bTDukSTLRFlkEIBWWzErjwQo396vhcrM8u8Ou89RqFmt3jEN0HX/nyE8eYNDsxgQ+4Y+fYP
VjgwnItpA6xGP+wnvAvX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BODY, GIT_PATCH_2, GOOD_FROM_CORINNA_CYGWIN, KAM_DMARC_STATUS,
RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL,
TXREP autolearn=ham autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <http://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <http://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <http://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Reply-To: cygwin AT cygwin DOT com
Errors-To: cygwin-bounces AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>

--===============5896253471367158595==
Content-Type: multipart/signed; micalg=pgp-sha256;
	protocol="application/pgp-signature"; boundary="Zi0sgQQBxRFxMTsj"
Content-Disposition: inline


--Zi0sgQQBxRFxMTsj
Content-Type: multipart/mixed; boundary="WK3l2KTTmXPVedZ6"
Content-Disposition: inline


--WK3l2KTTmXPVedZ6
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mar 26 10:00, Thomas Wolff wrote:
> A symbolic link created with WSL is neither interpreted in cygwin nor can=
 it
> be deleted:
> > touch file
> > wsl ln -s file link
> > wsl ls -l link
> lrwxrwxrwx=C2=A0=C2=A0=C2=A0 1 towo=C2=A0=C2=A0=C2=A0=C2=A0 towo=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 1 Mar 26 08=
:56 link -> file
> > ls -l link
> -rw-r----- 1 Unknown+User Unknown+Group 0 Mar 26 00:00 link

What kind of file are they in the real world?  Reparse points?  If so,
what content do they have?  I attached a Q&D source from my vault
of old test apps to check on reparse point content.  Please compile with

  gcc -g ../src/rd-reparse.c -o rd-reparse -lntdll

It takes a single native NT path as parameter, kind of like this:

  ./rd-reparse '\??\C:\cygwin64\home\corinna\link'


Thanks,
Corinna

--=20
Corinna Vinschen
Cygwin Maintainer

--WK3l2KTTmXPVedZ6
Content-Type: text/plain; charset=utf-8
Content-Disposition: attachment; filename="rd-reparse.c"

#include <stdio.h>
#include <wchar.h>
#include <windows.h>
#include <winternl.h>

typedef struct {
    DWORD  ReparseTag;
    WORD   ReparseDataLength;
    WORD   Reserved;
    union {
        struct {
            WORD   SubstituteNameOffset;
            WORD   SubstituteNameLength;
            WORD   PrintNameOffset;
            WORD   PrintNameLength;
	    DWORD  Flag;
            WCHAR PathBuffer[1];
        } SymbolicLinkReparseBuffer;
        struct {
            WORD   SubstituteNameOffset;
            WORD   SubstituteNameLength;
            WORD   PrintNameOffset;
            WORD   PrintNameLength;
            WCHAR PathBuffer[1];
        } MountPointReparseBuffer;
        struct {
            BYTE   DataBuffer[1];
        } GenericReparseBuffer;
    };
} MY_REPARSE_DATA_BUFFER, *MY_PREPARSE_DATA_BUFFER;

//ULONG WINAPI RtlCreateUnicodeStringFromAsciiz (PUNICODE_STRING, PCSTR);

int
main (int argc, char **argv)
{
  HANDLE fh;
  char buf[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
  DWORD siz;
  MY_PREPARSE_DATA_BUFFER rp;
  char *pbuf;
  char name[32768];
  NTSTATUS status;
  IO_STATUS_BLOCK io;
  UNICODE_STRING fname;
  OBJECT_ATTRIBUTES attr;

  RtlCreateUnicodeStringFromAsciiz (&fname, argv[1]);
  InitializeObjectAttributes(&attr, &fname, OBJ_CASE_INSENSITIVE, NULL, 0);
  status = NtOpenFile (&fh, FILE_READ_EA | FILE_READ_ATTRIBUTES | SYNCHRONIZE,
		       &attr, &io,
		       FILE_SHARE_VALID_FLAGS,
		       FILE_SYNCHRONOUS_IO_NONALERT
		       | FILE_OPEN_FOR_BACKUP_INTENT
		       | FILE_OPEN_REPARSE_POINT);
  if (!NT_SUCCESS (status))
    {
      fprintf (stderr, "NtOpenFile: %08X\n", status);
      return 1;
    }
  status = NtFsControlFile (fh, NULL, NULL, NULL, &io,
			    FSCTL_GET_REPARSE_POINT, NULL, 0,
			    (LPVOID) buf, sizeof buf);
  if (!NT_SUCCESS (status))
    {
      fprintf (stderr, "NtDeviceIoControlFile: %08lX\n", status);
      CloseHandle (fh);
      return 1;
    }

  rp = (MY_PREPARSE_DATA_BUFFER) buf;
  printf ("ReparseTag:           0x%08x\n", rp->ReparseTag);
  printf ("ReparseDataLength:    %10d\n", rp->ReparseDataLength);
  printf ("Reserved:             %10d\n", rp->Reserved);
  if (rp->ReparseTag == IO_REPARSE_TAG_SYMLINK
      || rp->ReparseTag == IO_REPARSE_TAG_SYMLINK)
    {
      printf ("SubstituteNameOffset: %10d\n",
	      rp->SymbolicLinkReparseBuffer.SubstituteNameOffset);
      printf ("SubstituteNameLength: %10d\n",
	      rp->SymbolicLinkReparseBuffer.SubstituteNameLength);
      printf ("PrintNameOffset:      %10d\n",
	      rp->SymbolicLinkReparseBuffer.PrintNameOffset);
      printf ("PrintNameLength:      %10d\n",
	      rp->SymbolicLinkReparseBuffer.PrintNameLength);
      if (rp->ReparseTag == IO_REPARSE_TAG_SYMLINK)
	{
	  printf ("Flag:                 0x%08x\n",
		  rp->SymbolicLinkReparseBuffer.Flag);
	  pbuf = (char *) rp->SymbolicLinkReparseBuffer.PathBuffer;
	}
      else
	pbuf = (char *) rp->MountPointReparseBuffer.PathBuffer;
      wcstombs (name,
		(PWCHAR) (pbuf + rp->SymbolicLinkReparseBuffer.SubstituteNameOffset),
		rp->SymbolicLinkReparseBuffer.SubstituteNameLength / 2);
      name[rp->SymbolicLinkReparseBuffer.SubstituteNameLength / 2] = '\0';
      printf("SubstituteName:       %s\n", name);
      wcstombs (name,
		(PWCHAR) (pbuf + rp->SymbolicLinkReparseBuffer.PrintNameOffset),
		rp->SymbolicLinkReparseBuffer.PrintNameLength / 2);
      name[rp->SymbolicLinkReparseBuffer.PrintNameLength / 2] = '\0';
      printf("PrintName:            %s\n", name);
    }
  else
    {
      WORD i;

      for (i = 0; i < rp->ReparseDataLength; ++i)
	{
	  printf ("%02x ", rp->GenericReparseBuffer.DataBuffer[i]);
	  if ((i + 1) % 16 == 0)
	    putchar ('\n');
	}
    }

  CloseHandle (fh);
  return 0;
}

--WK3l2KTTmXPVedZ6--

--Zi0sgQQBxRFxMTsj
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIyBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAl58i2sACgkQ9TYGna5E
T6Bp7Q/3bJs0t+TN4VsQRbeXICYhYcVIN1ky+Wk1r54tp5e7M7x6CQ7vhDShzkUX
iGiJjjIkpTpKoAzqX6r0LY0j3nmH77g2Na2gggxnRVRIEiVXG6gc7GxEeNDbcoeI
8jvtuoMSUoxHHXvuCm6COKRV5nsVBFm16Gxlix1eF/KYeB4LT7owsfXEHRndBPKy
KXXyf97evj616F6Als8m+iO9oDaeejCh/bD5JAG46/OD73JmjiECBZNz7XIFbNjO
G6UczY+ME20mltvWclDMpFUqUQ4WE9CghQohbr/isQXActAkv4ZzjEnVqFmZ/hTg
slzGuc5CHSDpoUAgpf9SCetoFc65BoGv/M128Md5sT74Ubip4a1kobVzvgd5NqCI
q2xLWz1JHv/tV4eikTB3FSbrm5hJMoEQcNJJlO8bSmfNclwBK1QH8CbkHJIDzXm/
tUoWQUQpF24g8NENYVHxWd2qaYD3ylUZR+bQeK5VxBftGYsVXFCItlam1zLuBMC3
GL9qkpGL5PoESf6prtVi3xOuAIbtNX1xA9HikiiEv/R2zdgdyQfgpwIowGwQE4vG
xpi7iWBaHNHMnz+kqS5EwsMcS3roL5Hl+1Y0U9Awa/ONVbSQ8Piwy1S5c5thNC71
w+8mOhrBtUY0vhiPSCkpyh2YXV0sLWYX3t21nugnn0/JHrQF8w==
=DFfv
-----END PGP SIGNATURE-----

--Zi0sgQQBxRFxMTsj--

--===============5896253471367158595==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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

--===============5896253471367158595==--

- Raw text -


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