Commit 9a79574a authored by Erich E. Hoover's avatar Erich E. Hoover Committed by Vitaly Lipatov

ntdll: Perform the Unix-style hidden file check within the unified file info grabbing routine.

parent bbf5d35e
...@@ -1311,15 +1311,15 @@ static BOOLEAN get_dir_case_sensitivity( const char *dir ) ...@@ -1311,15 +1311,15 @@ static BOOLEAN get_dir_case_sensitivity( const char *dir )
* *
* Check if the specified file should be hidden based on its name and the show dot files option. * Check if the specified file should be hidden based on its name and the show dot files option.
*/ */
static BOOL is_hidden_file( const UNICODE_STRING *name ) static BOOL is_hidden_file( const char *name )
{ {
WCHAR *p, *end; const char *p, *end;
if (show_dot_files) return FALSE; if (show_dot_files) return FALSE;
end = p = name->Buffer + name->Length/sizeof(WCHAR); end = p = name + strlen( name );
while (p > name->Buffer && p[-1] == '\\') p--; while (p > name && p[-1] == '\\') p--;
while (p > name->Buffer && p[-1] != '\\') p--; while (p > name && p[-1] != '\\') p--;
return (p < end && *p == '.'); return (p < end && *p == '.');
} }
...@@ -1662,6 +1662,10 @@ static int get_file_info( const char *path, struct stat *st, ULONG *attr ) ...@@ -1662,6 +1662,10 @@ static int get_file_info( const char *path, struct stat *st, ULONG *attr )
free( parent_path ); free( parent_path );
} }
*attr |= get_file_attributes( st ); *attr |= get_file_attributes( st );
/* convert Unix-style hidden files to a DOS hidden file attribute */
if (is_hidden_file( path ))
*attr |= FILE_ATTRIBUTE_HIDDEN;
/* retrieve any stored DOS attributes */
len = xattr_get( path, SAMBA_XATTR_DOS_ATTRIB, hexattr, sizeof(hexattr)-1 ); len = xattr_get( path, SAMBA_XATTR_DOS_ATTRIB, hexattr, sizeof(hexattr)-1 );
if (len == -1) return ret; if (len == -1) return ret;
*attr |= get_file_xattr( hexattr, len ); *attr |= get_file_xattr( hexattr, len );
...@@ -2190,11 +2194,6 @@ static NTSTATUS get_dir_data_entry( struct dir_data *dir_data, void *info_ptr, I ...@@ -2190,11 +2194,6 @@ static NTSTATUS get_dir_data_entry( struct dir_data *dir_data, void *info_ptr, I
if (class != FileNamesInformation) if (class != FileNamesInformation)
{ {
if (st.st_dev != dir_data->id.dev) st.st_ino = 0; /* ignore inode if on a different device */ if (st.st_dev != dir_data->id.dev) st.st_ino = 0; /* ignore inode if on a different device */
if (!show_dot_files && names->long_name[0] == '.' && names->long_name[1] &&
(names->long_name[1] != '.' || names->long_name[2]))
attributes |= FILE_ATTRIBUTE_HIDDEN;
fill_file_info( &st, attributes, info, class ); fill_file_info( &st, attributes, info, class );
} }
...@@ -4158,7 +4157,6 @@ NTSTATUS WINAPI NtQueryFullAttributesFile( const OBJECT_ATTRIBUTES *attr, ...@@ -4158,7 +4157,6 @@ NTSTATUS WINAPI NtQueryFullAttributesFile( const OBJECT_ATTRIBUTES *attr,
info->AllocationSize = std.AllocationSize; info->AllocationSize = std.AllocationSize;
info->EndOfFile = std.EndOfFile; info->EndOfFile = std.EndOfFile;
info->FileAttributes = basic.FileAttributes; info->FileAttributes = basic.FileAttributes;
if (is_hidden_file( attr->ObjectName )) info->FileAttributes |= FILE_ATTRIBUTE_HIDDEN;
} }
free( unix_name ); free( unix_name );
} }
...@@ -4189,10 +4187,7 @@ NTSTATUS WINAPI NtQueryAttributesFile( const OBJECT_ATTRIBUTES *attr, FILE_BASIC ...@@ -4189,10 +4187,7 @@ NTSTATUS WINAPI NtQueryAttributesFile( const OBJECT_ATTRIBUTES *attr, FILE_BASIC
else if (!S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode)) else if (!S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode))
status = STATUS_INVALID_INFO_CLASS; status = STATUS_INVALID_INFO_CLASS;
else else
{
status = fill_file_info( &st, attributes, info, FileBasicInformation ); status = fill_file_info( &st, attributes, info, FileBasicInformation );
if (is_hidden_file( attr->ObjectName )) info->FileAttributes |= FILE_ATTRIBUTE_HIDDEN;
}
free( unix_name ); free( unix_name );
} }
else WARN( "%s not found (%x)\n", debugstr_us(attr->ObjectName), status ); else WARN( "%s not found (%x)\n", debugstr_us(attr->ObjectName), status );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment