OSDN Git Service

Set the hidden flag according to the latest name when hide_dot_files is set
authorJean-Pierre André <jpandre@users.sourceforge.net>
Wed, 21 Mar 2012 18:19:39 +0000 (19:19 +0100)
committerJean-Pierre André <jpandre@users.sourceforge.net>
Wed, 21 Mar 2012 18:19:39 +0000 (19:19 +0100)
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
src/ntfs-3g.8.in

index b0d5093..e015db9 100644 (file)
@@ -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);
index 9714ba1..bacb592 100644 (file)
@@ -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