[FORMATTING]

- Bring formatting closer to ReactOS kernelmode style.
- Fix a typo in a variable name.

svn path=/trunk/; revision=39036
This commit is contained in:
Aleksey Bragin 2009-01-23 10:47:32 +00:00
parent 460906f80f
commit eb5644eb1b

View file

@ -44,7 +44,8 @@ typedef struct _FAT_ENUM_DIR_CONTEXT
PWCHAR FileName;
} FAT_ENUM_DIR_CONTEXT;
typedef enum _FILE_TIME_INDEX {
typedef enum _FILE_TIME_INDEX
{
FileCreationTime = 0,
FileLastAccessTime,
FileLastWriteTime,
@ -52,82 +53,70 @@ typedef enum _FILE_TIME_INDEX {
} FILE_TIME_INDEX;
VOID
FatQueryFileTimes(
OUT PLARGE_INTEGER FileTimes,
IN PDIR_ENTRY Dirent);
FatQueryFileTimes(OUT PLARGE_INTEGER FileTimes,
IN PDIR_ENTRY Dirent);
VOID
Fat8dot3ToUnicodeString(
OUT PUNICODE_STRING FileName,
IN PUCHAR ShortName,
IN UCHAR Flags);
Fat8dot3ToUnicodeString(OUT PUNICODE_STRING FileName,
IN PUCHAR ShortName,
IN UCHAR Flags);
ULONG
FatDirentToDirInfo(
IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer);
FatDirentToDirInfo(IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer);
ULONG
FatDirentToFullDirInfo(
IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer);
FatDirentToFullDirInfo(IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer);
ULONG
FatDirentToIdFullDirInfo(
IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer);
FatDirentToIdFullDirInfo(IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer);
ULONG
FatDirentToBothDirInfo(
IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer);
FatDirentToBothDirInfo(IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer);
ULONG
FatDirentToIdBothDirInfo(
IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer);
FatDirentToIdBothDirInfo(IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer);
ULONG
FatDirentToNamesInfo(
IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer);
FatDirentToNamesInfo(IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer);
ULONG
FatDirentToObjectIdInfo(
IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer);
FatDirentToObjectIdInfo(IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer);
/* FUNCTIONS *****************************************************************/
FORCEINLINE
VOID
FatDateTimeToSystemTime(
OUT PLARGE_INTEGER SystemTime,
IN PFAT_DATETIME FatDateTime,
IN UCHAR TenMs OPTIONAL)
FatDateTimeToSystemTime(OUT PLARGE_INTEGER SystemTime,
IN PFAT_DATETIME FatDateTime,
IN UCHAR TenMs OPTIONAL)
{
TIME_FIELDS TimeFields;
/*
* Setup time fields.
*/
/* Setup time fields */
TimeFields.Year = FatDateTime->Date.Year + 1980;
TimeFields.Month = FatDateTime->Date.Month;
TimeFields.Day = FatDateTime->Date.Day;
TimeFields.Hour = FatDateTime->Time.Hour;
TimeFields.Minute = FatDateTime->Time.Minute;
TimeFields.Second = (FatDateTime->Time.DoubleSeconds << 1);
/*
* Adjust up to 10 milliseconds
* if the parameter was supplied
*/
/* Adjust up to 10 milliseconds
* if the parameter was supplied
*/
if (ARGUMENT_PRESENT(TenMs))
{
TimeFields.Second += TenMs / 100;
@ -137,17 +126,15 @@ FatDateTimeToSystemTime(
{
TimeFields.Milliseconds = 0;
}
/*
* Fix seconds value that might get beyoud the bound.
*/
if (TimeFields.Second > 59)
TimeFields.Second = 0;
/*
* Perform ceonversion to system time if possible.
*/
if (RtlTimeFieldsToTime(&TimeFields, SystemTime)) {
/* Fix seconds value that might get beyoud the bound */
if (TimeFields.Second > 59) TimeFields.Second = 0;
/* Perform ceonversion to system time if possible */
if (RtlTimeFieldsToTime(&TimeFields, SystemTime))
{
/* Convert to system time */
ExLocalTimeToSystemTime( SystemTime, SystemTime );
ExLocalTimeToSystemTime(SystemTime, SystemTime);
}
else
{
@ -157,20 +144,16 @@ FatDateTimeToSystemTime(
}
VOID
FatQueryFileTimes(
OUT PLARGE_INTEGER FileTimes,
IN PDIR_ENTRY Dirent)
FatQueryFileTimes(OUT PLARGE_INTEGER FileTimes,
IN PDIR_ENTRY Dirent)
{
/*
* Convert LastWriteTime
*/
FatDateTimeToSystemTime(
&FileTimes[FileLastWriteTime],
&Dirent->LastWriteDateTime, 0);
/*
* All other time fileds are valid (according to MS)
* only if Win31 compatability mode is set.
*/
/* Convert LastWriteTime */
FatDateTimeToSystemTime(&FileTimes[FileLastWriteTime],
&Dirent->LastWriteDateTime,
0);
/* All other time fileds are valid (according to MS)
* only if Win31 compatability mode is set.
*/
if (FatGlobalData.Win31FileSystem)
{
/* We can avoid calling conversion routine
@ -194,10 +177,9 @@ FatQueryFileTimes(
else
{
/* Perform conversion */
FatDateTimeToSystemTime(
&FileTimes[FileCreationTime],
&Dirent->CreationDateTime,
Dirent->CreationTimeTenMs);
FatDateTimeToSystemTime(&FileTimes[FileCreationTime],
&Dirent->CreationDateTime,
Dirent->CreationTimeTenMs);
}
if (Dirent->LastAccessDate.Value == 0)
{
@ -217,18 +199,17 @@ FatQueryFileTimes(
LastAccessDateTime.Date.Value = Dirent->LastAccessDate.Value;
LastAccessDateTime.Time.Value = 0;
FatDateTimeToSystemTime(
&FileTimes[FileLastAccessTime],
&LastAccessDateTime, 0);
FatDateTimeToSystemTime(&FileTimes[FileLastAccessTime],
&LastAccessDateTime,
0);
}
}
}
VOID
Fat8dot3ToUnicodeString(
OUT PUNICODE_STRING FileName,
IN PUCHAR ShortName,
IN UCHAR Flags)
Fat8dot3ToUnicodeString(OUT PUNICODE_STRING FileName,
IN PUCHAR ShortName,
IN UCHAR Flags)
{
PCHAR Name;
UCHAR Index, Ext = 0;
@ -237,11 +218,11 @@ Fat8dot3ToUnicodeString(
Name = Add2Ptr(FileName->Buffer, 0x0c, PCHAR);
RtlCopyMemory(Name, ShortName, 0x0b);
/* Restore the name byte used to mark deleted entries. */
/* Restore the name byte used to mark deleted entries */
if (Name[0] == 0x05)
Name[0] |= 0xe0;
/* Locate the end of name part. */
/* Locate the end of name part */
for (Index = 0; Index < 0x08
&& Name[Index] != 0x20; Index++);
@ -260,6 +241,7 @@ Fat8dot3ToUnicodeString(
Index ++; Ext ++;
}
}
/* Perform Oem to Unicode conversion. */
Oem.Buffer = Name;
Oem.Length = Index;
@ -279,32 +261,28 @@ Fat8dot3ToUnicodeString(
{
/* Set extension for downcase */
Oem.Length = Ext * sizeof(WCHAR);
Oem.Buffer = Add2Ptr(
FileName->Buffer,
FileName->Length - Oem.Length,
PSTR);
Oem.Buffer = Add2Ptr(FileName->Buffer,
FileName->Length - Oem.Length,
PSTR);
}
else
{
/* Set base name for downcase */
Oem.Buffer = (PSTR) FileName->Buffer;
Oem.Length = FileName->Length
- Ext * sizeof(WCHAR);
Oem.Length = FileName->Length - Ext * sizeof(WCHAR);
}
Oem.MaximumLength = Oem.Length;
RtlUpcaseUnicodeString(
(PUNICODE_STRING)&Oem,
(PUNICODE_STRING)&Oem,
FALSE);
RtlUpcaseUnicodeString((PUNICODE_STRING)&Oem,
(PUNICODE_STRING)&Oem,
FALSE);
}
}
}
ULONG
FatDirentToDirInfo(
IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer)
FatDirentToDirInfo(IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer)
{
PFILE_DIRECTORY_INFORMATION Info;
//UNICODE_STRING FileName;
@ -324,10 +302,9 @@ FatDirentToDirInfo(
// FatQueryShortName(&FileName, Dirent);
// Info->ShortNameLength = (CCHAR) FileName.Length;
Info->NextEntryOffset = sizeof(*Info);
/*
* Associate LFN buffer and length pointers
* of this entry with the context.
*/
/* Associate LFN buffer and length pointers
* of this entry with the context.
*/
Context->NextEntryOffset = &Info->NextEntryOffset;
Context->FileName = Info->FileName;
Context->FileNameLength = &Info->FileNameLength;
@ -335,10 +312,9 @@ FatDirentToDirInfo(
}
ULONG
FatDirentToFullDirInfo(
IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer)
FatDirentToFullDirInfo(IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer)
{
PFILE_FULL_DIR_INFORMATION Info;
//UNICODE_STRING FileName;
@ -369,10 +345,9 @@ FatDirentToFullDirInfo(
}
ULONG
FatDirentToIdFullDirInfo(
IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer)
FatDirentToIdFullDirInfo(IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer)
{
PFILE_ID_FULL_DIR_INFORMATION Info;
//UNICODE_STRING FileName;
@ -403,10 +378,9 @@ FatDirentToIdFullDirInfo(
}
ULONG
FatDirentToBothDirInfo(
IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer)
FatDirentToBothDirInfo(IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer)
{
PFILE_BOTH_DIR_INFORMATION Info;
UNICODE_STRING FileName;
@ -426,10 +400,9 @@ FatDirentToBothDirInfo(
Fat8dot3ToUnicodeString(&FileName, Dirent->FileName, Dirent->Case);
Info->ShortNameLength = (CCHAR) FileName.Length;
Info->NextEntryOffset = sizeof(*Info);
/*
* Associate LFN buffer and length pointers
* of this entry with the context.
*/
/* Associate LFN buffer and length pointers
* of this entry with the context.
*/
Context->NextEntryOffset = &Info->NextEntryOffset;
Context->FileName = Info->FileName;
Context->FileNameLength = &Info->FileNameLength;
@ -437,10 +410,9 @@ FatDirentToBothDirInfo(
}
ULONG
FatDirentToIdBothDirInfo(
IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer)
FatDirentToIdBothDirInfo(IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer)
{
PFILE_ID_BOTH_DIR_INFORMATION Info;
UNICODE_STRING FileName;
@ -471,20 +443,18 @@ FatDirentToIdBothDirInfo(
}
ULONG
FatDirentToNamesInfo(
IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer)
FatDirentToNamesInfo(IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer)
{
PFILE_NAMES_INFORMATION Info;
Info = (PFILE_NAMES_INFORMATION) Buffer;
// FatQueryShortName(&FileName, Dirent);
Info->NextEntryOffset = sizeof(*Info);
/*
* Associate LFN buffer and length pointers
* of this entry with the context.
*/
/* Associate LFN buffer and length pointers
* of this entry with the context.
*/
Context->NextEntryOffset = &Info->NextEntryOffset;
Context->FileName = Info->FileName;
Context->FileNameLength = &Info->FileNameLength;
@ -492,10 +462,9 @@ FatDirentToNamesInfo(
}
ULONG
FatDirentToObjectIdInfo(
IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer)
FatDirentToObjectIdInfo(IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN PDIR_ENTRY Dirent,
IN PVOID Buffer)
{
PFILE_OBJECTID_INFORMATION Info;
@ -504,26 +473,23 @@ FatDirentToObjectIdInfo(
}
ULONG
FatEnumerateDirents(
IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN ULONG Index,
IN BOOLEAN CanWait)
FatEnumerateDirents(IN OUT PFAT_ENUM_DIR_CONTEXT Context,
IN ULONG Index,
IN BOOLEAN CanWait)
{
LONGLONG PageOffset;
SIZE_T OffsetWithinPage, PageValidLength;
PUCHAR Entry, BeyoudLastEntry;
/*
* Determine page offset and the offset within page
* for the first cluster.
*/
PUCHAR Entry, BeyondLastEntry;
/* Determine page offset and the offset within page
* for the first cluster.
*/
PageValidLength = PAGE_SIZE;
PageOffset = ((LONGLONG) Index) << BYTES_PER_DIRENT_LOG;
OffsetWithinPage = (SIZE_T) (PageOffset & (PAGE_SIZE - 1));
PageOffset -= OffsetWithinPage;
/*
* Check if the context already has the required page mapped.
* Map the first page is necessary.
*/
/* Check if the context already has the required page mapped.
* Map the first page is necessary.
*/
if (PageOffset != Context->PageOffset.QuadPart)
{
Context->PageOffset.QuadPart = PageOffset;
@ -532,24 +498,28 @@ FatEnumerateDirents(
CcUnpinData(Context->PageBcb);
Context->PageBcb = NULL;
}
if (!CcMapData(Context->FileObject, &Context->PageOffset,
PAGE_SIZE, CanWait, &Context->PageBcb, &Context->PageBuffer))
if (!CcMapData(Context->FileObject,
&Context->PageOffset,
PAGE_SIZE,
CanWait,
&Context->PageBcb,
&Context->PageBuffer))
{
Context->PageOffset.QuadPart = 0LL;
ExRaiseStatus(STATUS_CANT_WAIT);
}
}
Entry = Add2Ptr(Context->PageBuffer, OffsetWithinPage, PUCHAR);
/*
* Next Page Offset.
*/
/* Next Page Offset */
PageOffset = Context->PageOffset.QuadPart + PAGE_SIZE;
if (PageOffset > Context->BeyoundLastEntryOffset)
{
PageValidLength = (SIZE_T) (Context->BeyoundLastEntryOffset
- Context->PageOffset.QuadPart);
BeyoudLastEntry = Add2Ptr(Context->PageBuffer, PageValidLength, PUCHAR);
}
BeyondLastEntry = Add2Ptr(Context->PageBuffer, PageValidLength, PUCHAR);
while (TRUE)
{
{
do
{
if (*Entry == FAT_DIRENT_NEVER_USED)
@ -568,39 +538,38 @@ FatEnumerateDirents(
PDIR_ENTRY Dirent;
Dirent = (PDIR_ENTRY) Entry;
RtlCopyMemory(Context->DirentFileName,
Dirent->FileName,
sizeof(Dirent->FileName));
Dirent->FileName,
sizeof(Dirent->FileName));
}
}
while (++Entry < BeyoudLastEntry);
/*
* Check if this is the last available entry.
*/
} while (++Entry < BeyondLastEntry);
/* Check if this is the last available entry */
if (PageValidLength < PAGE_SIZE)
break;
/*
* We are getting beyound current page and
* are still in the continous run, map the next page.
*/
/* We are getting beyound current page and
* are still in the continous run, map the next page.
*/
Context->PageOffset.QuadPart = PageOffset;
CcUnpinData(Context->PageBcb);
if (!CcMapData(Context->FileObject,
&Context->PageOffset, PAGE_SIZE, CanWait,
&Context->PageBcb, &Context->PageBuffer))
&Context->PageOffset,
PAGE_SIZE,
CanWait,
&Context->PageBcb,
&Context->PageBuffer))
{
Context->PageBcb = NULL;
Context->PageOffset.QuadPart = 0LL;
ExRaiseStatus(STATUS_CANT_WAIT);
}
Entry = (PUCHAR) Context->PageBuffer;
/*
* Next Page Offset.
*/
/* Next Page Offset */
PageOffset = Context->PageOffset.QuadPart + PAGE_SIZE;
if (PageOffset > Context->BeyoundLastEntryOffset)
{
PageValidLength = (SIZE_T) (Context->BeyoundLastEntryOffset
- Context->PageOffset.QuadPart);
BeyoudLastEntry = Add2Ptr(Context->PageBuffer, PageValidLength, PUCHAR);
}
BeyondLastEntry = Add2Ptr(Context->PageBuffer, PageValidLength, PUCHAR);
}
return 0;
}