[filesystem] to support Windows NTFS symlinks

Hello All, As far as I understand Boost.Filesystem assumes that there is no symbolic link support in Windows (is_symlink() always returns false, it is impossible to create, etc.), but only hardlinks (using the CreateHardLink API call). As you probably know, symlinks have been introduced in Vista (NTFS only): the API now includes CreateSymbolicLink and a user is able to create symlinks using mklink and see them using dir. [ http://en.wikipedia.org/wiki/NTFS_symbolic_link]<http://en.wikipedia.org/wiki/NTFS_symbolic_link> However, creating fully functional symbolic links was quite possible already in Windows 2000 on NTFS drives - using junction reparse points. [ http://en.wikipedia.org/wiki/NTFS_junction_point]<http://en.wikipedia.org/wiki/NTFS_junction_point> A junction is created with 2 main API calls: hFile = CreateFile( LinkDirectory, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS, NULL ); . . . DeviceIoControl( hFile, FSCTL_SET_REPARSE_POINT, reparseInfo, reparseInfo->ReparseDataLength + REPARSE_MOUNTPOINT_HEADER_SIZE, NULL, 0, &returnedLength, NULL ) . . . A popular free SysInternals' http://www.microsoft.com/technet/sysinternals/FileAndDisk/Junction.mspx tool is usually used to create/list junctions in Win2000, XP, Vista. Its source-code can be found here: http://web.archive.org/web/20060106050745/www.sysinternals.com/Utilities/Jun... [At the Web-Archive, as the source-code has not yet been officially re-released by Microsoft since SysInternals migration to Technet] (There is also another pre-Vista tool - the Microsoft's fsutil)<http://technet2.microsoft.com/windowsserver/en/library/14cb706b-2a38-48e0-a569-a7fa9ca3b3401033.mspx?mfr=true> As far as I understand, junctions behave similar to symbolic links - they point to specific "real" locations not only on the same drive, they can be deleted without deleting the target, they still point to already deleted file/directory, etc. They are even in formal use in Windows Vista: for example, "Documents and Settings" is no longer a directory but a junction pointing to some newly introduced user folder; junctions are supported in the mklink tool and are shown using dir. Maybe it is worth considering to introduce Windows NTFS symlinks support in Boost.FileSystem - a straightforward approach would be to use new symbolic link API for Vista target build and junctions for 2000 and XP. [I am sorry if this subject has already been discussed - I have not found any posts on it] Best Regards, David Sirovsky.

David Sirovsky wrote:
... Maybe it is worth considering to introduce Windows NTFS symlinks support in Boost.FileSystem - a straightforward approach would be to use new symbolic link API for Vista target build and junctions for 2000 and XP.
I'd very much like to see NTFS symlink support added, but I just don't have the time right now. I might be able to add the support for Vista some in the next month or two, as that is less work, but am worried the 2000 and XP support will be troublesome. If anyone else would like to contribute such support, let me know. Good test coverage would have be part of such support. Thanks, --Beman

Beman Dawes wrote:
I'd very much like to see NTFS symlink support added, but I just don't have the time right now. I might be able to add the support for Vista some in the next month or two, as that is less work, but am worried the 2000 and XP support will be troublesome.
If anyone else would like to contribute such support, let me know. Good test coverage would have be part of such support.
My Hamigaki.Filesystem library supports Windows Vista symbolic links. http://tinyurl.com/2lfmah And the documentation (in Japanese) http://hamigaki.sourceforge.jp/libs/filesystem/ Hamigaki.Filesystem provides the following functions: void create_file_symlink(const path&, const path&); void create_directory_symlink(const path&, const path&); void create_symlink(const path&, const path&); Windows Vista symbolic links distinguish between the link to the file and the link to the directory. So we need create_file_symlink() and create_directory_symlink(). If the target of the symbolic link exists, you can use create_symlink(). Regards, Takeshi Mouri

My Hamigaki.Filesystem library supports Windows Vista symbolic links. http://tinyurl.com/2lfmah
Ooops! Hamigaki.Filesystem supports NTFS junctions too. Regards, Takeshi Mouri

Hello, I submitted a patch for NTFS symbolic links. http://svn.boost.org/trac/boost/ticket/1681 Regards, Takeshi Mouri

Takeshi Mouri wrote:
Hello,
I submitted a patch for NTFS symbolic links. http://svn.boost.org/trac/boost/ticket/1681
Thank you very much! --Beman
participants (3)
-
Beman Dawes
-
David Sirovsky
-
Takeshi Mouri