2005-08-24 18:29:45 +00:00
|
|
|
/*
|
1999-01-13 15:25:50 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
* FILE: drivers/filesystems/fastfat/dirwr.c
|
1999-01-13 15:25:50 +00:00
|
|
|
* PURPOSE: VFAT Filesystem : write in directory
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
* PROGRAMMER: Rex Jolliff (rex@lvcablemodem.com)
|
|
|
|
* Herve Poussineau (reactos@poussine.freesurf.fr)
|
|
|
|
* Pierre Schweitzer (pierre@reactos.org)
|
2000-03-12 23:28:59 +00:00
|
|
|
*
|
|
|
|
*/
|
1999-01-13 15:25:50 +00:00
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
|
|
|
#include "vfat.h"
|
|
|
|
|
2013-12-19 16:20:28 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
2018-05-18 12:03:20 +00:00
|
|
|
#ifdef KDBG
|
|
|
|
extern UNICODE_STRING DebugFile;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
vfatFCBInitializeCacheFromVolume(
|
|
|
|
PVCB vcb,
|
|
|
|
PVFATFCB fcb)
|
|
|
|
{
|
|
|
|
PFILE_OBJECT fileObject;
|
|
|
|
PVFATCCB newCCB;
|
|
|
|
NTSTATUS status;
|
|
|
|
BOOLEAN Acquired;
|
|
|
|
|
|
|
|
/* Don't re-initialize if already done */
|
|
|
|
if (BooleanFlagOn(fcb->Flags, FCB_CACHE_INITIALIZED))
|
|
|
|
{
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT(vfatFCBIsDirectory(fcb));
|
2018-05-18 12:51:24 +00:00
|
|
|
ASSERT(fcb->FileObject == NULL);
|
2018-05-18 12:03:20 +00:00
|
|
|
|
|
|
|
Acquired = FALSE;
|
|
|
|
if (!ExIsResourceAcquiredExclusive(&vcb->DirResource))
|
|
|
|
{
|
|
|
|
ExAcquireResourceExclusiveLite(&vcb->DirResource, TRUE);
|
|
|
|
Acquired = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
fileObject = IoCreateStreamFileObject (NULL, vcb->StorageDevice);
|
2018-05-20 11:53:11 +00:00
|
|
|
if (fileObject == NULL)
|
|
|
|
{
|
|
|
|
status = STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
goto Quit;
|
|
|
|
}
|
2018-05-18 12:03:20 +00:00
|
|
|
|
|
|
|
#ifdef KDBG
|
|
|
|
if (DebugFile.Buffer != NULL && FsRtlIsNameInExpression(&DebugFile, &fcb->LongNameU, FALSE, NULL))
|
|
|
|
{
|
|
|
|
DPRINT1("Attaching %p to %p (%d)\n", fcb, fileObject, fcb->RefCount);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
newCCB = ExAllocateFromNPagedLookasideList(&VfatGlobalData->CcbLookasideList);
|
|
|
|
if (newCCB == NULL)
|
|
|
|
{
|
2018-05-19 11:45:56 +00:00
|
|
|
status = STATUS_INSUFFICIENT_RESOURCES;
|
2018-05-18 12:03:20 +00:00
|
|
|
ObDereferenceObject(fileObject);
|
2018-05-19 08:07:14 +00:00
|
|
|
goto Quit;
|
2018-05-18 12:03:20 +00:00
|
|
|
}
|
|
|
|
RtlZeroMemory(newCCB, sizeof (VFATCCB));
|
|
|
|
|
|
|
|
fileObject->SectionObjectPointer = &fcb->SectionObjectPointers;
|
|
|
|
fileObject->FsContext = fcb;
|
|
|
|
fileObject->FsContext2 = newCCB;
|
|
|
|
fileObject->Vpb = vcb->IoVPB;
|
|
|
|
fcb->FileObject = fileObject;
|
|
|
|
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
CcInitializeCacheMap(fileObject,
|
|
|
|
(PCC_FILE_SIZES)(&fcb->RFCB.AllocationSize),
|
|
|
|
TRUE,
|
|
|
|
&VfatGlobalData->CacheMgrCallbacks,
|
|
|
|
fcb);
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
status = _SEH2_GetExceptionCode();
|
|
|
|
fcb->FileObject = NULL;
|
|
|
|
ExFreeToNPagedLookasideList(&VfatGlobalData->CcbLookasideList, newCCB);
|
|
|
|
ObDereferenceObject(fileObject);
|
2018-05-19 08:07:14 +00:00
|
|
|
if (Acquired)
|
|
|
|
{
|
|
|
|
ExReleaseResourceLite(&vcb->DirResource);
|
|
|
|
}
|
2018-05-18 12:03:20 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
|
|
|
|
vfatGrabFCB(vcb, fcb);
|
|
|
|
SetFlag(fcb->Flags, FCB_CACHE_INITIALIZED);
|
2018-05-19 11:45:56 +00:00
|
|
|
status = STATUS_SUCCESS;
|
2018-05-18 12:03:20 +00:00
|
|
|
|
2018-05-19 08:07:14 +00:00
|
|
|
Quit:
|
2018-05-18 12:03:20 +00:00
|
|
|
if (Acquired)
|
|
|
|
{
|
|
|
|
ExReleaseResourceLite(&vcb->DirResource);
|
|
|
|
}
|
|
|
|
|
2018-05-19 11:45:56 +00:00
|
|
|
return status;
|
2018-05-18 12:03:20 +00:00
|
|
|
}
|
|
|
|
|
1999-01-13 15:25:50 +00:00
|
|
|
/*
|
2002-03-18 22:37:13 +00:00
|
|
|
* update an existing FAT entry
|
|
|
|
*/
|
2008-05-06 06:57:05 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatUpdateEntry(
|
2018-05-18 12:03:20 +00:00
|
|
|
IN PDEVICE_EXTENSION DeviceExt,
|
|
|
|
IN PVFATFCB pFcb)
|
1999-01-13 15:25:50 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
PVOID Context;
|
|
|
|
PDIR_ENTRY PinEntry;
|
|
|
|
LARGE_INTEGER Offset;
|
|
|
|
ULONG SizeDirEntry;
|
|
|
|
ULONG dirIndex;
|
2018-05-18 12:03:20 +00:00
|
|
|
NTSTATUS Status;
|
2000-03-13 17:58:06 +00:00
|
|
|
|
2008-05-06 06:57:05 +00:00
|
|
|
ASSERT(pFcb);
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2018-05-18 12:03:20 +00:00
|
|
|
if (vfatVolumeIsFatX(DeviceExt))
|
2008-05-06 06:57:05 +00:00
|
|
|
{
|
|
|
|
SizeDirEntry = sizeof(FATX_DIR_ENTRY);
|
|
|
|
dirIndex = pFcb->startIndex;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SizeDirEntry = sizeof(FAT_DIR_ENTRY);
|
|
|
|
dirIndex = pFcb->dirIndex;
|
|
|
|
}
|
2003-10-11 17:51:56 +00:00
|
|
|
|
2013-05-11 11:03:12 +00:00
|
|
|
DPRINT("updEntry dirIndex %u, PathName \'%wZ\'\n", dirIndex, &pFcb->PathNameU);
|
2001-08-14 20:47:30 +00:00
|
|
|
|
2017-02-17 17:58:18 +00:00
|
|
|
if (vfatFCBIsRoot(pFcb) || BooleanFlagOn(pFcb->Flags, FCB_IS_FAT | FCB_IS_VOLUME))
|
2005-01-25 21:08:54 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
return STATUS_SUCCESS;
|
2005-01-25 21:08:54 +00:00
|
|
|
}
|
|
|
|
|
2008-05-06 06:57:05 +00:00
|
|
|
ASSERT(pFcb->parentFcb);
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2018-05-18 12:03:20 +00:00
|
|
|
Status = vfatFCBInitializeCacheFromVolume(DeviceExt, pFcb->parentFcb);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-05-06 06:57:05 +00:00
|
|
|
Offset.u.HighPart = 0;
|
|
|
|
Offset.u.LowPart = dirIndex * SizeDirEntry;
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_TRY
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2016-07-10 18:16:03 +00:00
|
|
|
CcPinRead(pFcb->parentFcb->FileObject, &Offset, SizeDirEntry, PIN_WAIT, &Context, (PVOID*)&PinEntry);
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
DPRINT1("Failed write to \'%wZ\'.\n", &pFcb->parentFcb->PathNameU);
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_END;
|
|
|
|
|
|
|
|
pFcb->Flags &= ~FCB_IS_DIRTY;
|
|
|
|
RtlCopyMemory(PinEntry, &pFcb->entry, SizeDirEntry);
|
|
|
|
CcSetDirtyPinnedData(Context, NULL);
|
|
|
|
CcUnpinData(Context);
|
|
|
|
return STATUS_SUCCESS;
|
1999-01-13 15:25:50 +00:00
|
|
|
}
|
|
|
|
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
/*
|
|
|
|
* rename an existing FAT entry
|
|
|
|
*/
|
|
|
|
NTSTATUS
|
|
|
|
vfatRenameEntry(
|
|
|
|
IN PDEVICE_EXTENSION DeviceExt,
|
|
|
|
IN PVFATFCB pFcb,
|
|
|
|
IN PUNICODE_STRING FileName,
|
|
|
|
IN BOOLEAN CaseChangeOnly)
|
|
|
|
{
|
|
|
|
OEM_STRING NameA;
|
|
|
|
ULONG StartIndex;
|
|
|
|
PVOID Context = NULL;
|
|
|
|
LARGE_INTEGER Offset;
|
|
|
|
PFATX_DIR_ENTRY pDirEntry;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
DPRINT("vfatRenameEntry(%p, %p, %wZ, %d)\n", DeviceExt, pFcb, FileName, CaseChangeOnly);
|
|
|
|
|
2018-05-18 12:03:20 +00:00
|
|
|
Status = vfatFCBInitializeCacheFromVolume(DeviceExt, pFcb->parentFcb);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2017-02-17 21:24:12 +00:00
|
|
|
if (vfatVolumeIsFatX(DeviceExt))
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
{
|
2016-04-30 08:20:00 +00:00
|
|
|
VFAT_DIRENTRY_CONTEXT DirContext;
|
|
|
|
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
/* Open associated dir entry */
|
|
|
|
StartIndex = pFcb->startIndex;
|
|
|
|
Offset.u.HighPart = 0;
|
|
|
|
Offset.u.LowPart = (StartIndex * sizeof(FATX_DIR_ENTRY) / PAGE_SIZE) * PAGE_SIZE;
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_TRY
|
|
|
|
{
|
2016-08-03 12:54:46 +00:00
|
|
|
CcPinRead(pFcb->parentFcb->FileObject, &Offset, PAGE_SIZE, PIN_WAIT, &Context, (PVOID*)&pDirEntry);
|
2016-07-10 17:14:33 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
{
|
|
|
|
DPRINT1("CcPinRead(Offset %x:%x, Length %d) failed\n", Offset.u.HighPart, Offset.u.LowPart, PAGE_SIZE);
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
}
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_END;
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
|
|
|
|
pDirEntry = &pDirEntry[StartIndex % (PAGE_SIZE / sizeof(FATX_DIR_ENTRY))];
|
|
|
|
|
|
|
|
/* Set file name */
|
|
|
|
NameA.Buffer = (PCHAR)pDirEntry->Filename;
|
|
|
|
NameA.Length = 0;
|
|
|
|
NameA.MaximumLength = 42;
|
|
|
|
RtlUnicodeStringToOemString(&NameA, FileName, FALSE);
|
|
|
|
pDirEntry->FilenameLength = (unsigned char)NameA.Length;
|
|
|
|
|
|
|
|
/* Update FCB */
|
2018-05-18 12:03:20 +00:00
|
|
|
DirContext.DeviceExt = DeviceExt;
|
2016-04-30 08:20:00 +00:00
|
|
|
DirContext.ShortNameU.Length = 0;
|
|
|
|
DirContext.ShortNameU.MaximumLength = 0;
|
|
|
|
DirContext.ShortNameU.Buffer = NULL;
|
|
|
|
DirContext.LongNameU = *FileName;
|
|
|
|
DirContext.DirEntry.FatX = *pDirEntry;
|
2016-08-03 12:54:46 +00:00
|
|
|
|
|
|
|
CcSetDirtyPinnedData(Context, NULL);
|
|
|
|
CcUnpinData(Context);
|
|
|
|
|
2016-04-30 08:20:00 +00:00
|
|
|
Status = vfatUpdateFCB(DeviceExt, pFcb, &DirContext, pFcb->parentFcb);
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
2017-04-17 16:54:28 +00:00
|
|
|
CcFlushCache(&pFcb->parentFcb->SectionObjectPointers, NULL, 0, NULL);
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* This we cannot handle properly, move file - would likely need love */
|
|
|
|
return VfatMoveEntry(DeviceExt, pFcb, FileName, pFcb->parentFcb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
/*
|
|
|
|
* try to find contiguous entries frees in directory,
|
2016-11-13 15:31:39 +00:00
|
|
|
* extend a directory if is necessary
|
2002-03-18 22:37:13 +00:00
|
|
|
*/
|
2008-05-06 06:57:05 +00:00
|
|
|
BOOLEAN
|
|
|
|
vfatFindDirSpace(
|
|
|
|
IN PDEVICE_EXTENSION DeviceExt,
|
|
|
|
IN PVFATFCB pDirFcb,
|
|
|
|
IN ULONG nbSlots,
|
|
|
|
OUT PULONG start)
|
|
|
|
{
|
|
|
|
LARGE_INTEGER FileOffset;
|
|
|
|
ULONG i, count, size, nbFree = 0;
|
2009-06-19 00:21:21 +00:00
|
|
|
PDIR_ENTRY pFatEntry = NULL;
|
2008-05-06 06:57:05 +00:00
|
|
|
PVOID Context = NULL;
|
|
|
|
NTSTATUS Status;
|
|
|
|
ULONG SizeDirEntry;
|
2017-02-18 21:37:56 +00:00
|
|
|
BOOLEAN IsFatX = vfatVolumeIsFatX(DeviceExt);
|
2008-05-06 06:57:05 +00:00
|
|
|
FileOffset.QuadPart = 0;
|
|
|
|
|
2017-02-18 21:37:56 +00:00
|
|
|
if (IsFatX)
|
2008-05-06 06:57:05 +00:00
|
|
|
SizeDirEntry = sizeof(FATX_DIR_ENTRY);
|
2002-03-18 22:37:13 +00:00
|
|
|
else
|
2008-05-06 06:57:05 +00:00
|
|
|
SizeDirEntry = sizeof(FAT_DIR_ENTRY);
|
|
|
|
|
2018-05-18 12:03:20 +00:00
|
|
|
Status = vfatFCBInitializeCacheFromVolume(DeviceExt, pDirFcb);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-05-06 06:57:05 +00:00
|
|
|
count = pDirFcb->RFCB.FileSize.u.LowPart / SizeDirEntry;
|
|
|
|
size = DeviceExt->FatInfo.BytesPerCluster / SizeDirEntry;
|
|
|
|
for (i = 0; i < count; i++, pFatEntry = (PDIR_ENTRY)((ULONG_PTR)pFatEntry + SizeDirEntry))
|
2002-03-18 22:37:13 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
if (Context == NULL || (i % size) == 0)
|
|
|
|
{
|
|
|
|
if (Context)
|
|
|
|
{
|
|
|
|
CcUnpinData(Context);
|
|
|
|
}
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_TRY
|
2012-01-20 00:32:47 +00:00
|
|
|
{
|
2016-07-10 18:16:03 +00:00
|
|
|
CcPinRead(pDirFcb->FileObject, &FileOffset, DeviceExt->FatInfo.BytesPerCluster, PIN_WAIT, &Context, (PVOID*)&pFatEntry);
|
2016-07-10 17:14:33 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
_SEH2_YIELD(return FALSE);
|
2012-01-20 00:32:47 +00:00
|
|
|
}
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_END;
|
|
|
|
|
2008-05-06 06:57:05 +00:00
|
|
|
FileOffset.u.LowPart += DeviceExt->FatInfo.BytesPerCluster;
|
|
|
|
}
|
2017-02-18 21:37:56 +00:00
|
|
|
if (ENTRY_END(IsFatX, pFatEntry))
|
2008-05-06 06:57:05 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2017-02-18 21:37:56 +00:00
|
|
|
if (ENTRY_DELETED(IsFatX, pFatEntry))
|
2008-05-06 06:57:05 +00:00
|
|
|
{
|
|
|
|
nbFree++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nbFree = 0;
|
|
|
|
}
|
|
|
|
if (nbFree == nbSlots)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2002-03-18 22:37:13 +00:00
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
if (Context)
|
2002-03-18 22:37:13 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
CcUnpinData(Context);
|
|
|
|
Context = NULL;
|
2002-03-18 22:37:13 +00:00
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
if (nbFree == nbSlots)
|
2002-03-18 22:37:13 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
/* found enough contiguous free slots */
|
|
|
|
*start = i - nbSlots + 1;
|
2002-03-18 22:37:13 +00:00
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
else
|
2002-04-27 19:25:57 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
*start = i - nbFree;
|
|
|
|
if (*start + nbSlots > count)
|
|
|
|
{
|
|
|
|
LARGE_INTEGER AllocationSize;
|
|
|
|
/* extend the directory */
|
|
|
|
if (vfatFCBIsRoot(pDirFcb) && DeviceExt->FatInfo.FatType != FAT32)
|
|
|
|
{
|
|
|
|
/* 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;
|
|
|
|
Status = VfatSetAllocationSizeInformation(pDirFcb->FileObject, pDirFcb,
|
|
|
|
DeviceExt, &AllocationSize);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* clear the new dir cluster */
|
|
|
|
FileOffset.u.LowPart = (ULONG)(pDirFcb->RFCB.FileSize.QuadPart -
|
|
|
|
DeviceExt->FatInfo.BytesPerCluster);
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_TRY
|
2012-01-20 00:32:47 +00:00
|
|
|
{
|
2016-07-10 18:16:03 +00:00
|
|
|
CcPinRead(pDirFcb->FileObject, &FileOffset, DeviceExt->FatInfo.BytesPerCluster, PIN_WAIT, &Context, (PVOID*)&pFatEntry);
|
2012-01-20 00:32:47 +00:00
|
|
|
}
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
_SEH2_YIELD(return FALSE);
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
|
2017-02-18 21:37:56 +00:00
|
|
|
if (IsFatX)
|
2008-05-06 06:57:05 +00:00
|
|
|
memset(pFatEntry, 0xff, DeviceExt->FatInfo.BytesPerCluster);
|
|
|
|
else
|
|
|
|
RtlZeroMemory(pFatEntry, DeviceExt->FatInfo.BytesPerCluster);
|
|
|
|
}
|
|
|
|
else if (*start + nbSlots < count)
|
|
|
|
{
|
|
|
|
/* clear the entry after the last new entry */
|
|
|
|
FileOffset.u.LowPart = (*start + nbSlots) * SizeDirEntry;
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_TRY
|
2012-01-20 00:32:47 +00:00
|
|
|
{
|
2016-07-10 18:16:03 +00:00
|
|
|
CcPinRead(pDirFcb->FileObject, &FileOffset, SizeDirEntry, PIN_WAIT, &Context, (PVOID*)&pFatEntry);
|
2016-07-10 17:14:33 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
_SEH2_YIELD(return FALSE);
|
2012-01-20 00:32:47 +00:00
|
|
|
}
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_END;
|
|
|
|
|
2017-02-18 21:37:56 +00:00
|
|
|
if (IsFatX)
|
2008-05-06 06:57:05 +00:00
|
|
|
memset(pFatEntry, 0xff, SizeDirEntry);
|
|
|
|
else
|
|
|
|
RtlZeroMemory(pFatEntry, SizeDirEntry);
|
|
|
|
}
|
|
|
|
if (Context)
|
|
|
|
{
|
|
|
|
CcSetDirtyPinnedData(Context, NULL);
|
|
|
|
CcUnpinData(Context);
|
|
|
|
}
|
2002-04-27 19:25:57 +00:00
|
|
|
}
|
2013-05-11 11:03:12 +00:00
|
|
|
DPRINT("nbSlots %u nbFree %u, entry number %u\n", nbSlots, nbFree, *start);
|
2008-05-06 06:57:05 +00:00
|
|
|
return TRUE;
|
2002-03-18 22:37:13 +00:00
|
|
|
}
|
|
|
|
|
1999-01-13 15:25:50 +00:00
|
|
|
/*
|
|
|
|
create a new FAT entry
|
|
|
|
*/
|
2008-05-06 06:57:05 +00:00
|
|
|
static NTSTATUS
|
|
|
|
FATAddEntry(
|
|
|
|
IN PDEVICE_EXTENSION DeviceExt,
|
|
|
|
IN PUNICODE_STRING NameU,
|
|
|
|
IN PVFATFCB* Fcb,
|
|
|
|
IN PVFATFCB ParentFcb,
|
|
|
|
IN ULONG RequestedOptions,
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
IN UCHAR ReqAttr,
|
|
|
|
IN PVFAT_MOVE_CONTEXT MoveContext)
|
1999-01-13 15:25:50 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
PVOID Context = NULL;
|
|
|
|
PFAT_DIR_ENTRY pFatEntry;
|
|
|
|
slot *pSlots;
|
2016-11-10 11:04:29 +00:00
|
|
|
USHORT nbSlots = 0, j;
|
2008-05-06 06:57:05 +00:00
|
|
|
PUCHAR Buffer;
|
|
|
|
BOOLEAN needTilde = FALSE, needLong = FALSE;
|
2016-11-10 11:04:29 +00:00
|
|
|
BOOLEAN BaseAllLower, BaseAllUpper;
|
|
|
|
BOOLEAN ExtensionAllLower, ExtensionAllUpper;
|
|
|
|
BOOLEAN InExtension;
|
2017-02-17 17:58:18 +00:00
|
|
|
BOOLEAN IsDirectory;
|
2016-11-10 11:04:29 +00:00
|
|
|
WCHAR c;
|
2008-05-06 06:57:05 +00:00
|
|
|
ULONG CurrentCluster;
|
|
|
|
LARGE_INTEGER SystemTime, FileOffset;
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
ULONG size;
|
|
|
|
long i;
|
|
|
|
|
|
|
|
OEM_STRING NameA;
|
|
|
|
CHAR aName[13];
|
|
|
|
BOOLEAN IsNameLegal;
|
|
|
|
BOOLEAN SpacesFound;
|
|
|
|
|
|
|
|
VFAT_DIRENTRY_CONTEXT DirContext;
|
|
|
|
WCHAR LongNameBuffer[LONGNAME_MAX_LENGTH + 1];
|
|
|
|
WCHAR ShortNameBuffer[13];
|
|
|
|
|
|
|
|
DPRINT("addEntry: Name='%wZ', Dir='%wZ'\n", NameU, &ParentFcb->PathNameU);
|
|
|
|
|
|
|
|
DirContext.LongNameU = *NameU;
|
2017-02-17 17:58:18 +00:00
|
|
|
IsDirectory = BooleanFlagOn(RequestedOptions, FILE_DIRECTORY_FILE);
|
2008-05-06 06:57:05 +00:00
|
|
|
|
|
|
|
/* nb of entry needed for long name+normal entry */
|
|
|
|
nbSlots = (DirContext.LongNameU.Length / sizeof(WCHAR) + 12) / 13 + 1;
|
2013-05-11 11:03:12 +00:00
|
|
|
DPRINT("NameLen= %u, nbSlots =%u\n", DirContext.LongNameU.Length / sizeof(WCHAR), nbSlots);
|
2018-08-21 06:36:51 +00:00
|
|
|
Buffer = ExAllocatePoolWithTag(NonPagedPool, (nbSlots - 1) * sizeof(FAT_DIR_ENTRY), TAG_DIRENT);
|
2008-05-06 06:57:05 +00:00
|
|
|
if (Buffer == NULL)
|
|
|
|
{
|
|
|
|
return STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
}
|
|
|
|
RtlZeroMemory(Buffer, (nbSlots - 1) * sizeof(FAT_DIR_ENTRY));
|
|
|
|
pSlots = (slot *) Buffer;
|
|
|
|
|
|
|
|
NameA.Buffer = aName;
|
|
|
|
NameA.Length = 0;
|
|
|
|
NameA.MaximumLength = sizeof(aName);
|
|
|
|
|
2018-05-18 12:03:20 +00:00
|
|
|
DirContext.DeviceExt = DeviceExt;
|
2008-05-06 06:57:05 +00:00
|
|
|
DirContext.ShortNameU.Buffer = ShortNameBuffer;
|
|
|
|
DirContext.ShortNameU.Length = 0;
|
|
|
|
DirContext.ShortNameU.MaximumLength = sizeof(ShortNameBuffer);
|
|
|
|
|
|
|
|
RtlZeroMemory(&DirContext.DirEntry.Fat, sizeof(FAT_DIR_ENTRY));
|
|
|
|
|
|
|
|
IsNameLegal = RtlIsNameLegalDOS8Dot3(&DirContext.LongNameU, &NameA, &SpacesFound);
|
|
|
|
|
|
|
|
if (!IsNameLegal || SpacesFound)
|
|
|
|
{
|
|
|
|
GENERATE_NAME_CONTEXT NameContext;
|
|
|
|
VFAT_DIRENTRY_CONTEXT SearchContext;
|
|
|
|
WCHAR ShortSearchName[13];
|
|
|
|
needTilde = TRUE;
|
|
|
|
needLong = TRUE;
|
|
|
|
RtlZeroMemory(&NameContext, sizeof(GENERATE_NAME_CONTEXT));
|
2018-05-18 12:03:20 +00:00
|
|
|
SearchContext.DeviceExt = DeviceExt;
|
2008-05-06 06:57:05 +00:00
|
|
|
SearchContext.LongNameU.Buffer = LongNameBuffer;
|
|
|
|
SearchContext.LongNameU.MaximumLength = sizeof(LongNameBuffer);
|
|
|
|
SearchContext.ShortNameU.Buffer = ShortSearchName;
|
|
|
|
SearchContext.ShortNameU.MaximumLength = sizeof(ShortSearchName);
|
|
|
|
|
|
|
|
for (i = 0; i < 100; i++)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
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);
|
|
|
|
if (!NT_SUCCESS(Status))
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
break;
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2016-05-06 21:06:31 +00:00
|
|
|
else if (MoveContext)
|
|
|
|
{
|
|
|
|
ASSERT(*Fcb);
|
|
|
|
if (strncmp((char *)SearchContext.DirEntry.Fat.ShortName, (char *)(*Fcb)->entry.Fat.ShortName, 11) == 0)
|
|
|
|
{
|
|
|
|
if (MoveContext->InPlace)
|
|
|
|
{
|
|
|
|
ASSERT(SearchContext.DirEntry.Fat.FileSize == MoveContext->FileSize);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
if (i == 100) /* FIXME : what to do after this ? */
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2018-08-21 06:36:51 +00:00
|
|
|
ExFreePoolWithTag(Buffer, TAG_DIRENT);
|
2008-05-06 06:57:05 +00:00
|
|
|
return STATUS_UNSUCCESSFUL;
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
IsNameLegal = RtlIsNameLegalDOS8Dot3(&DirContext.ShortNameU, &NameA, &SpacesFound);
|
2000-12-29 23:17:12 +00:00
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
else
|
2001-08-03 19:01:17 +00:00
|
|
|
{
|
2016-11-10 11:04:29 +00:00
|
|
|
BaseAllLower = BaseAllUpper = TRUE;
|
|
|
|
ExtensionAllLower = ExtensionAllUpper = TRUE;
|
|
|
|
InExtension = FALSE;
|
|
|
|
for (i = 0; i < DirContext.LongNameU.Length / sizeof(WCHAR); i++)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2016-11-10 11:04:29 +00:00
|
|
|
c = DirContext.LongNameU.Buffer[i];
|
|
|
|
if (c >= L'A' && c <= L'Z')
|
2008-05-06 06:57:05 +00:00
|
|
|
{
|
2016-11-10 11:04:29 +00:00
|
|
|
if (InExtension)
|
|
|
|
ExtensionAllLower = FALSE;
|
|
|
|
else
|
|
|
|
BaseAllLower = FALSE;
|
|
|
|
}
|
|
|
|
else if (c >= L'a' && c <= L'z')
|
|
|
|
{
|
|
|
|
if (InExtension)
|
|
|
|
ExtensionAllUpper = FALSE;
|
|
|
|
else
|
|
|
|
BaseAllUpper = FALSE;
|
|
|
|
}
|
|
|
|
else if (c > 0x7f)
|
|
|
|
{
|
|
|
|
needLong = TRUE;
|
2008-05-06 06:57:05 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-11-10 11:04:29 +00:00
|
|
|
|
|
|
|
if (c == L'.')
|
|
|
|
{
|
|
|
|
InExtension = TRUE;
|
|
|
|
}
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2016-11-10 11:04:29 +00:00
|
|
|
|
|
|
|
if ((!BaseAllLower && !BaseAllUpper) ||
|
|
|
|
(!ExtensionAllLower && !ExtensionAllUpper))
|
2002-03-18 22:37:13 +00:00
|
|
|
{
|
2016-11-10 11:04:29 +00:00
|
|
|
needLong = TRUE;
|
2002-03-18 22:37:13 +00:00
|
|
|
}
|
2016-11-10 11:04:29 +00:00
|
|
|
|
2008-05-06 06:57:05 +00:00
|
|
|
RtlUpcaseUnicodeString(&DirContext.ShortNameU, &DirContext.LongNameU, FALSE);
|
|
|
|
DirContext.ShortNameU.Buffer[DirContext.ShortNameU.Length / sizeof(WCHAR)] = 0;
|
2000-12-29 23:17:12 +00:00
|
|
|
}
|
2016-11-10 11:04:29 +00:00
|
|
|
aName[NameA.Length] = 0;
|
2013-05-11 11:03:12 +00:00
|
|
|
DPRINT("'%s', '%wZ', needTilde=%u, needLong=%u\n",
|
2008-05-06 06:57:05 +00:00
|
|
|
aName, &DirContext.LongNameU, needTilde, needLong);
|
|
|
|
memset(DirContext.DirEntry.Fat.ShortName, ' ', 11);
|
|
|
|
for (i = 0; i < 8 && aName[i] && aName[i] != '.'; i++)
|
2002-03-18 22:37:13 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
DirContext.DirEntry.Fat.Filename[i] = aName[i];
|
2000-12-29 23:17:12 +00:00
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
if (aName[i] == '.')
|
2002-03-18 22:37:13 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
i++;
|
|
|
|
for (j = 0; j < 3 && aName[i]; j++, i++)
|
2002-03-18 22:37:13 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
DirContext.DirEntry.Fat.Ext[j] = aName[i];
|
2002-03-18 22:37:13 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
if (DirContext.DirEntry.Fat.Filename[0] == 0xe5)
|
2002-12-03 01:14:49 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
DirContext.DirEntry.Fat.Filename[0] = 0x05;
|
2002-12-03 01:14:49 +00:00
|
|
|
}
|
2003-10-11 17:51:56 +00:00
|
|
|
|
2008-05-06 06:57:05 +00:00
|
|
|
if (needLong)
|
2002-12-03 01:14:49 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
RtlCopyMemory(LongNameBuffer, DirContext.LongNameU.Buffer, DirContext.LongNameU.Length);
|
|
|
|
DirContext.LongNameU.Buffer = LongNameBuffer;
|
|
|
|
DirContext.LongNameU.MaximumLength = sizeof(LongNameBuffer);
|
|
|
|
DirContext.LongNameU.Buffer[DirContext.LongNameU.Length / sizeof(WCHAR)] = 0;
|
|
|
|
memset(DirContext.LongNameU.Buffer + DirContext.LongNameU.Length / sizeof(WCHAR) + 1, 0xff,
|
|
|
|
DirContext.LongNameU.MaximumLength - DirContext.LongNameU.Length - sizeof(WCHAR));
|
2002-12-03 01:14:49 +00:00
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
else
|
2002-12-03 01:14:49 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
nbSlots = 1;
|
2016-11-10 11:04:29 +00:00
|
|
|
if (BaseAllLower && !BaseAllUpper)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
DirContext.DirEntry.Fat.lCase |= VFAT_CASE_LOWER_BASE;
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2016-11-10 11:04:29 +00:00
|
|
|
if (ExtensionAllLower && !ExtensionAllUpper)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
DirContext.DirEntry.Fat.lCase |= VFAT_CASE_LOWER_EXT;
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2002-12-03 01:14:49 +00:00
|
|
|
}
|
2003-10-11 17:51:56 +00:00
|
|
|
|
2008-05-06 06:57:05 +00:00
|
|
|
DPRINT ("dos name=%11.11s\n", DirContext.DirEntry.Fat.Filename);
|
|
|
|
|
|
|
|
/* set attributes */
|
|
|
|
DirContext.DirEntry.Fat.Attrib = ReqAttr;
|
2017-02-17 17:58:18 +00:00
|
|
|
if (IsDirectory)
|
2008-05-06 06:57:05 +00:00
|
|
|
{
|
|
|
|
DirContext.DirEntry.Fat.Attrib |= FILE_ATTRIBUTE_DIRECTORY;
|
|
|
|
}
|
|
|
|
/* set dates and times */
|
|
|
|
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;
|
|
|
|
DirContext.DirEntry.Fat.AccessDate = DirContext.DirEntry.Fat.CreationDate;
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
/* If it's moving, preserve creation time and file size */
|
|
|
|
if (MoveContext != NULL)
|
|
|
|
{
|
|
|
|
DirContext.DirEntry.Fat.CreationDate = MoveContext->CreationDate;
|
|
|
|
DirContext.DirEntry.Fat.CreationTime = MoveContext->CreationTime;
|
|
|
|
DirContext.DirEntry.Fat.FileSize = MoveContext->FileSize;
|
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
|
|
|
|
if (needLong)
|
|
|
|
{
|
|
|
|
/* calculate checksum for 8.3 name */
|
|
|
|
for (pSlots[0].alias_checksum = 0, i = 0; i < 11; i++)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
pSlots[0].alias_checksum = (((pSlots[0].alias_checksum & 1) << 7
|
|
|
|
| ((pSlots[0].alias_checksum & 0xfe) >> 1))
|
2008-05-11 18:57:07 +00:00
|
|
|
+ DirContext.DirEntry.Fat.ShortName[i]);
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
/* construct slots and entry */
|
|
|
|
for (i = nbSlots - 2; i >= 0; i--)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
DPRINT("construct slot %d\n", i);
|
|
|
|
pSlots[i].attr = 0xf;
|
|
|
|
if (i)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
pSlots[i].id = (unsigned char)(nbSlots - i - 1);
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
else
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
pSlots[i].id = (unsigned char)(nbSlots - i - 1 + 0x40);
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
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);
|
|
|
|
}
|
2002-12-03 01:14:49 +00:00
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
/* try to find nbSlots contiguous entries frees in directory */
|
|
|
|
if (!vfatFindDirSpace(DeviceExt, ParentFcb, nbSlots, &DirContext.StartIndex))
|
2001-08-14 20:47:30 +00:00
|
|
|
{
|
2018-08-21 06:36:51 +00:00
|
|
|
ExFreePoolWithTag(Buffer, TAG_DIRENT);
|
2008-05-06 06:57:05 +00:00
|
|
|
return STATUS_DISK_FULL;
|
2001-08-14 20:47:30 +00:00
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
DirContext.DirIndex = DirContext.StartIndex + nbSlots - 1;
|
2017-02-17 17:58:18 +00:00
|
|
|
if (IsDirectory)
|
2002-03-18 22:37:13 +00:00
|
|
|
{
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
/* If we aren't moving, use next */
|
|
|
|
if (MoveContext == NULL)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
CurrentCluster = 0;
|
|
|
|
Status = NextCluster(DeviceExt, 0, &CurrentCluster, TRUE);
|
|
|
|
if (CurrentCluster == 0xffffffff || !NT_SUCCESS(Status))
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2018-08-21 06:36:51 +00:00
|
|
|
ExFreePoolWithTag(Buffer, TAG_DIRENT);
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
return STATUS_DISK_FULL;
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2018-06-09 16:21:32 +00:00
|
|
|
|
|
|
|
if (DeviceExt->FatInfo.FatType == FAT32)
|
|
|
|
{
|
|
|
|
FAT32UpdateFreeClustersCount(DeviceExt);
|
|
|
|
}
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
CurrentCluster = MoveContext->FirstCluster;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DeviceExt->FatInfo.FatType == FAT32)
|
|
|
|
{
|
|
|
|
DirContext.DirEntry.Fat.FirstClusterHigh = (unsigned short)(CurrentCluster >> 16);
|
|
|
|
}
|
|
|
|
DirContext.DirEntry.Fat.FirstCluster = (unsigned short)CurrentCluster;
|
|
|
|
}
|
|
|
|
else if (MoveContext != NULL)
|
|
|
|
{
|
|
|
|
CurrentCluster = MoveContext->FirstCluster;
|
|
|
|
|
2008-05-06 06:57:05 +00:00
|
|
|
if (DeviceExt->FatInfo.FatType == FAT32)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
DirContext.DirEntry.Fat.FirstClusterHigh = (unsigned short)(CurrentCluster >> 16);
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
DirContext.DirEntry.Fat.FirstCluster = (unsigned short)CurrentCluster;
|
2000-12-29 23:17:12 +00:00
|
|
|
}
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2018-05-18 12:03:20 +00:00
|
|
|
/* No need to init cache here, vfatFindDirSpace() will have done it for us */
|
2018-05-19 08:07:14 +00:00
|
|
|
ASSERT(BooleanFlagOn(ParentFcb->Flags, FCB_CACHE_INITIALIZED));
|
2018-05-18 12:03:20 +00:00
|
|
|
|
2008-05-06 06:57:05 +00:00
|
|
|
i = DeviceExt->FatInfo.BytesPerCluster / sizeof(FAT_DIR_ENTRY);
|
|
|
|
FileOffset.u.HighPart = 0;
|
|
|
|
FileOffset.u.LowPart = DirContext.StartIndex * sizeof(FAT_DIR_ENTRY);
|
|
|
|
if (DirContext.StartIndex / i == DirContext.DirIndex / i)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
/* one cluster */
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_TRY
|
|
|
|
{
|
2016-07-10 18:16:03 +00:00
|
|
|
CcPinRead(ParentFcb->FileObject, &FileOffset, nbSlots * sizeof(FAT_DIR_ENTRY), PIN_WAIT, &Context, (PVOID*)&pFatEntry);
|
2016-07-10 17:14:33 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2012-01-20 00:32:47 +00:00
|
|
|
{
|
2018-08-21 06:36:51 +00:00
|
|
|
ExFreePoolWithTag(Buffer, TAG_DIRENT);
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
2012-01-20 00:32:47 +00:00
|
|
|
}
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_END;
|
|
|
|
|
2008-05-06 06:57:05 +00:00
|
|
|
if (nbSlots > 1)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
RtlCopyMemory(pFatEntry, Buffer, (nbSlots - 1) * sizeof(FAT_DIR_ENTRY));
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
RtlCopyMemory(pFatEntry + (nbSlots - 1), &DirContext.DirEntry.Fat, sizeof(FAT_DIR_ENTRY));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* two clusters */
|
|
|
|
size = DeviceExt->FatInfo.BytesPerCluster -
|
|
|
|
(DirContext.StartIndex * sizeof(FAT_DIR_ENTRY)) % DeviceExt->FatInfo.BytesPerCluster;
|
|
|
|
i = size / sizeof(FAT_DIR_ENTRY);
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_TRY
|
|
|
|
{
|
2016-07-10 18:16:03 +00:00
|
|
|
CcPinRead(ParentFcb->FileObject, &FileOffset, size, PIN_WAIT, &Context, (PVOID*)&pFatEntry);
|
2016-07-10 17:14:33 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2012-01-20 00:32:47 +00:00
|
|
|
{
|
2018-08-21 06:36:51 +00:00
|
|
|
ExFreePoolWithTag(Buffer, TAG_DIRENT);
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
2012-01-20 00:32:47 +00:00
|
|
|
}
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_END;
|
2008-05-06 06:57:05 +00:00
|
|
|
RtlCopyMemory(pFatEntry, Buffer, size);
|
|
|
|
CcSetDirtyPinnedData(Context, NULL);
|
|
|
|
CcUnpinData(Context);
|
|
|
|
FileOffset.u.LowPart += size;
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_TRY
|
|
|
|
{
|
2016-07-10 18:16:03 +00:00
|
|
|
CcPinRead(ParentFcb->FileObject, &FileOffset, nbSlots * sizeof(FAT_DIR_ENTRY) - size, PIN_WAIT, &Context, (PVOID*)&pFatEntry);
|
2016-07-10 17:14:33 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2012-01-20 00:32:47 +00:00
|
|
|
{
|
2018-08-21 06:36:51 +00:00
|
|
|
ExFreePoolWithTag(Buffer, TAG_DIRENT);
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
2012-01-20 00:32:47 +00:00
|
|
|
}
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_END;
|
2008-05-06 06:57:05 +00:00
|
|
|
if (nbSlots - 1 > i)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
RtlCopyMemory(pFatEntry, (PVOID)(Buffer + size), (nbSlots - 1 - i) * sizeof(FAT_DIR_ENTRY));
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
RtlCopyMemory(pFatEntry + nbSlots - 1 - i, &DirContext.DirEntry.Fat, sizeof(FAT_DIR_ENTRY));
|
|
|
|
}
|
|
|
|
CcSetDirtyPinnedData(Context, NULL);
|
|
|
|
CcUnpinData(Context);
|
|
|
|
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
if (MoveContext != NULL)
|
|
|
|
{
|
|
|
|
/* We're modifying an existing FCB - likely rename/move */
|
2016-04-30 08:20:00 +00:00
|
|
|
Status = vfatUpdateFCB(DeviceExt, *Fcb, &DirContext, ParentFcb);
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Status = vfatMakeFCBFromDirEntry(DeviceExt, ParentFcb, &DirContext, Fcb);
|
|
|
|
}
|
2010-07-06 18:39:09 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2018-08-21 06:36:51 +00:00
|
|
|
ExFreePoolWithTag(Buffer, TAG_DIRENT);
|
2010-07-06 18:39:09 +00:00
|
|
|
return Status;
|
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
|
|
|
|
DPRINT("new : entry=%11.11s\n", (*Fcb)->entry.Fat.Filename);
|
|
|
|
DPRINT("new : entry=%11.11s\n", DirContext.DirEntry.Fat.Filename);
|
|
|
|
|
2017-02-17 17:58:18 +00:00
|
|
|
if (IsDirectory)
|
2008-05-06 06:57:05 +00:00
|
|
|
{
|
2018-05-18 12:03:20 +00:00
|
|
|
Status = vfatFCBInitializeCacheFromVolume(DeviceExt, (*Fcb));
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2018-08-21 06:36:51 +00:00
|
|
|
ExFreePoolWithTag(Buffer, TAG_DIRENT);
|
2018-05-18 12:03:20 +00:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-05-06 06:57:05 +00:00
|
|
|
FileOffset.QuadPart = 0;
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_TRY
|
|
|
|
{
|
2016-07-10 18:16:03 +00:00
|
|
|
CcPinRead((*Fcb)->FileObject, &FileOffset, DeviceExt->FatInfo.BytesPerCluster, PIN_WAIT, &Context, (PVOID*)&pFatEntry);
|
2016-07-10 17:14:33 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2012-01-20 00:32:47 +00:00
|
|
|
{
|
2018-08-21 06:36:51 +00:00
|
|
|
ExFreePoolWithTag(Buffer, TAG_DIRENT);
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
2012-01-20 00:32:47 +00:00
|
|
|
}
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_END;
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
/* clear the new directory cluster if not moving */
|
|
|
|
if (MoveContext == NULL)
|
|
|
|
{
|
|
|
|
RtlZeroMemory(pFatEntry, DeviceExt->FatInfo.BytesPerCluster);
|
|
|
|
/* create '.' and '..' */
|
2018-08-19 07:55:03 +00:00
|
|
|
RtlCopyMemory(&pFatEntry[0].Attrib, &DirContext.DirEntry.Fat.Attrib,
|
|
|
|
sizeof(FAT_DIR_ENTRY) - FIELD_OFFSET(FAT_DIR_ENTRY, Attrib));
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
RtlCopyMemory(pFatEntry[0].ShortName, ". ", 11);
|
2018-08-19 07:55:03 +00:00
|
|
|
RtlCopyMemory(&pFatEntry[1].Attrib, &DirContext.DirEntry.Fat.Attrib,
|
|
|
|
sizeof(FAT_DIR_ENTRY) - FIELD_OFFSET(FAT_DIR_ENTRY, Attrib));
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
RtlCopyMemory(pFatEntry[1].ShortName, ".. ", 11);
|
|
|
|
}
|
|
|
|
|
2008-05-06 06:57:05 +00:00
|
|
|
pFatEntry[1].FirstCluster = ParentFcb->entry.Fat.FirstCluster;
|
|
|
|
pFatEntry[1].FirstClusterHigh = ParentFcb->entry.Fat.FirstClusterHigh;
|
|
|
|
if (vfatFCBIsRoot(ParentFcb))
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
pFatEntry[1].FirstCluster = 0;
|
|
|
|
pFatEntry[1].FirstClusterHigh = 0;
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
CcSetDirtyPinnedData(Context, NULL);
|
|
|
|
CcUnpinData(Context);
|
2000-12-29 23:17:12 +00:00
|
|
|
}
|
2018-08-21 06:36:51 +00:00
|
|
|
ExFreePoolWithTag(Buffer, TAG_DIRENT);
|
2008-05-06 06:57:05 +00:00
|
|
|
DPRINT("addentry ok\n");
|
|
|
|
return STATUS_SUCCESS;
|
1999-01-13 15:25:50 +00:00
|
|
|
}
|
|
|
|
|
2004-12-05 16:31:51 +00:00
|
|
|
/*
|
|
|
|
create a new FAT entry
|
|
|
|
*/
|
2008-05-06 06:57:05 +00:00
|
|
|
static NTSTATUS
|
|
|
|
FATXAddEntry(
|
|
|
|
IN PDEVICE_EXTENSION DeviceExt,
|
|
|
|
IN PUNICODE_STRING NameU,
|
|
|
|
IN PVFATFCB* Fcb,
|
|
|
|
IN PVFATFCB ParentFcb,
|
|
|
|
IN ULONG RequestedOptions,
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
IN UCHAR ReqAttr,
|
|
|
|
IN PVFAT_MOVE_CONTEXT MoveContext)
|
2004-12-05 16:31:51 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
PVOID Context = NULL;
|
|
|
|
LARGE_INTEGER SystemTime, FileOffset;
|
|
|
|
OEM_STRING NameA;
|
|
|
|
VFAT_DIRENTRY_CONTEXT DirContext;
|
|
|
|
PFATX_DIR_ENTRY pFatXDirEntry;
|
|
|
|
ULONG Index;
|
|
|
|
|
|
|
|
DPRINT("addEntry: Name='%wZ', Dir='%wZ'\n", NameU, &ParentFcb->PathNameU);
|
|
|
|
|
|
|
|
DirContext.LongNameU = *NameU;
|
|
|
|
|
|
|
|
if (DirContext.LongNameU.Length / sizeof(WCHAR) > 42)
|
|
|
|
{
|
|
|
|
/* name too long */
|
|
|
|
return STATUS_NAME_TOO_LONG;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* try to find 1 entry free in directory */
|
|
|
|
if (!vfatFindDirSpace(DeviceExt, ParentFcb, 1, &DirContext.StartIndex))
|
|
|
|
{
|
|
|
|
return STATUS_DISK_FULL;
|
|
|
|
}
|
|
|
|
Index = DirContext.DirIndex = DirContext.StartIndex;
|
|
|
|
if (!vfatFCBIsRoot(ParentFcb))
|
|
|
|
{
|
|
|
|
DirContext.DirIndex += 2;
|
|
|
|
DirContext.StartIndex += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
DirContext.ShortNameU.Buffer = 0;
|
|
|
|
DirContext.ShortNameU.Length = 0;
|
|
|
|
DirContext.ShortNameU.MaximumLength = 0;
|
2018-05-18 12:03:20 +00:00
|
|
|
DirContext.DeviceExt = DeviceExt;
|
2008-05-06 06:57:05 +00:00
|
|
|
RtlZeroMemory(&DirContext.DirEntry.FatX, sizeof(FATX_DIR_ENTRY));
|
|
|
|
memset(DirContext.DirEntry.FatX.Filename, 0xff, 42);
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
/* Use cluster, if moving */
|
|
|
|
if (MoveContext != NULL)
|
|
|
|
{
|
|
|
|
DirContext.DirEntry.FatX.FirstCluster = MoveContext->FirstCluster;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DirContext.DirEntry.FatX.FirstCluster = 0;
|
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
DirContext.DirEntry.FatX.FileSize = 0;
|
|
|
|
|
|
|
|
/* set file name */
|
|
|
|
NameA.Buffer = (PCHAR)DirContext.DirEntry.FatX.Filename;
|
|
|
|
NameA.Length = 0;
|
|
|
|
NameA.MaximumLength = 42;
|
|
|
|
RtlUnicodeStringToOemString(&NameA, &DirContext.LongNameU, FALSE);
|
|
|
|
DirContext.DirEntry.FatX.FilenameLength = (unsigned char)NameA.Length;
|
|
|
|
|
|
|
|
/* set attributes */
|
|
|
|
DirContext.DirEntry.FatX.Attrib = ReqAttr;
|
2017-02-17 17:58:18 +00:00
|
|
|
if (BooleanFlagOn(RequestedOptions, FILE_DIRECTORY_FILE))
|
2008-05-06 06:57:05 +00:00
|
|
|
{
|
|
|
|
DirContext.DirEntry.FatX.Attrib |= FILE_ATTRIBUTE_DIRECTORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set dates and times */
|
|
|
|
KeQuerySystemTime(&SystemTime);
|
|
|
|
FsdSystemTimeToDosDateTime(DeviceExt, &SystemTime, &DirContext.DirEntry.FatX.CreationDate,
|
|
|
|
&DirContext.DirEntry.FatX.CreationTime);
|
|
|
|
DirContext.DirEntry.FatX.UpdateDate = DirContext.DirEntry.FatX.CreationDate;
|
|
|
|
DirContext.DirEntry.FatX.UpdateTime = DirContext.DirEntry.FatX.CreationTime;
|
|
|
|
DirContext.DirEntry.FatX.AccessDate = DirContext.DirEntry.FatX.CreationDate;
|
|
|
|
DirContext.DirEntry.FatX.AccessTime = DirContext.DirEntry.FatX.CreationTime;
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
/* If it's moving, preserve creation time and file size */
|
|
|
|
if (MoveContext != NULL)
|
|
|
|
{
|
|
|
|
DirContext.DirEntry.FatX.CreationDate = MoveContext->CreationDate;
|
|
|
|
DirContext.DirEntry.FatX.CreationTime = MoveContext->CreationTime;
|
|
|
|
DirContext.DirEntry.FatX.FileSize = MoveContext->FileSize;
|
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
|
2018-05-18 12:03:20 +00:00
|
|
|
/* No need to init cache here, vfatFindDirSpace() will have done it for us */
|
2018-05-19 08:07:14 +00:00
|
|
|
ASSERT(BooleanFlagOn(ParentFcb->Flags, FCB_CACHE_INITIALIZED));
|
2018-05-18 12:03:20 +00:00
|
|
|
|
2008-05-06 06:57:05 +00:00
|
|
|
/* add entry into parent directory */
|
|
|
|
FileOffset.u.HighPart = 0;
|
|
|
|
FileOffset.u.LowPart = Index * sizeof(FATX_DIR_ENTRY);
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_TRY
|
|
|
|
{
|
2016-07-10 18:16:03 +00:00
|
|
|
CcPinRead(ParentFcb->FileObject, &FileOffset, sizeof(FATX_DIR_ENTRY), PIN_WAIT, &Context, (PVOID*)&pFatXDirEntry);
|
2016-07-10 17:14:33 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2012-01-20 00:32:47 +00:00
|
|
|
{
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
2012-01-20 00:32:47 +00:00
|
|
|
}
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_END;
|
2008-05-06 06:57:05 +00:00
|
|
|
RtlCopyMemory(pFatXDirEntry, &DirContext.DirEntry.FatX, sizeof(FATX_DIR_ENTRY));
|
|
|
|
CcSetDirtyPinnedData(Context, NULL);
|
|
|
|
CcUnpinData(Context);
|
|
|
|
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
if (MoveContext != NULL)
|
|
|
|
{
|
|
|
|
/* We're modifying an existing FCB - likely rename/move */
|
|
|
|
/* FIXME: check status */
|
2016-04-30 08:20:00 +00:00
|
|
|
vfatUpdateFCB(DeviceExt, *Fcb, &DirContext, ParentFcb);
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* FIXME: check status */
|
|
|
|
vfatMakeFCBFromDirEntry(DeviceExt, ParentFcb, &DirContext, Fcb);
|
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
|
|
|
|
DPRINT("addentry ok\n");
|
|
|
|
return STATUS_SUCCESS;
|
2004-12-05 16:31:51 +00:00
|
|
|
}
|
|
|
|
|
2001-08-14 20:47:30 +00:00
|
|
|
/*
|
2002-03-18 22:37:13 +00:00
|
|
|
* deleting an existing FAT entry
|
|
|
|
*/
|
2008-05-06 06:57:05 +00:00
|
|
|
static NTSTATUS
|
|
|
|
FATDelEntry(
|
|
|
|
IN PDEVICE_EXTENSION DeviceExt,
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
IN PVFATFCB pFcb,
|
|
|
|
OUT PVFAT_MOVE_CONTEXT MoveContext)
|
2001-08-14 20:47:30 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
ULONG CurrentCluster = 0, NextCluster, i;
|
|
|
|
PVOID Context = NULL;
|
|
|
|
LARGE_INTEGER Offset;
|
2009-06-19 00:21:21 +00:00
|
|
|
PFAT_DIR_ENTRY pDirEntry = NULL;
|
2018-05-18 12:03:20 +00:00
|
|
|
NTSTATUS Status;
|
2008-05-06 06:57:05 +00:00
|
|
|
|
|
|
|
ASSERT(pFcb);
|
|
|
|
ASSERT(pFcb->parentFcb);
|
|
|
|
|
2018-05-18 12:03:20 +00:00
|
|
|
Status = vfatFCBInitializeCacheFromVolume(DeviceExt, pFcb->parentFcb);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-05-06 06:57:05 +00:00
|
|
|
DPRINT("delEntry PathName \'%wZ\'\n", &pFcb->PathNameU);
|
2013-05-11 11:03:12 +00:00
|
|
|
DPRINT("delete entry: %u to %u\n", pFcb->startIndex, pFcb->dirIndex);
|
2008-05-06 06:57:05 +00:00
|
|
|
Offset.u.HighPart = 0;
|
|
|
|
for (i = pFcb->startIndex; i <= pFcb->dirIndex; i++)
|
2001-08-14 20:47:30 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
if (Context == NULL || ((i * sizeof(FAT_DIR_ENTRY)) % PAGE_SIZE) == 0)
|
2002-03-18 22:37:13 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
if (Context)
|
|
|
|
{
|
|
|
|
CcSetDirtyPinnedData(Context, NULL);
|
|
|
|
CcUnpinData(Context);
|
|
|
|
}
|
|
|
|
Offset.u.LowPart = (i * sizeof(FAT_DIR_ENTRY) / PAGE_SIZE) * PAGE_SIZE;
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_TRY
|
|
|
|
{
|
2016-08-03 12:54:46 +00:00
|
|
|
CcPinRead(pFcb->parentFcb->FileObject, &Offset, PAGE_SIZE, PIN_WAIT, &Context, (PVOID*)&pDirEntry);
|
2016-07-10 17:14:33 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2012-01-20 00:32:47 +00:00
|
|
|
{
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
2012-01-20 00:32:47 +00:00
|
|
|
}
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_END;
|
2004-11-06 13:44:57 +00:00
|
|
|
}
|
2008-05-06 06:57:05 +00:00
|
|
|
pDirEntry[i % (PAGE_SIZE / sizeof(FAT_DIR_ENTRY))].Filename[0] = 0xe5;
|
|
|
|
if (i == pFcb->dirIndex)
|
2003-10-11 17:51:56 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
CurrentCluster =
|
|
|
|
vfatDirEntryGetFirstCluster(DeviceExt,
|
|
|
|
(PDIR_ENTRY)&pDirEntry[i % (PAGE_SIZE / sizeof(FAT_DIR_ENTRY))]);
|
2003-10-11 17:51:56 +00:00
|
|
|
}
|
2001-08-14 20:47:30 +00:00
|
|
|
}
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2016-08-03 12:54:46 +00:00
|
|
|
/* In case of moving, save properties */
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
if (MoveContext != NULL)
|
2001-08-14 20:47:30 +00:00
|
|
|
{
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
pDirEntry = &pDirEntry[pFcb->dirIndex % (PAGE_SIZE / sizeof(FAT_DIR_ENTRY))];
|
|
|
|
MoveContext->FirstCluster = CurrentCluster;
|
|
|
|
MoveContext->FileSize = pDirEntry->FileSize;
|
|
|
|
MoveContext->CreationTime = pDirEntry->CreationTime;
|
|
|
|
MoveContext->CreationDate = pDirEntry->CreationDate;
|
2001-08-14 20:47:30 +00:00
|
|
|
}
|
2016-08-03 12:54:46 +00:00
|
|
|
|
|
|
|
if (Context)
|
|
|
|
{
|
|
|
|
CcSetDirtyPinnedData(Context, NULL);
|
|
|
|
CcUnpinData(Context);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* In case of moving, don't delete data */
|
|
|
|
if (MoveContext == NULL)
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
{
|
|
|
|
while (CurrentCluster && CurrentCluster != 0xffffffff)
|
|
|
|
{
|
|
|
|
GetNextCluster(DeviceExt, CurrentCluster, &NextCluster);
|
|
|
|
/* FIXME: check status */
|
|
|
|
WriteCluster(DeviceExt, CurrentCluster, 0);
|
|
|
|
CurrentCluster = NextCluster;
|
2018-06-09 10:36:43 +00:00
|
|
|
}
|
|
|
|
|
2018-06-09 16:21:32 +00:00
|
|
|
if (DeviceExt->FatInfo.FatType == FAT32)
|
2018-06-09 10:36:43 +00:00
|
|
|
{
|
2018-06-09 16:21:32 +00:00
|
|
|
FAT32UpdateFreeClustersCount(DeviceExt);
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-06 06:57:05 +00:00
|
|
|
return STATUS_SUCCESS;
|
2001-08-14 20:47:30 +00:00
|
|
|
}
|
|
|
|
|
2004-12-05 16:31:51 +00:00
|
|
|
/*
|
|
|
|
* deleting an existing FAT entry
|
|
|
|
*/
|
2008-05-06 06:57:05 +00:00
|
|
|
static NTSTATUS
|
|
|
|
FATXDelEntry(
|
|
|
|
IN PDEVICE_EXTENSION DeviceExt,
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
IN PVFATFCB pFcb,
|
|
|
|
OUT PVFAT_MOVE_CONTEXT MoveContext)
|
2004-12-05 16:31:51 +00:00
|
|
|
{
|
2008-05-06 06:57:05 +00:00
|
|
|
ULONG CurrentCluster = 0, NextCluster;
|
|
|
|
PVOID Context = NULL;
|
|
|
|
LARGE_INTEGER Offset;
|
|
|
|
PFATX_DIR_ENTRY pDirEntry;
|
|
|
|
ULONG StartIndex;
|
2018-05-18 12:03:20 +00:00
|
|
|
NTSTATUS Status;
|
2008-05-06 06:57:05 +00:00
|
|
|
|
|
|
|
ASSERT(pFcb);
|
|
|
|
ASSERT(pFcb->parentFcb);
|
2017-02-17 21:24:12 +00:00
|
|
|
ASSERT(vfatVolumeIsFatX(DeviceExt));
|
2008-05-06 06:57:05 +00:00
|
|
|
|
|
|
|
StartIndex = pFcb->startIndex;
|
|
|
|
|
2018-05-18 12:03:20 +00:00
|
|
|
Status = vfatFCBInitializeCacheFromVolume(DeviceExt, pFcb->parentFcb);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-05-06 06:57:05 +00:00
|
|
|
DPRINT("delEntry PathName \'%wZ\'\n", &pFcb->PathNameU);
|
2013-05-11 11:03:12 +00:00
|
|
|
DPRINT("delete entry: %u\n", StartIndex);
|
2008-05-06 06:57:05 +00:00
|
|
|
Offset.u.HighPart = 0;
|
|
|
|
Offset.u.LowPart = (StartIndex * sizeof(FATX_DIR_ENTRY) / PAGE_SIZE) * PAGE_SIZE;
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_TRY
|
|
|
|
{
|
2016-08-03 12:54:46 +00:00
|
|
|
CcPinRead(pFcb->parentFcb->FileObject, &Offset, PAGE_SIZE, PIN_WAIT, &Context, (PVOID*)&pDirEntry);
|
2016-07-10 17:14:33 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2008-05-06 06:57:05 +00:00
|
|
|
{
|
|
|
|
DPRINT1("CcPinRead(Offset %x:%x, Length %d) failed\n", Offset.u.HighPart, Offset.u.LowPart, PAGE_SIZE);
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
2008-05-06 06:57:05 +00:00
|
|
|
}
|
2016-07-10 17:14:33 +00:00
|
|
|
_SEH2_END;
|
2008-05-06 06:57:05 +00:00
|
|
|
pDirEntry = &pDirEntry[StartIndex % (PAGE_SIZE / sizeof(FATX_DIR_ENTRY))];
|
|
|
|
pDirEntry->FilenameLength = 0xe5;
|
|
|
|
CurrentCluster = vfatDirEntryGetFirstCluster(DeviceExt,
|
|
|
|
(PDIR_ENTRY)pDirEntry);
|
|
|
|
|
2016-08-03 12:54:46 +00:00
|
|
|
/* In case of moving, save properties */
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
if (MoveContext != NULL)
|
2008-05-06 06:57:05 +00:00
|
|
|
{
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
MoveContext->FirstCluster = CurrentCluster;
|
|
|
|
MoveContext->FileSize = pDirEntry->FileSize;
|
|
|
|
MoveContext->CreationTime = pDirEntry->CreationTime;
|
|
|
|
MoveContext->CreationDate = pDirEntry->CreationDate;
|
2008-05-06 06:57:05 +00:00
|
|
|
}
|
2016-08-03 12:54:46 +00:00
|
|
|
|
|
|
|
CcSetDirtyPinnedData(Context, NULL);
|
|
|
|
CcUnpinData(Context);
|
|
|
|
|
|
|
|
/* In case of moving, don't delete data */
|
|
|
|
if (MoveContext == NULL)
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
{
|
|
|
|
while (CurrentCluster && CurrentCluster != 0xffffffff)
|
|
|
|
{
|
|
|
|
GetNextCluster(DeviceExt, CurrentCluster, &NextCluster);
|
|
|
|
/* FIXME: check status */
|
|
|
|
WriteCluster(DeviceExt, CurrentCluster, 0);
|
|
|
|
CurrentCluster = NextCluster;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-06 06:57:05 +00:00
|
|
|
return STATUS_SUCCESS;
|
2004-12-05 16:31:51 +00:00
|
|
|
}
|
|
|
|
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
/*
|
|
|
|
* move an existing FAT entry
|
|
|
|
*/
|
|
|
|
NTSTATUS
|
|
|
|
VfatMoveEntry(
|
|
|
|
IN PDEVICE_EXTENSION DeviceExt,
|
|
|
|
IN PVFATFCB pFcb,
|
|
|
|
IN PUNICODE_STRING FileName,
|
|
|
|
IN PVFATFCB ParentFcb)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
PVFATFCB OldParent;
|
|
|
|
VFAT_MOVE_CONTEXT MoveContext;
|
|
|
|
|
|
|
|
DPRINT("VfatMoveEntry(%p, %p, %wZ, %p)\n", DeviceExt, pFcb, FileName, ParentFcb);
|
|
|
|
|
|
|
|
/* Delete old entry while keeping data */
|
|
|
|
Status = VfatDelEntry(DeviceExt, pFcb, &MoveContext);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
OldParent = pFcb->parentFcb;
|
2017-04-17 16:54:28 +00:00
|
|
|
CcFlushCache(&OldParent->SectionObjectPointers, NULL, 0, NULL);
|
2016-05-06 21:06:31 +00:00
|
|
|
MoveContext.InPlace = (OldParent == ParentFcb);
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
|
|
|
|
/* Add our new entry with our cluster */
|
|
|
|
Status = VfatAddEntry(DeviceExt,
|
|
|
|
FileName,
|
|
|
|
&pFcb,
|
|
|
|
ParentFcb,
|
|
|
|
(vfatFCBIsDirectory(pFcb) ? FILE_DIRECTORY_FILE : 0),
|
|
|
|
*pFcb->Attributes,
|
|
|
|
&MoveContext);
|
|
|
|
|
2017-04-17 16:54:28 +00:00
|
|
|
CcFlushCache(&pFcb->parentFcb->SectionObjectPointers, NULL, 0, NULL);
|
[FASTFAT]
- Implement vfatPrepareTargetForRename() that prepares for renaming. It tries to open target and deletes it if it exists and if allowed. And then, it opens the parent directory.
- Implement VfatSetRenameInformation() that actually does the renaming (call as SetInformationFile). It handles cases we we have (or we don't have) TargetDirectory provided. It sends notifications as appropriated on demands.
- Implement vfatRenameEntry() that renames an entry in place. So far, it only supports FATX entries renaming. FAT entries are a bit more complex. It falls back to vfatMoveEntry() in later cases.
- Implement VfatMoveEntry() that will move an entry accross directories (or in place for FAT). Its principles are simple: it deletes the entry in old parent, and recreate it in new parent, keeping file metadata & data.
- Modify VfatDelEntry() and VfatAddEntry() so that they can handle deleting an entry without touching its data and adding an entry with an already provided FCB and thus use the given metadata.
- Implement vfatDelFCBFromTable() which is just old code moved to new routine to allow reuse. It deletes a FCB entry from hash table. Doesn't deal with references!
- Implement vfatMakeFullName() which is mostly old code moved to new routine to allow reuse. It allocates buffer and copy data for FCB full name.
- Implement vfatUpdateFCB() that will update a FCB with new names and parent. It will remove anything related to old name and will recreate using new data. It will adjust references count.
- Modify vfatMakeFCBFromDirEntry() so that it calls vfatMakeFullName().
- Modify vfatReleaseFCB() so that it calls vfatDelFCBFromTable().
- Revert VfatOpenFile() to its previous features.
- Modify VfatCreateFile() to reimplement support for SL_OPEN_TARGET_DIRECTORY. It is way less hackish than previously. It also properly opens parent now, by incrementing its handle count and by setting appropriate access rights.
[KERNEL32]
- Rewritten MoveFileWithProgressW() to implement all the missing features that are used in Windows 2k3 including links and reparse points.
- Implemented BasepMoveFileDelayed() to replace deprecated add_boot_rename_entry(). This functions is matching the features implemented in SMSS.
- Implemented BasepMoveFileCopyProgress() which is used in MoveFileWithProgressW().
- Stubbed BasepNotifyTrackingService() which is not use at the moment (FastFAT, even in Windows doesn't provide such feature).
- Reimplemented ReplaceFileA(), MoveFileWithProgressA() to quit Winisms and use our internal helpers.
- Make MoveFileX() use MoveFileWithProgressX() directly.
- Fixed a few prototypes.
TL;DR:
This (huge) commit implements file and directory renaming in FastFAT driver. This allows getting rid of old implementation in kernel32 where files were force copied.
A feature is still missing, but Jérôme should implement it anytime soon (he prototyped it already): moving directories across volumes. This requires some work in BasepCopyFileExW().
Kudos to all the devs who helped me on this: Christoph, Hervé, Jérôme, Thomas.
This finally allows killing CR-52... It was about time!
svn path=/trunk/; revision=64836
2014-10-19 21:38:32 +00:00
|
|
|
|
|
|
|
return Status;
|
2004-12-05 16:31:51 +00:00
|
|
|
}
|
|
|
|
|
2018-05-18 12:03:20 +00:00
|
|
|
extern BOOLEAN FATXIsDirectoryEmpty(PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb);
|
|
|
|
extern BOOLEAN FATIsDirectoryEmpty(PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb);
|
2017-02-17 22:25:03 +00:00
|
|
|
extern NTSTATUS FATGetNextDirEntry(PVOID *pContext, PVOID *pPage, PVFATFCB pDirFcb, PVFAT_DIRENTRY_CONTEXT DirContext, BOOLEAN First);
|
|
|
|
extern NTSTATUS FATXGetNextDirEntry(PVOID *pContext, PVOID *pPage, PVFATFCB pDirFcb, PVFAT_DIRENTRY_CONTEXT DirContext, BOOLEAN First);
|
|
|
|
|
|
|
|
VFAT_DISPATCH FatXDispatch = {
|
2017-03-12 18:11:00 +00:00
|
|
|
FATXIsDirectoryEmpty, // .IsDirectoryEmpty
|
|
|
|
FATXAddEntry, // .AddEntry
|
|
|
|
FATXDelEntry, // .DelEntry
|
|
|
|
FATXGetNextDirEntry, // .GetNextDirEntry
|
2017-02-17 22:25:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
VFAT_DISPATCH FatDispatch = {
|
2017-03-12 18:11:00 +00:00
|
|
|
FATIsDirectoryEmpty, // .IsDirectoryEmpty
|
|
|
|
FATAddEntry, // .AddEntry
|
|
|
|
FATDelEntry, // .DelEntry
|
|
|
|
FATGetNextDirEntry, // .GetNextDirEntry
|
2017-02-17 22:25:03 +00:00
|
|
|
};
|
|
|
|
|
2000-03-12 23:28:59 +00:00
|
|
|
/* EOF */
|