Author: pschweitzer
Date: Thu Sep 21 09:45:23 2017
New Revision: 75917
URL:
http://svn.reactos.org/svn/reactos?rev=75917&view=rev
Log:
[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
Modified:
trunk/reactos/drivers/filesystems/fastfat/finfo.c
Modified: trunk/reactos/drivers/filesystems/fastfat/finfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/finfo.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/finfo.c [iso-8859-1] Thu Sep 21 09:45:23
2017
@@ -165,6 +165,36 @@
/* 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)
@@ -216,18 +246,6 @@
&FCB->entry.Fat.UpdateDate,
&FCB->entry.Fat.UpdateTime);
}
- }
-
- 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));