Fix indentation

svn path=/trunk/; revision=33311
This commit is contained in:
Hervé Poussineau 2008-05-06 06:57:05 +00:00
parent d6273ed28e
commit 78fb45b54a

View file

@ -11,11 +11,12 @@
#define NDEBUG #define NDEBUG
#include "vfat.h" #include "vfat.h"
NTSTATUS
VfatUpdateEntry (PVFATFCB pFcb)
/* /*
* update an existing FAT entry * update an existing FAT entry
*/ */
NTSTATUS
VfatUpdateEntry(
IN PVFATFCB pFcb)
{ {
PVOID Context; PVOID Context;
PDIR_ENTRY PinEntry; PDIR_ENTRY PinEntry;
@ -64,16 +65,17 @@ VfatUpdateEntry (PVFATFCB pFcb)
} }
} }
BOOLEAN
vfatFindDirSpace(PDEVICE_EXTENSION DeviceExt,
PVFATFCB pDirFcb,
ULONG nbSlots,
PULONG start)
{
/* /*
* try to find contiguous entries frees in directory, * try to find contiguous entries frees in directory,
* extend a directory if is neccesary * extend a directory if is neccesary
*/ */
BOOLEAN
vfatFindDirSpace(
IN PDEVICE_EXTENSION DeviceExt,
IN PVFATFCB pDirFcb,
IN ULONG nbSlots,
OUT PULONG start)
{
LARGE_INTEGER FileOffset; LARGE_INTEGER FileOffset;
ULONG i, count, size, nbFree = 0; ULONG i, count, size, nbFree = 0;
PDIR_ENTRY pFatEntry; PDIR_ENTRY pFatEntry;
@ -97,7 +99,7 @@ vfatFindDirSpace(PDEVICE_EXTENSION DeviceExt,
{ {
CcUnpinData(Context); CcUnpinData(Context);
} }
// FIXME: check return value /* FIXME: check return value */
CcPinRead(pDirFcb->FileObject, &FileOffset, DeviceExt->FatInfo.BytesPerCluster, CcPinRead(pDirFcb->FileObject, &FileOffset, DeviceExt->FatInfo.BytesPerCluster,
TRUE, &Context, (PVOID*)&pFatEntry); TRUE, &Context, (PVOID*)&pFatEntry);
FileOffset.u.LowPart += DeviceExt->FatInfo.BytesPerCluster; FileOffset.u.LowPart += DeviceExt->FatInfo.BytesPerCluster;
@ -126,7 +128,7 @@ vfatFindDirSpace(PDEVICE_EXTENSION DeviceExt,
} }
if (nbFree == nbSlots) if (nbFree == nbSlots)
{ {
// found enough contiguous free slots /* found enough contiguous free slots */
*start = i - nbSlots + 1; *start = i - nbSlots + 1;
} }
else else
@ -136,10 +138,10 @@ vfatFindDirSpace(PDEVICE_EXTENSION DeviceExt,
{ {
LARGE_INTEGER AllocationSize; LARGE_INTEGER AllocationSize;
CHECKPOINT; CHECKPOINT;
// extend the directory /* extend the directory */
if (vfatFCBIsRoot(pDirFcb) && DeviceExt->FatInfo.FatType != FAT32) if (vfatFCBIsRoot(pDirFcb) && DeviceExt->FatInfo.FatType != FAT32)
{ {
// We can't extend a root directory on a FAT12/FAT16/FATX partition /* We can't extend a root directory on a FAT12/FAT16/FATX partition */
return FALSE; return FALSE;
} }
AllocationSize.QuadPart = pDirFcb->RFCB.FileSize.u.LowPart + DeviceExt->FatInfo.BytesPerCluster; AllocationSize.QuadPart = pDirFcb->RFCB.FileSize.u.LowPart + DeviceExt->FatInfo.BytesPerCluster;
@ -149,7 +151,7 @@ vfatFindDirSpace(PDEVICE_EXTENSION DeviceExt,
{ {
return FALSE; return FALSE;
} }
// clear the new dir cluster /* clear the new dir cluster */
FileOffset.u.LowPart = (ULONG)(pDirFcb->RFCB.FileSize.QuadPart - FileOffset.u.LowPart = (ULONG)(pDirFcb->RFCB.FileSize.QuadPart -
DeviceExt->FatInfo.BytesPerCluster); DeviceExt->FatInfo.BytesPerCluster);
CcPinRead(pDirFcb->FileObject, &FileOffset, DeviceExt->FatInfo.BytesPerCluster, CcPinRead(pDirFcb->FileObject, &FileOffset, DeviceExt->FatInfo.BytesPerCluster,
@ -161,7 +163,7 @@ vfatFindDirSpace(PDEVICE_EXTENSION DeviceExt,
} }
else if (*start + nbSlots < count) else if (*start + nbSlots < count)
{ {
// clear the entry after the last new entry /* clear the entry after the last new entry */
FileOffset.u.LowPart = (*start + nbSlots) * SizeDirEntry; FileOffset.u.LowPart = (*start + nbSlots) * SizeDirEntry;
CcPinRead(pDirFcb->FileObject, &FileOffset, SizeDirEntry, CcPinRead(pDirFcb->FileObject, &FileOffset, SizeDirEntry,
TRUE, &Context, (PVOID*)&pFatEntry); TRUE, &Context, (PVOID*)&pFatEntry);
@ -180,16 +182,17 @@ vfatFindDirSpace(PDEVICE_EXTENSION DeviceExt,
return TRUE; return TRUE;
} }
static NTSTATUS
FATAddEntry (PDEVICE_EXTENSION DeviceExt,
PUNICODE_STRING NameU,
PVFATFCB* Fcb,
PVFATFCB ParentFcb,
ULONG RequestedOptions,
UCHAR ReqAttr)
/* /*
create a new FAT entry create a new FAT entry
*/ */
static NTSTATUS
FATAddEntry(
IN PDEVICE_EXTENSION DeviceExt,
IN PUNICODE_STRING NameU,
IN PVFATFCB* Fcb,
IN PVFATFCB ParentFcb,
IN ULONG RequestedOptions,
IN UCHAR ReqAttr)
{ {
PVOID Context = NULL; PVOID Context = NULL;
PFAT_DIR_ENTRY pFatEntry; PFAT_DIR_ENTRY pFatEntry;
@ -217,7 +220,8 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
DirContext.LongNameU = *NameU; DirContext.LongNameU = *NameU;
nbSlots = (DirContext.LongNameU.Length / sizeof(WCHAR) + 12) / 13 + 1; //nb of entry needed for long name+normal entry /* nb of entry needed for long name+normal entry */
nbSlots = (DirContext.LongNameU.Length / sizeof(WCHAR) + 12) / 13 + 1;
DPRINT("NameLen= %d, nbSlots =%d\n", DirContext.LongNameU.Length / sizeof(WCHAR), nbSlots); DPRINT("NameLen= %d, nbSlots =%d\n", DirContext.LongNameU.Length / sizeof(WCHAR), nbSlots);
Buffer = ExAllocatePoolWithTag(NonPagedPool, (nbSlots - 1) * sizeof(FAT_DIR_ENTRY), TAG_VFAT); Buffer = ExAllocatePoolWithTag(NonPagedPool, (nbSlots - 1) * sizeof(FAT_DIR_ENTRY), TAG_VFAT);
if (Buffer == NULL) if (Buffer == NULL)
@ -265,7 +269,7 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
} }
if (i == 100) /* FIXME : what to do after this ? */ if (i == 100) /* FIXME : what to do after this ? */
{ {
ExFreePool (Buffer); ExFreePoolWithTag(Buffer, TAG_VFAT);
CHECKPOINT; CHECKPOINT;
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
@ -369,16 +373,6 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
} }
/* set dates and times */ /* set dates and times */
KeQuerySystemTime(&SystemTime); KeQuerySystemTime(&SystemTime);
#if 0
{
TIME_FIELDS tf;
RtlTimeToTimeFields (&SystemTime, &tf);
DPRINT1("%d.%d.%d %02d:%02d:%02d.%03d '%wZ'\n",
tf.Day, tf.Month, tf.Year, tf.Hour,
tf.Minute, tf.Second, tf.Milliseconds,
NameU);
}
#endif
FsdSystemTimeToDosDateTime(DeviceExt, &SystemTime, &DirContext.DirEntry.Fat.CreationDate, FsdSystemTimeToDosDateTime(DeviceExt, &SystemTime, &DirContext.DirEntry.Fat.CreationDate,
&DirContext.DirEntry.Fat.CreationTime); &DirContext.DirEntry.Fat.CreationTime);
DirContext.DirEntry.Fat.UpdateDate = DirContext.DirEntry.Fat.CreationDate; DirContext.DirEntry.Fat.UpdateDate = DirContext.DirEntry.Fat.CreationDate;
@ -416,7 +410,7 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
/* try to find nbSlots contiguous entries frees in directory */ /* try to find nbSlots contiguous entries frees in directory */
if (!vfatFindDirSpace(DeviceExt, ParentFcb, nbSlots, &DirContext.StartIndex)) if (!vfatFindDirSpace(DeviceExt, ParentFcb, nbSlots, &DirContext.StartIndex))
{ {
ExFreePool (Buffer); ExFreePoolWithTag(Buffer, TAG_VFAT);
return STATUS_DISK_FULL; return STATUS_DISK_FULL;
} }
DirContext.DirIndex = DirContext.StartIndex + nbSlots - 1; DirContext.DirIndex = DirContext.StartIndex + nbSlots - 1;
@ -426,7 +420,7 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
Status = NextCluster(DeviceExt, 0, &CurrentCluster, TRUE); Status = NextCluster(DeviceExt, 0, &CurrentCluster, TRUE);
if (CurrentCluster == 0xffffffff || !NT_SUCCESS(Status)) if (CurrentCluster == 0xffffffff || !NT_SUCCESS(Status))
{ {
ExFreePool (Buffer); ExFreePoolWithTag(Buffer, TAG_VFAT);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
return Status; return Status;
@ -508,21 +502,22 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
CcSetDirtyPinnedData(Context, NULL); CcSetDirtyPinnedData(Context, NULL);
CcUnpinData(Context); CcUnpinData(Context);
} }
ExFreePool (Buffer); ExFreePoolWithTag(Buffer, TAG_VFAT);
DPRINT("addentry ok\n"); DPRINT("addentry ok\n");
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
static NTSTATUS
FATXAddEntry (PDEVICE_EXTENSION DeviceExt,
PUNICODE_STRING NameU,
PVFATFCB* Fcb,
PVFATFCB ParentFcb,
ULONG RequestedOptions,
UCHAR ReqAttr)
/* /*
create a new FAT entry create a new FAT entry
*/ */
static NTSTATUS
FATXAddEntry(
IN PDEVICE_EXTENSION DeviceExt,
IN PUNICODE_STRING NameU,
IN PVFATFCB* Fcb,
IN PVFATFCB ParentFcb,
IN ULONG RequestedOptions,
IN UCHAR ReqAttr)
{ {
PVOID Context = NULL; PVOID Context = NULL;
LARGE_INTEGER SystemTime, FileOffset; LARGE_INTEGER SystemTime, FileOffset;
@ -578,18 +573,6 @@ FATXAddEntry (PDEVICE_EXTENSION DeviceExt,
/* set dates and times */ /* set dates and times */
KeQuerySystemTime(&SystemTime); KeQuerySystemTime(&SystemTime);
#if 0
{
TIME_FIELDS tf;
RtlTimeToTimeFields (&SystemTime, &tf);
DPRINT1("%d.%d.%d %02d:%02d:%02d.%03d '%wZ'\n",
tf.Day, tf.Month, tf.Year, tf.Hour,
tf.Minute, tf.Second, tf.Milliseconds,
NameU);
}
#endif
FsdSystemTimeToDosDateTime(DeviceExt, &SystemTime, &DirContext.DirEntry.FatX.CreationDate, FsdSystemTimeToDosDateTime(DeviceExt, &SystemTime, &DirContext.DirEntry.FatX.CreationDate,
&DirContext.DirEntry.FatX.CreationTime); &DirContext.DirEntry.FatX.CreationTime);
DirContext.DirEntry.FatX.UpdateDate = DirContext.DirEntry.FatX.CreationDate; DirContext.DirEntry.FatX.UpdateDate = DirContext.DirEntry.FatX.CreationDate;
@ -614,12 +597,13 @@ FATXAddEntry (PDEVICE_EXTENSION DeviceExt,
} }
NTSTATUS NTSTATUS
VfatAddEntry (PDEVICE_EXTENSION DeviceExt, VfatAddEntry(
PUNICODE_STRING NameU, IN PDEVICE_EXTENSION DeviceExt,
PVFATFCB *Fcb, IN PUNICODE_STRING NameU,
PVFATFCB ParentFcb, IN PVFATFCB *Fcb,
ULONG RequestedOptions, IN PVFATFCB ParentFcb,
UCHAR ReqAttr) IN ULONG RequestedOptions,
IN UCHAR ReqAttr)
{ {
if (DeviceExt->Flags & VCB_IS_FATX) if (DeviceExt->Flags & VCB_IS_FATX)
return FATXAddEntry(DeviceExt, NameU, Fcb, ParentFcb, RequestedOptions, ReqAttr); return FATXAddEntry(DeviceExt, NameU, Fcb, ParentFcb, RequestedOptions, ReqAttr);
@ -627,11 +611,13 @@ VfatAddEntry (PDEVICE_EXTENSION DeviceExt,
return FATAddEntry(DeviceExt, NameU, Fcb, ParentFcb, RequestedOptions, ReqAttr); return FATAddEntry(DeviceExt, NameU, Fcb, ParentFcb, RequestedOptions, ReqAttr);
} }
static NTSTATUS
FATDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
/* /*
* deleting an existing FAT entry * deleting an existing FAT entry
*/ */
static NTSTATUS
FATDelEntry(
IN PDEVICE_EXTENSION DeviceExt,
IN PVFATFCB pFcb)
{ {
ULONG CurrentCluster = 0, NextCluster, i; ULONG CurrentCluster = 0, NextCluster, i;
PVOID Context = NULL; PVOID Context = NULL;
@ -681,11 +667,13 @@ FATDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
static NTSTATUS
FATXDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
/* /*
* deleting an existing FAT entry * deleting an existing FAT entry
*/ */
static NTSTATUS
FATXDelEntry(
IN PDEVICE_EXTENSION DeviceExt,
IN PVFATFCB pFcb)
{ {
ULONG CurrentCluster = 0, NextCluster; ULONG CurrentCluster = 0, NextCluster;
PVOID Context = NULL; PVOID Context = NULL;
@ -727,7 +715,9 @@ FATXDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
} }
NTSTATUS NTSTATUS
VfatDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb) VfatDelEntry(
IN PDEVICE_EXTENSION DeviceExt,
IN PVFATFCB pFcb)
{ {
if (DeviceExt->Flags & VCB_IS_FATX) if (DeviceExt->Flags & VCB_IS_FATX)
return FATXDelEntry(DeviceExt, pFcb); return FATXDelEntry(DeviceExt, pFcb);