Author: pschweitzer
Date: Fri Feb 17 17:58:18 2017
New Revision: 73819
URL:
http://svn.reactos.org/svn/reactos?rev=73819&view=rev
Log:
[FASTFAT]
More FastFAT cleanup.
Except a light performances boost due to useless checks removal in read/write and to some
functions inlining
More to follow...
Modified:
trunk/reactos/drivers/filesystems/fastfat/blockdev.c
trunk/reactos/drivers/filesystems/fastfat/cleanup.c
trunk/reactos/drivers/filesystems/fastfat/close.c
trunk/reactos/drivers/filesystems/fastfat/create.c
trunk/reactos/drivers/filesystems/fastfat/dir.c
trunk/reactos/drivers/filesystems/fastfat/direntry.c
trunk/reactos/drivers/filesystems/fastfat/dirwr.c
trunk/reactos/drivers/filesystems/fastfat/fastio.c
trunk/reactos/drivers/filesystems/fastfat/fcb.c
trunk/reactos/drivers/filesystems/fastfat/finfo.c
trunk/reactos/drivers/filesystems/fastfat/flush.c
trunk/reactos/drivers/filesystems/fastfat/fsctl.c
trunk/reactos/drivers/filesystems/fastfat/misc.c
trunk/reactos/drivers/filesystems/fastfat/rw.c
trunk/reactos/drivers/filesystems/fastfat/vfat.h
trunk/reactos/drivers/filesystems/fastfat/volume.c
Modified: trunk/reactos/drivers/filesystems/fastfat/blockdev.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/blockdev.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/blockdev.c [iso-8859-1] Fri Feb 17 17:58:18
2017
@@ -56,7 +56,7 @@
}
if (0 == InterlockedDecrement((PLONG)&IrpContext->RefCount) &&
- IrpContext->Flags & IRPCONTEXT_PENDINGRETURNED)
+ BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_PENDINGRETURNED))
{
KeSetEvent(&IrpContext->Event, IO_NO_INCREMENT, FALSE);
}
Modified: trunk/reactos/drivers/filesystems/fastfat/cleanup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/cleanup.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/cleanup.c [iso-8859-1] Fri Feb 17 17:58:18
2017
@@ -35,7 +35,7 @@
if (!pFcb)
return STATUS_SUCCESS;
- if (pFcb->Flags & FCB_IS_VOLUME)
+ if (BooleanFlagOn(pFcb->Flags, FCB_IS_VOLUME))
{
pFcb->OpenHandleCount--;
@@ -76,12 +76,12 @@
NULL);
}
- if (pFcb->Flags & FCB_IS_DIRTY)
+ if (BooleanFlagOn(pFcb->Flags, FCB_IS_DIRTY))
{
VfatUpdateEntry (pFcb);
}
- if (pFcb->Flags & FCB_DELETE_PENDING &&
+ if (BooleanFlagOn(pFcb->Flags, FCB_DELETE_PENDING) &&
pFcb->OpenHandleCount == 0)
{
if (vfatFCBIsDirectory(pFcb) &&
@@ -109,7 +109,7 @@
/* Uninitialize the cache (should be done even if caching was never initialized)
*/
CcUninitializeCacheMap(FileObject, &pFcb->RFCB.FileSize, NULL);
- if (pFcb->Flags & FCB_DELETE_PENDING &&
+ if (BooleanFlagOn(pFcb->Flags, FCB_DELETE_PENDING) &&
pFcb->OpenHandleCount == 0)
{
VfatDelEntry(DeviceExt, pFcb, NULL);
@@ -120,8 +120,8 @@
pFcb->PathNameU.Length -
pFcb->LongNameU.Length,
NULL,
NULL,
- ((*pFcb->Attributes &
FILE_ATTRIBUTE_DIRECTORY) ?
- FILE_NOTIFY_CHANGE_DIR_NAME :
FILE_NOTIFY_CHANGE_FILE_NAME),
+ VfatIsDirectoryEmpty(pFcb) ?
+ FILE_NOTIFY_CHANGE_DIR_NAME :
FILE_NOTIFY_CHANGE_FILE_NAME,
FILE_ACTION_REMOVED,
NULL);
}
@@ -138,7 +138,7 @@
}
#ifdef ENABLE_SWAPOUT
- if (DeviceExt->Flags & VCB_DISMOUNT_PENDING)
+ if (BooleanFlagOn(DeviceExt->Flags, VCB_DISMOUNT_PENDING))
{
VfatCheckForDismount(DeviceExt, FALSE);
}
Modified: trunk/reactos/drivers/filesystems/fastfat/close.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/close.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/close.c [iso-8859-1] Fri Feb 17 17:58:18
2017
@@ -39,7 +39,7 @@
return STATUS_SUCCESS;
}
- if (pFcb->Flags & FCB_IS_VOLUME)
+ if (BooleanFlagOn(pFcb->Flags, FCB_IS_VOLUME))
{
DPRINT("Volume\n");
FileObject->FsContext2 = NULL;
Modified: trunk/reactos/drivers/filesystems/fastfat/create.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/create.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/create.c [iso-8859-1] Fri Feb 17 17:58:18
2017
@@ -57,7 +57,7 @@
RtlOemStringToUnicodeString(NameU, &StringA, FALSE);
- if (pEntry->lCase & VFAT_CASE_LOWER_BASE)
+ if (BooleanFlagOn(pEntry->lCase, VFAT_CASE_LOWER_BASE))
{
RtlDowncaseUnicodeString(NameU, NameU, FALSE);
}
@@ -81,7 +81,7 @@
StringA.Length++);
StringA.MaximumLength = StringA.Length;
RtlOemStringToUnicodeString(NameU, &StringA, FALSE);
- if (pEntry->lCase & VFAT_CASE_LOWER_EXT)
+ if (BooleanFlagOn(pEntry->lCase, VFAT_CASE_LOWER_EXT))
{
RtlDowncaseUnicodeString(NameU, NameU, FALSE);
}
@@ -119,7 +119,7 @@
*(Vpb->VolumeLabel) = 0;
Vpb->VolumeLabelLength = 0;
- if (DeviceExt->Flags & VCB_IS_FATX)
+ if (BooleanFlagOn(DeviceExt->Flags, VCB_IS_FATX))
{
SizeDirEntry = sizeof(FATX_DIR_ENTRY);
EntriesPerPage = FATX_ENTRIES_PER_PAGE;
@@ -151,7 +151,7 @@
if (ENTRY_VOLUME(DeviceExt, Entry))
{
/* copy volume label */
- if (DeviceExt->Flags & VCB_IS_FATX)
+ if (BooleanFlagOn(DeviceExt->Flags, VCB_IS_FATX))
{
StringO.Buffer = (PCHAR)Entry->FatX.Filename;
StringO.MaximumLength = StringO.Length =
Entry->FatX.FilenameLength;
@@ -259,7 +259,7 @@
if (rcFcb)
{
ULONG startIndex = rcFcb->startIndex;
- if ((rcFcb->Flags & FCB_IS_FATX_ENTRY) &&
!vfatFCBIsRoot(Parent))
+ if (BooleanFlagOn(rcFcb->Flags, FCB_IS_FATX_ENTRY) &&
!vfatFCBIsRoot(Parent))
{
startIndex += 2;
}
@@ -436,7 +436,7 @@
}
/* Fail, if we try to overwrite an existing directory */
- if ((!(RequestedOptions & FILE_DIRECTORY_FILE) && (*Fcb->Attributes
& FILE_ATTRIBUTE_DIRECTORY)) &&
+ if ((!BooleanFlagOn(RequestedOptions, FILE_DIRECTORY_FILE) &&
vfatFCBIsDirectory(Fcb)) &&
(RequestedDisposition == FILE_OVERWRITE ||
RequestedDisposition == FILE_OVERWRITE_IF ||
RequestedDisposition == FILE_SUPERSEDE))
@@ -445,14 +445,14 @@
return STATUS_OBJECT_NAME_COLLISION;
}
- if (Fcb->Flags & FCB_DELETE_PENDING)
+ if (BooleanFlagOn(Fcb->Flags, FCB_DELETE_PENDING))
{
vfatReleaseFCB(DeviceExt, Fcb);
return STATUS_DELETE_PENDING;
}
/* Fail, if we try to overwrite a read-only file */
- if ((*Fcb->Attributes & FILE_ATTRIBUTE_READONLY) &&
+ if (vfatFCBIsReadOnly(Fcb) &&
(RequestedDisposition == FILE_OVERWRITE ||
RequestedDisposition == FILE_OVERWRITE_IF))
{
@@ -460,7 +460,7 @@
return STATUS_ACCESS_DENIED;
}
- if ((*Fcb->Attributes & FILE_ATTRIBUTE_READONLY) &&
+ if (vfatFCBIsReadOnly(Fcb) &&
(RequestedOptions & FILE_DELETE_ON_CLOSE))
{
vfatReleaseFCB(DeviceExt, Fcb);
@@ -470,7 +470,7 @@
if ((vfatFCBIsRoot(Fcb) ||
(Fcb->LongNameU.Length == sizeof(WCHAR) &&
Fcb->LongNameU.Buffer[0] == L'.') ||
(Fcb->LongNameU.Length == 2 * sizeof(WCHAR) &&
Fcb->LongNameU.Buffer[0] == L'.' && Fcb->LongNameU.Buffer[1] ==
L'.')) &&
- (RequestedOptions & FILE_DELETE_ON_CLOSE))
+ BooleanFlagOn(RequestedOptions, FILE_DELETE_ON_CLOSE))
{
// we cannot delete a '.', '..' or the root directory
vfatReleaseFCB(DeviceExt, Fcb);
@@ -513,32 +513,32 @@
Stack = IoGetCurrentIrpStackLocation(Irp);
RequestedDisposition = ((Stack->Parameters.Create.Options >> 24) &
0xff);
RequestedOptions = Stack->Parameters.Create.Options &
FILE_VALID_OPTION_FLAGS;
- PagingFileCreate = (Stack->Flags & SL_OPEN_PAGING_FILE) ? TRUE : FALSE;
- OpenTargetDir = (Stack->Flags & SL_OPEN_TARGET_DIRECTORY) ? TRUE : FALSE;
+ PagingFileCreate = BooleanFlagOn(Stack->Flags, SL_OPEN_PAGING_FILE);
+ OpenTargetDir = BooleanFlagOn(Stack->Flags, SL_OPEN_TARGET_DIRECTORY);
FileObject = Stack->FileObject;
DeviceExt = DeviceObject->DeviceExtension;
- if (Stack->Parameters.Create.Options & FILE_OPEN_BY_FILE_ID)
+ if (BooleanFlagOn(Stack->Parameters.Create.Options, FILE_OPEN_BY_FILE_ID))
{
return STATUS_NOT_IMPLEMENTED;
}
/* Check their validity. */
- if (RequestedOptions & FILE_DIRECTORY_FILE &&
+ if (BooleanFlagOn(RequestedOptions, FILE_DIRECTORY_FILE) &&
RequestedDisposition == FILE_SUPERSEDE)
{
return STATUS_INVALID_PARAMETER;
}
- if (RequestedOptions & FILE_DIRECTORY_FILE &&
- RequestedOptions & FILE_NON_DIRECTORY_FILE)
+ if (BooleanFlagOn(RequestedOptions, FILE_DIRECTORY_FILE) &&
+ BooleanFlagOn(RequestedOptions, FILE_NON_DIRECTORY_FILE))
{
return STATUS_INVALID_PARAMETER;
}
/* Deny create if the volume is locked */
- if (DeviceExt->Flags & VCB_VOLUME_LOCKED)
+ if (BooleanFlagOn(DeviceExt->Flags, VCB_VOLUME_LOCKED))
{
return STATUS_ACCESS_DENIED;
}
@@ -569,7 +569,7 @@
return STATUS_INVALID_PARAMETER;
}
- if (RequestedOptions & FILE_DELETE_ON_CLOSE)
+ if (BooleanFlagOn(RequestedOptions, FILE_DELETE_ON_CLOSE))
{
return STATUS_CANNOT_DELETE;
}
@@ -798,11 +798,11 @@
RequestedDisposition == FILE_SUPERSEDE)
{
Attributes = Stack->Parameters.Create.FileAttributes &
~FILE_ATTRIBUTE_NORMAL;
- if (!(RequestedOptions & FILE_DIRECTORY_FILE))
+ if (!BooleanFlagOn(RequestedOptions, FILE_DIRECTORY_FILE))
Attributes |= FILE_ATTRIBUTE_ARCHIVE;
vfatSplitPathName(&PathNameU, NULL, &FileNameU);
Status = VfatAddEntry(DeviceExt, &FileNameU, &pFcb, ParentFcb,
RequestedOptions,
- (UCHAR)(Attributes & FILE_ATTRIBUTE_VALID_FLAGS),
NULL);
+ (UCHAR)FlagOn(Attributes, FILE_ATTRIBUTE_VALID_FLAGS),
NULL);
vfatReleaseFCB(DeviceExt, ParentFcb);
if (NT_SUCCESS(Status))
{
@@ -875,22 +875,22 @@
/*
* Check the file has the requested attributes
*/
- if (RequestedOptions & FILE_NON_DIRECTORY_FILE &&
- *pFcb->Attributes & FILE_ATTRIBUTE_DIRECTORY)
+ if (BooleanFlagOn(RequestedOptions, FILE_NON_DIRECTORY_FILE) &&
+ vfatFCBIsDirectory(pFcb))
{
VfatCloseFile (DeviceExt, FileObject);
return STATUS_FILE_IS_A_DIRECTORY;
}
- if (RequestedOptions & FILE_DIRECTORY_FILE &&
- !(*pFcb->Attributes & FILE_ATTRIBUTE_DIRECTORY))
+ if (BooleanFlagOn(RequestedOptions, FILE_DIRECTORY_FILE) &&
+ !vfatFCBIsDirectory(pFcb))
{
VfatCloseFile (DeviceExt, FileObject);
return STATUS_NOT_A_DIRECTORY;
}
#ifndef USE_ROS_CC_AND_FS
- if (!(*pFcb->Attributes & FILE_ATTRIBUTE_DIRECTORY))
- {
- if (Stack->Parameters.Create.SecurityContext->DesiredAccess &
FILE_WRITE_DATA ||
+ if (!vfatFCBIsDirectory(pFcb))
+ {
+ if
(BooleanFlagOn(Stack->Parameters.Create.SecurityContext->DesiredAccess,
FILE_WRITE_DATA) ||
RequestedDisposition == FILE_OVERWRITE ||
RequestedDisposition == FILE_OVERWRITE_IF ||
(RequestedOptions & FILE_DELETE_ON_CLOSE))
@@ -901,8 +901,8 @@
DPRINT1("%d %d %d\n",
Stack->Parameters.Create.SecurityContext->DesiredAccess & FILE_WRITE_DATA,
RequestedDisposition == FILE_OVERWRITE, RequestedDisposition
== FILE_OVERWRITE_IF);
VfatCloseFile (DeviceExt, FileObject);
- return (RequestedOptions & FILE_DELETE_ON_CLOSE) ?
STATUS_CANNOT_DELETE
- :
STATUS_SHARING_VIOLATION;
+ return (BooleanFlagOn(RequestedOptions, FILE_DELETE_ON_CLOSE)) ?
STATUS_CANNOT_DELETE
+ :
STATUS_SHARING_VIOLATION;
}
}
}
@@ -919,7 +919,7 @@
*/
if (pFcb->RefCount > 1)
{
- if(!(pFcb->Flags & FCB_IS_PAGE_FILE))
+ if(!BooleanFlagOn(pFcb->Flags, FCB_IS_PAGE_FILE))
{
VfatCloseFile(DeviceExt, FileObject);
return STATUS_INVALID_PARAMETER;
@@ -932,7 +932,7 @@
}
else
{
- if (pFcb->Flags & FCB_IS_PAGE_FILE)
+ if (BooleanFlagOn(pFcb->Flags, FCB_IS_PAGE_FILE))
{
VfatCloseFile(DeviceExt, FileObject);
return STATUS_INVALID_PARAMETER;
@@ -943,7 +943,7 @@
RequestedDisposition == FILE_OVERWRITE_IF ||
RequestedDisposition == FILE_SUPERSEDE)
{
- if (!(*pFcb->Attributes & FILE_ATTRIBUTE_DIRECTORY))
+ if (!vfatFCBIsDirectory(pFcb))
{
*pFcb->Attributes = Stack->Parameters.Create.FileAttributes &
~FILE_ATTRIBUTE_NORMAL;
*pFcb->Attributes |= FILE_ATTRIBUTE_ARCHIVE;
@@ -999,7 +999,7 @@
pFcb->PathNameU.Length -
pFcb->LongNameU.Length,
NULL,
NULL,
- ((*pFcb->Attributes &
FILE_ATTRIBUTE_DIRECTORY) ?
+ (vfatFCBIsDirectory(pFcb) ?
FILE_NOTIFY_CHANGE_DIR_NAME :
FILE_NOTIFY_CHANGE_FILE_NAME),
FILE_ACTION_ADDED,
NULL);
@@ -1034,7 +1034,7 @@
return STATUS_SUCCESS;
}
- if (!(IrpContext->Flags & IRPCONTEXT_CANWAIT))
+ if (!BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT))
{
return VfatMarkIrpContextForQueue(IrpContext);
}
Modified: trunk/reactos/drivers/filesystems/fastfat/dir.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/dir.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/dir.c [iso-8859-1] Fri Feb 17 17:58:18 2017
@@ -127,7 +127,7 @@
DirContext->LongNameU.Buffer,
DirContext->LongNameU.Length);
- if (DeviceExt->Flags & VCB_IS_FATX)
+ if (BooleanFlagOn(DeviceExt->Flags, VCB_IS_FATX))
{
FsdDosDateTimeToSystemTime(DeviceExt,
DirContext->DirEntry.FatX.CreationDate,
@@ -144,7 +144,7 @@
pInfo->ChangeTime = pInfo->LastWriteTime;
- if (DirContext->DirEntry.FatX.Attrib & FILE_ATTRIBUTE_DIRECTORY)
+ if (BooleanFlagOn(DirContext->DirEntry.FatX.Attrib,
FILE_ATTRIBUTE_DIRECTORY))
{
pInfo->EndOfFile.QuadPart = 0;
pInfo->AllocationSize.QuadPart = 0;
@@ -178,7 +178,7 @@
pInfo->ChangeTime = pInfo->LastWriteTime;
- if (DirContext->DirEntry.Fat.Attrib & FILE_ATTRIBUTE_DIRECTORY)
+ if (BooleanFlagOn(DirContext->DirEntry.Fat.Attrib, FILE_ATTRIBUTE_DIRECTORY))
{
pInfo->EndOfFile.QuadPart = 0;
pInfo->AllocationSize.QuadPart = 0;
@@ -220,7 +220,7 @@
DirContext->LongNameU.Buffer,
DirContext->LongNameU.Length);
- if (DeviceExt->Flags & VCB_IS_FATX)
+ if (BooleanFlagOn(DeviceExt->Flags, VCB_IS_FATX))
{
FsdDosDateTimeToSystemTime(DeviceExt,
DirContext->DirEntry.FatX.CreationDate,
@@ -285,7 +285,7 @@
pInfo->EaSize = 0;
- if (DeviceExt->Flags & VCB_IS_FATX)
+ if (BooleanFlagOn(DeviceExt->Flags, VCB_IS_FATX))
{
pInfo->FileNameLength = DirContext->LongNameU.Length;
@@ -314,7 +314,7 @@
pInfo->ChangeTime = pInfo->LastWriteTime;
- if (DirContext->DirEntry.FatX.Attrib & FILE_ATTRIBUTE_DIRECTORY)
+ if (BooleanFlagOn(DirContext->DirEntry.FatX.Attrib,
FILE_ATTRIBUTE_DIRECTORY))
{
pInfo->EndOfFile.QuadPart = 0;
pInfo->AllocationSize.QuadPart = 0;
@@ -364,7 +364,7 @@
pInfo->ChangeTime = pInfo->LastWriteTime;
- if (DirContext->DirEntry.Fat.Attrib & FILE_ATTRIBUTE_DIRECTORY)
+ if (BooleanFlagOn(DirContext->DirEntry.Fat.Attrib, FILE_ATTRIBUTE_DIRECTORY))
{
pInfo->EndOfFile.QuadPart = 0;
pInfo->AllocationSize.QuadPart = 0;
@@ -497,11 +497,11 @@
pCcb->SearchPattern.Length = sizeof(WCHAR);
}
- if (IrpContext->Stack->Flags & SL_INDEX_SPECIFIED)
+ if (BooleanFlagOn(IrpContext->Stack->Flags, SL_INDEX_SPECIFIED))
{
DirContext.DirIndex = pCcb->Entry =
Stack->Parameters.QueryDirectory.FileIndex;
}
- else if (FirstQuery || (IrpContext->Stack->Flags & SL_RESTART_SCAN))
+ else if (FirstQuery || BooleanFlagOn(IrpContext->Stack->Flags,
SL_RESTART_SCAN))
{
DirContext.DirIndex = pCcb->Entry = 0;
}
@@ -579,7 +579,7 @@
pCcb->Entry = ++DirContext.DirIndex;
BufferLength -= Buffer0->NextEntryOffset;
- if (IrpContext->Stack->Flags & SL_RETURN_SINGLE_ENTRY)
+ if (BooleanFlagOn(IrpContext->Stack->Flags, SL_RETURN_SINGLE_ENTRY))
break;
Buffer += Buffer0->NextEntryOffset;
@@ -653,7 +653,7 @@
break;
}
- if (Status == STATUS_PENDING && IrpContext->Flags &
IRPCONTEXT_COMPLETE)
+ if (Status == STATUS_PENDING && BooleanFlagOn(IrpContext->Flags,
IRPCONTEXT_COMPLETE))
{
return VfatMarkIrpContextForQueue(IrpContext);
}
Modified: trunk/reactos/drivers/filesystems/fastfat/direntry.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/direntry.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/direntry.c [iso-8859-1] Fri Feb 17 17:58:18
2017
@@ -27,7 +27,7 @@
cluster = pFatDirEntry->Fat.FirstCluster |
(pFatDirEntry->Fat.FirstClusterHigh << 16);
}
- else if (pDeviceExt->Flags & VCB_IS_FATX)
+ else if (BooleanFlagOn(pDeviceExt->Flags, VCB_IS_FATX))
{
cluster = pFatDirEntry->FatX.FirstCluster;
}
@@ -172,7 +172,7 @@
VfatIsDirectoryEmpty(
PVFATFCB Fcb)
{
- if (Fcb->Flags & FCB_IS_FATX_ENTRY)
+ if (BooleanFlagOn(Fcb->Flags, FCB_IS_FATX_ENTRY))
return FATXIsDirectoryEmpty(Fcb);
else
return FATIsDirectoryEmpty(Fcb);
Modified: trunk/reactos/drivers/filesystems/fastfat/dirwr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/dirwr.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/dirwr.c [iso-8859-1] Fri Feb 17 17:58:18
2017
@@ -31,7 +31,7 @@
ASSERT(pFcb);
- if (pFcb->Flags & FCB_IS_FATX_ENTRY)
+ if (BooleanFlagOn(pFcb->Flags, FCB_IS_FATX_ENTRY))
{
SizeDirEntry = sizeof(FATX_DIR_ENTRY);
dirIndex = pFcb->startIndex;
@@ -44,7 +44,7 @@
DPRINT("updEntry dirIndex %u, PathName \'%wZ\'\n", dirIndex,
&pFcb->PathNameU);
- if (vfatFCBIsRoot(pFcb) || (pFcb->Flags & (FCB_IS_FAT|FCB_IS_VOLUME)))
+ if (vfatFCBIsRoot(pFcb) || BooleanFlagOn(pFcb->Flags, FCB_IS_FAT |
FCB_IS_VOLUME))
{
return STATUS_SUCCESS;
}
@@ -90,7 +90,7 @@
DPRINT("vfatRenameEntry(%p, %p, %wZ, %d)\n", DeviceExt, pFcb, FileName,
CaseChangeOnly);
- if (pFcb->Flags & FCB_IS_FATX_ENTRY)
+ if (BooleanFlagOn(pFcb->Flags, FCB_IS_FATX_ENTRY))
{
VFAT_DIRENTRY_CONTEXT DirContext;
@@ -162,7 +162,7 @@
ULONG SizeDirEntry;
FileOffset.QuadPart = 0;
- if (DeviceExt->Flags & VCB_IS_FATX)
+ if (BooleanFlagOn(DeviceExt->Flags, VCB_IS_FATX))
SizeDirEntry = sizeof(FATX_DIR_ENTRY);
else
SizeDirEntry = sizeof(FAT_DIR_ENTRY);
@@ -304,6 +304,7 @@
BOOLEAN BaseAllLower, BaseAllUpper;
BOOLEAN ExtensionAllLower, ExtensionAllUpper;
BOOLEAN InExtension;
+ BOOLEAN IsDirectory;
WCHAR c;
ULONG CurrentCluster;
LARGE_INTEGER SystemTime, FileOffset;
@@ -323,6 +324,7 @@
DPRINT("addEntry: Name='%wZ', Dir='%wZ'\n", NameU,
&ParentFcb->PathNameU);
DirContext.LongNameU = *NameU;
+ IsDirectory = BooleanFlagOn(RequestedOptions, FILE_DIRECTORY_FILE);
/* nb of entry needed for long name+normal entry */
nbSlots = (DirContext.LongNameU.Length / sizeof(WCHAR) + 12) / 13 + 1;
@@ -480,7 +482,7 @@
/* set attributes */
DirContext.DirEntry.Fat.Attrib = ReqAttr;
- if (RequestedOptions & FILE_DIRECTORY_FILE)
+ if (IsDirectory)
{
DirContext.DirEntry.Fat.Attrib |= FILE_ATTRIBUTE_DIRECTORY;
}
@@ -534,7 +536,7 @@
return STATUS_DISK_FULL;
}
DirContext.DirIndex = DirContext.StartIndex + nbSlots - 1;
- if (RequestedOptions & FILE_DIRECTORY_FILE)
+ if (IsDirectory)
{
/* If we aren't moving, use next */
if (MoveContext == NULL)
@@ -653,7 +655,7 @@
DPRINT("new : entry=%11.11s\n", (*Fcb)->entry.Fat.Filename);
DPRINT("new : entry=%11.11s\n", DirContext.DirEntry.Fat.Filename);
- if (RequestedOptions & FILE_DIRECTORY_FILE)
+ if (IsDirectory)
{
FileOffset.QuadPart = 0;
_SEH2_TRY
@@ -759,7 +761,7 @@
/* set attributes */
DirContext.DirEntry.FatX.Attrib = ReqAttr;
- if (RequestedOptions & FILE_DIRECTORY_FILE)
+ if (BooleanFlagOn(RequestedOptions, FILE_DIRECTORY_FILE))
{
DirContext.DirEntry.FatX.Attrib |= FILE_ATTRIBUTE_DIRECTORY;
}
@@ -822,7 +824,7 @@
IN UCHAR ReqAttr,
IN PVFAT_MOVE_CONTEXT MoveContext)
{
- if (DeviceExt->Flags & VCB_IS_FATX)
+ if (BooleanFlagOn(DeviceExt->Flags, VCB_IS_FATX))
return FATXAddEntry(DeviceExt, NameU, Fcb, ParentFcb, RequestedOptions, ReqAttr,
MoveContext);
else
return FATAddEntry(DeviceExt, NameU, Fcb, ParentFcb, RequestedOptions, ReqAttr,
MoveContext);
@@ -925,7 +927,7 @@
ASSERT(pFcb);
ASSERT(pFcb->parentFcb);
- ASSERT(pFcb->Flags & FCB_IS_FATX_ENTRY);
+ ASSERT(BooleanFlagOn(pFcb->Flags, FCB_IS_FATX_ENTRY));
StartIndex = pFcb->startIndex;
@@ -981,7 +983,7 @@
IN PVFATFCB pFcb,
OUT PVFAT_MOVE_CONTEXT MoveContext)
{
- if (DeviceExt->Flags & VCB_IS_FATX)
+ if (BooleanFlagOn(DeviceExt->Flags, VCB_IS_FATX))
return FATXDelEntry(DeviceExt, pFcb, MoveContext);
else
return FATDelEntry(DeviceExt, pFcb, MoveContext);
Modified: trunk/reactos/drivers/filesystems/fastfat/fastio.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/fastio.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/fastio.c [iso-8859-1] Fri Feb 17 17:58:18
2017
@@ -131,7 +131,7 @@
FsRtlEnterFileSystem();
- if (!(FCB->Flags & FCB_IS_PAGE_FILE))
+ if (!BooleanFlagOn(FCB->Flags, FCB_IS_PAGE_FILE))
{
if (!ExAcquireResourceSharedLite(&FCB->MainResource, Wait))
{
@@ -146,7 +146,7 @@
Buffer,
&BufferLength);
- if (!(FCB->Flags & FCB_IS_PAGE_FILE))
+ if (!BooleanFlagOn(FCB->Flags, FCB_IS_PAGE_FILE))
{
ExReleaseResourceLite(&FCB->MainResource);
}
@@ -192,7 +192,7 @@
FsRtlEnterFileSystem();
- if (!(FCB->Flags & FCB_IS_PAGE_FILE))
+ if (!BooleanFlagOn(FCB->Flags, FCB_IS_PAGE_FILE))
{
if (!ExAcquireResourceSharedLite(&FCB->MainResource, Wait))
{
@@ -205,7 +205,7 @@
Buffer,
&BufferLength);
- if (!(FCB->Flags & FCB_IS_PAGE_FILE))
+ if (!BooleanFlagOn(FCB->Flags, FCB_IS_PAGE_FILE))
{
ExReleaseResourceLite(&FCB->MainResource);
}
@@ -691,7 +691,7 @@
UNREFERENCED_PARAMETER(DeviceObject);
/* Make sure it is not a volume lock */
- ASSERT(!(Fcb->Flags & FCB_IS_VOLUME));
+ ASSERT(!BooleanFlagOn(Fcb->Flags, FCB_IS_VOLUME));
/* Acquire the resource */
ExAcquireResourceExclusiveLite(&(Fcb->MainResource), TRUE);
@@ -715,7 +715,7 @@
UNREFERENCED_PARAMETER(DeviceObject);
/* Make sure it is not a volume lock */
- ASSERT(!(Fcb->Flags & FCB_IS_VOLUME));
+ ASSERT(!BooleanFlagOn(Fcb->Flags, FCB_IS_VOLUME));
/* Release the resource */
ExReleaseResourceLite(&(Fcb->MainResource));
Modified: trunk/reactos/drivers/filesystems/fastfat/fcb.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/fcb.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/fcb.c [iso-8859-1] Fri Feb 17 17:58:18 2017
@@ -136,7 +136,7 @@
}
RtlZeroMemory(rcFCB, sizeof(VFATFCB));
vfatInitFcb(rcFCB, pFileNameU);
- if (pVCB->Flags & VCB_IS_FATX)
+ if (BooleanFlagOn(pVCB->Flags, VCB_IS_FATX))
{
rcFCB->Flags |= FCB_IS_FATX_ENTRY;
rcFCB->Attributes = &rcFCB->entry.FatX.Attrib;
@@ -281,13 +281,6 @@
}
BOOLEAN
-vfatFCBIsDirectory(
- PVFATFCB FCB)
-{
- return ((*FCB->Attributes & FILE_ATTRIBUTE_DIRECTORY) ==
FILE_ATTRIBUTE_DIRECTORY);
-}
-
-BOOLEAN
vfatFCBIsRoot(
PVFATFCB FCB)
{
@@ -408,7 +401,7 @@
}
}
}
- else if (Fcb->Flags & FCB_IS_FATX_ENTRY)
+ else if (BooleanFlagOn(Fcb->Flags, FCB_IS_FATX_ENTRY))
{
Size = Fcb->entry.FatX.FileSize;
}
@@ -418,7 +411,7 @@
}
Fcb->dirIndex = DirContext->DirIndex;
Fcb->startIndex = DirContext->StartIndex;
- if ((Fcb->Flags & FCB_IS_FATX_ENTRY) && !vfatFCBIsRoot(Fcb))
+ if (BooleanFlagOn(Fcb->Flags, FCB_IS_FATX_ENTRY) && !vfatFCBIsRoot(Fcb))
{
ASSERT(DirContext->DirIndex >= 2 && DirContext->StartIndex >=
2);
Fcb->dirIndex = DirContext->DirIndex-2;
@@ -460,7 +453,7 @@
Fcb->DirNameU.Buffer = Fcb->PathNameU.Buffer;
vfatSplitPathName(&Fcb->PathNameU, &Fcb->DirNameU,
&Fcb->LongNameU);
Fcb->Hash.Hash = vfatNameHash(0, &Fcb->PathNameU);
- if (pVCB->Flags & VCB_IS_FATX)
+ if (BooleanFlagOn(pVCB->Flags, VCB_IS_FATX))
{
Fcb->ShortHash.Hash = Fcb->Hash.Hash;
}
@@ -644,7 +637,7 @@
UNICODE_STRING NameU = RTL_CONSTANT_STRING(L"\\");
FCB = vfatNewFCB(pVCB, &NameU);
- if (FCB->Flags & FCB_IS_FATX_ENTRY)
+ if (BooleanFlagOn(FCB->Flags, FCB_IS_FATX_ENTRY))
{
memset(FCB->entry.FatX.Filename, ' ', 42);
FCB->entry.FatX.FileSize = pVCB->FatInfo.rootDirectorySectors *
pVCB->FatInfo.BytesPerSector;
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] Fri Feb 17 17:58:18
2017
@@ -338,7 +338,7 @@
return STATUS_SUCCESS;
}
- if (*FCB->Attributes & FILE_ATTRIBUTE_READONLY)
+ if (vfatFCBIsReadOnly(FCB))
{
return STATUS_CANNOT_DELETE;
}
@@ -398,7 +398,7 @@
if (ReplaceIfExists)
{
/* If that's a directory or a read-only file, we're not allowed */
- if (vfatFCBIsDirectory(TargetFcb) || ((*TargetFcb->Attributes &
FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY))
+ if (vfatFCBIsDirectory(TargetFcb) || vfatFCBIsReadOnly(TargetFcb))
{
DPRINT("And this is a readonly file!\n");
vfatReleaseFCB(DeviceExt, *ParentFCB);
@@ -791,7 +791,7 @@
FCB->PathNameU.Length -
FCB->LongNameU.Length,
NULL,
NULL,
- ((*FCB->Attributes &
FILE_ATTRIBUTE_DIRECTORY) ?
+ (vfatFCBIsDirectory(FCB) ?
FILE_NOTIFY_CHANGE_DIR_NAME :
FILE_NOTIFY_CHANGE_FILE_NAME),
FILE_ACTION_RENAMED_OLD_NAME,
NULL);
@@ -804,7 +804,7 @@
FCB->PathNameU.Length -
FCB->LongNameU.Length,
NULL,
NULL,
- ((*FCB->Attributes &
FILE_ATTRIBUTE_DIRECTORY) ?
+ (vfatFCBIsDirectory(FCB) ?
FILE_NOTIFY_CHANGE_DIR_NAME :
FILE_NOTIFY_CHANGE_FILE_NAME),
FILE_ACTION_RENAMED_NEW_NAME,
NULL);
@@ -834,7 +834,7 @@
FCB->PathNameU.Length -
FCB->LongNameU.Length,
NULL,
NULL,
- ((*FCB->Attributes &
FILE_ATTRIBUTE_DIRECTORY) ?
+ (vfatFCBIsDirectory(FCB) ?
FILE_NOTIFY_CHANGE_DIR_NAME :
FILE_NOTIFY_CHANGE_FILE_NAME),
(DeletedTarget ? FILE_ACTION_REMOVED :
FILE_ACTION_RENAMED_OLD_NAME),
NULL);
@@ -862,7 +862,7 @@
FCB->PathNameU.Length -
FCB->LongNameU.Length,
NULL,
NULL,
- ((*FCB->Attributes &
FILE_ATTRIBUTE_DIRECTORY) ?
+ (vfatFCBIsDirectory(FCB) ?
FILE_NOTIFY_CHANGE_DIR_NAME :
FILE_NOTIFY_CHANGE_FILE_NAME),
FILE_ACTION_RENAMED_NEW_NAME,
NULL);
@@ -905,7 +905,7 @@
FCB->PathNameU.Length - FCB->LongNameU.Length,
NULL,
NULL,
- ((*FCB->Attributes & FILE_ATTRIBUTE_DIRECTORY)
?
+ (vfatFCBIsDirectory(FCB) ?
FILE_NOTIFY_CHANGE_DIR_NAME :
FILE_NOTIFY_CHANGE_FILE_NAME),
FILE_ACTION_REMOVED,
NULL);
@@ -933,7 +933,7 @@
FCB->PathNameU.Length -
FCB->LongNameU.Length,
NULL,
NULL,
- ((*FCB->Attributes &
FILE_ATTRIBUTE_DIRECTORY) ?
+ (vfatFCBIsDirectory(FCB) ?
FILE_NOTIFY_CHANGE_DIR_NAME :
FILE_NOTIFY_CHANGE_FILE_NAME),
FILE_ACTION_ADDED,
NULL);
Modified: trunk/reactos/drivers/filesystems/fastfat/flush.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/flush.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/flush.c [iso-8859-1] Fri Feb 17 17:58:18
2017
@@ -33,7 +33,7 @@
IoStatus.Status = STATUS_SUCCESS;
}
- if (Fcb->Flags & FCB_IS_DIRTY)
+ if (BooleanFlagOn(Fcb->Flags, FCB_IS_DIRTY))
{
Status = VfatUpdateEntry(Fcb);
if (!NT_SUCCESS(Status))
@@ -157,7 +157,7 @@
Fcb = (PVFATFCB)IrpContext->FileObject->FsContext;
ASSERT(Fcb);
- if (Fcb->Flags & FCB_IS_VOLUME)
+ if (BooleanFlagOn(Fcb->Flags, FCB_IS_VOLUME))
{
ExAcquireResourceExclusiveLite(&IrpContext->DeviceExt->DirResource,
TRUE);
Status = VfatFlushVolume(IrpContext->DeviceExt, Fcb);
Modified: trunk/reactos/drivers/filesystems/fastfat/fsctl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/fsctl.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/fsctl.c [iso-8859-1] Fri Feb 17 17:58:18
2017
@@ -816,8 +816,8 @@
Flags = (PULONG)IrpContext->Irp->AssociatedIrp.SystemBuffer;
*Flags = 0;
- if ((IrpContext->DeviceExt->VolumeFcb->Flags & VCB_IS_DIRTY) &&
- !(IrpContext->DeviceExt->VolumeFcb->Flags & VCB_CLEAR_DIRTY))
+ if (BooleanFlagOn(IrpContext->DeviceExt->VolumeFcb->Flags, VCB_IS_DIRTY)
&&
+ !BooleanFlagOn(IrpContext->DeviceExt->VolumeFcb->Flags,
VCB_CLEAR_DIRTY))
{
*Flags |= VOLUME_IS_DIRTY;
}
@@ -837,7 +837,7 @@
DPRINT("VfatMarkVolumeDirty(IrpContext %p)\n", IrpContext);
DeviceExt = IrpContext->DeviceExt;
- if (!(DeviceExt->VolumeFcb->Flags & VCB_IS_DIRTY))
+ if (!BooleanFlagOn(DeviceExt->VolumeFcb->Flags, VCB_IS_DIRTY))
{
Status = GetNextCluster(DeviceExt, 1, &eocMark);
if (NT_SUCCESS(Status))
@@ -870,14 +870,14 @@
Fcb = FileObject->FsContext;
/* Only allow locking with the volume open */
- if (!(Fcb->Flags & FCB_IS_VOLUME))
+ if (!BooleanFlagOn(Fcb->Flags, FCB_IS_VOLUME))
{
return STATUS_ACCESS_DENIED;
}
/* Bail out if it's already in the demanded state */
- if (((DeviceExt->Flags & VCB_VOLUME_LOCKED) && Lock) ||
- (!(DeviceExt->Flags & VCB_VOLUME_LOCKED) && !Lock))
+ if ((BooleanFlagOn(DeviceExt->Flags, VCB_VOLUME_LOCKED) && Lock) ||
+ (!BooleanFlagOn(DeviceExt->Flags, VCB_VOLUME_LOCKED) && !Lock))
{
return STATUS_ACCESS_DENIED;
}
@@ -921,13 +921,13 @@
/* We HAVE to be locked. Windows also allows dismount with no lock
* but we're here mainly for 1st stage, so KISS
*/
- if (!(DeviceExt->Flags & VCB_VOLUME_LOCKED))
+ if (!BooleanFlagOn(DeviceExt->Flags, VCB_VOLUME_LOCKED))
{
return STATUS_ACCESS_DENIED;
}
/* Race condition? */
- if (DeviceExt->Flags & VCB_DISMOUNT_PENDING)
+ if (BooleanFlagOn(DeviceExt->Flags, VCB_DISMOUNT_PENDING))
{
return STATUS_VOLUME_DISMOUNTED;
}
@@ -937,7 +937,7 @@
ExAcquireResourceExclusiveLite(&DeviceExt->FatResource, TRUE);
- if (DeviceExt->VolumeFcb->Flags & VCB_CLEAR_DIRTY)
+ if (BooleanFlagOn(DeviceExt->VolumeFcb->Flags, VCB_CLEAR_DIRTY))
{
/* Set clean shutdown bit */
Status = GetNextCluster(DeviceExt, 1, &eocMark);
Modified: trunk/reactos/drivers/filesystems/fastfat/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/misc.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/misc.c [iso-8859-1] Fri Feb 17 17:58:18
2017
@@ -76,7 +76,7 @@
return STATUS_INVALID_DEVICE_REQUEST;
}
- if (*Fcb->Attributes & FILE_ATTRIBUTE_DIRECTORY)
+ if (vfatFCBIsDirectory(Fcb))
{
return STATUS_INVALID_PARAMETER;
}
@@ -106,6 +106,7 @@
IN PVFAT_IRP_CONTEXT IrpContext)
{
NTSTATUS Status;
+ BOOLEAN QueueIrp, CompleteIrp;
DPRINT("VfatDispatchRequest (IrpContext %p), is called for %s\n",
IrpContext,
IrpContext->MajorFunction >= IRP_MJ_MAXIMUM_FUNCTION ? "????"
: MajorFunctionNames[IrpContext->MajorFunction]);
@@ -181,17 +182,20 @@
Status = STATUS_DRIVER_INTERNAL_ERROR;
}
- ASSERT((!(IrpContext->Flags & IRPCONTEXT_COMPLETE) &&
!(IrpContext->Flags & IRPCONTEXT_QUEUE)) ||
- ((IrpContext->Flags & IRPCONTEXT_COMPLETE) &&
!(IrpContext->Flags & IRPCONTEXT_QUEUE)) ||
- (!(IrpContext->Flags & IRPCONTEXT_COMPLETE) &&
(IrpContext->Flags & IRPCONTEXT_QUEUE)));
-
- if (IrpContext->Flags & IRPCONTEXT_COMPLETE)
+ QueueIrp = BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_QUEUE);
+ CompleteIrp = BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_COMPLETE);
+
+ ASSERT((!CompleteIrp && !QueueIrp) ||
+ (CompleteIrp && !QueueIrp) ||
+ (!CompleteIrp && QueueIrp));
+
+ if (CompleteIrp)
{
IrpContext->Irp->IoStatus.Status = Status;
IoCompleteRequest(IrpContext->Irp, IrpContext->PriorityBoost);
}
- if (IrpContext->Flags & IRPCONTEXT_QUEUE)
+ if (QueueIrp)
{
/* Reset our status flags before queueing the IRP */
IrpContext->Flags |= IRPCONTEXT_COMPLETE;
Modified: trunk/reactos/drivers/filesystems/fastfat/rw.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/rw.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/rw.c [iso-8859-1] Fri Feb 17 17:58:18 2017
@@ -155,7 +155,7 @@
ASSERT(Length % BytesPerSector == 0);
/* Is this a read of the FAT? */
- if (Fcb->Flags & FCB_IS_FAT)
+ if (BooleanFlagOn(Fcb->Flags, FCB_IS_FAT))
{
ReadOffset.QuadPart += DeviceExt->FatInfo.FATStart * BytesPerSector;
Status = VfatReadDiskPartial(IrpContext, &ReadOffset, Length, 0, TRUE);
@@ -172,7 +172,7 @@
}
/* Is this a read of the Volume ? */
- if (Fcb->Flags & FCB_IS_VOLUME)
+ if (BooleanFlagOn(Fcb->Flags, FCB_IS_VOLUME))
{
Status = VfatReadDiskPartial(IrpContext, &ReadOffset, Length, 0, TRUE);
if (NT_SUCCESS(Status))
@@ -367,7 +367,7 @@
ASSERT(Length % BytesPerSector == 0);
/* Is this a write of the volume? */
- if (Fcb->Flags & FCB_IS_VOLUME)
+ if (BooleanFlagOn(Fcb->Flags, FCB_IS_VOLUME))
{
Status = VfatWriteDiskPartial(IrpContext, &WriteOffset, Length, 0, TRUE);
if (!NT_SUCCESS(Status))
@@ -378,7 +378,7 @@
}
/* Is this a write to the FAT? */
- if (Fcb->Flags & FCB_IS_FAT)
+ if (BooleanFlagOn(Fcb->Flags, FCB_IS_FAT))
{
WriteOffset.u.LowPart += DeviceExt->FatInfo.FATStart * BytesPerSector;
IrpContext->RefCount = 1;
@@ -547,7 +547,7 @@
LARGE_INTEGER ByteOffset;
PVOID Buffer;
ULONG BytesPerSector;
- BOOLEAN PagingIo, CanWait, IsVolume;
+ BOOLEAN PagingIo, CanWait, IsVolume, NoCache;
ASSERT(IrpContext);
@@ -568,7 +568,7 @@
Fcb = IrpContext->FileObject->FsContext;
ASSERT(Fcb);
- if (Fcb->Flags & FCB_IS_PAGE_FILE)
+ if (BooleanFlagOn(Fcb->Flags, FCB_IS_PAGE_FILE))
{
PFATINFO FatInfo = &IrpContext->DeviceExt->FatInfo;
IrpContext->Stack->Parameters.Read.ByteOffset.QuadPart +=
FatInfo->dataStart * FatInfo->BytesPerSector;
@@ -587,9 +587,10 @@
PagingIo = BooleanFlagOn(IrpContext->Irp->Flags, IRP_PAGING_IO);
CanWait = BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT);
IsVolume = BooleanFlagOn(Fcb->Flags, FCB_IS_VOLUME);
+ NoCache = BooleanFlagOn(IrpContext->Irp->Flags, IRP_NOCACHE);
/* fail if file is a directory and no paged read */
- if (*Fcb->Attributes & FILE_ATTRIBUTE_DIRECTORY && !PagingIo)
+ if (vfatFCBIsDirectory(Fcb) && !PagingIo)
{
Status = STATUS_INVALID_PARAMETER;
goto ByeBye;
@@ -617,7 +618,7 @@
goto ByeBye;
}
- if (IrpContext->Irp->Flags & (IRP_PAGING_IO | IRP_NOCACHE) || IsVolume)
+ if (NoCache || PagingIo || IsVolume)
{
if (ByteOffset.u.LowPart % BytesPerSector != 0 || Length % BytesPerSector != 0)
{
@@ -660,8 +661,7 @@
Buffer = VfatGetUserBuffer(IrpContext->Irp, PagingIo);
- if (!(IrpContext->Irp->Flags & (IRP_NOCACHE|IRP_PAGING_IO)) &&
- !(Fcb->Flags & (FCB_IS_PAGE_FILE|FCB_IS_VOLUME)))
+ if (!PagingIo && !NoCache && !IsVolume)
{
// cached read
Status = STATUS_SUCCESS;
@@ -744,7 +744,7 @@
else
{
IrpContext->Irp->IoStatus.Status = Status;
- if (IrpContext->FileObject->Flags & FO_SYNCHRONOUS_IO &&
+ if (BooleanFlagOn(IrpContext->FileObject->Flags, FO_SYNCHRONOUS_IO)
&&
!PagingIo &&
(NT_SUCCESS(Status) || Status == STATUS_END_OF_FILE))
{
@@ -771,7 +771,7 @@
ULONG Length = 0;
PVOID Buffer;
ULONG BytesPerSector;
- BOOLEAN PagingIo, CanWait, IsVolume;
+ BOOLEAN PagingIo, CanWait, IsVolume, IsFAT, NoCache;
ASSERT(IrpContext);
@@ -792,7 +792,7 @@
Fcb = IrpContext->FileObject->FsContext;
ASSERT(Fcb);
- if (Fcb->Flags & FCB_IS_PAGE_FILE)
+ if (BooleanFlagOn(Fcb->Flags, FCB_IS_PAGE_FILE))
{
PFATINFO FatInfo = &IrpContext->DeviceExt->FatInfo;
IrpContext->Stack->Parameters.Write.ByteOffset.QuadPart +=
FatInfo->dataStart * FatInfo->BytesPerSector;
@@ -808,9 +808,11 @@
PagingIo = BooleanFlagOn(IrpContext->Irp->Flags, IRP_PAGING_IO);
CanWait = BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT);
IsVolume = BooleanFlagOn(Fcb->Flags, FCB_IS_VOLUME);
+ IsFAT = BooleanFlagOn(Fcb->Flags, FCB_IS_FAT);
+ NoCache = BooleanFlagOn(IrpContext->Irp->Flags, IRP_NOCACHE);
/* fail if file is a directory and no paged read */
- if (*Fcb->Attributes & FILE_ATTRIBUTE_DIRECTORY && !PagingIo)
+ if (vfatFCBIsDirectory(Fcb) && !PagingIo)
{
Status = STATUS_INVALID_PARAMETER;
goto ByeBye;
@@ -831,7 +833,7 @@
goto ByeBye;
}
- if (Fcb->Flags & (FCB_IS_FAT | FCB_IS_VOLUME) ||
+ if (IsFAT || IsVolume ||
vfatDirEntryGetFirstCluster(IrpContext->DeviceExt, &Fcb->entry) == 1)
{
if (ByteOffset.QuadPart + Length > Fcb->RFCB.FileSize.QuadPart)
@@ -842,7 +844,7 @@
}
}
- if (IrpContext->Irp->Flags & (IRP_PAGING_IO|IRP_NOCACHE) || IsVolume)
+ if (PagingIo || NoCache || IsVolume)
{
if (ByteOffset.u.LowPart % BytesPerSector != 0 || Length % BytesPerSector != 0)
{
@@ -889,7 +891,7 @@
Resource = &Fcb->MainResource;
}
- if ((Fcb->Flags & FCB_IS_PAGE_FILE) || PagingIo)
+ if (PagingIo)
{
if (!ExAcquireResourceSharedLite(Resource, CanWait))
{
@@ -929,8 +931,7 @@
Buffer = VfatGetUserBuffer(IrpContext->Irp, PagingIo);
- if (!(Fcb->Flags & (FCB_IS_FAT|FCB_IS_VOLUME)) &&
- !PagingIo &&
+ if (!IsFAT && !IsVolume && !PagingIo &&
ByteOffset.u.LowPart + Length > Fcb->RFCB.FileSize.u.LowPart)
{
LARGE_INTEGER AllocationSize;
@@ -943,8 +944,7 @@
}
}
- if (!(IrpContext->Irp->Flags & (IRP_NOCACHE|IRP_PAGING_IO)) &&
- !(Fcb->Flags & (FCB_IS_PAGE_FILE|FCB_IS_VOLUME)))
+ if (!NoCache && !PagingIo && !IsVolume)
{
// cached write
@@ -1008,17 +1008,16 @@
}
Metadata:
- if (!PagingIo &&
- !(Fcb->Flags & (FCB_IS_FAT|FCB_IS_VOLUME)))
- {
- if(!(*Fcb->Attributes & FILE_ATTRIBUTE_DIRECTORY))
+ if (!PagingIo && !IsFAT && !IsVolume)
+ {
+ if(!vfatFCBIsDirectory(Fcb))
{
LARGE_INTEGER SystemTime;
ULONG Filter;
// set dates and times
KeQuerySystemTime (&SystemTime);
- if (Fcb->Flags & FCB_IS_FATX_ENTRY)
+ if (BooleanFlagOn(Fcb->Flags, FCB_IS_FATX_ENTRY))
{
FsdSystemTimeToDosDateTime(IrpContext->DeviceExt,
&SystemTime,
&Fcb->entry.FatX.UpdateDate,
@@ -1069,7 +1068,7 @@
else
{
IrpContext->Irp->IoStatus.Status = Status;
- if (IrpContext->FileObject->Flags & FO_SYNCHRONOUS_IO &&
+ if (BooleanFlagOn(IrpContext->FileObject->Flags, FO_SYNCHRONOUS_IO)
&&
!PagingIo && NT_SUCCESS(Status))
{
IrpContext->FileObject->CurrentByteOffset.QuadPart =
Modified: trunk/reactos/drivers/filesystems/fastfat/vfat.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/vfat.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/vfat.h [iso-8859-1] Fri Feb 17 17:58:18
2017
@@ -516,6 +516,20 @@
return STATUS_PENDING;
}
+FORCEINLINE
+BOOLEAN
+vfatFCBIsDirectory(PVFATFCB FCB)
+{
+ return BooleanFlagOn(*FCB->Attributes, FILE_ATTRIBUTE_DIRECTORY);
+}
+
+FORCEINLINE
+BOOLEAN
+vfatFCBIsReadOnly(PVFATFCB FCB)
+{
+ return BooleanFlagOn(*FCB->Attributes, FILE_ATTRIBUTE_READONLY);
+}
+
/* blockdev.c */
NTSTATUS
Modified: trunk/reactos/drivers/filesystems/fastfat/volume.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/volume.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/volume.c [iso-8859-1] Fri Feb 17 17:58:18
2017
@@ -59,7 +59,7 @@
*BufferLength -= DeviceObject->Vpb->VolumeLabelLength;
}
- if (DeviceExt->VolumeFcb->Flags & FCB_IS_FATX_ENTRY)
+ if (BooleanFlagOn(DeviceExt->VolumeFcb->Flags, FCB_IS_FATX_ENTRY))
{
FsdDosDateTimeToSystemTime(DeviceExt,
DeviceExt->VolumeFcb->entry.FatX.CreationDate,
@@ -260,7 +260,7 @@
return STATUS_NAME_TOO_LONG;
}
- if (DeviceExt->Flags & VCB_IS_FATX)
+ if (BooleanFlagOn(DeviceExt->Flags, VCB_IS_FATX))
{
if (FsLabelInfo->VolumeLabelLength / sizeof(WCHAR) > 42)
return STATUS_NAME_TOO_LONG;
@@ -289,7 +289,7 @@
if (!NT_SUCCESS(Status))
return Status;
- if (DeviceExt->Flags & VCB_IS_FATX)
+ if (BooleanFlagOn(DeviceExt->Flags, VCB_IS_FATX))
{
RtlCopyMemory(VolumeLabelDirEntry.FatX.Filename, cString, LabelLen);
memset(&VolumeLabelDirEntry.FatX.Filename[LabelLen], ' ', 42 -
LabelLen);