ntfs: Support Windows native symbolic links
Subsystems (3)
Hyunchul Lee
maintainerv2 cover ntfs: Support Windows native symbolic links
This patch series adds support for Windows native symbolic links and introduces mount options to configure how symbolic links are resolved and created.
Currently, the NTFS driver creates WSL-compatible symbolic links and has limited support for native Windows symbolic links. This series addresses these limitations.
1. Following/Resolving Symlinks & Junctions:
- Add support for parsing and following Windows native symbolic links.
- Introduce the "native_symlink=raw|rel" mount option to configure absolute target resolution.
2. Creating Symlinks:
- Introduce the "symlink=wsl|native" mount option to choose the creation behavior of symlinks. Under "native", Windows native symbolic links are created by converting the target path to UTF-16 Windows format.
3. Fixes & Cleanups:
- Fix an issue where the size of symbolic links is reported as 0.
- Clean up target name conversion for WSL symlinks by avoiding redundant conversion.
4. Documentation:
- Document the newly introduced mount options in ntfs.rst.
Changes since v1:
- Add a boundary check to verify that reparse point attribute size is at least the size of the reparse_point.
- Fix target inode fields (reparse_tag, reparse_flags) not being updated ntfs_reparse_set_wsl_symlink(), ntfs_reparse_set_wsl_not_symlink(), and ntfs_set_ntfs_reparse_data().
- Improve absolute path validation in ntfs_reparse_set_native_symlink() by ensuring that absolute paths actually start with a valid drive letter and a path separator.
- Optimize memory allocations in ntfs_reparse_set_native_symlink() by sharing the same buffer for print name and substitute name in the relative symlink path.
---
Hyunchul Lee (7):
ntfs: fix incorrect size of symbolic link
ntfs: support following Windows native symlink with relative paths
ntfs: support following Windows native symlink with absolute paths
ntfs: add native_symlink mount option
ntfs: clean up target name conversion for WSL symlinks
ntfs: support creating Windows native symlinks docs/fs/ntfs: add mount options to support Windows native symbolic links
Documentation/filesystems/ntfs.rst | 13 + fs/ntfs/file.c | 24 +- fs/ntfs/inode.c | 49 ++-- fs/ntfs/inode.h | 2 + fs/ntfs/layout.h | 19 ++ fs/ntfs/namei.c | 22 +- fs/ntfs/reparse.c | 476 +++++++++++++++++++++++++++++++++---- fs/ntfs/reparse.h | 6 +- fs/ntfs/super.c | 38 +++ fs/ntfs/volume.h | 5 + 10 files changed, 577 insertions(+), 77 deletions(-)
---
base-commit: 5aec1efb11ab2a87d1e4be063830268f7980ec4a
change-id: 20260612-topic-symlink-d70873e4721e
Best regards,
Signature · 2 lines
Thanks, Hyunchul
Hyunchul Lee
maintainerPATCH v2 1/7 ntfs: fix incorrect size of symbolic link
This patch fixes the issue where a symbolic link size is displayed as 0.
--- fs/ntfs/inode.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ntfs/inode.c +3 -0
@@ -1199,6 +1199,9 @@ static int ntfs_read_locked_inode(struct inode *vi)else vi->i_blocks = ni->allocated_size >>9 ; +if (S_ISLNK (vi->i_mode) && ni->target) + vi->i_size =strlen (ni->target); +ntfs_debug ("Done." );return 0 ; unm_err_out:
Signature · 1 line
2.43.0
Hyunchul Lee
maintainerPATCH v2 2/7 ntfs: support following Windows native symlink with relative paths
In reply to Hyunchul LeeMake ntfs_make_symlink() parse native Windows symbolic link reparse payloads when the SYMLINK_FLAG_RELATIVE bit is set. Implement the following changes:
* Add a dedicated on-disk layout definition for symbolic link reparse data.
* validate the UTF-16 name ranges before decoding them.
* convert the substitute name into the mount's NLS and normalize path separators.
--- fs/ntfs/inode.c | 36 +++++++++------- fs/ntfs/layout.h | 11 +++++ fs/ntfs/reparse.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 147 insertions(+), 27 deletions(-)
fs/ntfs/inode.c +21 -15
@@ -863,8 +863,26 @@ static int ntfs_read_locked_inode(struct inode *vi)ntfs_ea_get_wsl_inode (vi, &dev, flags); } -if (m->flags &MFT_RECORD_IS_DIRECTORY ) { +if (ni->flags &FILE_ATTR_REPARSE_POINT ) { +unsigned int mode; + + mode =ntfs_make_symlink (ni); +if (mode) + vi->i_mode |= mode; +else { + vi->i_mode &= ~S_IFLNK ; +if (m->flags &MFT_RECORD_IS_DIRECTORY ) + vi->i_mode |=S_IFDIR ; +else + vi->i_mode |=S_IFREG ; + } + }else if (m->flags &MFT_RECORD_IS_DIRECTORY ) { vi->i_mode |=S_IFDIR ; + }else { + vi->i_mode |=S_IFREG ; + } + +if (S_ISDIR (vi->i_mode)) {/* * Apply the directory permissions mask set in the mount * options.
@@ -874,18 +892,6 @@ static int ntfs_read_locked_inode(struct inode *vi)if (vi->i_nlink >1 )set_nlink (vi,1 ); }else { -if (ni->flags &FILE_ATTR_REPARSE_POINT ) { -unsigned int mode; - - mode =ntfs_make_symlink (ni); -if (mode) - vi->i_mode |= mode; -else { - vi->i_mode &= ~S_IFLNK ; - vi->i_mode |=S_IFREG ; - } - }else - vi->i_mode |=S_IFREG ;/* Apply the file permissions mask set in the mount options. */ vi->i_mode &= ~vol->fmask; }
@@ -894,7 +900,7 @@ static int ntfs_read_locked_inode(struct inode *vi)* If an attribute list is present we now have the attribute list value * in ntfs_ino->attr_list and it is ntfs_ino->attr_list_size bytes. */ -if (S_ISDIR (vi->i_mode)) { +if (m->flags &MFT_RECORD_IS_DIRECTORY ) {struct index_root *ir; view_index_meta:
@@ -1018,7 +1024,7 @@ static int ntfs_read_locked_inode(struct inode *vi) m =NULL ; ctx =NULL ;/* Setup the operations for this inode. */ -ntfs_set_vfs_operations (vi,S_IFDIR ,0 ); +ntfs_set_vfs_operations (vi, vi->i_mode,0 );if (ir->index.flags &LARGE_INDEX )NInoSetIndexAllocPresent (ni); }else {
fs/ntfs/layout.h +11 -0
@@ -2267,6 +2267,8 @@ enum { IO_REPARSE_PLUGIN_SELECT = cpu_to_le32(0xffff0fff), }; +#define SYMLINK_FLAG_RELATIVE 1 +/* * struct reparse_point - $REPARSE_POINT attribute content (0xc0)\ *
@@ -2287,6 +2289,15 @@ struct reparse_point {u8 reparse_data[]; } __packed; +struct symlink_reparse_data { +__le16 substitute_name_offset; +__le16 substitute_name_length; +__le16 print_name_offset; +__le16 print_name_length; +__le32 flags; +__le16 path_buffer[]; +} __packed; +/* * struct ea_information - $EA_INFORMATION attribute content (0xd0) *
fs/ntfs/reparse.c +115 -12
182 lines not on this page · raw message
Signature · 1 line
2.43.0
Hyunchul Lee
maintainerPATCH v2 3/7 ntfs: support following Windows native symlink with absolute paths
In reply to Hyunchul LeeExtend reparse-point handling beyond relative symlinks so NTFS can expose the Windows absolute forms used by non-relative symbolic links and junctions.
* Store the reparse tag and symlink flags in the inode.
* Validate junction payloads, and parse targets from substitute_name.
* Add function to rewrite supported Windows absolute path into Linux path relative to the mounted NTFS volume.
--- fs/ntfs/file.c | 22 ++++++- fs/ntfs/inode.c | 2 + fs/ntfs/inode.h | 2 + fs/ntfs/layout.h | 8 +++ fs/ntfs/reparse.c | 194 +++++++++++++++++++++++++++++++++++++++++++++++++----- fs/ntfs/reparse.h | 2 + 6 files changed, 212 insertions(+), 18 deletions(-)
fs/ntfs/file.c +20 -2
@@ -675,10 +675,28 @@ static int ntfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,static const char *ntfs_get_link (struct dentry *dentry,struct inode *inode,struct delayed_call *done) { -if (!NTFS_I (inode)->target) +struct ntfs_inode *ni =NTFS_I (inode); +char *target; +int err; + +if (!dentry) +return ERR_PTR (-ECHILD ); + +if (!ni->target)return ERR_PTR (-EINVAL ); -return NTFS_I (inode)->target; +if (ni->reparse_tag ==IO_REPARSE_TAG_MOUNT_POINT || + (ni->reparse_tag ==IO_REPARSE_TAG_SYMLINK && + !(ni->reparse_flags &cpu_to_le32 (SYMLINK_FLAG_RELATIVE )))) { + err =ntfs_translate_symlink_path (dentry, ni->target, &target); +if (err <0 ) +return ERR_PTR (err); + +set_delayed_call (done, kfree_link, target); +return target; + } + +return ni->target; } static ssize_t ntfs_file_splice_read(struct file *in, loff_t *ppos,
fs/ntfs/inode.c +2 -0
@@ -488,6 +488,8 @@ void __ntfs_init_inode(struct super_block *sb, struct ntfs_inode *ni) ni->flags =0 ; ni->mft_lcn[0 ] =LCN_RL_NOT_MAPPED ; ni->mft_lcn_count =0 ; + ni->reparse_tag =0 ; + ni->reparse_flags =0 ; ni->target =NULL ; ni->i_dealloc_clusters =0 ; }
fs/ntfs/inode.h +2 -0
@@ -142,6 +142,8 @@ struct ntfs_inode {struct ntfs_inode *base_ntfs_ino; } ext;unsigned int i_dealloc_clusters; +__le32 reparse_tag; +__le32 reparse_flags;char *target; };
fs/ntfs/layout.h +8 -0
@@ -2289,6 +2289,14 @@ struct reparse_point {u8 reparse_data[]; } __packed; +struct mount_point_reparse_data { +__le16 substitute_name_offset; +__le16 substitute_name_length; +__le16 print_name_offset; +__le16 print_name_length; +__le16 path_buffer[]; +} __packed; +struct symlink_reparse_data {__le16 substitute_name_offset;__le16 substitute_name_length;
fs/ntfs/reparse.c +178 -16
278 lines not on this page · raw message
fs/ntfs/reparse.h +2 -0
@@ -11,6 +11,8 @@ extern __le16 reparse_index_name[];unsigned int ntfs_make_symlink (struct ntfs_inode *ni);unsigned int ntfs_reparse_tag_dt_types (struct ntfs_volume *vol,unsigned long mref); +int ntfs_translate_symlink_path (struct dentry *dentry,const char *target, +char **translated);int ntfs_reparse_set_wsl_symlink (struct ntfs_inode *ni,const __le16 *target,int target_len);int ntfs_reparse_set_wsl_not_symlink (struct ntfs_inode *ni,mode_t mode);
Signature · 1 line
2.43.0
Hyunchul Lee
maintainerPATCH v2 4/7 ntfs: add native_symlink mount option
In reply to Hyunchul LeeBecause bind-mounted subtrees of the volume may resolve to unexpected locations, change converting junctions and non-relative symbolic links into paths relative to the NTFS volume to be allowed only if the native_symlink=rel mount option is specified.
Add the native_symlink=<value> mount option to configure how absolute symbolic links and mount points (junctions) are handled. The option accepts "raw" or "rel", with "raw" being the default.
Under "raw", the absolute target path (ni->target) is returned as-is without translation. Under "rel", ntfs_translate_junction() is called to rewrite the absolute path as a relative path anchored at the volume root.
--- fs/ntfs/file.c | 14 ++++++++------ fs/ntfs/inode.c | 4 ++++ fs/ntfs/super.c | 19 +++++++++++++++++++ fs/ntfs/volume.h | 3 +++ 4 files changed, 34 insertions(+), 6 deletions(-)
fs/ntfs/file.c +8 -6
@@ -22,6 +22,7 @@#include "ea.h" #include "iomap.h" #include "bitmap.h" +#include "volume.h" #include <linux/filelock.h>
@@ -688,12 +689,13 @@ static const char *ntfs_get_link(struct dentry *dentry, struct inode *inode,if (ni->reparse_tag ==IO_REPARSE_TAG_MOUNT_POINT || (ni->reparse_tag ==IO_REPARSE_TAG_SYMLINK && !(ni->reparse_flags &cpu_to_le32 (SYMLINK_FLAG_RELATIVE )))) { - err =ntfs_translate_symlink_path (dentry, ni->target, &target); -if (err <0 ) -return ERR_PTR (err); - -set_delayed_call (done, kfree_link, target); -return target; +if (NVolNativeSymlinkRel (ni->vol)) { + err =ntfs_translate_symlink_path (dentry, ni->target, &target); +if (err <0 ) +return ERR_PTR (err); +set_delayed_call (done, kfree_link, target); +return target; + } }return ni->target;
fs/ntfs/inode.c +4 -0
@@ -2378,6 +2378,10 @@ int ntfs_show_options(struct seq_file *sf, struct dentry *root)seq_puts (sf,",discard" );if (NVolDisableSparse (vol))seq_puts (sf,",disable_sparse" ); +if (NVolNativeSymlinkRel (vol)) +seq_puts (sf,",native_symlink=rel" ); +else +seq_puts (sf,",native_symlink=raw" );if (vol->sb->s_flags &SB_POSIXACL )seq_puts (sf,",acl" );return 0 ;
fs/ntfs/super.c +19 -0
@@ -43,6 +43,17 @@ static const struct constant_table ntfs_param_enums[] = { {} }; +enum { +NATIVE_SYMLINK_RAW , +NATIVE_SYMLINK_REL , +}; + +static const struct constant_table ntfs_native_symlink_enums[] = { + {"raw" ,NATIVE_SYMLINK_RAW }, + {"rel" ,NATIVE_SYMLINK_REL }, + {} +}; +enum { Opt_uid, Opt_gid,
@@ -66,6 +77,7 @@ enum { Opt_acl, Opt_discard, Opt_nocase, + Opt_native_symlink, }; static const struct fs_parameter_spec ntfs_parameters[] = {
@@ -91,6 +103,7 @@ static const struct fs_parameter_spec ntfs_parameters[] = {fsparam_flag ("discard" , Opt_discard),fsparam_flag ("sparse" , Opt_sparse),fsparam_flag ("nocase" , Opt_nocase), + fsparam_enum("native_symlink", Opt_native_symlink, ntfs_native_symlink_enums), {} };
@@ -215,6 +228,12 @@ static int ntfs_parse_param(struct fs_context *fc, struct fs_parameter *param)else NVolClearDisableSparse (vol);break ; +case Opt_native_symlink: +if (result.uint_32 ==NATIVE_SYMLINK_REL ) +NVolSetNativeSymlinkRel (vol); +else +NVolClearNativeSymlinkRel (vol); +break ;case Opt_sparse:break ;default :
fs/ntfs/volume.h +3 -0
@@ -177,6 +177,7 @@ struct ntfs_volume {* * NV_Discard Issue discard/TRIM commands for freed clusters. * NV_DisableSparse Disable creation of sparse regions. +* NV_NativeSymlinkRel Translate absolute Windows reparse targets (native_symlink=rel). */ enum { NV_Errors,
@@ -194,6 +195,7 @@ enum { NV_CheckWindowsNames, NV_Discard, NV_DisableSparse, + NV_NativeSymlinkRel, };/*
@@ -230,6 +232,7 @@ DEFINE_NVOL_BIT_OPS(HideDotFiles)DEFINE_NVOL_BIT_OPS (CheckWindowsNames)DEFINE_NVOL_BIT_OPS (Discard )DEFINE_NVOL_BIT_OPS (DisableSparse) +DEFINE_NVOL_BIT_OPS (NativeSymlinkRel) static inline void ntfs_inc_free_clusters(struct ntfs_volume *vol, s64 nr) {
Signature · 1 line
2.43.0
Hyunchul Lee
maintainerPATCH v2 5/7 ntfs: clean up target name conversion for WSL symlinks
In reply to Hyunchul LeeWSL symlink target names are stored as narrow NLS/UTF-8 strings on disk. Converting the target name to Unicode in ntfs_symlink and converting it back to NLS in ntfs_reparse_set_wsl_symlink is redundant.
Remove this conversion and pass the symname directly to the reparse data setter.
--- fs/ntfs/namei.c | 17 ++--------------- fs/ntfs/reparse.c | 56 +++++++++++++++++++++++++++---------------------------- fs/ntfs/reparse.h | 2 +- 3 files changed, 30 insertions(+), 45 deletions(-)
fs/ntfs/namei.c +2 -15
@@ -394,7 +394,7 @@ static int ntfs_sd_add_everyone(struct ntfs_inode *ni)static struct ntfs_inode *__ntfs_create (struct mnt_idmap *idmap,struct inode *dir,__le16 *name,u8 name_len,mode_t mode,dev_t dev, -__le16 *target,int target_len) +const char *target,int target_len) {struct ntfs_inode *dir_ni =NTFS_I (dir);struct ntfs_volume *vol = dir_ni->vol;
@@ -1409,9 +1409,7 @@ static int ntfs_symlink(struct mnt_idmap *idmap, struct inode *dir,int err =0 ;struct ntfs_inode *ni;__le16 *usrc; -__le16 *utarget;int usrc_len; -int utarget_len;int symlen =strlen (symname);if (NVolShutdown (vol))
@@ -1432,23 +1430,12 @@ static int ntfs_symlink(struct mnt_idmap *idmap, struct inode *dir, goto out; } - utarget_len =ntfs_nlstoucs (vol, symname, symlen, &utarget, -PATH_MAX ); -if (utarget_len <0 ) { -if (utarget_len != -ENAMETOOLONG ) -ntfs_error (sb,"Failed to convert target name to Unicode." ); - err = -ENOMEM ; -kmem_cache_free (ntfs_name_cache, usrc); - goto out; - } -if (!(vol->vol_flags &VOLUME_IS_DIRTY ))ntfs_set_volume_flags (vol,VOLUME_IS_DIRTY ); ni =__ntfs_create (idmap, dir, usrc, usrc_len,S_IFLNK |0777 ,0 , - utarget, utarget_len); + symname, symlen);kmem_cache_free (ntfs_name_cache, usrc); -kvfree (utarget);if (IS_ERR (ni)) { err =PTR_ERR (ni); goto out;
fs/ntfs/reparse.c +27 -29
70 lines not on this page · raw message
fs/ntfs/reparse.h +1 -1
@@ -14,7 +14,7 @@ unsigned int ntfs_reparse_tag_dt_types(struct ntfs_volume *vol, unsigned long mrint ntfs_translate_symlink_path (struct dentry *dentry,const char *target,char **translated);int ntfs_reparse_set_wsl_symlink (struct ntfs_inode *ni, -const __le16 *target,int target_len); +const char *target,int target_len);int ntfs_reparse_set_wsl_not_symlink (struct ntfs_inode *ni,mode_t mode);int ntfs_delete_reparse_index (struct ntfs_inode *ni);int ntfs_remove_ntfs_reparse_data (struct ntfs_inode *ni);
Signature · 1 line
2.43.0
Hyunchul Lee
maintainerPATCH v2 6/7 ntfs: support creating Windows native symlinks
In reply to Hyunchul LeeAnd introduce the symlink=<value> mount option to configure how symbolic links are created. The option accepts "wsl" or "native", with "wsl" being the default.
--- fs/ntfs/inode.c | 4 ++ fs/ntfs/namei.c | 5 ++- fs/ntfs/reparse.c | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++- fs/ntfs/reparse.h | 2 + fs/ntfs/super.c | 19 ++++++++ fs/ntfs/volume.h | 2 + 6 files changed, 160 insertions(+), 3 deletions(-)
fs/ntfs/inode.c +4 -0
@@ -2382,6 +2382,10 @@ int ntfs_show_options(struct seq_file *sf, struct dentry *root)seq_puts (sf,",native_symlink=rel" ); else seq_puts(sf, ",native_symlink=raw"); + if (NVolSymlinkNative(vol)) +seq_puts (sf,",symlink=native" ); + else + seq_puts(sf, ",symlink=wsl"); if (vol->sb->s_flags & SB_POSIXACL)seq_puts (sf,",acl" );return 0 ;
fs/ntfs/namei.c +4 -1
@@ -608,7 +608,10 @@ static struct ntfs_inode *__ntfs_create(struct mnt_idmap *idmap, struct inode *d goto err_out;if (S_ISLNK (mode)) { - err =ntfs_reparse_set_wsl_symlink (ni, target, target_len); +if (NVolSymlinkNative (vol)) + err =ntfs_reparse_set_native_symlink (ni, target, target_len); +else + err =ntfs_reparse_set_wsl_symlink (ni, target, target_len);if (!err) rollback_reparse = true; } else if (S_ISBLK(mode) || S_ISCHR(mode) || S_ISSOCK(mode) ||
fs/ntfs/reparse.c +129 -2
149 lines not on this page · raw message
fs/ntfs/reparse.h +2 -0
@@ -15,6 +15,8 @@ int ntfs_translate_symlink_path(struct dentry *dentry, const char *target, char **translated);int ntfs_reparse_set_wsl_symlink (struct ntfs_inode *ni,const char *target,int target_len); +int ntfs_reparse_set_native_symlink (struct ntfs_inode *ni, +const char *symname,int symlen);int ntfs_reparse_set_wsl_not_symlink (struct ntfs_inode *ni,mode_t mode);int ntfs_delete_reparse_index (struct ntfs_inode *ni);int ntfs_remove_ntfs_reparse_data (struct ntfs_inode *ni);
fs/ntfs/super.c +19 -0
@@ -54,6 +54,17 @@ static const struct constant_table ntfs_native_symlink_enums[] = { {} }; +enum { +SYMLINK_WSL , +SYMLINK_NATIVE , +}; + +static const struct constant_table ntfs_symlink_enums[] = { + {"wsl" ,SYMLINK_WSL }, + {"native" ,SYMLINK_NATIVE }, + {} +}; +enum { Opt_uid, Opt_gid,
@@ -78,6 +89,7 @@ enum { Opt_discard, Opt_nocase, Opt_native_symlink, + Opt_symlink, }; static const struct fs_parameter_spec ntfs_parameters[] = {
@@ -104,6 +116,7 @@ static const struct fs_parameter_spec ntfs_parameters[] = {fsparam_flag ("sparse" , Opt_sparse),fsparam_flag ("nocase" , Opt_nocase),fsparam_enum ("native_symlink" , Opt_native_symlink, ntfs_native_symlink_enums), + fsparam_enum("symlink", Opt_symlink, ntfs_symlink_enums), {} };
@@ -234,6 +247,12 @@ static int ntfs_parse_param(struct fs_context *fc, struct fs_parameter *param)else NVolClearNativeSymlinkRel (vol);break ; +case Opt_symlink: +if (result.uint_32 ==SYMLINK_NATIVE ) +NVolSetSymlinkNative (vol); +else +NVolClearSymlinkNative (vol); +break ;case Opt_sparse:break ;default :
fs/ntfs/volume.h +2 -0
@@ -196,6 +196,7 @@ enum { NV_Discard, NV_DisableSparse, NV_NativeSymlinkRel, + NV_SymlinkNative, };/*
@@ -233,6 +234,7 @@ DEFINE_NVOL_BIT_OPS(CheckWindowsNames)DEFINE_NVOL_BIT_OPS (Discard)DEFINE_NVOL_BIT_OPS (DisableSparse )DEFINE_NVOL_BIT_OPS (NativeSymlinkRel) +DEFINE_NVOL_BIT_OPS (SymlinkNative) static inline void ntfs_inc_free_clusters(struct ntfs_volume *vol, s64 nr) {
Signature · 1 line
2.43.0
Hyunchul Lee
maintainerPATCH v2 7/7 docs/fs/ntfs: add mount options to support Windows native symbolic links
In reply to Hyunchul LeeIntroduce the "symlink=<value>" and the "native_symlink=<value>" mount options to configure the creation behavior of symbolic links and support creating Windows native symbolic links (reparse points with the IO_REPARSE_TAG_SYMLINK tag).
--- Documentation/filesystems/ntfs.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+)
Documentation/filesystems/ntfs.rst +13 -0
@@ -156,4 +156,17 @@ windows_names=<BOOL> Refuse creation/rename of files with characters or discard=<BOOL> Issue block device discard for clusters freed on file deletion/truncation to inform underlying storage. + +native_symlink=raw|rel Configure how absolute symbolic links and mount + points (junctions) are handled. Under "raw" + (default), the absolute target path is returned + as-is without translation. Under "rel", it is + rewritten as a relative path anchored at + the volume root. + +symlink=wsl|native Configure how symbolic links are created. Under + "wsl" (default), WSL (Windows Subsystem for + Linux) compatible symlinks are created. Under + "native", Windows native symbolic links are + created. ======================= ====================================================
Signature · 1 line
2.43.0
Quoted 43 lines · Hyunchul Lee
This patch series adds support for Windows native symbolic links and introduces mount options to configure how symbolic links are resolved and created.
Currently, the NTFS driver creates WSL-compatible symbolic links and has limited support for native Windows symbolic links. This series addresses these limitations.
1. Following/Resolving Symlinks & Junctions:
- Add support for parsing and following Windows native symbolic links.
- Introduce the "native_symlink=raw|rel" mount option to configure absolute target resolution.2. Creating Symlinks:
- Introduce the "symlink=wsl|native" mount option to choose the creation behavior of symlinks. Under "native", Windows native symbolic links are created by converting the target path to UTF-16 Windows format.3. Fixes & Cleanups:
- Fix an issue where the size of symbolic links is reported as 0.
- Clean up target name conversion for WSL symlinks by avoiding redundant conversion.4. Documentation:
- Document the newly introduced mount options inntfs.rst.Changes since v1:
- Add a boundary check to verify that reparse point attribute size is at least the size of thereparse_point.
- Fix target inode fields (reparse_tag,reparse_flags) not being updatedntfs_reparse_set_wsl_symlink(),ntfs_reparse_set_wsl_not_symlink(), andntfs_set_ntfs_reparse_data().
- Improve absolute path validation inntfs_reparse_set_native_symlink()by ensuring that absolute paths actually start with a valid drive letter and a path separator.
- Optimize memory allocations inntfs_reparse_set_native_symlink()by sharing the same buffer for print name and substitute name in the relative symlink path.Signed-off-by Hyunchul Lee <[email protected]>
Quoted 9 lines
---
Hyunchul Lee (7):
ntfs: fix incorrect size of symbolic link
ntfs: support following Windows native symlink with relative paths
ntfs: support following Windows native symlink with absolute paths
ntfs: addnative_symlinkmount option
ntfs: clean up target name conversion for WSL symlinks
ntfs: support creating Windows native symlinks docs/fs/ntfs: add mount options to support Windows native symbolic links
Applied them to #ntfs-next.
Thanks!