From 911ecba5e260045b48bacf637fddd73b383ff57a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Wed, 21 Mar 2012 19:19:39 +0100 Subject: [PATCH] Set the hidden flag according to the latest name when hide_dot_files is set When the hide_dot_files option is set, a file is marked hidden if the first character in its name is a dot. This patch updates the hidden flag when the file is renamed or hard linked (useful for text editors which create files with a temporary name) --- libntfs-3g/dir.c | 9 +++++++++ src/ntfs-3g.8.in | 2 ++ 2 files changed, 11 insertions(+) diff --git a/libntfs-3g/dir.c b/libntfs-3g/dir.c index b0d50931..e015db9d 100644 --- a/libntfs-3g/dir.c +++ b/libntfs-3g/dir.c @@ -2075,6 +2075,15 @@ static int ntfs_link_i(ntfs_inode *ni, ntfs_inode *dir_ni, ntfschar *name, err = EOPNOTSUPP; goto err_out; } + if (NVolHideDotFiles(dir_ni->vol)) { + /* Set hidden flag according to the latest name */ + if ((name_len > 1) + && (name[0] == const_cpu_to_le16('.')) + && (name[1] != const_cpu_to_le16('.'))) + ni->flags |= FILE_ATTR_HIDDEN; + else + ni->flags &= ~FILE_ATTR_HIDDEN; + } /* Create FILE_NAME attribute. */ fn_len = sizeof(FILE_NAME_ATTR) + name_len * sizeof(ntfschar); diff --git a/src/ntfs-3g.8.in b/src/ntfs-3g.8.in index 9714ba16..bacb5925 100644 --- a/src/ntfs-3g.8.in +++ b/src/ntfs-3g.8.in @@ -227,6 +227,8 @@ Set the hidden flag in the NTFS attribute for created files and directories whose first character of the name is a dot. Such files and directories normally do not appear in directory listings, and when the flag is set they do not appear in Windows directory displays either. +When a file is renamed or linked with a new name, the hidden flag is +adjusted to the latest name. .TP .B windows_names This option prevents files, directories and extended attributes to be