* Cygwin tool to differ junctions from soft links? @ 2023-11-01 9:14 Martin Wege 2023-11-16 7:29 ` Martin Wege 2023-11-16 8:47 ` Andrey Repin 0 siblings, 2 replies; 10+ messages in thread From: Martin Wege @ 2023-11-01 9:14 UTC (permalink / raw) To: cygwin Good morning! Does Cygwin have a command line tool (Scriptable!) which can be used to differ between soft links and Windows junctions? Thanks, Martin ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Cygwin tool to differ junctions from soft links? 2023-11-01 9:14 Cygwin tool to differ junctions from soft links? Martin Wege @ 2023-11-16 7:29 ` Martin Wege 2023-11-17 1:59 ` Doug Henderson 2023-11-16 8:47 ` Andrey Repin 1 sibling, 1 reply; 10+ messages in thread From: Martin Wege @ 2023-11-16 7:29 UTC (permalink / raw) To: cygwin ? On Wed, Nov 1, 2023 at 10:14 AM Martin Wege <martin.l.wege@gmail.com> wrote: > > Good morning! > > Does Cygwin have a command line tool (Scriptable!) which can be used > to differ between soft links and Windows junctions? > > Thanks, > Martin ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Cygwin tool to differ junctions from soft links? 2023-11-16 7:29 ` Martin Wege @ 2023-11-17 1:59 ` Doug Henderson 0 siblings, 0 replies; 10+ messages in thread From: Doug Henderson @ 2023-11-17 1:59 UTC (permalink / raw) To: cygwin > On Wed, Nov 1, 2023 at 10:14 AM Martin Wege <martin.l.wege@gmail.com> wrote: > > > > Good morning! > > > > Does Cygwin have a command line tool (Scriptable!) which can be used > > to differ between soft links and Windows junctions? > > > > Thanks, > > Martin Cygwin itself does not have a command, that I know of, to do this. However, you can use the windows command shell to call its internal commands. In bash, e.g. $ /cygdrive/c/Windows/System32/cmd.exe /c dir /a:l /b shows all the junctions in my windows user home folder when I am there. The windows dir command can list links and junctions. The mklink command documentation at https://ss64.com/nt/mklink.html has more information than the "mklink/?" help text about links. HTH Doug -- Doug Henderson, Calgary, Alberta, Canada - from gmail.com ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Cygwin tool to differ junctions from soft links? 2023-11-01 9:14 Cygwin tool to differ junctions from soft links? Martin Wege 2023-11-16 7:29 ` Martin Wege @ 2023-11-16 8:47 ` Andrey Repin 2023-11-16 18:55 ` matthew patton 1 sibling, 1 reply; 10+ messages in thread From: Andrey Repin @ 2023-11-16 8:47 UTC (permalink / raw) To: Martin Wege, cygwin Greetings, Martin Wege! > Does Cygwin have a command line tool (Scriptable!) which can be used > to differ between soft links and Windows junctions? It would be easier to help you, if you specify the purpose of your request. I.e. what you want to achieve with such tool. -- With best regards, Andrey Repin Thursday, November 16, 2023 11:46:09 Sorry for my terrible english... ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Cygwin tool to differ junctions from soft links? 2023-11-16 8:47 ` Andrey Repin @ 2023-11-16 18:55 ` matthew patton 2023-11-16 20:30 ` Brian Inglis 0 siblings, 1 reply; 10+ messages in thread From: matthew patton @ 2023-11-16 18:55 UTC (permalink / raw) To: Andrey Repin via Cygwin [-- Attachment #1: Type: text/plain, Size: 1453 bytes --] AFAIK no. what I do is re-implement 'ln' with a wrapper because the Cygwin behavior (Junctions) was driving me up the wall. https://github.com/tb3088/shell-environment/blob/ccf7aa161899c2c4ebe2d9e980e674bc726a3ef3/.functions_os.CYGWIN_NT#L9 ============ "In the information society, nobody thinks. We expected to banish paper, but we actually banished thought.” -- Michael Crichton, Jurassic Park “Ours may become the first civilization destroyed, not by the power of our enemies, but by the ignorance of our teachers and the dangerous nonsense they are teaching our children. In an age of artificial intelligence, they are creating artificial stupidity.' - Thomas Sowell On Thursday, November 16, 2023 at 03:50:24 AM EST, Andrey Repin via Cygwin <cygwin@cygwin.com> wrote: Greetings, Martin Wege! > Does Cygwin have a command line tool (Scriptable!) which can be used > to differ between soft links and Windows junctions? It would be easier to help you, if you specify the purpose of your request. I.e. what you want to achieve with such tool. -- With best regards, Andrey Repin Thursday, November 16, 2023 11:46:09 Sorry for my terrible english... -- 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Cygwin tool to differ junctions from soft links? 2023-11-16 18:55 ` matthew patton @ 2023-11-16 20:30 ` Brian Inglis 2023-11-17 5:54 ` Thomas Wolff 0 siblings, 1 reply; 10+ messages in thread From: Brian Inglis @ 2023-11-16 20:30 UTC (permalink / raw) To: cygwin On 2023-11-16 11:55, matthew patton via Cygwin wrote: > On Thursday, November 16, 2023 at 03:50:24 AM EST, Andrey Repin wrote: >>> Does Cygwin have a command line tool (Scriptable!) which can be used to >>> differ between soft links and Windows junctions? Distinguishing between types of Windows reparse points is not a POSIX or emulation function, so not of interest to Cygwin developers. I thought about it when support was added, but then realized there was no nice place to add it within the platform, without going the non-portable Windows specific utility route, as in lsattr. You could in a function or script by running lsattr -d which seems to fail on reparse points, then ls -dl which shows a Symbolic Link with a relative path, and a Junction with an absolute path, although it could just be a Symbolic Link with an absolute path. Perhaps something like the following would be useful to Windows users who want to know this stuff: https://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html >> It would be easier to help you, if you specify the purpose of your >> request. I.e. what you want to achieve with such tool. > AFAIK no. what I do is re-implement 'ln' with a wrapper because the Cygwin > behavior (Junctions) was driving me up the wall. > https://github.com/tb3088/shell-environment/blob/ccf7aa161899c2c4ebe2d9e980e674bc726a3ef3/.functions_os.CYGWIN_NT#L9 Cygwin never creates Windows Directory or Filesystem Junction reparse points, and by default it uses its own version of Unix path symlink files, preceded by a flag ("magic cookie") value, and with system attribute, to allow compatibility with FAT file system limitations, or else NFS symlinks on NFS filesystems. CYGWIN env var settings allow creation of Windows shortcuts and symbolic link reparse points instead of its default (equivalent to winsymlinks:sys), when supported by the file system and Windows release: https://cygwin.com/cygwin-ug-net/using-cygwinenv.html https://cygwin.com/cygwin-ug-net/using.html#pathnames-symlinks -- Take care. Thanks, Brian Inglis Calgary, Alberta, Canada La perfection est atteinte Perfection is achieved non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to add mais lorsqu'il n'y a plus rien à retirer but when there is no more to cut -- Antoine de Saint-Exupéry ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Cygwin tool to differ junctions from soft links? 2023-11-16 20:30 ` Brian Inglis @ 2023-11-17 5:54 ` Thomas Wolff 2023-11-17 12:06 ` Corinna Vinschen 2023-11-17 14:56 ` Brian Inglis 0 siblings, 2 replies; 10+ messages in thread From: Thomas Wolff @ 2023-11-17 5:54 UTC (permalink / raw) To: cygwin Am 16.11.2023 um 21:30 schrieb Brian Inglis via Cygwin: > On 2023-11-16 11:55, matthew patton via Cygwin wrote: >> On Thursday, November 16, 2023 at 03:50:24 AM EST, Andrey Repin wrote: >>>> Does Cygwin have a command line tool (Scriptable!) which can be >>>> used to >>>> differ between soft links and Windows junctions? > > Distinguishing between types of Windows reparse points is not a POSIX > or emulation function, so not of interest to Cygwin developers. > > I thought about it when support was added, but then realized there was > no nice place to add it within the platform, without going the > non-portable Windows specific utility route, as in lsattr. > > You could in a function or script by running lsattr -d which seems to > fail on reparse points, then ls -dl which shows a Symbolic Link with a > relative path, and a Junction with an absolute path, although it could > just be a Symbolic Link with an absolute path. lsattr has an explicit flag: 'r', 'Reparse': file or directory that has a reparse point I don't know whether it's the same as a junction, otherwise a 'j' flag could be added. > > Perhaps something like the following would be useful to Windows users > who want to know this stuff: > > https://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html > >>> It would be easier to help you, if you specify the purpose of your >>> request. I.e. what you want to achieve with such tool. >> AFAIK no. what I do is re-implement 'ln' with a wrapper because the >> Cygwin >> behavior (Junctions) was driving me up the wall. >> https://github.com/tb3088/shell-environment/blob/ccf7aa161899c2c4ebe2d9e980e674bc726a3ef3/.functions_os.CYGWIN_NT#L9 >> > > Cygwin never creates Windows Directory or Filesystem Junction reparse > points, and by default it uses its own version of Unix path symlink > files, preceded by a flag ("magic cookie") value, and with system > attribute, to allow compatibility with FAT file system limitations, or > else NFS symlinks on NFS filesystems. > > CYGWIN env var settings allow creation of Windows shortcuts and > symbolic link reparse points instead of its default (equivalent to > winsymlinks:sys), when supported by the file system and Windows release: > > https://cygwin.com/cygwin-ug-net/using-cygwinenv.html > > https://cygwin.com/cygwin-ug-net/using.html#pathnames-symlinks > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Cygwin tool to differ junctions from soft links? 2023-11-17 5:54 ` Thomas Wolff @ 2023-11-17 12:06 ` Corinna Vinschen 2023-11-17 14:56 ` Brian Inglis 1 sibling, 0 replies; 10+ messages in thread From: Corinna Vinschen @ 2023-11-17 12:06 UTC (permalink / raw) To: cygwin On Nov 17 06:54, Thomas Wolff via Cygwin wrote: > > > Am 16.11.2023 um 21:30 schrieb Brian Inglis via Cygwin: > > On 2023-11-16 11:55, matthew patton via Cygwin wrote: > > > On Thursday, November 16, 2023 at 03:50:24 AM EST, Andrey Repin wrote: > > > > > Does Cygwin have a command line tool (Scriptable!) which can > > > > > be used to > > > > > differ between soft links and Windows junctions? > > > > Distinguishing between types of Windows reparse points is not a POSIX or > > emulation function, so not of interest to Cygwin developers. > > > > I thought about it when support was added, but then realized there was > > no nice place to add it within the platform, without going the > > non-portable Windows specific utility route, as in lsattr. > > > > You could in a function or script by running lsattr -d which seems to > > fail on reparse points, then ls -dl which shows a Symbolic Link with a > > relative path, and a Junction with an absolute path, although it could > > just be a Symbolic Link with an absolute path. > lsattr has an explicit flag: > 'r', 'Reparse': file or directory that has a reparse > point > I don't know whether it's the same as a junction, otherwise a 'j' flag could > be added. lsattr is basically a frontend for the ioctl(FS_IOC_GETFLAGS) call. It centers around showing file attributes. DOS attributes as per https://learn.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants know about reparse points, but only as a flag. Just as its Linux counterpart showing ext[234] attributes, lsattr only works on regular files and directories. If you try to run it on a file Cygwin handles as a symbolic link, you get an error: $ mkdir foo $ ln -s foo bar $ lsattr -d foo bar ------------ foo lsattr: Not supported on bar $ cmd /c mklink /j baz foo Junction created for baz <<===>> foo $ ls -l total 0 lrwxrwxrwx 1 corinna vinschen 3 Nov 17 11:28 bar -> foo lrwxrwxrwx 1 corinna vinschen 23 Nov 17 11:29 baz -> /home/corinna/tmp/x/foo drwxr-xr-x 1 corinna vinschen 0 Nov 17 11:28 foo $ lsattr -d foo bar baz ------------ foo lsattr: Not supported on bar lsattr: Not supported on baz Actually, even if you run lsattr on a reparse point NOT handled as a symlink, you probably won't see the Reparse attribute at all. The reason is that the open(2) call doesn't expose a way to POSIX apps to open a reparse point as reparse point. There's just no POSIX flag for that, given the entire concept of reparse points is alien. As a result, the underlying Windows kernel NtCreateFile call will try to reparse. If the reparse point is one known to the OS, or a reparse point which is handled by some driver, you'll see the attributes of the reparse target. Volume mount points are a known variety not handled as symlink by Cygwin. Open the volume mount point with open(2), and you actually opened the root directory of the mounted filesystem. Funny enough, same goes for Windows attrib.exe tool... Having said that, I don't see an easy way to provide the required information from inside Cygwin by providing an API for stuff like that. If you want to see this kind of information, there are ways. For instance, a tool can do something like that: lstat("foo"); if (S_ISLNK("foo")) { HANDLE h = CreateFile("foo", ..., FILE_FLAG_OPEN_REPARSE_POINT, ...); if (h != INVALID_HANDLE_VALUE) { FILE_ATTRIBUTE_TAG_INFO at; if (GetFileInformationByHandleEx (h, FileAttributeTagInfo, &at, sizeof at)) { if (at.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { /* Check at.ReparseTag: IO_REPARSE_TAG_LX_SYMLINK: WSL symlink IO_REPARSE_TAG_SYMLINK: Windows symlink IO_REPARSE_TAG_MOUNT_POINT: Volume mount point or directory junction IO_REPARSE_TAG_APPEXECLINK: App execution alias Anything else: *shrug* } } } } Corinna ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Cygwin tool to differ junctions from soft links? 2023-11-17 5:54 ` Thomas Wolff 2023-11-17 12:06 ` Corinna Vinschen @ 2023-11-17 14:56 ` Brian Inglis 2023-11-17 18:44 ` matthew patton 1 sibling, 1 reply; 10+ messages in thread From: Brian Inglis @ 2023-11-17 14:56 UTC (permalink / raw) To: cygwin On 2023-11-16 22:54, Thomas Wolff via Cygwin wrote: > Am 16.11.2023 um 21:30 schrieb Brian Inglis via Cygwin: >> On 2023-11-16 11:55, matthew patton via Cygwin wrote: >>> On Thursday, November 16, 2023 at 03:50:24 AM EST, Andrey Repin wrote: >>>>> Does Cygwin have a command line tool (Scriptable!) which can be used to >>>>> differ between soft links and Windows junctions? >> Distinguishing between types of Windows reparse points is not a POSIX or >> emulation function, so not of interest to Cygwin developers. >> I thought about it when support was added, but then realized there was no nice >> place to add it within the platform, without going the non-portable Windows >> specific utility route, as in lsattr. >> You could in a function or script by running lsattr -d which seems to fail on >> reparse points, then ls -dl which shows a Symbolic Link with a relative path, >> and a Junction with an absolute path, although it could just be a Symbolic >> Link with an absolute path. > lsattr has an explicit flag: > 'r', 'Reparse': file or directory that has a reparse point > I don't know whether it's the same as a junction, otherwise a 'j' flag could be > added. Notice that the flag is the same as 'r' "Readonly" and lsattr does not work on Windows Reparse Points which are Junctions, Directory or File Symbolic Links [sanitized]: $ cd ~ $ cmd /c dir /a:l | grep '>' 2021-04-13 10:41 <JUNCTION> Application Data [$HOME/AppData/Roaming] 2021-06-21 21:07 <JUNCTION> Bookshelf [...] 2021-04-13 10:41 <JUNCTION> Cookies [$HOME/AppData/Local/Microsoft/Windows/INetCookies] 2021-09-15 10:23 <JUNCTION> cygwin-64t [...] 2021-04-13 10:41 <JUNCTION> Local Settings [$HOME/AppData/Local] 2020-04-21 03:33 <SYMLINKD> Mail [AppData/Roaming/...] 2021-04-13 10:41 <JUNCTION> My Documents [$HOME/Documents] 2021-04-13 10:41 <JUNCTION> NetHood [$HOME/AppData/Roaming/Microsoft/Windows/Network Shortcuts] 2023-05-27 07:30 <JUNCTION> ntp-dev [...] 2023-05-27 07:30 <JUNCTION> ntp-stable [...] 2021-04-13 10:41 <JUNCTION> PrintHood [$HOME/AppData/Roaming/Microsoft/Windows/Printer Shortcuts] 2021-04-13 10:41 <JUNCTION> Recent [$HOME/AppData/Roaming/Microsoft/Windows/Recent] 2021-04-13 10:41 <JUNCTION> SendTo [$HOME/AppData/Roaming/Microsoft/Windows/SendTo] 2021-04-13 10:41 <JUNCTION> Start Menu [$HOME/AppData/Roaming/Microsoft/Windows/Start Menu] 2021-02-10 21:19 <JUNCTION> Tech [...] 2021-04-13 10:41 <JUNCTION> Templates [$HOME/AppData/Roaming/Microsoft/Windows/Templates] 2022-05-27 19:15 <JUNCTION> weather [...] 2020-06-20 01:19 <SYMLINK> _gvimrc [.vim/gvimrc] 2020-06-20 01:06 <SYMLINKD> _vim [.vim] 2020-06-20 00:51 <SYMLINK> _viminfo [.vim/viminfo] 2020-06-20 00:51 <SYMLINK> _vimrc [.vim/vimrc] $ cmd /c dir /a:l /b "$HOMEPATH" | d2u | xargs -I@ lsattr -d '@' lsattr: Not supported on Application Data lsattr: Not supported on Bookshelf lsattr: Not supported on Cookies lsattr: Not supported on cygwin-64t lsattr: Not supported on Local Settings lsattr: Not supported on Mail lsattr: Not supported on My Documents lsattr: Not supported on NetHood lsattr: Not supported on ntp-dev lsattr: Not supported on ntp-stable lsattr: Not supported on PrintHood lsattr: Not supported on Recent lsattr: Not supported on SendTo lsattr: Not supported on Start Menu lsattr: Not supported on Tech lsattr: Not supported on Templates lsattr: Not supported on weather lsattr: Not supported on _gvimrc lsattr: Not supported on _vim lsattr: Not supported on _viminfo lsattr: Not supported on _vimrc >> Perhaps something like the following would be useful to Windows users who want >> to know this stuff: >> https://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html >>>> It would be easier to help you, if you specify the purpose of your >>>> request. I.e. what you want to achieve with such tool. >>> AFAIK no. what I do is re-implement 'ln' with a wrapper because the Cygwin >>> behavior (Junctions) was driving me up the wall. >>> https://github.com/tb3088/shell-environment/blob/ccf7aa161899c2c4ebe2d9e980e674bc726a3ef3/.functions_os.CYGWIN_NT#L9 >> Cygwin never creates Windows Directory or Filesystem Junction reparse points, >> and by default it uses its own version of Unix path symlink files, preceded by >> a flag ("magic cookie") value, and with system attribute, to allow >> compatibility with FAT file system limitations, or else NFS symlinks on NFS >> filesystems. >> CYGWIN env var settings allow creation of Windows shortcuts and symbolic link >> reparse points instead of its default (equivalent to winsymlinks:sys), when >> supported by the file system and Windows release: >> https://cygwin.com/cygwin-ug-net/using-cygwinenv.html >> https://cygwin.com/cygwin-ug-net/using.html#pathnames-symlinks -- Take care. Thanks, Brian Inglis Calgary, Alberta, Canada La perfection est atteinte Perfection is achieved non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to add mais lorsqu'il n'y a plus rien à retirer but when there is no more to cut -- Antoine de Saint-Exupéry ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Cygwin tool to differ junctions from soft links? 2023-11-17 14:56 ` Brian Inglis @ 2023-11-17 18:44 ` matthew patton 0 siblings, 0 replies; 10+ messages in thread From: matthew patton @ 2023-11-17 18:44 UTC (permalink / raw) To: cygwin; +Cc: Brian Inglis [-- Attachment #1: Type: text/plain, Size: 1406 bytes --] >> Cygwin never creates Windows Directory or Filesystem Junction reparse points, >> and by default it uses its own version of Unix path symlink files, preceded by >> a flag ("magic cookie") value, and with system attribute, to allow >> compatibility with FAT file system limitations, or else NFS symlinks on NFS >> filesystems. >> CYGWIN env var settings allow creation of Windows shortcuts and symbolic link >> reparse points instead of its default (equivalent to winsymlinks:sys), when >> supported by the file system and Windows release: >> https://cygwin.com/cygwin-ug-net/using-cygwinenv.html >> https://cygwin.com/cygwin-ug-net/using.html#pathnames-symlinks That ^^^ hasn't been true for how many years now? That was the OLD, deprecated mechanism which hasn't seen the light of day since what, WIndows 7 or 10? 13:36 45 $ unset CYGWIN; /bin/ln -s README.md test-link13:37 46 $ cmd /c dir /a: test-link Volume in drive C is Windows Directory of C:\Users\pattonma 11/17/2023 01:37 PM <JUNCTION> test-link [...] 1 File(s) 0 bytes 0 Dir(s) 241,024,512,000 bytes free My environment is shared between Win10, Cygwin, and WSL and Dropbox for a bunch of targets of symlinks. Some 'DOS' tools, specifically AWS CLI can't follow Junctions so I had to take matters into my own hands. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-11-17 18:44 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-11-01 9:14 Cygwin tool to differ junctions from soft links? Martin Wege 2023-11-16 7:29 ` Martin Wege 2023-11-17 1:59 ` Doug Henderson 2023-11-16 8:47 ` Andrey Repin 2023-11-16 18:55 ` matthew patton 2023-11-16 20:30 ` Brian Inglis 2023-11-17 5:54 ` Thomas Wolff 2023-11-17 12:06 ` Corinna Vinschen 2023-11-17 14:56 ` Brian Inglis 2023-11-17 18:44 ` matthew patton
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).