From 8e33b21e3450e14dad6a72ecf934045c406077ea Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Thu, 21 Sep 2017 09:45:23 +0000 Subject: [PATCH] [FASTFAT] Misc fixes: - Only set file attributes if they changed - Fail to set attributes if directory attribute is asked for a file - Perform file attributes setting before dates to allow safe fail svn path=/trunk/; revision=75917 --- reactos/drivers/filesystems/fastfat/finfo.c | 42 +++++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/reactos/drivers/filesystems/fastfat/finfo.c b/reactos/drivers/filesystems/fastfat/finfo.c index 1396430d40d..418e94d9e76 100644 --- a/reactos/drivers/filesystems/fastfat/finfo.c +++ b/reactos/drivers/filesystems/fastfat/finfo.c @@ -165,6 +165,36 @@ VfatSetBasicInformation( /* Check volume label bit */ ASSERT(0 == (*FCB->Attributes & _A_VOLID)); + if (BasicInfo->FileAttributes != 0) + { + UCHAR Attributes; + + Attributes = (BasicInfo->FileAttributes & (FILE_ATTRIBUTE_ARCHIVE | + FILE_ATTRIBUTE_SYSTEM | + FILE_ATTRIBUTE_HIDDEN | + FILE_ATTRIBUTE_DIRECTORY | + FILE_ATTRIBUTE_READONLY)); + + if (vfatFCBIsDirectory(FCB)) + { + Attributes |= FILE_ATTRIBUTE_DIRECTORY; + } + else + { + if (BooleanFlagOn(BasicInfo->FileAttributes, FILE_ATTRIBUTE_DIRECTORY)) + { + DPRINT("Setting directory attribute on a file!\n"); + return STATUS_INVALID_PARAMETER; + } + } + + if (Attributes != *FCB->Attributes) + { + *FCB->Attributes = Attributes; + DPRINT("Setting attributes 0x%02x\n", *FCB->Attributes); + } + } + if (vfatVolumeIsFatX(DeviceExt)) { if (BasicInfo->CreationTime.QuadPart != 0 && BasicInfo->CreationTime.QuadPart != -1) @@ -218,18 +248,6 @@ VfatSetBasicInformation( } } - if (BasicInfo->FileAttributes) - { - *FCB->Attributes = (unsigned char)((*FCB->Attributes & - (FILE_ATTRIBUTE_DIRECTORY | 0x48)) | - (BasicInfo->FileAttributes & - (FILE_ATTRIBUTE_ARCHIVE | - FILE_ATTRIBUTE_SYSTEM | - FILE_ATTRIBUTE_HIDDEN | - FILE_ATTRIBUTE_READONLY))); - DPRINT("Setting attributes 0x%02x\n", *FCB->Attributes); - } - VfatUpdateEntry(FCB, vfatVolumeIsFatX(DeviceExt)); return STATUS_SUCCESS;