NTLinks + NTLinksMaker: NTFS links creation and information

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Stefan2, white, sheep, Hacker

Post Reply
User avatar
MVV
Power Member
Power Member
Posts: 8276
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV » 2017-02-25, 19:44 UTC

If you set level to -1, the tool will duplicate complete folder structure and create symlinks for every file, it is almost what you want. However it is impossible to have a nonzero size for a file symlink.

Perhaps I can add an option to copy standard attributes to symlinks.

I won't add any comment-managing code into the tool, sorry. So perhaps copying descript.ion files as a links is better because they will always show up-to-date descriptions... Or you can skip them using filter and then copy only descript.ion files using TC copy dialog (or some kind of script)...

User avatar
DrShark
Power Member
Power Member
Posts: 1264
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262

Post by *DrShark » 2017-02-25, 20:36 UTC

MVV wrote:If you set level to -1, the tool will duplicate complete folder structure and create symlinks for every file, it is almost what you want.
I just tried to do it with Maker 1.0.5.272 (level to "-1", with option "Symbolic links only" for link types) on some test folder with subfiles and subfolders. This created just a symlink to the selected folder.
The point of making real folders and making symlinks only for files is to have access to full folder/file tree even if linked files are not available (for example because they are on removable media).
MVV wrote:Perhaps I can add an option to copy standard attributes to symlinks.
Please copy folder attributes too if possible, if you will add real folder creation (see above).
MVV wrote:I won't add any comment-managing code into the tool, sorry.
OK. What about read errors handling? I see like this:
tool makes catalog of e.g. CD, if it cannot read file attribules it have to try to make symlink preserving at least filename; if it can't get subfolder/filelist of some folder, only target folder with same name must be created (attributes handling like above for files); if media is not responding for X seconds and tool can't do the job for some file/folder, it should try for next folder or file in the tree and so on until the tree made in target path.
Android 4.3.1 no root, kernel 08.09.2016; Vista Home Premium SP2 rus 32 bit
TC #149847 Personal licence

Cuz we're all in this together, We're here to make it right

User avatar
MVV
Power Member
Power Member
Posts: 8276
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV » 2017-02-25, 21:16 UTC

This created just a symlink to the selected folder.
I've just tried with NTLinks Maker 1.2.0.340, and it works as expected.
What about read errors handling?
NTLinks Maker is not a tool for reading damaged media, it may only show a error message with skip button if some folder is not readable...

User avatar
DrShark
Power Member
Power Member
Posts: 1264
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262

Post by *DrShark » 2017-02-25, 22:39 UTC

MVV wrote:I've just tried with NTLinks Maker 1.2.0.340, and it works as expected.
Latest version worked mostly as expected. For normal folders it's ok (targets are folders with subfolders and file symlinks inside; unfortunately, target folder attributes not copied from source), but if source is either junction or folder symlink, the target is a folder symlink too. I'd like to have options to treat a) source junctions and b) source folder symlinks like normal folders, so target will be a folder with subfolders and file symlinks inside.
it may only show a error message with skip button if some folder is not readable...
Is it possible to make a checkbox in tool's GUI like "silently ignore all read errors"? BTW read errors may happen also because of file/folder NTFS rights, illegal file name, or when they are used and locked by some process, maybe some other reasons.
Android 4.3.1 no root, kernel 08.09.2016; Vista Home Premium SP2 rus 32 bit
TC #149847 Personal licence

Cuz we're all in this together, We're here to make it right

User avatar
MVV
Power Member
Power Member
Posts: 8276
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV » 2017-02-26, 08:40 UTC

I'd like to have options to treat a) source junctions and b) source folder symlinks like normal folders, so target will be a folder with subfolders and file symlinks inside.
Since NTLinks Maker is a tool for creating links, it is completely by design that it stops recursion on links.
Is it possible to make a checkbox in tool's GUI like "silently ignore all read errors"?
Everything is possible. :)
But since it is an interactive tool, it should ask questions and let you select what to do next (skip/elevate/retry/cancel). I'll consider GUI option but I'm not sure that I will add it. You can ignore errors silently using non-interactive mode BTW.

User avatar
DrShark
Power Member
Power Member
Posts: 1264
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262

Post by *DrShark » 2017-02-26, 09:15 UTC

MVV wrote:Since NTLinks Maker is a tool for creating links
Agree...
MVV wrote:it is completely by design that it stops recursion on links.
... and making symlinks of files after following junctions/folder symlinks is a specific kind of "creating links" job. Maybe you can add command line switches to make tool work that way?
MVV wrote:You can ignore errors silently using non-interactive mode BTW.
Non-interactive mode is that what Maker does with "/q" switch? If yes, for my specific task I can use a separate button with this switch.
Android 4.3.1 no root, kernel 08.09.2016; Vista Home Premium SP2 rus 32 bit
TC #149847 Personal licence

Cuz we're all in this together, We're here to make it right

User avatar
MVV
Power Member
Power Member
Posts: 8276
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV » 2017-02-26, 09:45 UTC

making symlinks of files after following junctions/folder symlinks is a specific kind of "creating links" job
I think it is a bit excess... Ok, I'll consider that too.
If yes, for my specific task I can use a separate button with this switch.
Yes, I mean /q switch.

User avatar
Dalai
Power Member
Power Member
Posts: 6589
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai » 2017-06-05, 14:35 UTC

I have a question regarding long path support. I created some junctions on Win7 and they seem to be kind of incompatible (with mklink):

Code: Select all

C:\Users\Dalai\a>mklink /J MachineGames_mklink \\?\E:\Profiles\Spiele\MachineGames
Verbindung erstellt für MachineGames_mklink <<===>> \\?\E:\Profiles\Spiele\MachineGames

C:\Users\Dalai\a>mklink /J MachineGames_mklink2 \??\E:\Profiles\Spiele\MachineGames
Verbindung erstellt für MachineGames_mklink2 <<===>> \??\E:\Profiles\Spiele\MachineGames

C:\Users\Dalai\a>dir

05.06.2017  16:05    <DIR>          .
05.06.2017  16:05    <DIR>          ..
05.06.2017  16:05    <VERBINDUNG>   MachineGames_mklink [\\?\E:\Profiles\Spiele\MachineGames]
05.06.2017  16:05    <VERBINDUNG>   MachineGames_mklink2 [C:\??\E:\Profiles\Spiele\MachineGames]
05.06.2017  16:05    <VERBINDUNG>   MachineGames_NTFS Links [\??\E:\Profiles\Spiele\MachineGames]
05.06.2017  16:05    <VERBINDUNG>   MachineGames_NTLinksMaker [\??\E:\Profiles\Spiele\MachineGames]
See the code above on how I created the "mklink" ones. The last two have been created using NTFS Links and NTLinksMaker (obviously).

Now to the questions: Why doesn't the creation with \??\ prefix work in mklink? Why does the same thing work in both GUI tools? Where does the prefix come from anyway? Up until today I've known only \\?\ prefix, and that's the one mentioned by Microsoft as well. Is it possible to create a valid link with the \??\ prefix via mklink?

I'm quite sure that I'm missing something, but I don't know what it is.

Note that I used an older build (1.1.0.304) of NTLinksMaker in the process; the latest version (1.2.0.340) doesn't use any prefix at all, at least for paths as short as these.

Regards
Dalai
#101164 Personal licence
Athlon X4 880K, 16 GiB RAM, Gigabyte F2A88X-D3HP, Win7 x64

Plugins: Services2, Startups

User avatar
sqa_wizard
Power Member
Power Member
Posts: 3463
Joined: 2003-02-06, 11:41 UTC
Location: Germany

Post by *sqa_wizard » 2017-06-05, 15:17 UTC

Well, the most logical explanation is:
If you don't use the special prefix"\\?\", then the expression is resolved as a relative path.

Being at "C:\Users\Dalai\a" your current drive is C.
Creating there a link to "\??\E:\" will result in "C:\??\E:\" which is a absolute path based link.
NTFS Links and NTLinksMaker are obviously able to make relative based links ...

It seems none of them does a check for invalid characters for filenames such as ":" or "?" though.
#5767 Personal license

User avatar
MVV
Power Member
Power Member
Posts: 8276
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV » 2017-06-05, 16:05 UTC

Well, \??\ is a special prefix that is required for reparse points, it is not connected with long path prefix.

Most probably mklink simply doesn't support long paths (just like Explorer or other Windows console tools) therefore you can't create junctions with such paths. Note that there is no public Windows API for creating junctions, every tool have to fill corresponding structure and calls DeviceIoControl function.

As it was discovered, public Windows API for creating symbolic links isn't good too (it doesn't add null characters to strings so Explorer fails to show link properties), so latest NTLinksMaker versions also fill corresponding structure manually.

User avatar
Dalai
Power Member
Power Member
Posts: 6589
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai » 2017-06-05, 17:35 UTC

MVV wrote:Well, \??\ is a special prefix that is required for reparse points, it is not connected with long path prefix.
Apparently, it's not required. I can create valid junctions to the path without any prefix via mklink and the latest version of NTLinksMaker (which doesn't add prefix):

Code: Select all

C:\Users\Dalai\a>mklink /J c:\Users\Dalai\a\MachineGames_mklink e:\Profiles\Spiele\MachineGames
Verbindung erstellt für c:\Users\Dalai\a\MachineGames_mklink <<===>> e:\Profiles\Spiele\MachineGames

C:\Users\Dalai\a>mklink /J c:\Users\Dalai\a\MachineGames_mklink2 \\?\e:\Profiles\Spiele\MachineGames
Verbindung erstellt für c:\Users\Dalai\a\MachineGames_mklink2 <<===>> \\?\e:\Profiles\Spiele\MachineGames

C:\Users\Dalai\a>mklink /J c:\Users\Dalai\a\MachineGames_mklink3 \??\e:\Profiles\Spiele\MachineGames
Verbindung erstellt für c:\Users\Dalai\a\MachineGames_mklink3 <<===>> \??\e:\Profiles\Spiele\MachineGames

C:\Users\Dalai\a>dir

05.06.2017  19:24    <VERBINDUNG>   MachineGames_mklink [e:\Profiles\Spiele\MachineGames]
05.06.2017  19:24    <VERBINDUNG>   MachineGames_mklink2 [\\?\e:\Profiles\Spiele\MachineGames]
05.06.2017  19:24    <VERBINDUNG>   MachineGames_mklink3 [C:\??\e:\Profiles\Spiele\MachineGames]
05.06.2017  19:24    <VERBINDUNG>   MachineGames_NTLinksMaker_120340 [E:\Profiles\Spiele\MachineGames]
This time I used absolute paths in all places, so no relative paths matter here. All of the above paths except mklink3 are accessible.
Most probably mklink simply doesn't support long paths (just like Explorer or other Windows console tools) therefore you can't create junctions with such paths.
I don't try to. I just wondered why NTFS Links and older versions of NTLinksMaker use \??\ prefix.

Apparently my initial sentence causes some irritation. It's not about long path support but the difference between \??\ and \\?\ prefixes.
Note that there is no public Windows API for creating junctions, every tool have to fill corresponding structure and calls DeviceIoControl function.
Yes, that's what I found out in the meantime. But I guess there's some rules about the paths to use, isn't there?

Regards
Dalai
Last edited by Dalai on 2017-06-05, 18:28 UTC, edited 1 time in total.
#101164 Personal licence
Athlon X4 880K, 16 GiB RAM, Gigabyte F2A88X-D3HP, Win7 x64

Plugins: Services2, Startups

User avatar
MVV
Power Member
Power Member
Posts: 8276
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV » 2017-06-05, 18:24 UTC

Apparently, it's not required. I can create valid junctions to the path without any prefix via mklink and the latest version of NTLinksMaker (which doesn't add prefix):
It is internal prefix, of course you don't need to input it. And, reparse points have paths in two forms: substituting one that is used for resolving links (it must contain \??\ prefix but you don't see it) and printable one that is used to show link target to the user (it may contain anything, and some programs use same string for both symbolic and printable paths therefore you can see the prefix). So it isn't actually easy to say is link correct or not if you only see its printable path (you can use my NTLinks plugin to see substituting paths - it currently only reads them and writes both using same strings).

User avatar
Dalai
Power Member
Power Member
Posts: 6589
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai » 2017-06-05, 18:43 UTC

MVV wrote:It is internal prefix, of course you don't need to input it. And, reparse points have paths in two forms: one symbolic that is used for resolving links (it must contain \??\ prefix but you don't see it)
So, you're saying that the input into one API function may not correspond to the output of another API function (stripping or adding the prefix in the process)?

The \??\ prefix is for reparse points and has nothing to do with the long path prefix \\?\ - did I understand that correctly? What happens when I want to create a junction to a long path? Which prefix is used in this case? Does the special prefix \??\ support long paths by itself?

Regards
Dalai
#101164 Personal licence
Athlon X4 880K, 16 GiB RAM, Gigabyte F2A88X-D3HP, Win7 x64

Plugins: Services2, Startups

User avatar
MVV
Power Member
Power Member
Posts: 8276
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV » 2017-06-05, 18:52 UTC

The \??\ prefix is for reparse points and has nothing to do with the long path prefix \\?\ - did I understand that correctly?
Yes.
So, you're saying that the input into one API function may not correspond to the output of another API function (stripping or adding the prefix in the process)?
What happens when I want to create a junction to a long path? Which prefix is used in this case? Does the special prefix \??\ support long paths by itself?
There are no API functions that read or write reparse points (except buggy CreateSymbolicLink one), you have to fill or read structures that contain offsets to strings and strings itself. So different tools may fill or read fields differently, but link will not work if substituting path has no \??\ prefix, also it must not contain long path prefix \\?\ (long paths should be stored w/o prefix - perhaps because they are used at the kernel level where prefixes are not used).

User avatar
Dalai
Power Member
Power Member
Posts: 6589
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai » 2017-06-05, 20:01 UTC

I still don't understand all aspects of the whole thing, but my main question has been answered. Thanks for the explanation :)! Now I can write a script based on mklink that (re)creates junctions for the profiles of all of my games (I really hate it when they dump their stuff all over the system partition).

Regards
Dalai
#101164 Personal licence
Athlon X4 880K, 16 GiB RAM, Gigabyte F2A88X-D3HP, Win7 x64

Plugins: Services2, Startups

Post Reply