mirror of
https://github.com/reactos/reactos.git
synced 2025-07-28 01:41:48 +00:00
Fix indentation
svn path=/trunk/; revision=33311
This commit is contained in:
parent
d6273ed28e
commit
78fb45b54a
1 changed files with 657 additions and 667 deletions
|
@ -11,11 +11,12 @@
|
|||
#define NDEBUG
|
||||
#include "vfat.h"
|
||||
|
||||
NTSTATUS
|
||||
VfatUpdateEntry (PVFATFCB pFcb)
|
||||
/*
|
||||
* update an existing FAT entry
|
||||
*/
|
||||
NTSTATUS
|
||||
VfatUpdateEntry(
|
||||
IN PVFATFCB pFcb)
|
||||
{
|
||||
PVOID Context;
|
||||
PDIR_ENTRY PinEntry;
|
||||
|
@ -37,18 +38,18 @@ VfatUpdateEntry (PVFATFCB pFcb)
|
|||
dirIndex = pFcb->dirIndex;
|
||||
}
|
||||
|
||||
DPRINT ("updEntry dirIndex %d, PathName \'%wZ\'\n", dirIndex, &pFcb->PathNameU);
|
||||
DPRINT("updEntry dirIndex %d, PathName \'%wZ\'\n", dirIndex, &pFcb->PathNameU);
|
||||
|
||||
if (vfatFCBIsRoot(pFcb) || (pFcb->Flags & (FCB_IS_FAT|FCB_IS_VOLUME)))
|
||||
{
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
ASSERT (pFcb->parentFcb);
|
||||
ASSERT(pFcb->parentFcb);
|
||||
|
||||
Offset.u.HighPart = 0;
|
||||
Offset.u.LowPart = dirIndex * SizeDirEntry;
|
||||
if (CcPinRead (pFcb->parentFcb->FileObject, &Offset, SizeDirEntry,
|
||||
if (CcPinRead(pFcb->parentFcb->FileObject, &Offset, SizeDirEntry,
|
||||
TRUE, &Context, (PVOID*)&PinEntry))
|
||||
{
|
||||
pFcb->Flags &= ~FCB_IS_DIRTY;
|
||||
|
@ -59,21 +60,22 @@ VfatUpdateEntry (PVFATFCB pFcb)
|
|||
}
|
||||
else
|
||||
{
|
||||
DPRINT1 ("Failed write to \'%wZ\'.\n", &pFcb->parentFcb->PathNameU);
|
||||
DPRINT1("Failed write to \'%wZ\'.\n", &pFcb->parentFcb->PathNameU);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
vfatFindDirSpace(PDEVICE_EXTENSION DeviceExt,
|
||||
PVFATFCB pDirFcb,
|
||||
ULONG nbSlots,
|
||||
PULONG start)
|
||||
{
|
||||
/*
|
||||
* try to find contiguous entries frees in directory,
|
||||
* extend a directory if is neccesary
|
||||
*/
|
||||
BOOLEAN
|
||||
vfatFindDirSpace(
|
||||
IN PDEVICE_EXTENSION DeviceExt,
|
||||
IN PVFATFCB pDirFcb,
|
||||
IN ULONG nbSlots,
|
||||
OUT PULONG start)
|
||||
{
|
||||
LARGE_INTEGER FileOffset;
|
||||
ULONG i, count, size, nbFree = 0;
|
||||
PDIR_ENTRY pFatEntry;
|
||||
|
@ -97,8 +99,8 @@ vfatFindDirSpace(PDEVICE_EXTENSION DeviceExt,
|
|||
{
|
||||
CcUnpinData(Context);
|
||||
}
|
||||
// FIXME: check return value
|
||||
CcPinRead (pDirFcb->FileObject, &FileOffset, DeviceExt->FatInfo.BytesPerCluster,
|
||||
/* FIXME: check return value */
|
||||
CcPinRead(pDirFcb->FileObject, &FileOffset, DeviceExt->FatInfo.BytesPerCluster,
|
||||
TRUE, &Context, (PVOID*)&pFatEntry);
|
||||
FileOffset.u.LowPart += DeviceExt->FatInfo.BytesPerCluster;
|
||||
}
|
||||
|
@ -126,7 +128,7 @@ vfatFindDirSpace(PDEVICE_EXTENSION DeviceExt,
|
|||
}
|
||||
if (nbFree == nbSlots)
|
||||
{
|
||||
// found enough contiguous free slots
|
||||
/* found enough contiguous free slots */
|
||||
*start = i - nbSlots + 1;
|
||||
}
|
||||
else
|
||||
|
@ -136,10 +138,10 @@ vfatFindDirSpace(PDEVICE_EXTENSION DeviceExt,
|
|||
{
|
||||
LARGE_INTEGER AllocationSize;
|
||||
CHECKPOINT;
|
||||
// extend the directory
|
||||
/* extend the directory */
|
||||
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;
|
||||
}
|
||||
AllocationSize.QuadPart = pDirFcb->RFCB.FileSize.u.LowPart + DeviceExt->FatInfo.BytesPerCluster;
|
||||
|
@ -149,10 +151,10 @@ vfatFindDirSpace(PDEVICE_EXTENSION DeviceExt,
|
|||
{
|
||||
return FALSE;
|
||||
}
|
||||
// clear the new dir cluster
|
||||
/* clear the new dir cluster */
|
||||
FileOffset.u.LowPart = (ULONG)(pDirFcb->RFCB.FileSize.QuadPart -
|
||||
DeviceExt->FatInfo.BytesPerCluster);
|
||||
CcPinRead (pDirFcb->FileObject, &FileOffset, DeviceExt->FatInfo.BytesPerCluster,
|
||||
CcPinRead(pDirFcb->FileObject, &FileOffset, DeviceExt->FatInfo.BytesPerCluster,
|
||||
TRUE, &Context, (PVOID*)&pFatEntry);
|
||||
if (DeviceExt->Flags & VCB_IS_FATX)
|
||||
memset(pFatEntry, 0xff, DeviceExt->FatInfo.BytesPerCluster);
|
||||
|
@ -161,9 +163,9 @@ vfatFindDirSpace(PDEVICE_EXTENSION DeviceExt,
|
|||
}
|
||||
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;
|
||||
CcPinRead (pDirFcb->FileObject, &FileOffset, SizeDirEntry,
|
||||
CcPinRead(pDirFcb->FileObject, &FileOffset, SizeDirEntry,
|
||||
TRUE, &Context, (PVOID*)&pFatEntry);
|
||||
if (DeviceExt->Flags & VCB_IS_FATX)
|
||||
memset(pFatEntry, 0xff, SizeDirEntry);
|
||||
|
@ -176,20 +178,21 @@ vfatFindDirSpace(PDEVICE_EXTENSION DeviceExt,
|
|||
CcUnpinData(Context);
|
||||
}
|
||||
}
|
||||
DPRINT ("nbSlots %d nbFree %d, entry number %d\n", nbSlots, nbFree, *start);
|
||||
DPRINT("nbSlots %d nbFree %d, entry number %d\n", nbSlots, nbFree, *start);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static NTSTATUS
|
||||
FATAddEntry (PDEVICE_EXTENSION DeviceExt,
|
||||
PUNICODE_STRING NameU,
|
||||
PVFATFCB* Fcb,
|
||||
PVFATFCB ParentFcb,
|
||||
ULONG RequestedOptions,
|
||||
UCHAR ReqAttr)
|
||||
/*
|
||||
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;
|
||||
PFAT_DIR_ENTRY pFatEntry;
|
||||
|
@ -213,18 +216,19 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
|
|||
WCHAR LongNameBuffer[LONGNAME_MAX_LENGTH + 1];
|
||||
WCHAR ShortNameBuffer[13];
|
||||
|
||||
DPRINT ("addEntry: Name='%wZ', Dir='%wZ'\n", NameU, &ParentFcb->PathNameU);
|
||||
DPRINT("addEntry: Name='%wZ', Dir='%wZ'\n", NameU, &ParentFcb->PathNameU);
|
||||
|
||||
DirContext.LongNameU = *NameU;
|
||||
|
||||
nbSlots = (DirContext.LongNameU.Length / sizeof(WCHAR) + 12) / 13 + 1; //nb of entry needed for long name+normal entry
|
||||
DPRINT ("NameLen= %d, nbSlots =%d\n", DirContext.LongNameU.Length / sizeof(WCHAR), nbSlots);
|
||||
Buffer = ExAllocatePoolWithTag (NonPagedPool, (nbSlots - 1) * sizeof (FAT_DIR_ENTRY), TAG_VFAT);
|
||||
/* 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);
|
||||
Buffer = ExAllocatePoolWithTag(NonPagedPool, (nbSlots - 1) * sizeof(FAT_DIR_ENTRY), TAG_VFAT);
|
||||
if (Buffer == NULL)
|
||||
{
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
RtlZeroMemory (Buffer, (nbSlots - 1) * sizeof (FAT_DIR_ENTRY));
|
||||
RtlZeroMemory(Buffer, (nbSlots - 1) * sizeof(FAT_DIR_ENTRY));
|
||||
pSlots = (slot *) Buffer;
|
||||
|
||||
NameA.Buffer = aName;
|
||||
|
@ -257,7 +261,7 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
|
|||
RtlGenerate8dot3Name(&DirContext.LongNameU, FALSE, &NameContext, &DirContext.ShortNameU);
|
||||
DirContext.ShortNameU.Buffer[DirContext.ShortNameU.Length / sizeof(WCHAR)] = 0;
|
||||
SearchContext.DirIndex = 0;
|
||||
Status = FindFile (DeviceExt, ParentFcb, &DirContext.ShortNameU, &SearchContext, TRUE);
|
||||
Status = FindFile(DeviceExt, ParentFcb, &DirContext.ShortNameU, &SearchContext, TRUE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
break;
|
||||
|
@ -265,7 +269,7 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
|
|||
}
|
||||
if (i == 100) /* FIXME : what to do after this ? */
|
||||
{
|
||||
ExFreePool (Buffer);
|
||||
ExFreePoolWithTag(Buffer, TAG_VFAT);
|
||||
CHECKPOINT;
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
@ -317,7 +321,7 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
|
|||
needLong = TRUE;
|
||||
}
|
||||
}
|
||||
DPRINT ("'%s', '%wZ', needTilde=%d, needLong=%d\n",
|
||||
DPRINT("'%s', '%wZ', needTilde=%d, needLong=%d\n",
|
||||
aName, &DirContext.LongNameU, needTilde, needLong);
|
||||
memset(DirContext.DirEntry.Fat.ShortName, ' ', 11);
|
||||
for (i = 0; i < 8 && aName[i] && aName[i] != '.'; i++)
|
||||
|
@ -368,18 +372,8 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
|
|||
DirContext.DirEntry.Fat.Attrib |= FILE_ATTRIBUTE_DIRECTORY;
|
||||
}
|
||||
/* set dates and times */
|
||||
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,
|
||||
KeQuerySystemTime(&SystemTime);
|
||||
FsdSystemTimeToDosDateTime(DeviceExt, &SystemTime, &DirContext.DirEntry.Fat.CreationDate,
|
||||
&DirContext.DirEntry.Fat.CreationTime);
|
||||
DirContext.DirEntry.Fat.UpdateDate = DirContext.DirEntry.Fat.CreationDate;
|
||||
DirContext.DirEntry.Fat.UpdateTime = DirContext.DirEntry.Fat.CreationTime;
|
||||
|
@ -397,7 +391,7 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
|
|||
/* construct slots and entry */
|
||||
for (i = nbSlots - 2; i >= 0; i--)
|
||||
{
|
||||
DPRINT ("construct slot %d\n", i);
|
||||
DPRINT("construct slot %d\n", i);
|
||||
pSlots[i].attr = 0xf;
|
||||
if (i)
|
||||
{
|
||||
|
@ -408,25 +402,25 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
|
|||
pSlots[i].id = (unsigned char)(nbSlots - i - 1 + 0x40);
|
||||
}
|
||||
pSlots[i].alias_checksum = pSlots[0].alias_checksum;
|
||||
RtlCopyMemory (pSlots[i].name0_4, DirContext.LongNameU.Buffer + (nbSlots - i - 2) * 13, 10);
|
||||
RtlCopyMemory (pSlots[i].name5_10, DirContext.LongNameU.Buffer + (nbSlots - i - 2) * 13 + 5, 12);
|
||||
RtlCopyMemory (pSlots[i].name11_12, DirContext.LongNameU.Buffer + (nbSlots - i - 2) * 13 + 11, 4);
|
||||
RtlCopyMemory(pSlots[i].name0_4, DirContext.LongNameU.Buffer + (nbSlots - i - 2) * 13, 10);
|
||||
RtlCopyMemory(pSlots[i].name5_10, DirContext.LongNameU.Buffer + (nbSlots - i - 2) * 13 + 5, 12);
|
||||
RtlCopyMemory(pSlots[i].name11_12, DirContext.LongNameU.Buffer + (nbSlots - i - 2) * 13 + 11, 4);
|
||||
}
|
||||
}
|
||||
/* try to find nbSlots contiguous entries frees in directory */
|
||||
if (!vfatFindDirSpace(DeviceExt, ParentFcb, nbSlots, &DirContext.StartIndex))
|
||||
{
|
||||
ExFreePool (Buffer);
|
||||
ExFreePoolWithTag(Buffer, TAG_VFAT);
|
||||
return STATUS_DISK_FULL;
|
||||
}
|
||||
DirContext.DirIndex = DirContext.StartIndex + nbSlots - 1;
|
||||
if (RequestedOptions & FILE_DIRECTORY_FILE)
|
||||
{
|
||||
CurrentCluster = 0;
|
||||
Status = NextCluster (DeviceExt, 0, &CurrentCluster, TRUE);
|
||||
Status = NextCluster(DeviceExt, 0, &CurrentCluster, TRUE);
|
||||
if (CurrentCluster == 0xffffffff || !NT_SUCCESS(Status))
|
||||
{
|
||||
ExFreePool (Buffer);
|
||||
ExFreePoolWithTag(Buffer, TAG_VFAT);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
|
@ -447,7 +441,7 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
|
|||
{
|
||||
/* one cluster */
|
||||
CHECKPOINT;
|
||||
CcPinRead (ParentFcb->FileObject, &FileOffset, nbSlots * sizeof(FAT_DIR_ENTRY),
|
||||
CcPinRead(ParentFcb->FileObject, &FileOffset, nbSlots * sizeof(FAT_DIR_ENTRY),
|
||||
TRUE, &Context, (PVOID*)&pFatEntry);
|
||||
if (nbSlots > 1)
|
||||
{
|
||||
|
@ -462,13 +456,13 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
|
|||
size = DeviceExt->FatInfo.BytesPerCluster -
|
||||
(DirContext.StartIndex * sizeof(FAT_DIR_ENTRY)) % DeviceExt->FatInfo.BytesPerCluster;
|
||||
i = size / sizeof(FAT_DIR_ENTRY);
|
||||
CcPinRead (ParentFcb->FileObject, &FileOffset, size, TRUE,
|
||||
CcPinRead(ParentFcb->FileObject, &FileOffset, size, TRUE,
|
||||
&Context, (PVOID*)&pFatEntry);
|
||||
RtlCopyMemory(pFatEntry, Buffer, size);
|
||||
CcSetDirtyPinnedData(Context, NULL);
|
||||
CcUnpinData(Context);
|
||||
FileOffset.u.LowPart += size;
|
||||
CcPinRead (ParentFcb->FileObject, &FileOffset,
|
||||
CcPinRead(ParentFcb->FileObject, &FileOffset,
|
||||
nbSlots * sizeof(FAT_DIR_ENTRY) - size,
|
||||
TRUE, &Context, (PVOID*)&pFatEntry);
|
||||
if (nbSlots - 1 > i)
|
||||
|
@ -481,23 +475,23 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
|
|||
CcUnpinData(Context);
|
||||
|
||||
/* FIXME: check status */
|
||||
vfatMakeFCBFromDirEntry (DeviceExt, ParentFcb, &DirContext, Fcb);
|
||||
vfatMakeFCBFromDirEntry(DeviceExt, ParentFcb, &DirContext, Fcb);
|
||||
|
||||
DPRINT ("new : entry=%11.11s\n", (*Fcb)->entry.Fat.Filename);
|
||||
DPRINT ("new : entry=%11.11s\n", DirContext.DirEntry.Fat.Filename);
|
||||
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)
|
||||
{
|
||||
FileOffset.QuadPart = 0;
|
||||
CcMapData ((*Fcb)->FileObject, &FileOffset, DeviceExt->FatInfo.BytesPerCluster, TRUE,
|
||||
CcMapData((*Fcb)->FileObject, &FileOffset, DeviceExt->FatInfo.BytesPerCluster, TRUE,
|
||||
&Context, (PVOID*)&pFatEntry);
|
||||
/* clear the new directory cluster */
|
||||
RtlZeroMemory (pFatEntry, DeviceExt->FatInfo.BytesPerCluster);
|
||||
RtlZeroMemory(pFatEntry, DeviceExt->FatInfo.BytesPerCluster);
|
||||
/* create '.' and '..' */
|
||||
RtlCopyMemory (&pFatEntry[0].Attrib, &DirContext.DirEntry.Fat.Attrib, sizeof(FAT_DIR_ENTRY) - 11);
|
||||
RtlCopyMemory (pFatEntry[0].ShortName, ". ", 11);
|
||||
RtlCopyMemory (&pFatEntry[1].Attrib, &DirContext.DirEntry.Fat.Attrib, sizeof(FAT_DIR_ENTRY) - 11);
|
||||
RtlCopyMemory (pFatEntry[1].ShortName, ".. ", 11);
|
||||
RtlCopyMemory(&pFatEntry[0].Attrib, &DirContext.DirEntry.Fat.Attrib, sizeof(FAT_DIR_ENTRY) - 11);
|
||||
RtlCopyMemory(pFatEntry[0].ShortName, ". ", 11);
|
||||
RtlCopyMemory(&pFatEntry[1].Attrib, &DirContext.DirEntry.Fat.Attrib, sizeof(FAT_DIR_ENTRY) - 11);
|
||||
RtlCopyMemory(pFatEntry[1].ShortName, ".. ", 11);
|
||||
pFatEntry[1].FirstCluster = ParentFcb->entry.Fat.FirstCluster;
|
||||
pFatEntry[1].FirstClusterHigh = ParentFcb->entry.Fat.FirstClusterHigh;
|
||||
if (vfatFCBIsRoot(ParentFcb))
|
||||
|
@ -508,21 +502,22 @@ FATAddEntry (PDEVICE_EXTENSION DeviceExt,
|
|||
CcSetDirtyPinnedData(Context, NULL);
|
||||
CcUnpinData(Context);
|
||||
}
|
||||
ExFreePool (Buffer);
|
||||
DPRINT ("addentry ok\n");
|
||||
ExFreePoolWithTag(Buffer, TAG_VFAT);
|
||||
DPRINT("addentry ok\n");
|
||||
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
|
||||
*/
|
||||
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;
|
||||
LARGE_INTEGER SystemTime, FileOffset;
|
||||
|
@ -531,7 +526,7 @@ FATXAddEntry (PDEVICE_EXTENSION DeviceExt,
|
|||
PFATX_DIR_ENTRY pFatXDirEntry;
|
||||
ULONG Index;
|
||||
|
||||
DPRINT ("addEntry: Name='%wZ', Dir='%wZ'\n", NameU, &ParentFcb->PathNameU);
|
||||
DPRINT("addEntry: Name='%wZ', Dir='%wZ'\n", NameU, &ParentFcb->PathNameU);
|
||||
|
||||
DirContext.LongNameU = *NameU;
|
||||
|
||||
|
@ -577,19 +572,7 @@ FATXAddEntry (PDEVICE_EXTENSION DeviceExt,
|
|||
}
|
||||
|
||||
/* set dates and times */
|
||||
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
|
||||
|
||||
|
||||
KeQuerySystemTime(&SystemTime);
|
||||
FsdSystemTimeToDosDateTime(DeviceExt, &SystemTime, &DirContext.DirEntry.FatX.CreationDate,
|
||||
&DirContext.DirEntry.FatX.CreationTime);
|
||||
DirContext.DirEntry.FatX.UpdateDate = DirContext.DirEntry.FatX.CreationDate;
|
||||
|
@ -614,12 +597,13 @@ FATXAddEntry (PDEVICE_EXTENSION DeviceExt,
|
|||
}
|
||||
|
||||
NTSTATUS
|
||||
VfatAddEntry (PDEVICE_EXTENSION DeviceExt,
|
||||
PUNICODE_STRING NameU,
|
||||
PVFATFCB *Fcb,
|
||||
PVFATFCB ParentFcb,
|
||||
ULONG RequestedOptions,
|
||||
UCHAR ReqAttr)
|
||||
VfatAddEntry(
|
||||
IN PDEVICE_EXTENSION DeviceExt,
|
||||
IN PUNICODE_STRING NameU,
|
||||
IN PVFATFCB *Fcb,
|
||||
IN PVFATFCB ParentFcb,
|
||||
IN ULONG RequestedOptions,
|
||||
IN UCHAR ReqAttr)
|
||||
{
|
||||
if (DeviceExt->Flags & VCB_IS_FATX)
|
||||
return FATXAddEntry(DeviceExt, NameU, Fcb, ParentFcb, RequestedOptions, ReqAttr);
|
||||
|
@ -627,11 +611,13 @@ VfatAddEntry (PDEVICE_EXTENSION DeviceExt,
|
|||
return FATAddEntry(DeviceExt, NameU, Fcb, ParentFcb, RequestedOptions, ReqAttr);
|
||||
}
|
||||
|
||||
static NTSTATUS
|
||||
FATDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
|
||||
/*
|
||||
* deleting an existing FAT entry
|
||||
*/
|
||||
static NTSTATUS
|
||||
FATDelEntry(
|
||||
IN PDEVICE_EXTENSION DeviceExt,
|
||||
IN PVFATFCB pFcb)
|
||||
{
|
||||
ULONG CurrentCluster = 0, NextCluster, i;
|
||||
PVOID Context = NULL;
|
||||
|
@ -641,8 +627,8 @@ FATDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
|
|||
ASSERT(pFcb);
|
||||
ASSERT(pFcb->parentFcb);
|
||||
|
||||
DPRINT ("delEntry PathName \'%wZ\'\n", &pFcb->PathNameU);
|
||||
DPRINT ("delete entry: %d to %d\n", pFcb->startIndex, pFcb->dirIndex);
|
||||
DPRINT("delEntry PathName \'%wZ\'\n", &pFcb->PathNameU);
|
||||
DPRINT("delete entry: %d to %d\n", pFcb->startIndex, pFcb->dirIndex);
|
||||
Offset.u.HighPart = 0;
|
||||
for (i = pFcb->startIndex; i <= pFcb->dirIndex; i++)
|
||||
{
|
||||
|
@ -654,14 +640,14 @@ FATDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
|
|||
CcUnpinData(Context);
|
||||
}
|
||||
Offset.u.LowPart = (i * sizeof(FAT_DIR_ENTRY) / PAGE_SIZE) * PAGE_SIZE;
|
||||
CcPinRead (pFcb->parentFcb->FileObject, &Offset, PAGE_SIZE, TRUE,
|
||||
CcPinRead(pFcb->parentFcb->FileObject, &Offset, PAGE_SIZE, TRUE,
|
||||
&Context, (PVOID*)&pDirEntry);
|
||||
}
|
||||
pDirEntry[i % (PAGE_SIZE / sizeof(FAT_DIR_ENTRY))].Filename[0] = 0xe5;
|
||||
if (i == pFcb->dirIndex)
|
||||
{
|
||||
CurrentCluster =
|
||||
vfatDirEntryGetFirstCluster (DeviceExt,
|
||||
vfatDirEntryGetFirstCluster(DeviceExt,
|
||||
(PDIR_ENTRY)&pDirEntry[i % (PAGE_SIZE / sizeof(FAT_DIR_ENTRY))]);
|
||||
}
|
||||
}
|
||||
|
@ -673,7 +659,7 @@ FATDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
|
|||
|
||||
while (CurrentCluster && CurrentCluster != 0xffffffff)
|
||||
{
|
||||
GetNextCluster (DeviceExt, CurrentCluster, &NextCluster);
|
||||
GetNextCluster(DeviceExt, CurrentCluster, &NextCluster);
|
||||
/* FIXME: check status */
|
||||
WriteCluster(DeviceExt, CurrentCluster, 0);
|
||||
CurrentCluster = NextCluster;
|
||||
|
@ -681,11 +667,13 @@ FATDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static NTSTATUS
|
||||
FATXDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
|
||||
/*
|
||||
* deleting an existing FAT entry
|
||||
*/
|
||||
static NTSTATUS
|
||||
FATXDelEntry(
|
||||
IN PDEVICE_EXTENSION DeviceExt,
|
||||
IN PVFATFCB pFcb)
|
||||
{
|
||||
ULONG CurrentCluster = 0, NextCluster;
|
||||
PVOID Context = NULL;
|
||||
|
@ -699,11 +687,11 @@ FATXDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
|
|||
|
||||
StartIndex = pFcb->startIndex;
|
||||
|
||||
DPRINT ("delEntry PathName \'%wZ\'\n", &pFcb->PathNameU);
|
||||
DPRINT ("delete entry: %d\n", StartIndex);
|
||||
DPRINT("delEntry PathName \'%wZ\'\n", &pFcb->PathNameU);
|
||||
DPRINT("delete entry: %d\n", StartIndex);
|
||||
Offset.u.HighPart = 0;
|
||||
Offset.u.LowPart = (StartIndex * sizeof(FATX_DIR_ENTRY) / PAGE_SIZE) * PAGE_SIZE;
|
||||
if (!CcPinRead (pFcb->parentFcb->FileObject, &Offset, PAGE_SIZE, TRUE,
|
||||
if (!CcPinRead(pFcb->parentFcb->FileObject, &Offset, PAGE_SIZE, TRUE,
|
||||
&Context, (PVOID*)&pDirEntry))
|
||||
{
|
||||
DPRINT1("CcPinRead(Offset %x:%x, Length %d) failed\n", Offset.u.HighPart, Offset.u.LowPart, PAGE_SIZE);
|
||||
|
@ -711,14 +699,14 @@ FATXDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
|
|||
}
|
||||
pDirEntry = &pDirEntry[StartIndex % (PAGE_SIZE / sizeof(FATX_DIR_ENTRY))];
|
||||
pDirEntry->FilenameLength = 0xe5;
|
||||
CurrentCluster = vfatDirEntryGetFirstCluster (DeviceExt,
|
||||
CurrentCluster = vfatDirEntryGetFirstCluster(DeviceExt,
|
||||
(PDIR_ENTRY)pDirEntry);
|
||||
CcSetDirtyPinnedData(Context, NULL);
|
||||
CcUnpinData(Context);
|
||||
|
||||
while (CurrentCluster && CurrentCluster != 0xffffffff)
|
||||
{
|
||||
GetNextCluster (DeviceExt, CurrentCluster, &NextCluster);
|
||||
GetNextCluster(DeviceExt, CurrentCluster, &NextCluster);
|
||||
/* FIXME: check status */
|
||||
WriteCluster(DeviceExt, CurrentCluster, 0);
|
||||
CurrentCluster = NextCluster;
|
||||
|
@ -727,7 +715,9 @@ FATXDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
|
|||
}
|
||||
|
||||
NTSTATUS
|
||||
VfatDelEntry (PDEVICE_EXTENSION DeviceExt, PVFATFCB pFcb)
|
||||
VfatDelEntry(
|
||||
IN PDEVICE_EXTENSION DeviceExt,
|
||||
IN PVFATFCB pFcb)
|
||||
{
|
||||
if (DeviceExt->Flags & VCB_IS_FATX)
|
||||
return FATXDelEntry(DeviceExt, pFcb);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue