2014-02-06 12:28:49 +00:00
|
|
|
#ifndef _FASTFAT_PCH_
|
|
|
|
#define _FASTFAT_PCH_
|
|
|
|
|
2005-10-03 07:15:12 +00:00
|
|
|
#include <ntifs.h>
|
|
|
|
#include <ntdddisk.h>
|
2010-12-27 18:11:35 +00:00
|
|
|
#include <dos.h>
|
2014-08-24 03:28:01 +00:00
|
|
|
#include <pseh/pseh2.h>
|
2018-12-30 11:19:11 +00:00
|
|
|
#include <section_attribs.h>
|
2018-04-29 10:33:53 +00:00
|
|
|
#ifdef KDBG
|
|
|
|
#include <ndk/kdfuncs.h>
|
|
|
|
#include <reactos/kdros.h>
|
|
|
|
#endif
|
2000-12-29 23:17:12 +00:00
|
|
|
|
[FASTFAT] Improvements for volume dismount + minor bugfixing.
- Cache the RootFcb so that its cleanup can be handled separately
during dismounting.
- Force volume dismount at cleanup if the VCB_DISMOUNT_PENDING flag
is set.
- Actually dismount a volume if its VCB has been flagged as not good,
or if we force dismounting.
NOTE: In their *CheckForDismount() function, our 3rd-party FS drivers
as well as MS' fastfat, perform a comparison check of the current VCB's
VPB ReferenceCount with some sort of "dangling"/"residual" open count.
It seems to be related to the fact that the volume root directory as
well as auxiliary data stream(s) are still opened, and only these are
allowed to be opened at that moment. After analysis it appears that for
the ReactOS' fastfat, this number is equal to "3".
- On dismounting, cleanup and destroy the RootFcb, VolumeFcb and the
FATFileObject. Then cleanup the SpareVPB or the IoVPB members, and
finish by removing the dismounted volume from the VolumeListEntry
and cleaning up the notify synchronization object and the resources.
- During dismounting, and on shutdown, flush the volume before
resetting its dirty bit.
- On shutdown, after volume flushing, try to unmount it without forcing.
- Release the VCB resources only when we actually dismount the volume
in VfatCheckForDismount().
- Initialize first the notify list and the synchronization object,
before sending the FSRTL_VOLUME_MOUNT notification.
- If we failed at mounting a volume but its VCB's FATFileObject was
already initialized, first call CcUninitializeCacheMap() on it
before dereferencing it.
- Send FSRTL_VOLUME_LOCK, FSRTL_VOLUME_LOCK_FAILED and
FSRTL_VOLUME_UNLOCK notifications during volume locking (and failure)
and volume unlocking.
- Flush the volume before locking it, and clean its dirty bit if needed.
NOTE: In addition to checking for VCB_CLEAR_DIRTY, we also check for the
presence of the VCB_IS_DIRTY flag before cleaning up the dirty bit: this
allows us to not re-clean the bit if it has been previously cleaned.
This is needed for instance in this scenario:
- The volume is locked (it gets flushed and the dirty bit is possibly cleared);
- The volume then gets formatted with a completely different FS, that
possibly clears up the first sector (e.g. BTRFS ignores 1st sector);
- The volume is then dismounted: if we didn't check whether VCB_IS_DIRTY
was set prior to resetting it, we could attempt clearing it again! But
now that the volume's filesystem has been completely changed, we would
then try to modify the dirty bit on an erroneous position on disk!
That's why it should not be touched in this case during dismounting.
- The volume is unlocked (same comment as above), and later can be
detected as being BTRFS.
2018-11-11 16:17:48 +00:00
|
|
|
|
2005-01-12 12:06:15 +00:00
|
|
|
#define USE_ROS_CC_AND_FS
|
2014-11-29 20:26:07 +00:00
|
|
|
#define ENABLE_SWAPOUT
|
[FASTFAT] Improvements for volume dismount + minor bugfixing.
- Cache the RootFcb so that its cleanup can be handled separately
during dismounting.
- Force volume dismount at cleanup if the VCB_DISMOUNT_PENDING flag
is set.
- Actually dismount a volume if its VCB has been flagged as not good,
or if we force dismounting.
NOTE: In their *CheckForDismount() function, our 3rd-party FS drivers
as well as MS' fastfat, perform a comparison check of the current VCB's
VPB ReferenceCount with some sort of "dangling"/"residual" open count.
It seems to be related to the fact that the volume root directory as
well as auxiliary data stream(s) are still opened, and only these are
allowed to be opened at that moment. After analysis it appears that for
the ReactOS' fastfat, this number is equal to "3".
- On dismounting, cleanup and destroy the RootFcb, VolumeFcb and the
FATFileObject. Then cleanup the SpareVPB or the IoVPB members, and
finish by removing the dismounted volume from the VolumeListEntry
and cleaning up the notify synchronization object and the resources.
- During dismounting, and on shutdown, flush the volume before
resetting its dirty bit.
- On shutdown, after volume flushing, try to unmount it without forcing.
- Release the VCB resources only when we actually dismount the volume
in VfatCheckForDismount().
- Initialize first the notify list and the synchronization object,
before sending the FSRTL_VOLUME_MOUNT notification.
- If we failed at mounting a volume but its VCB's FATFileObject was
already initialized, first call CcUninitializeCacheMap() on it
before dereferencing it.
- Send FSRTL_VOLUME_LOCK, FSRTL_VOLUME_LOCK_FAILED and
FSRTL_VOLUME_UNLOCK notifications during volume locking (and failure)
and volume unlocking.
- Flush the volume before locking it, and clean its dirty bit if needed.
NOTE: In addition to checking for VCB_CLEAR_DIRTY, we also check for the
presence of the VCB_IS_DIRTY flag before cleaning up the dirty bit: this
allows us to not re-clean the bit if it has been previously cleaned.
This is needed for instance in this scenario:
- The volume is locked (it gets flushed and the dirty bit is possibly cleared);
- The volume then gets formatted with a completely different FS, that
possibly clears up the first sector (e.g. BTRFS ignores 1st sector);
- The volume is then dismounted: if we didn't check whether VCB_IS_DIRTY
was set prior to resetting it, we could attempt clearing it again! But
now that the volume's filesystem has been completely changed, we would
then try to modify the dirty bit on an erroneous position on disk!
That's why it should not be touched in this case during dismounting.
- The volume is unlocked (same comment as above), and later can be
detected as being BTRFS.
2018-11-11 16:17:48 +00:00
|
|
|
|
|
|
|
/* FIXME: because volume is not cached, we have to perform direct IOs
|
|
|
|
* The day this is fixed, just comment out that line, and check
|
|
|
|
* it still works (and delete old code ;-))
|
|
|
|
*/
|
|
|
|
#define VOLUME_IS_NOT_CACHED_WORK_AROUND_IT
|
|
|
|
|
2005-01-12 12:06:15 +00:00
|
|
|
|
2009-01-25 16:13:16 +00:00
|
|
|
#define ROUND_DOWN(n, align) \
|
|
|
|
(((ULONG)n) & ~((align) - 1l))
|
|
|
|
|
|
|
|
#define ROUND_UP(n, align) \
|
|
|
|
ROUND_DOWN(((ULONG)n) + (align) - 1, (align))
|
|
|
|
|
2016-06-11 09:32:00 +00:00
|
|
|
#define ROUND_DOWN_64(n, align) \
|
|
|
|
(((ULONGLONG)n) & ~((align) - 1LL))
|
|
|
|
|
|
|
|
#define ROUND_UP_64(n, align) \
|
|
|
|
ROUND_DOWN_64(((ULONGLONG)n) + (align) - 1LL, (align))
|
|
|
|
|
2005-02-24 20:47:07 +00:00
|
|
|
#include <pshpack1.h>
|
2001-07-20 08:00:21 +00:00
|
|
|
struct _BootSector
|
|
|
|
{
|
2013-12-12 13:51:50 +00:00
|
|
|
unsigned char magic0, res0, magic1;
|
|
|
|
unsigned char OEMName[8];
|
|
|
|
unsigned short BytesPerSector;
|
|
|
|
unsigned char SectorsPerCluster;
|
|
|
|
unsigned short ReservedSectors;
|
|
|
|
unsigned char FATCount;
|
|
|
|
unsigned short RootEntries, Sectors;
|
|
|
|
unsigned char Media;
|
|
|
|
unsigned short FATSectors, SectorsPerTrack, Heads;
|
|
|
|
unsigned long HiddenSectors, SectorsHuge;
|
|
|
|
unsigned char Drive, Res1, Sig;
|
|
|
|
unsigned long VolumeID;
|
|
|
|
unsigned char VolumeLabel[11], SysType[8];
|
|
|
|
unsigned char Res2[448];
|
|
|
|
unsigned short Signatur1;
|
2005-02-24 20:47:07 +00:00
|
|
|
};
|
1998-10-05 04:00:59 +00:00
|
|
|
|
2001-07-20 08:00:21 +00:00
|
|
|
struct _BootSector32
|
|
|
|
{
|
2013-12-12 13:51:50 +00:00
|
|
|
unsigned char magic0, res0, magic1; // 0
|
|
|
|
unsigned char OEMName[8]; // 3
|
|
|
|
unsigned short BytesPerSector; // 11
|
|
|
|
unsigned char SectorsPerCluster; // 13
|
|
|
|
unsigned short ReservedSectors; // 14
|
|
|
|
unsigned char FATCount; // 16
|
|
|
|
unsigned short RootEntries, Sectors; // 17
|
|
|
|
unsigned char Media; // 21
|
|
|
|
unsigned short FATSectors, SectorsPerTrack, Heads; // 22
|
|
|
|
unsigned long HiddenSectors, SectorsHuge; // 28
|
|
|
|
unsigned long FATSectors32; // 36
|
|
|
|
unsigned short ExtFlag; // 40
|
|
|
|
unsigned short FSVersion; // 42
|
|
|
|
unsigned long RootCluster; // 44
|
|
|
|
unsigned short FSInfoSector; // 48
|
|
|
|
unsigned short BootBackup; // 50
|
|
|
|
unsigned char Res3[12]; // 52
|
|
|
|
unsigned char Drive; // 64
|
|
|
|
unsigned char Res4; // 65
|
|
|
|
unsigned char ExtBootSignature; // 66
|
|
|
|
unsigned long VolumeID; // 67
|
|
|
|
unsigned char VolumeLabel[11], SysType[8]; // 71
|
|
|
|
unsigned char Res2[420]; // 90
|
|
|
|
unsigned short Signature1; // 510
|
2005-02-24 20:47:07 +00:00
|
|
|
};
|
2001-07-20 08:00:21 +00:00
|
|
|
|
[FASTFAT] Completely rewrite support for dirty volumes.
Until now, our support for dirty volumes was totally broken
to a point where, on FAT32 volume, the dirty couldn't even
be written nor read from the disk.
This commit totally rewrites its handling, for both FAT16 and FAT32
so that it's now fully functionnal. Furthermore, it also gets
totally compatible with our vfatlib, and thus, autochk.
Now, on mount, FastFAT will check if the volume is dirty or not, and
autochk will be able to ask for a repair if dirty. vfatlib will
repair the volume and remove the dirty bit. So that, on next
reboot, the volume will be mounted clean.
As a reminder, the dirty bit is set immediately after mounting
the volume, so that, if you crash or have a powercut, autochk
will always attempt to repair your volume (with more or less,
that's FAT!).
If you want to experience without breaking your FAT volume,
just boot, open a cmd prompt and type: fsutil dirty set c:
and reboot!
CORE-13758
CORE-13760
CORE-13759
2018-05-18 21:00:13 +00:00
|
|
|
#define FAT_DIRTY_BIT 0x01
|
|
|
|
|
2004-12-05 16:31:51 +00:00
|
|
|
struct _BootSectorFatX
|
|
|
|
{
|
2013-12-12 13:51:50 +00:00
|
|
|
unsigned char SysType[4]; // 0
|
|
|
|
unsigned long VolumeID; // 4
|
|
|
|
unsigned long SectorsPerCluster; // 8
|
|
|
|
unsigned short FATCount; // 12
|
|
|
|
unsigned long Unknown; // 14
|
|
|
|
unsigned char Unused[4078]; // 18
|
2005-02-24 20:47:07 +00:00
|
|
|
};
|
2004-12-05 16:31:51 +00:00
|
|
|
|
2003-01-31 15:55:18 +00:00
|
|
|
struct _FsInfoSector
|
2001-07-20 08:00:21 +00:00
|
|
|
{
|
2013-12-12 13:51:50 +00:00
|
|
|
unsigned long ExtBootSignature2; // 0
|
|
|
|
unsigned char Res6[480]; // 4
|
|
|
|
unsigned long FSINFOSignature; // 484
|
|
|
|
unsigned long FreeCluster; // 488
|
|
|
|
unsigned long NextCluster; // 492
|
|
|
|
unsigned char Res7[12]; // 496
|
|
|
|
unsigned long Signatur2; // 508
|
2005-02-24 20:47:07 +00:00
|
|
|
};
|
1998-12-20 19:41:39 +00:00
|
|
|
|
1998-10-05 04:00:59 +00:00
|
|
|
typedef struct _BootSector BootSector;
|
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
struct _FATDirEntry
|
|
|
|
{
|
2013-12-12 13:51:50 +00:00
|
|
|
union
|
|
|
|
{
|
|
|
|
struct { unsigned char Filename[8], Ext[3]; };
|
|
|
|
unsigned char ShortName[11];
|
|
|
|
};
|
|
|
|
unsigned char Attrib;
|
|
|
|
unsigned char lCase;
|
|
|
|
unsigned char CreationTimeMs;
|
|
|
|
unsigned short CreationTime,CreationDate,AccessDate;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
unsigned short FirstClusterHigh; // FAT32
|
|
|
|
unsigned short ExtendedAttributes; // FAT12/FAT16
|
|
|
|
};
|
|
|
|
unsigned short UpdateTime; //time create/update
|
|
|
|
unsigned short UpdateDate; //date create/update
|
|
|
|
unsigned short FirstCluster;
|
|
|
|
unsigned long FileSize;
|
2005-02-24 20:47:07 +00:00
|
|
|
};
|
1998-10-05 04:00:59 +00:00
|
|
|
|
2006-05-07 18:50:18 +00:00
|
|
|
#define FAT_EAFILE "EA DATA. SF"
|
|
|
|
|
|
|
|
typedef struct _EAFileHeader FAT_EA_FILE_HEADER, *PFAT_EA_FILE_HEADER;
|
|
|
|
|
|
|
|
struct _EAFileHeader
|
|
|
|
{
|
2013-12-12 13:51:50 +00:00
|
|
|
unsigned short Signature; // ED
|
|
|
|
unsigned short Unknown[15];
|
|
|
|
unsigned short EASetTable[240];
|
2006-05-07 18:50:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _EASetHeader FAT_EA_SET_HEADER, *PFAT_EA_SET_HEADER;
|
|
|
|
|
|
|
|
struct _EASetHeader
|
|
|
|
{
|
2013-12-12 13:51:50 +00:00
|
|
|
unsigned short Signature; // EA
|
|
|
|
unsigned short Offset; // relative offset, same value as in the EASetTable
|
|
|
|
unsigned short Unknown1[2];
|
|
|
|
char TargetFileName[12];
|
|
|
|
unsigned short Unknown2[3];
|
|
|
|
unsigned int EALength;
|
|
|
|
// EA Header
|
2006-05-07 18:50:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _EAHeader FAT_EA_HEADER, *PFAT_EA_HEADER;
|
|
|
|
|
|
|
|
struct _EAHeader
|
|
|
|
{
|
2013-12-12 13:51:50 +00:00
|
|
|
unsigned char Unknown;
|
|
|
|
unsigned char EANameLength;
|
|
|
|
unsigned short EAValueLength;
|
|
|
|
// Name Data
|
|
|
|
// Value Data
|
2006-05-07 18:50:18 +00:00
|
|
|
};
|
|
|
|
|
2004-12-05 16:31:51 +00:00
|
|
|
typedef struct _FATDirEntry FAT_DIR_ENTRY, *PFAT_DIR_ENTRY;
|
|
|
|
|
|
|
|
struct _FATXDirEntry
|
|
|
|
{
|
2013-12-12 13:51:50 +00:00
|
|
|
unsigned char FilenameLength; // 0
|
|
|
|
unsigned char Attrib; // 1
|
|
|
|
unsigned char Filename[42]; // 2
|
|
|
|
unsigned long FirstCluster; // 44
|
|
|
|
unsigned long FileSize; // 48
|
|
|
|
unsigned short UpdateTime; // 52
|
|
|
|
unsigned short UpdateDate; // 54
|
|
|
|
unsigned short CreationTime; // 56
|
|
|
|
unsigned short CreationDate; // 58
|
|
|
|
unsigned short AccessTime; // 60
|
|
|
|
unsigned short AccessDate; // 62
|
2004-12-05 16:31:51 +00:00
|
|
|
};
|
|
|
|
|
1998-10-05 04:00:59 +00:00
|
|
|
struct _slot
|
|
|
|
{
|
2013-12-12 13:51:50 +00:00
|
|
|
unsigned char id; // sequence number for slot
|
|
|
|
WCHAR name0_4[5]; // first 5 characters in name
|
|
|
|
unsigned char attr; // attribute byte
|
|
|
|
unsigned char reserved; // always 0
|
|
|
|
unsigned char alias_checksum; // checksum for 8.3 alias
|
|
|
|
WCHAR name5_10[6]; // 6 more characters in name
|
|
|
|
unsigned char start[2]; // starting cluster number
|
|
|
|
WCHAR name11_12[2]; // last 2 characters in name
|
2005-02-24 20:47:07 +00:00
|
|
|
};
|
1998-10-05 04:00:59 +00:00
|
|
|
|
|
|
|
typedef struct _slot slot;
|
|
|
|
|
2005-02-24 20:47:07 +00:00
|
|
|
#include <poppack.h>
|
|
|
|
|
|
|
|
#define VFAT_CASE_LOWER_BASE 8 // base is lower case
|
|
|
|
#define VFAT_CASE_LOWER_EXT 16 // extension is lower case
|
|
|
|
|
|
|
|
#define LONGNAME_MAX_LENGTH 256 // max length for a long filename
|
|
|
|
|
2017-02-18 21:37:56 +00:00
|
|
|
#define ENTRY_DELETED(IsFatX, DirEntry) (IsFatX ? FATX_ENTRY_DELETED(&((DirEntry)->FatX)) : FAT_ENTRY_DELETED(&((DirEntry)->Fat)))
|
|
|
|
#define ENTRY_VOLUME(IsFatX, DirEntry) (IsFatX ? FATX_ENTRY_VOLUME(&((DirEntry)->FatX)) : FAT_ENTRY_VOLUME(&((DirEntry)->Fat)))
|
|
|
|
#define ENTRY_END(IsFatX, DirEntry) (IsFatX ? FATX_ENTRY_END(&((DirEntry)->FatX)) : FAT_ENTRY_END(&((DirEntry)->Fat)))
|
2017-02-18 21:24:31 +00:00
|
|
|
|
2005-02-24 20:47:07 +00:00
|
|
|
#define FAT_ENTRY_DELETED(DirEntry) ((DirEntry)->Filename[0] == 0xe5)
|
|
|
|
#define FAT_ENTRY_END(DirEntry) ((DirEntry)->Filename[0] == 0)
|
|
|
|
#define FAT_ENTRY_LONG(DirEntry) (((DirEntry)->Attrib & 0x3f) == 0x0f)
|
|
|
|
#define FAT_ENTRY_VOLUME(DirEntry) (((DirEntry)->Attrib & 0x1f) == 0x08)
|
|
|
|
|
|
|
|
#define FATX_ENTRY_DELETED(DirEntry) ((DirEntry)->FilenameLength == 0xe5)
|
|
|
|
#define FATX_ENTRY_END(DirEntry) ((DirEntry)->FilenameLength == 0xff)
|
|
|
|
#define FATX_ENTRY_LONG(DirEntry) (FALSE)
|
|
|
|
#define FATX_ENTRY_VOLUME(DirEntry) (((DirEntry)->Attrib & 0x1f) == 0x08)
|
|
|
|
|
|
|
|
#define FAT_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof (FAT_DIR_ENTRY))
|
|
|
|
#define FATX_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof (FATX_DIR_ENTRY))
|
|
|
|
|
|
|
|
typedef struct _FATXDirEntry FATX_DIR_ENTRY, *PFATX_DIR_ENTRY;
|
|
|
|
|
|
|
|
union _DIR_ENTRY
|
|
|
|
{
|
2013-12-12 13:51:50 +00:00
|
|
|
FAT_DIR_ENTRY Fat;
|
|
|
|
FATX_DIR_ENTRY FatX;
|
2005-02-24 20:47:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef union _DIR_ENTRY DIR_ENTRY, *PDIR_ENTRY;
|
|
|
|
|
1998-10-05 04:00:59 +00:00
|
|
|
#define BLOCKSIZE 512
|
1998-12-20 19:41:39 +00:00
|
|
|
|
2004-12-05 16:31:51 +00:00
|
|
|
#define FAT16 (1)
|
|
|
|
#define FAT12 (2)
|
|
|
|
#define FAT32 (3)
|
|
|
|
#define FATX16 (4)
|
|
|
|
#define FATX32 (5)
|
1998-12-30 18:43:27 +00:00
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
#define VCB_VOLUME_LOCKED 0x0001
|
|
|
|
#define VCB_DISMOUNT_PENDING 0x0002
|
2004-12-05 16:31:51 +00:00
|
|
|
#define VCB_IS_FATX 0x0004
|
2018-05-16 19:44:47 +00:00
|
|
|
#define VCB_IS_SYS_OR_HAS_PAGE 0x0008
|
2005-04-16 16:04:38 +00:00
|
|
|
#define VCB_IS_DIRTY 0x4000 /* Volume is dirty */
|
|
|
|
#define VCB_CLEAR_DIRTY 0x8000 /* Clean dirty flag at shutdown */
|
[FASTFAT] Improvements for volume dismount + minor bugfixing.
- Cache the RootFcb so that its cleanup can be handled separately
during dismounting.
- Force volume dismount at cleanup if the VCB_DISMOUNT_PENDING flag
is set.
- Actually dismount a volume if its VCB has been flagged as not good,
or if we force dismounting.
NOTE: In their *CheckForDismount() function, our 3rd-party FS drivers
as well as MS' fastfat, perform a comparison check of the current VCB's
VPB ReferenceCount with some sort of "dangling"/"residual" open count.
It seems to be related to the fact that the volume root directory as
well as auxiliary data stream(s) are still opened, and only these are
allowed to be opened at that moment. After analysis it appears that for
the ReactOS' fastfat, this number is equal to "3".
- On dismounting, cleanup and destroy the RootFcb, VolumeFcb and the
FATFileObject. Then cleanup the SpareVPB or the IoVPB members, and
finish by removing the dismounted volume from the VolumeListEntry
and cleaning up the notify synchronization object and the resources.
- During dismounting, and on shutdown, flush the volume before
resetting its dirty bit.
- On shutdown, after volume flushing, try to unmount it without forcing.
- Release the VCB resources only when we actually dismount the volume
in VfatCheckForDismount().
- Initialize first the notify list and the synchronization object,
before sending the FSRTL_VOLUME_MOUNT notification.
- If we failed at mounting a volume but its VCB's FATFileObject was
already initialized, first call CcUninitializeCacheMap() on it
before dereferencing it.
- Send FSRTL_VOLUME_LOCK, FSRTL_VOLUME_LOCK_FAILED and
FSRTL_VOLUME_UNLOCK notifications during volume locking (and failure)
and volume unlocking.
- Flush the volume before locking it, and clean its dirty bit if needed.
NOTE: In addition to checking for VCB_CLEAR_DIRTY, we also check for the
presence of the VCB_IS_DIRTY flag before cleaning up the dirty bit: this
allows us to not re-clean the bit if it has been previously cleaned.
This is needed for instance in this scenario:
- The volume is locked (it gets flushed and the dirty bit is possibly cleared);
- The volume then gets formatted with a completely different FS, that
possibly clears up the first sector (e.g. BTRFS ignores 1st sector);
- The volume is then dismounted: if we didn't check whether VCB_IS_DIRTY
was set prior to resetting it, we could attempt clearing it again! But
now that the volume's filesystem has been completely changed, we would
then try to modify the dirty bit on an erroneous position on disk!
That's why it should not be touched in this case during dismounting.
- The volume is unlocked (same comment as above), and later can be
detected as being BTRFS.
2018-11-11 16:17:48 +00:00
|
|
|
/* VCB condition state */
|
|
|
|
#define VCB_GOOD 0x0010 /* If not set, the VCB is improper for usage */
|
2002-03-18 22:37:13 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2013-12-12 13:51:50 +00:00
|
|
|
ULONG VolumeID;
|
2017-02-06 19:43:48 +00:00
|
|
|
CHAR VolumeLabel[11];
|
2013-12-12 13:51:50 +00:00
|
|
|
ULONG FATStart;
|
|
|
|
ULONG FATCount;
|
|
|
|
ULONG FATSectors;
|
|
|
|
ULONG rootDirectorySectors;
|
|
|
|
ULONG rootStart;
|
|
|
|
ULONG dataStart;
|
|
|
|
ULONG RootCluster;
|
|
|
|
ULONG SectorsPerCluster;
|
|
|
|
ULONG BytesPerSector;
|
|
|
|
ULONG BytesPerCluster;
|
|
|
|
ULONG NumberOfClusters;
|
|
|
|
ULONG FatType;
|
|
|
|
ULONG Sectors;
|
|
|
|
BOOLEAN FixedMedia;
|
2018-06-09 10:11:43 +00:00
|
|
|
ULONG FSInfoSector;
|
2002-08-14 20:58:39 +00:00
|
|
|
} FATINFO, *PFATINFO;
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2002-05-05 20:18:33 +00:00
|
|
|
struct _VFATFCB;
|
2004-12-05 16:31:51 +00:00
|
|
|
struct _VFAT_DIRENTRY_CONTEXT;
|
2017-02-17 22:25:03 +00:00
|
|
|
struct _VFAT_MOVE_CONTEXT;
|
[FASTFAT] Implement delayed close
When we're about to close a file (ie, forget everything about it
and release any associated structure), actually delay it.
This allows keep data fresh in memory for faster reuse in case
it would be required. The effective closing will only happen after some time.
For specific operations, this will produce a real speed up in ReactOS.
For instance, with that patch, Winamp starts within seconds, instead of dozen
of minutes.
In most cases, it will bring ReactOS to performances it had before fixing
the huge leak in FastFAT (commit 94ead99) without leaking the whole FS.
For now, due to regressions, this is only activated for files and not
for directories. Once it gets fixed, it will be enabled for both.
CORE-14826
CORE-14917
2018-08-18 15:04:02 +00:00
|
|
|
struct _VFAT_CLOSE_CONTEXT;
|
2002-05-05 20:18:33 +00:00
|
|
|
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
typedef struct _HASHENTRY
|
|
|
|
{
|
2013-12-12 13:51:50 +00:00
|
|
|
ULONG Hash;
|
|
|
|
struct _VFATFCB* self;
|
|
|
|
struct _HASHENTRY* next;
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
}
|
|
|
|
HASHENTRY;
|
|
|
|
|
2004-08-01 21:57:18 +00:00
|
|
|
typedef struct DEVICE_EXTENSION *PDEVICE_EXTENSION;
|
|
|
|
|
|
|
|
typedef NTSTATUS (*PGET_NEXT_CLUSTER)(PDEVICE_EXTENSION,ULONG,PULONG);
|
|
|
|
typedef NTSTATUS (*PFIND_AND_MARK_AVAILABLE_CLUSTER)(PDEVICE_EXTENSION,PULONG);
|
|
|
|
typedef NTSTATUS (*PWRITE_CLUSTER)(PDEVICE_EXTENSION,ULONG,ULONG,PULONG);
|
|
|
|
|
2018-05-18 12:03:20 +00:00
|
|
|
typedef BOOLEAN (*PIS_DIRECTORY_EMPTY)(PDEVICE_EXTENSION,struct _VFATFCB*);
|
2017-02-17 22:25:03 +00:00
|
|
|
typedef NTSTATUS (*PADD_ENTRY)(PDEVICE_EXTENSION,PUNICODE_STRING,struct _VFATFCB**,struct _VFATFCB*,ULONG,UCHAR,struct _VFAT_MOVE_CONTEXT*);
|
|
|
|
typedef NTSTATUS (*PDEL_ENTRY)(PDEVICE_EXTENSION,struct _VFATFCB*,struct _VFAT_MOVE_CONTEXT*);
|
2004-12-05 16:31:51 +00:00
|
|
|
typedef NTSTATUS (*PGET_NEXT_DIR_ENTRY)(PVOID*,PVOID*,struct _VFATFCB*,struct _VFAT_DIRENTRY_CONTEXT*,BOOLEAN);
|
[FASTFAT] Completely rewrite support for dirty volumes.
Until now, our support for dirty volumes was totally broken
to a point where, on FAT32 volume, the dirty couldn't even
be written nor read from the disk.
This commit totally rewrites its handling, for both FAT16 and FAT32
so that it's now fully functionnal. Furthermore, it also gets
totally compatible with our vfatlib, and thus, autochk.
Now, on mount, FastFAT will check if the volume is dirty or not, and
autochk will be able to ask for a repair if dirty. vfatlib will
repair the volume and remove the dirty bit. So that, on next
reboot, the volume will be mounted clean.
As a reminder, the dirty bit is set immediately after mounting
the volume, so that, if you crash or have a powercut, autochk
will always attempt to repair your volume (with more or less,
that's FAT!).
If you want to experience without breaking your FAT volume,
just boot, open a cmd prompt and type: fsutil dirty set c:
and reboot!
CORE-13758
CORE-13760
CORE-13759
2018-05-18 21:00:13 +00:00
|
|
|
typedef NTSTATUS (*PGET_DIRTY_STATUS)(PDEVICE_EXTENSION,PBOOLEAN);
|
|
|
|
typedef NTSTATUS (*PSET_DIRTY_STATUS)(PDEVICE_EXTENSION,BOOLEAN);
|
2004-12-05 16:31:51 +00:00
|
|
|
|
2017-02-17 22:25:03 +00:00
|
|
|
typedef struct _VFAT_DISPATCH
|
|
|
|
{
|
|
|
|
PIS_DIRECTORY_EMPTY IsDirectoryEmpty;
|
|
|
|
PADD_ENTRY AddEntry;
|
|
|
|
PDEL_ENTRY DelEntry;
|
|
|
|
PGET_NEXT_DIR_ENTRY GetNextDirEntry;
|
|
|
|
} VFAT_DISPATCH, *PVFAT_DISPATCH;
|
|
|
|
|
2017-09-24 08:56:06 +00:00
|
|
|
#define STATISTICS_SIZE_NO_PAD (sizeof(FILESYSTEM_STATISTICS) + sizeof(FAT_STATISTICS))
|
|
|
|
typedef struct _STATISTICS {
|
|
|
|
FILESYSTEM_STATISTICS Base;
|
|
|
|
FAT_STATISTICS Fat;
|
|
|
|
UCHAR Pad[((STATISTICS_SIZE_NO_PAD + 0x3f) & ~0x3f) - STATISTICS_SIZE_NO_PAD];
|
|
|
|
} STATISTICS, *PSTATISTICS;
|
|
|
|
|
2004-08-01 21:57:18 +00:00
|
|
|
typedef struct DEVICE_EXTENSION
|
1998-12-30 18:43:27 +00:00
|
|
|
{
|
2013-12-12 13:51:50 +00:00
|
|
|
ERESOURCE DirResource;
|
|
|
|
ERESOURCE FatResource;
|
|
|
|
|
|
|
|
KSPIN_LOCK FcbListLock;
|
|
|
|
LIST_ENTRY FcbListHead;
|
|
|
|
ULONG HashTableSize;
|
|
|
|
struct _HASHENTRY **FcbHashTable;
|
|
|
|
|
2014-11-10 22:11:36 +00:00
|
|
|
PDEVICE_OBJECT VolumeDevice;
|
2013-12-12 13:51:50 +00:00
|
|
|
PDEVICE_OBJECT StorageDevice;
|
|
|
|
PFILE_OBJECT FATFileObject;
|
|
|
|
FATINFO FatInfo;
|
|
|
|
ULONG LastAvailableCluster;
|
|
|
|
ULONG AvailableClusters;
|
|
|
|
BOOLEAN AvailableClustersValid;
|
|
|
|
ULONG Flags;
|
|
|
|
struct _VFATFCB *VolumeFcb;
|
[FASTFAT] Improvements for volume dismount + minor bugfixing.
- Cache the RootFcb so that its cleanup can be handled separately
during dismounting.
- Force volume dismount at cleanup if the VCB_DISMOUNT_PENDING flag
is set.
- Actually dismount a volume if its VCB has been flagged as not good,
or if we force dismounting.
NOTE: In their *CheckForDismount() function, our 3rd-party FS drivers
as well as MS' fastfat, perform a comparison check of the current VCB's
VPB ReferenceCount with some sort of "dangling"/"residual" open count.
It seems to be related to the fact that the volume root directory as
well as auxiliary data stream(s) are still opened, and only these are
allowed to be opened at that moment. After analysis it appears that for
the ReactOS' fastfat, this number is equal to "3".
- On dismounting, cleanup and destroy the RootFcb, VolumeFcb and the
FATFileObject. Then cleanup the SpareVPB or the IoVPB members, and
finish by removing the dismounted volume from the VolumeListEntry
and cleaning up the notify synchronization object and the resources.
- During dismounting, and on shutdown, flush the volume before
resetting its dirty bit.
- On shutdown, after volume flushing, try to unmount it without forcing.
- Release the VCB resources only when we actually dismount the volume
in VfatCheckForDismount().
- Initialize first the notify list and the synchronization object,
before sending the FSRTL_VOLUME_MOUNT notification.
- If we failed at mounting a volume but its VCB's FATFileObject was
already initialized, first call CcUninitializeCacheMap() on it
before dereferencing it.
- Send FSRTL_VOLUME_LOCK, FSRTL_VOLUME_LOCK_FAILED and
FSRTL_VOLUME_UNLOCK notifications during volume locking (and failure)
and volume unlocking.
- Flush the volume before locking it, and clean its dirty bit if needed.
NOTE: In addition to checking for VCB_CLEAR_DIRTY, we also check for the
presence of the VCB_IS_DIRTY flag before cleaning up the dirty bit: this
allows us to not re-clean the bit if it has been previously cleaned.
This is needed for instance in this scenario:
- The volume is locked (it gets flushed and the dirty bit is possibly cleared);
- The volume then gets formatted with a completely different FS, that
possibly clears up the first sector (e.g. BTRFS ignores 1st sector);
- The volume is then dismounted: if we didn't check whether VCB_IS_DIRTY
was set prior to resetting it, we could attempt clearing it again! But
now that the volume's filesystem has been completely changed, we would
then try to modify the dirty bit on an erroneous position on disk!
That's why it should not be touched in this case during dismounting.
- The volume is unlocked (same comment as above), and later can be
detected as being BTRFS.
2018-11-11 16:17:48 +00:00
|
|
|
struct _VFATFCB *RootFcb;
|
2017-09-24 08:56:06 +00:00
|
|
|
PSTATISTICS Statistics;
|
2013-12-12 13:51:50 +00:00
|
|
|
|
2020-10-18 13:23:52 +00:00
|
|
|
/* Overflow request queue */
|
|
|
|
KSPIN_LOCK OverflowQueueSpinLock;
|
|
|
|
LIST_ENTRY OverflowQueue;
|
|
|
|
ULONG OverflowQueueCount;
|
|
|
|
ULONG PostedRequestCount;
|
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* Pointers to functions for manipulating FAT. */
|
|
|
|
PGET_NEXT_CLUSTER GetNextCluster;
|
|
|
|
PFIND_AND_MARK_AVAILABLE_CLUSTER FindAndMarkAvailableCluster;
|
|
|
|
PWRITE_CLUSTER WriteCluster;
|
[FASTFAT] Completely rewrite support for dirty volumes.
Until now, our support for dirty volumes was totally broken
to a point where, on FAT32 volume, the dirty couldn't even
be written nor read from the disk.
This commit totally rewrites its handling, for both FAT16 and FAT32
so that it's now fully functionnal. Furthermore, it also gets
totally compatible with our vfatlib, and thus, autochk.
Now, on mount, FastFAT will check if the volume is dirty or not, and
autochk will be able to ask for a repair if dirty. vfatlib will
repair the volume and remove the dirty bit. So that, on next
reboot, the volume will be mounted clean.
As a reminder, the dirty bit is set immediately after mounting
the volume, so that, if you crash or have a powercut, autochk
will always attempt to repair your volume (with more or less,
that's FAT!).
If you want to experience without breaking your FAT volume,
just boot, open a cmd prompt and type: fsutil dirty set c:
and reboot!
CORE-13758
CORE-13760
CORE-13759
2018-05-18 21:00:13 +00:00
|
|
|
PGET_DIRTY_STATUS GetDirtyStatus;
|
|
|
|
PSET_DIRTY_STATUS SetDirtyStatus;
|
2013-12-12 13:51:50 +00:00
|
|
|
|
|
|
|
ULONG BaseDateYear;
|
|
|
|
|
|
|
|
LIST_ENTRY VolumeListEntry;
|
2014-03-07 19:38:35 +00:00
|
|
|
|
|
|
|
/* Notifications */
|
|
|
|
LIST_ENTRY NotifyList;
|
|
|
|
PNOTIFY_SYNC NotifySync;
|
2014-10-30 20:56:40 +00:00
|
|
|
|
2014-11-10 22:11:36 +00:00
|
|
|
/* Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLOSE */
|
2014-10-30 20:56:40 +00:00
|
|
|
ULONG OpenHandleCount;
|
2014-11-10 17:42:51 +00:00
|
|
|
|
|
|
|
/* VPBs for dismount */
|
|
|
|
PVPB IoVPB;
|
|
|
|
PVPB SpareVPB;
|
2017-02-17 22:25:03 +00:00
|
|
|
|
|
|
|
/* Pointers to functions for manipulating directory entries. */
|
|
|
|
VFAT_DISPATCH Dispatch;
|
2004-08-01 21:57:18 +00:00
|
|
|
} DEVICE_EXTENSION, VCB, *PVCB;
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2017-02-17 22:25:03 +00:00
|
|
|
FORCEINLINE
|
|
|
|
BOOLEAN
|
|
|
|
VfatIsDirectoryEmpty(PDEVICE_EXTENSION DeviceExt,
|
|
|
|
struct _VFATFCB* Fcb)
|
|
|
|
{
|
2018-05-18 12:03:20 +00:00
|
|
|
return DeviceExt->Dispatch.IsDirectoryEmpty(DeviceExt, Fcb);
|
2017-02-17 22:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
|
|
|
NTSTATUS
|
|
|
|
VfatAddEntry(PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PUNICODE_STRING NameU,
|
|
|
|
struct _VFATFCB** Fcb,
|
|
|
|
struct _VFATFCB* ParentFcb,
|
|
|
|
ULONG RequestedOptions,
|
|
|
|
UCHAR ReqAttr,
|
|
|
|
struct _VFAT_MOVE_CONTEXT* MoveContext)
|
|
|
|
{
|
|
|
|
return DeviceExt->Dispatch.AddEntry(DeviceExt, NameU, Fcb, ParentFcb, RequestedOptions, ReqAttr, MoveContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
|
|
|
NTSTATUS
|
|
|
|
VfatDelEntry(PDEVICE_EXTENSION DeviceExt,
|
|
|
|
struct _VFATFCB* Fcb,
|
|
|
|
struct _VFAT_MOVE_CONTEXT* MoveContext)
|
|
|
|
{
|
|
|
|
return DeviceExt->Dispatch.DelEntry(DeviceExt, Fcb, MoveContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
|
|
|
NTSTATUS
|
|
|
|
VfatGetNextDirEntry(PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PVOID *pContext,
|
|
|
|
PVOID *pPage,
|
|
|
|
struct _VFATFCB* pDirFcb,
|
|
|
|
struct _VFAT_DIRENTRY_CONTEXT* DirContext,
|
|
|
|
BOOLEAN First)
|
|
|
|
{
|
|
|
|
return DeviceExt->Dispatch.GetNextDirEntry(pContext, pPage, pDirFcb, DirContext, First);
|
|
|
|
}
|
|
|
|
|
2015-11-01 08:55:47 +00:00
|
|
|
#define VFAT_BREAK_ON_CORRUPTION 1
|
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2013-12-12 13:51:50 +00:00
|
|
|
PDRIVER_OBJECT DriverObject;
|
|
|
|
PDEVICE_OBJECT DeviceObject;
|
|
|
|
ULONG Flags;
|
2017-09-24 08:56:06 +00:00
|
|
|
ULONG NumberProcessors;
|
2013-12-12 13:51:50 +00:00
|
|
|
ERESOURCE VolumeListLock;
|
|
|
|
LIST_ENTRY VolumeListHead;
|
|
|
|
NPAGED_LOOKASIDE_LIST FcbLookasideList;
|
|
|
|
NPAGED_LOOKASIDE_LIST CcbLookasideList;
|
|
|
|
NPAGED_LOOKASIDE_LIST IrpContextLookasideList;
|
[FASTFAT] Implement delayed close
When we're about to close a file (ie, forget everything about it
and release any associated structure), actually delay it.
This allows keep data fresh in memory for faster reuse in case
it would be required. The effective closing will only happen after some time.
For specific operations, this will produce a real speed up in ReactOS.
For instance, with that patch, Winamp starts within seconds, instead of dozen
of minutes.
In most cases, it will bring ReactOS to performances it had before fixing
the huge leak in FastFAT (commit 94ead99) without leaking the whole FS.
For now, due to regressions, this is only activated for files and not
for directories. Once it gets fixed, it will be enabled for both.
CORE-14826
CORE-14917
2018-08-18 15:04:02 +00:00
|
|
|
PAGED_LOOKASIDE_LIST CloseContextLookasideList;
|
2013-12-12 13:51:50 +00:00
|
|
|
FAST_IO_DISPATCH FastIoDispatch;
|
|
|
|
CACHE_MANAGER_CALLBACKS CacheMgrCallbacks;
|
[FASTFAT] Implement delayed close
When we're about to close a file (ie, forget everything about it
and release any associated structure), actually delay it.
This allows keep data fresh in memory for faster reuse in case
it would be required. The effective closing will only happen after some time.
For specific operations, this will produce a real speed up in ReactOS.
For instance, with that patch, Winamp starts within seconds, instead of dozen
of minutes.
In most cases, it will bring ReactOS to performances it had before fixing
the huge leak in FastFAT (commit 94ead99) without leaking the whole FS.
For now, due to regressions, this is only activated for files and not
for directories. Once it gets fixed, it will be enabled for both.
CORE-14826
CORE-14917
2018-08-18 15:04:02 +00:00
|
|
|
FAST_MUTEX CloseMutex;
|
|
|
|
ULONG CloseCount;
|
|
|
|
LIST_ENTRY CloseListHead;
|
|
|
|
BOOLEAN CloseWorkerRunning;
|
|
|
|
PIO_WORKITEM CloseWorkItem;
|
2018-08-19 07:55:38 +00:00
|
|
|
BOOLEAN ShutdownStarted;
|
2002-08-14 20:58:39 +00:00
|
|
|
} VFAT_GLOBAL_DATA, *PVFAT_GLOBAL_DATA;
|
2002-03-18 22:37:13 +00:00
|
|
|
|
|
|
|
extern PVFAT_GLOBAL_DATA VfatGlobalData;
|
1998-12-30 18:43:27 +00:00
|
|
|
|
2001-08-14 20:47:30 +00:00
|
|
|
#define FCB_CACHE_INITIALIZED 0x0001
|
|
|
|
#define FCB_DELETE_PENDING 0x0002
|
2001-10-10 22:20:48 +00:00
|
|
|
#define FCB_IS_FAT 0x0004
|
2001-11-02 22:57:14 +00:00
|
|
|
#define FCB_IS_PAGE_FILE 0x0008
|
2002-05-05 20:18:33 +00:00
|
|
|
#define FCB_IS_VOLUME 0x0010
|
2004-12-05 16:31:51 +00:00
|
|
|
#define FCB_IS_DIRTY 0x0020
|
[FASTFAT] Implement delayed close
When we're about to close a file (ie, forget everything about it
and release any associated structure), actually delay it.
This allows keep data fresh in memory for faster reuse in case
it would be required. The effective closing will only happen after some time.
For specific operations, this will produce a real speed up in ReactOS.
For instance, with that patch, Winamp starts within seconds, instead of dozen
of minutes.
In most cases, it will bring ReactOS to performances it had before fixing
the huge leak in FastFAT (commit 94ead99) without leaking the whole FS.
For now, due to regressions, this is only activated for files and not
for directories. Once it gets fixed, it will be enabled for both.
CORE-14826
CORE-14917
2018-08-18 15:04:02 +00:00
|
|
|
#define FCB_DELAYED_CLOSE 0x0040
|
2018-04-28 07:34:10 +00:00
|
|
|
#ifdef KDBG
|
[FASTFAT] Implement delayed close
When we're about to close a file (ie, forget everything about it
and release any associated structure), actually delay it.
This allows keep data fresh in memory for faster reuse in case
it would be required. The effective closing will only happen after some time.
For specific operations, this will produce a real speed up in ReactOS.
For instance, with that patch, Winamp starts within seconds, instead of dozen
of minutes.
In most cases, it will bring ReactOS to performances it had before fixing
the huge leak in FastFAT (commit 94ead99) without leaking the whole FS.
For now, due to regressions, this is only activated for files and not
for directories. Once it gets fixed, it will be enabled for both.
CORE-14826
CORE-14917
2018-08-18 15:04:02 +00:00
|
|
|
#define FCB_CLEANED_UP 0x0080
|
|
|
|
#define FCB_CLOSED 0x0100
|
2018-04-28 07:34:10 +00:00
|
|
|
#endif
|
2001-08-14 20:47:30 +00:00
|
|
|
|
2018-04-27 16:56:31 +00:00
|
|
|
#define NODE_TYPE_FCB ((CSHORT)0x0502)
|
|
|
|
|
1999-12-11 21:14:49 +00:00
|
|
|
typedef struct _VFATFCB
|
1998-12-30 18:43:27 +00:00
|
|
|
{
|
2013-12-12 13:51:50 +00:00
|
|
|
/* FCB header required by ROS/NT */
|
|
|
|
FSRTL_COMMON_FCB_HEADER RFCB;
|
|
|
|
SECTION_OBJECT_POINTERS SectionObjectPointers;
|
|
|
|
ERESOURCE MainResource;
|
|
|
|
ERESOURCE PagingIoResource;
|
|
|
|
/* end FCB header required by ROS/NT */
|
2003-02-13 22:24:19 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* directory entry for this file or directory */
|
|
|
|
DIR_ENTRY entry;
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* Pointer to attributes in entry */
|
|
|
|
PUCHAR Attributes;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* long file name, points into PathNameBuffer */
|
|
|
|
UNICODE_STRING LongNameU;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* short file name */
|
|
|
|
UNICODE_STRING ShortNameU;
|
2003-10-11 17:51:56 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* directory name, points into PathNameBuffer */
|
|
|
|
UNICODE_STRING DirNameU;
|
2003-10-11 17:51:56 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* path + long file name 260 max*/
|
|
|
|
UNICODE_STRING PathNameU;
|
2003-10-11 17:51:56 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* buffer for PathNameU */
|
|
|
|
PWCHAR PathNameBuffer;
|
2003-10-11 17:51:56 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* buffer for ShortNameU */
|
|
|
|
WCHAR ShortNameBuffer[13];
|
2003-02-13 22:24:19 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* */
|
|
|
|
LONG RefCount;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* List of FCB's for this volume */
|
|
|
|
LIST_ENTRY FcbListEntry;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
2021-06-11 12:29:21 +00:00
|
|
|
/* List of FCB's for the parent */
|
2016-08-06 08:32:17 +00:00
|
|
|
LIST_ENTRY ParentListEntry;
|
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* pointer to the parent fcb */
|
|
|
|
struct _VFATFCB *parentFcb;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
2016-08-06 08:32:17 +00:00
|
|
|
/* List for the children */
|
|
|
|
LIST_ENTRY ParentListHead;
|
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* Flags for the fcb */
|
|
|
|
ULONG Flags;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* pointer to the file object which has initialized the fcb */
|
|
|
|
PFILE_OBJECT FileObject;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* Directory index for the short name entry */
|
|
|
|
ULONG dirIndex;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* Directory index where the long name starts */
|
|
|
|
ULONG startIndex;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* Share access for the file object */
|
|
|
|
SHARE_ACCESS FCBShareAccess;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLEANUP */
|
|
|
|
ULONG OpenHandleCount;
|
2004-08-28 22:19:12 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* Entry into the hash table for the path + long name */
|
|
|
|
HASHENTRY Hash;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* Entry into the hash table for the path + short name */
|
|
|
|
HASHENTRY ShortHash;
|
2003-02-13 22:24:19 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* List of byte-range locks for this file */
|
|
|
|
FILE_LOCK FileLock;
|
2002-01-08 00:49:02 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/*
|
2016-11-13 15:31:39 +00:00
|
|
|
* Optimization: caching of last read/write cluster+offset pair. Can't
|
2013-12-12 13:51:50 +00:00
|
|
|
* be in VFATCCB because it must be reset everytime the allocated clusters
|
|
|
|
* change.
|
|
|
|
*/
|
|
|
|
FAST_MUTEX LastMutex;
|
|
|
|
ULONG LastCluster;
|
|
|
|
ULONG LastOffset;
|
[FASTFAT] Implement delayed close
When we're about to close a file (ie, forget everything about it
and release any associated structure), actually delay it.
This allows keep data fresh in memory for faster reuse in case
it would be required. The effective closing will only happen after some time.
For specific operations, this will produce a real speed up in ReactOS.
For instance, with that patch, Winamp starts within seconds, instead of dozen
of minutes.
In most cases, it will bring ReactOS to performances it had before fixing
the huge leak in FastFAT (commit 94ead99) without leaking the whole FS.
For now, due to regressions, this is only activated for files and not
for directories. Once it gets fixed, it will be enabled for both.
CORE-14826
CORE-14917
2018-08-18 15:04:02 +00:00
|
|
|
|
|
|
|
struct _VFAT_CLOSE_CONTEXT * CloseContext;
|
2002-08-14 20:58:39 +00:00
|
|
|
} VFATFCB, *PVFATFCB;
|
1999-01-04 11:59:25 +00:00
|
|
|
|
2017-05-02 19:33:14 +00:00
|
|
|
#define CCB_DELETE_ON_CLOSE 0x0001
|
|
|
|
|
1999-12-11 21:14:49 +00:00
|
|
|
typedef struct _VFATCCB
|
1999-01-04 11:59:25 +00:00
|
|
|
{
|
2013-12-12 13:51:50 +00:00
|
|
|
LARGE_INTEGER CurrentByteOffset;
|
2017-05-02 19:33:14 +00:00
|
|
|
ULONG Flags;
|
2013-12-12 13:51:50 +00:00
|
|
|
/* for DirectoryControl */
|
|
|
|
ULONG Entry;
|
|
|
|
/* for DirectoryControl */
|
|
|
|
UNICODE_STRING SearchPattern;
|
2002-08-14 20:58:39 +00:00
|
|
|
} VFATCCB, *PVFATCCB;
|
1998-12-30 18:43:27 +00:00
|
|
|
|
2018-08-18 17:00:42 +00:00
|
|
|
#define TAG_CCB 'CtaF'
|
|
|
|
#define TAG_FCB 'FtaF'
|
|
|
|
#define TAG_IRP 'ItaF'
|
[FASTFAT] Implement delayed close
When we're about to close a file (ie, forget everything about it
and release any associated structure), actually delay it.
This allows keep data fresh in memory for faster reuse in case
it would be required. The effective closing will only happen after some time.
For specific operations, this will produce a real speed up in ReactOS.
For instance, with that patch, Winamp starts within seconds, instead of dozen
of minutes.
In most cases, it will bring ReactOS to performances it had before fixing
the huge leak in FastFAT (commit 94ead99) without leaking the whole FS.
For now, due to regressions, this is only activated for files and not
for directories. Once it gets fixed, it will be enabled for both.
CORE-14826
CORE-14917
2018-08-18 15:04:02 +00:00
|
|
|
#define TAG_CLOSE 'xtaF'
|
2018-08-18 17:00:42 +00:00
|
|
|
#define TAG_STATS 'VtaF'
|
|
|
|
#define TAG_BUFFER 'OtaF'
|
2018-08-21 06:36:51 +00:00
|
|
|
#define TAG_VPB 'vtaF'
|
|
|
|
#define TAG_NAME 'ntaF'
|
|
|
|
#define TAG_SEARCH 'LtaF'
|
|
|
|
#define TAG_DIRENT 'DtaF'
|
1998-12-30 18:43:27 +00:00
|
|
|
|
|
|
|
#define ENTRIES_PER_SECTOR (BLOCKSIZE / sizeof(FATDirEntry))
|
|
|
|
|
1999-05-15 17:25:02 +00:00
|
|
|
typedef struct __DOSTIME
|
|
|
|
{
|
2013-12-12 13:51:50 +00:00
|
|
|
USHORT Second:5;
|
|
|
|
USHORT Minute:6;
|
|
|
|
USHORT Hour:5;
|
2002-03-18 22:37:13 +00:00
|
|
|
}
|
|
|
|
DOSTIME, *PDOSTIME;
|
1999-05-15 17:25:02 +00:00
|
|
|
|
|
|
|
typedef struct __DOSDATE
|
|
|
|
{
|
2013-12-12 13:51:50 +00:00
|
|
|
USHORT Day:5;
|
|
|
|
USHORT Month:4;
|
|
|
|
USHORT Year:7;
|
2002-03-18 22:37:13 +00:00
|
|
|
}
|
|
|
|
DOSDATE, *PDOSDATE;
|
1999-05-15 17:25:02 +00:00
|
|
|
|
2015-05-15 16:03:29 +00:00
|
|
|
#define IRPCONTEXT_CANWAIT 0x0001
|
|
|
|
#define IRPCONTEXT_COMPLETE 0x0002
|
|
|
|
#define IRPCONTEXT_QUEUE 0x0004
|
|
|
|
#define IRPCONTEXT_PENDINGRETURNED 0x0008
|
2018-04-29 18:42:24 +00:00
|
|
|
#define IRPCONTEXT_DEFERRED_WRITE 0x0010
|
2001-11-02 22:57:14 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2013-12-12 13:51:50 +00:00
|
|
|
PIRP Irp;
|
|
|
|
PDEVICE_OBJECT DeviceObject;
|
|
|
|
PDEVICE_EXTENSION DeviceExt;
|
|
|
|
ULONG Flags;
|
|
|
|
WORK_QUEUE_ITEM WorkQueueItem;
|
|
|
|
PIO_STACK_LOCATION Stack;
|
|
|
|
UCHAR MajorFunction;
|
|
|
|
UCHAR MinorFunction;
|
|
|
|
PFILE_OBJECT FileObject;
|
|
|
|
ULONG RefCount;
|
|
|
|
KEVENT Event;
|
2015-05-15 16:03:29 +00:00
|
|
|
CCHAR PriorityBoost;
|
2002-08-14 20:58:39 +00:00
|
|
|
} VFAT_IRP_CONTEXT, *PVFAT_IRP_CONTEXT;
|
2001-11-02 22:57:14 +00:00
|
|
|
|
2003-10-11 17:51:56 +00:00
|
|
|
typedef struct _VFAT_DIRENTRY_CONTEXT
|
|
|
|
{
|
2013-12-12 13:51:50 +00:00
|
|
|
ULONG StartIndex;
|
|
|
|
ULONG DirIndex;
|
|
|
|
DIR_ENTRY DirEntry;
|
|
|
|
UNICODE_STRING LongNameU;
|
|
|
|
UNICODE_STRING ShortNameU;
|
2018-05-18 12:03:20 +00:00
|
|
|
PDEVICE_EXTENSION DeviceExt;
|
2003-10-11 17:51:56 +00:00
|
|
|
} VFAT_DIRENTRY_CONTEXT, *PVFAT_DIRENTRY_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
|
|
|
typedef struct _VFAT_MOVE_CONTEXT
|
|
|
|
{
|
|
|
|
ULONG FirstCluster;
|
|
|
|
ULONG FileSize;
|
|
|
|
USHORT CreationDate;
|
|
|
|
USHORT CreationTime;
|
2016-05-06 21:06:31 +00:00
|
|
|
BOOLEAN InPlace;
|
[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
|
|
|
} VFAT_MOVE_CONTEXT, *PVFAT_MOVE_CONTEXT;
|
2003-10-11 17:51:56 +00:00
|
|
|
|
[FASTFAT] Implement delayed close
When we're about to close a file (ie, forget everything about it
and release any associated structure), actually delay it.
This allows keep data fresh in memory for faster reuse in case
it would be required. The effective closing will only happen after some time.
For specific operations, this will produce a real speed up in ReactOS.
For instance, with that patch, Winamp starts within seconds, instead of dozen
of minutes.
In most cases, it will bring ReactOS to performances it had before fixing
the huge leak in FastFAT (commit 94ead99) without leaking the whole FS.
For now, due to regressions, this is only activated for files and not
for directories. Once it gets fixed, it will be enabled for both.
CORE-14826
CORE-14917
2018-08-18 15:04:02 +00:00
|
|
|
typedef struct _VFAT_CLOSE_CONTEXT
|
|
|
|
{
|
|
|
|
PDEVICE_EXTENSION Vcb;
|
|
|
|
PVFATFCB Fcb;
|
|
|
|
LIST_ENTRY CloseListEntry;
|
|
|
|
} VFAT_CLOSE_CONTEXT, *PVFAT_CLOSE_CONTEXT;
|
|
|
|
|
2015-05-15 16:03:29 +00:00
|
|
|
FORCEINLINE
|
|
|
|
NTSTATUS
|
|
|
|
VfatMarkIrpContextForQueue(PVFAT_IRP_CONTEXT IrpContext)
|
|
|
|
{
|
|
|
|
PULONG Flags = &IrpContext->Flags;
|
|
|
|
|
|
|
|
*Flags &= ~IRPCONTEXT_COMPLETE;
|
|
|
|
*Flags |= IRPCONTEXT_QUEUE;
|
|
|
|
|
|
|
|
return STATUS_PENDING;
|
|
|
|
}
|
|
|
|
|
2017-02-17 17:58:18 +00:00
|
|
|
FORCEINLINE
|
|
|
|
BOOLEAN
|
|
|
|
vfatFCBIsDirectory(PVFATFCB FCB)
|
|
|
|
{
|
|
|
|
return BooleanFlagOn(*FCB->Attributes, FILE_ATTRIBUTE_DIRECTORY);
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
|
|
|
BOOLEAN
|
|
|
|
vfatFCBIsReadOnly(PVFATFCB FCB)
|
|
|
|
{
|
|
|
|
return BooleanFlagOn(*FCB->Attributes, FILE_ATTRIBUTE_READONLY);
|
|
|
|
}
|
|
|
|
|
2017-02-17 21:24:12 +00:00
|
|
|
FORCEINLINE
|
|
|
|
BOOLEAN
|
|
|
|
vfatVolumeIsFatX(PDEVICE_EXTENSION DeviceExt)
|
|
|
|
{
|
|
|
|
return BooleanFlagOn(DeviceExt->Flags, VCB_IS_FATX);
|
|
|
|
}
|
|
|
|
|
2018-01-07 13:16:11 +00:00
|
|
|
FORCEINLINE
|
|
|
|
VOID
|
|
|
|
vfatReportChange(
|
|
|
|
IN PDEVICE_EXTENSION DeviceExt,
|
|
|
|
IN PVFATFCB Fcb,
|
|
|
|
IN ULONG FilterMatch,
|
|
|
|
IN ULONG Action)
|
|
|
|
{
|
|
|
|
FsRtlNotifyFullReportChange(DeviceExt->NotifySync,
|
|
|
|
&(DeviceExt->NotifyList),
|
|
|
|
(PSTRING)&Fcb->PathNameU,
|
|
|
|
Fcb->PathNameU.Length - Fcb->LongNameU.Length,
|
|
|
|
NULL, NULL, FilterMatch, Action, NULL);
|
|
|
|
}
|
|
|
|
|
2017-09-24 09:50:36 +00:00
|
|
|
#define vfatAddToStat(Vcb, Stat, Inc) \
|
|
|
|
{ \
|
|
|
|
PSTATISTICS Stats = &(Vcb)->Statistics[KeGetCurrentProcessorNumber() % VfatGlobalData->NumberProcessors]; \
|
|
|
|
Stats->Stat += Inc; \
|
|
|
|
}
|
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* blockdev.c */
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatReadDisk(
|
|
|
|
IN PDEVICE_OBJECT pDeviceObject,
|
|
|
|
IN PLARGE_INTEGER ReadOffset,
|
|
|
|
IN ULONG ReadLength,
|
|
|
|
IN PUCHAR Buffer,
|
|
|
|
IN BOOLEAN Override);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatReadDiskPartial(
|
|
|
|
IN PVFAT_IRP_CONTEXT IrpContext,
|
|
|
|
IN PLARGE_INTEGER ReadOffset,
|
|
|
|
IN ULONG ReadLength,
|
|
|
|
IN ULONG BufferOffset,
|
|
|
|
IN BOOLEAN Wait);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
[FASTFAT] Completely rewrite support for dirty volumes.
Until now, our support for dirty volumes was totally broken
to a point where, on FAT32 volume, the dirty couldn't even
be written nor read from the disk.
This commit totally rewrites its handling, for both FAT16 and FAT32
so that it's now fully functionnal. Furthermore, it also gets
totally compatible with our vfatlib, and thus, autochk.
Now, on mount, FastFAT will check if the volume is dirty or not, and
autochk will be able to ask for a repair if dirty. vfatlib will
repair the volume and remove the dirty bit. So that, on next
reboot, the volume will be mounted clean.
As a reminder, the dirty bit is set immediately after mounting
the volume, so that, if you crash or have a powercut, autochk
will always attempt to repair your volume (with more or less,
that's FAT!).
If you want to experience without breaking your FAT volume,
just boot, open a cmd prompt and type: fsutil dirty set c:
and reboot!
CORE-13758
CORE-13760
CORE-13759
2018-05-18 21:00:13 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatWriteDisk(
|
|
|
|
IN PDEVICE_OBJECT pDeviceObject,
|
|
|
|
IN PLARGE_INTEGER WriteOffset,
|
|
|
|
IN ULONG WriteLength,
|
|
|
|
IN OUT PUCHAR Buffer,
|
|
|
|
IN BOOLEAN Override);
|
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatWriteDiskPartial(
|
|
|
|
IN PVFAT_IRP_CONTEXT IrpContext,
|
|
|
|
IN PLARGE_INTEGER WriteOffset,
|
|
|
|
IN ULONG WriteLength,
|
|
|
|
IN ULONG BufferOffset,
|
|
|
|
IN BOOLEAN Wait);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
VfatBlockDeviceIoControl(
|
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN ULONG CtlCode,
|
|
|
|
IN PVOID InputBuffer,
|
|
|
|
IN ULONG InputBufferSize,
|
|
|
|
IN OUT PVOID OutputBuffer,
|
|
|
|
IN OUT PULONG pOutputBufferSize,
|
|
|
|
IN BOOLEAN Override);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* cleanup.c */
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatCleanup(
|
|
|
|
PVFAT_IRP_CONTEXT IrpContext);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* close.c */
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatClose(
|
|
|
|
PVFAT_IRP_CONTEXT IrpContext);
|
2004-05-15 23:00:02 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatCloseFile(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PFILE_OBJECT FileObject);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* create.c */
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatCreate(
|
|
|
|
PVFAT_IRP_CONTEXT IrpContext);
|
2001-11-02 22:57:14 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
FindFile(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PVFATFCB Parent,
|
|
|
|
PUNICODE_STRING FileToFindU,
|
|
|
|
PVFAT_DIRENTRY_CONTEXT DirContext,
|
|
|
|
BOOLEAN First);
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
VOID
|
|
|
|
vfat8Dot3ToString(
|
|
|
|
PFAT_DIR_ENTRY pEntry,
|
|
|
|
PUNICODE_STRING NameU);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* dir.c */
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatDirectoryControl(
|
|
|
|
PVFAT_IRP_CONTEXT IrpContext);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
BOOLEAN
|
|
|
|
FsdDosDateTimeToSystemTime(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
USHORT DosDate,
|
|
|
|
USHORT DosTime,
|
|
|
|
PLARGE_INTEGER SystemTime);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
BOOLEAN
|
|
|
|
FsdSystemTimeToDosDateTime(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PLARGE_INTEGER SystemTime,
|
|
|
|
USHORT *pDosDate,
|
|
|
|
USHORT *pDosTime);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* direntry.c */
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
ULONG
|
|
|
|
vfatDirEntryGetFirstCluster(
|
|
|
|
PDEVICE_EXTENSION pDeviceExt,
|
|
|
|
PDIR_ENTRY pDirEntry);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* dirwr.c */
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2018-05-18 12:03:20 +00:00
|
|
|
NTSTATUS
|
|
|
|
vfatFCBInitializeCacheFromVolume(
|
|
|
|
PVCB vcb,
|
|
|
|
PVFATFCB fcb);
|
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatUpdateEntry(
|
2018-05-18 12:03:20 +00:00
|
|
|
IN PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PVFATFCB pFcb);
|
2013-12-12 13:51:50 +00:00
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
vfatFindDirSpace(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PVFATFCB pDirFcb,
|
|
|
|
ULONG nbSlots,
|
|
|
|
PULONG start);
|
2005-01-12 13:00:43 +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
|
|
|
NTSTATUS
|
|
|
|
vfatRenameEntry(
|
|
|
|
IN PDEVICE_EXTENSION DeviceExt,
|
|
|
|
IN PVFATFCB pFcb,
|
|
|
|
IN PUNICODE_STRING FileName,
|
|
|
|
IN BOOLEAN CaseChangeOnly);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
VfatMoveEntry(
|
|
|
|
IN PDEVICE_EXTENSION DeviceExt,
|
|
|
|
IN PVFATFCB pFcb,
|
|
|
|
IN PUNICODE_STRING FileName,
|
|
|
|
IN PVFATFCB ParentFcb);
|
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* ea.h */
|
2005-01-12 13:00:43 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatSetExtendedAttributes(
|
|
|
|
PFILE_OBJECT FileObject,
|
|
|
|
PVOID Ea,
|
|
|
|
ULONG EaLength);
|
2005-01-12 13:00:43 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* fastio.c */
|
2005-01-12 13:00:43 +00:00
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2013-12-12 13:51:50 +00:00
|
|
|
VOID
|
|
|
|
VfatInitFastIoRoutines(
|
|
|
|
PFAST_IO_DISPATCH FastIoDispatch);
|
2005-01-12 13:00:43 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
VfatAcquireForLazyWrite(
|
|
|
|
IN PVOID Context,
|
|
|
|
IN BOOLEAN Wait);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
VfatReleaseFromLazyWrite(
|
|
|
|
IN PVOID Context);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* fat.c */
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2002-08-14 20:58:39 +00:00
|
|
|
NTSTATUS
|
2013-12-12 13:51:50 +00:00
|
|
|
FAT12GetNextCluster(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
ULONG CurrentCluster,
|
|
|
|
PULONG NextCluster);
|
2002-08-14 20:58:39 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
FAT12FindAndMarkAvailableCluster(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PULONG Cluster);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
FAT12WriteCluster(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
ULONG ClusterToWrite,
|
|
|
|
ULONG NewValue,
|
|
|
|
PULONG OldValue);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
FAT16GetNextCluster(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
ULONG CurrentCluster,
|
|
|
|
PULONG NextCluster);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
FAT16FindAndMarkAvailableCluster(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PULONG Cluster);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
FAT16WriteCluster(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
ULONG ClusterToWrite,
|
|
|
|
ULONG NewValue,
|
|
|
|
PULONG OldValue);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
FAT32GetNextCluster(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
ULONG CurrentCluster,
|
|
|
|
PULONG NextCluster);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
FAT32FindAndMarkAvailableCluster(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PULONG Cluster);
|
2004-12-05 16:31:51 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
FAT32WriteCluster(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
ULONG ClusterToWrite,
|
|
|
|
ULONG NewValue,
|
|
|
|
PULONG OldValue);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
OffsetToCluster(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
ULONG FirstCluster,
|
|
|
|
ULONG FileOffset,
|
|
|
|
PULONG Cluster,
|
|
|
|
BOOLEAN Extend);
|
|
|
|
|
|
|
|
ULONGLONG
|
|
|
|
ClusterToSector(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
ULONG Cluster);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
GetNextCluster(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
ULONG CurrentCluster,
|
|
|
|
PULONG NextCluster);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
GetNextClusterExtend(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
ULONG CurrentCluster,
|
|
|
|
PULONG NextCluster);
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
CountAvailableClusters(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PLARGE_INTEGER Clusters);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
WriteCluster(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
ULONG ClusterToWrite,
|
|
|
|
ULONG NewValue);
|
2004-08-01 21:57:18 +00:00
|
|
|
|
[FASTFAT] Completely rewrite support for dirty volumes.
Until now, our support for dirty volumes was totally broken
to a point where, on FAT32 volume, the dirty couldn't even
be written nor read from the disk.
This commit totally rewrites its handling, for both FAT16 and FAT32
so that it's now fully functionnal. Furthermore, it also gets
totally compatible with our vfatlib, and thus, autochk.
Now, on mount, FastFAT will check if the volume is dirty or not, and
autochk will be able to ask for a repair if dirty. vfatlib will
repair the volume and remove the dirty bit. So that, on next
reboot, the volume will be mounted clean.
As a reminder, the dirty bit is set immediately after mounting
the volume, so that, if you crash or have a powercut, autochk
will always attempt to repair your volume (with more or less,
that's FAT!).
If you want to experience without breaking your FAT volume,
just boot, open a cmd prompt and type: fsutil dirty set c:
and reboot!
CORE-13758
CORE-13760
CORE-13759
2018-05-18 21:00:13 +00:00
|
|
|
NTSTATUS
|
|
|
|
GetDirtyStatus(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PBOOLEAN DirtyStatus);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
FAT16GetDirtyStatus(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PBOOLEAN DirtyStatus);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
FAT32GetDirtyStatus(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PBOOLEAN DirtyStatus);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
SetDirtyStatus(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
BOOLEAN DirtyStatus);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
FAT16SetDirtyStatus(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
BOOLEAN DirtyStatus);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
FAT32SetDirtyStatus(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
BOOLEAN DirtyStatus);
|
|
|
|
|
2018-06-09 10:36:43 +00:00
|
|
|
NTSTATUS
|
|
|
|
FAT32UpdateFreeClustersCount(
|
2018-06-09 16:21:32 +00:00
|
|
|
PDEVICE_EXTENSION DeviceExt);
|
2018-06-09 10:36:43 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* fcb.c */
|
2004-08-01 21:57:18 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
PVFATFCB
|
|
|
|
vfatNewFCB(
|
|
|
|
PDEVICE_EXTENSION pVCB,
|
|
|
|
PUNICODE_STRING pFileNameU);
|
2004-08-01 21:57:18 +00:00
|
|
|
|
2016-08-07 12:29:48 +00:00
|
|
|
NTSTATUS
|
|
|
|
vfatSetFCBNewDirName(
|
|
|
|
PDEVICE_EXTENSION pVCB,
|
|
|
|
PVFATFCB Fcb,
|
|
|
|
PVFATFCB 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
|
|
|
NTSTATUS
|
|
|
|
vfatUpdateFCB(
|
|
|
|
PDEVICE_EXTENSION pVCB,
|
|
|
|
PVFATFCB Fcb,
|
2016-04-30 08:20:00 +00:00
|
|
|
PVFAT_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
|
|
|
PVFATFCB ParentFcb);
|
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
VOID
|
|
|
|
vfatDestroyFCB(
|
|
|
|
PVFATFCB pFCB);
|
2004-08-01 21:57:18 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
VOID
|
|
|
|
vfatDestroyCCB(
|
|
|
|
PVFATCCB pCcb);
|
2004-08-01 21:57:18 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
VOID
|
2018-04-28 07:34:10 +00:00
|
|
|
#ifndef KDBG
|
2013-12-12 13:51:50 +00:00
|
|
|
vfatGrabFCB(
|
2018-04-28 07:34:10 +00:00
|
|
|
#else
|
|
|
|
_vfatGrabFCB(
|
|
|
|
#endif
|
2013-12-12 13:51:50 +00:00
|
|
|
PDEVICE_EXTENSION pVCB,
|
2018-04-28 07:34:10 +00:00
|
|
|
PVFATFCB pFCB
|
|
|
|
#ifdef KDBG
|
|
|
|
,
|
|
|
|
PCSTR File,
|
|
|
|
ULONG Line,
|
|
|
|
PCSTR Func
|
|
|
|
#endif
|
|
|
|
);
|
2004-08-01 21:57:18 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
VOID
|
2018-04-28 07:34:10 +00:00
|
|
|
#ifndef KDBG
|
2013-12-12 13:51:50 +00:00
|
|
|
vfatReleaseFCB(
|
2018-04-28 07:34:10 +00:00
|
|
|
#else
|
|
|
|
_vfatReleaseFCB(
|
|
|
|
#endif
|
2013-12-12 13:51:50 +00:00
|
|
|
PDEVICE_EXTENSION pVCB,
|
2018-04-28 07:34:10 +00:00
|
|
|
PVFATFCB pFCB
|
|
|
|
#ifdef KDBG
|
|
|
|
,
|
|
|
|
PCSTR File,
|
|
|
|
ULONG Line,
|
|
|
|
PCSTR Func
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
|
|
|
|
#ifdef KDBG
|
|
|
|
#define vfatGrabFCB(v, f) _vfatGrabFCB(v, f, __FILE__, __LINE__, __FUNCTION__)
|
|
|
|
#define vfatReleaseFCB(v, f) _vfatReleaseFCB(v, f, __FILE__, __LINE__, __FUNCTION__)
|
|
|
|
#endif
|
2004-08-01 21:57:18 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
PVFATFCB
|
|
|
|
vfatGrabFCBFromTable(
|
|
|
|
PDEVICE_EXTENSION pDeviceExt,
|
|
|
|
PUNICODE_STRING pFileNameU);
|
2004-08-01 21:57:18 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
PVFATFCB
|
|
|
|
vfatMakeRootFCB(
|
|
|
|
PDEVICE_EXTENSION pVCB);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
PVFATFCB
|
|
|
|
vfatOpenRootFCB(
|
|
|
|
PDEVICE_EXTENSION pVCB);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
BOOLEAN
|
|
|
|
vfatFCBIsDirectory(
|
|
|
|
PVFATFCB FCB);
|
2004-08-05 02:48:18 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
BOOLEAN
|
|
|
|
vfatFCBIsRoot(
|
|
|
|
PVFATFCB FCB);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
vfatAttachFCBToFileObject(
|
|
|
|
PDEVICE_EXTENSION vcb,
|
|
|
|
PVFATFCB fcb,
|
|
|
|
PFILE_OBJECT fileObject);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2003-07-24 19:00:42 +00:00
|
|
|
NTSTATUS
|
2013-12-12 13:51:50 +00:00
|
|
|
vfatDirFindFile(
|
|
|
|
PDEVICE_EXTENSION pVCB,
|
|
|
|
PVFATFCB parentFCB,
|
|
|
|
PUNICODE_STRING FileToFindU,
|
|
|
|
PVFATFCB *fileFCB);
|
2003-07-24 19:00:42 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
vfatGetFCBForFile(
|
|
|
|
PDEVICE_EXTENSION pVCB,
|
|
|
|
PVFATFCB *pParentFCB,
|
|
|
|
PVFATFCB *pFCB,
|
|
|
|
PUNICODE_STRING pFileNameU);
|
2001-07-05 01:51:53 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
vfatMakeFCBFromDirEntry(
|
|
|
|
PVCB vcb,
|
|
|
|
PVFATFCB directoryFCB,
|
|
|
|
PVFAT_DIRENTRY_CONTEXT DirContext,
|
|
|
|
PVFATFCB *fileFCB);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* finfo.c */
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2015-05-18 19:51:14 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatGetStandardInformation(
|
|
|
|
PVFATFCB FCB,
|
|
|
|
PFILE_STANDARD_INFORMATION StandardInfo,
|
|
|
|
PULONG BufferLength);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
VfatGetBasicInformation(
|
|
|
|
PFILE_OBJECT FileObject,
|
|
|
|
PVFATFCB FCB,
|
2017-06-26 18:10:43 +00:00
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
2015-05-18 19:51:14 +00:00
|
|
|
PFILE_BASIC_INFORMATION BasicInfo,
|
|
|
|
PULONG BufferLength);
|
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatQueryInformation(
|
|
|
|
PVFAT_IRP_CONTEXT IrpContext);
|
2004-12-05 16:31:51 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatSetInformation(
|
|
|
|
PVFAT_IRP_CONTEXT IrpContext);
|
2001-07-05 01:51:53 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatSetAllocationSizeInformation(
|
|
|
|
PFILE_OBJECT FileObject,
|
|
|
|
PVFATFCB Fcb,
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PLARGE_INTEGER AllocationSize);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* flush.c */
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatFlush(
|
|
|
|
PVFAT_IRP_CONTEXT IrpContext);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatFlushVolume(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PVFATFCB VolumeFcb);
|
2003-07-24 19:00:42 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* fsctl.c */
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatFileSystemControl(
|
|
|
|
PVFAT_IRP_CONTEXT IrpContext);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* iface.c */
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
DriverEntry(
|
|
|
|
PDRIVER_OBJECT DriverObject,
|
|
|
|
PUNICODE_STRING RegistryPath);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2018-04-29 10:33:53 +00:00
|
|
|
#ifdef KDBG
|
|
|
|
/* kdbg.c */
|
|
|
|
KDBG_CLI_ROUTINE vfatKdbgHandler;
|
|
|
|
#endif
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* misc.c */
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
DRIVER_DISPATCH
|
|
|
|
VfatBuildRequest;
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
VfatBuildRequest(
|
|
|
|
PDEVICE_OBJECT DeviceObject,
|
|
|
|
PIRP Irp);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
PVOID
|
|
|
|
VfatGetUserBuffer(
|
2019-06-09 15:56:06 +00:00
|
|
|
IN PIRP Irp,
|
2015-05-17 12:22:28 +00:00
|
|
|
IN BOOLEAN Paging);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatLockUserBuffer(
|
2019-06-09 15:56:06 +00:00
|
|
|
IN PIRP Irp,
|
|
|
|
IN ULONG Length,
|
|
|
|
IN LOCK_OPERATION Operation);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2014-11-10 22:11:36 +00:00
|
|
|
BOOLEAN
|
|
|
|
VfatCheckForDismount(
|
|
|
|
IN PDEVICE_EXTENSION DeviceExt,
|
|
|
|
IN BOOLEAN Create);
|
|
|
|
|
2018-01-07 13:16:11 +00:00
|
|
|
VOID
|
|
|
|
vfatReportChange(
|
|
|
|
IN PDEVICE_EXTENSION DeviceExt,
|
|
|
|
IN PVFATFCB Fcb,
|
|
|
|
IN ULONG FilterMatch,
|
|
|
|
IN ULONG Action);
|
|
|
|
|
2018-04-29 18:42:24 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
VfatHandleDeferredWrite(
|
|
|
|
IN PVOID IrpContext,
|
|
|
|
IN PVOID Unused);
|
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* pnp.c */
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatPnp(
|
|
|
|
PVFAT_IRP_CONTEXT IrpContext);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* rw.c */
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatRead(
|
|
|
|
PVFAT_IRP_CONTEXT IrpContext);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatWrite(
|
2020-10-11 13:02:26 +00:00
|
|
|
PVFAT_IRP_CONTEXT *pIrpContext);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NextCluster(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
ULONG FirstCluster,
|
|
|
|
PULONG CurrentCluster,
|
|
|
|
BOOLEAN Extend);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* shutdown.c */
|
2001-05-02 03:18:03 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
DRIVER_DISPATCH
|
|
|
|
VfatShutdown;
|
2002-05-05 20:18:33 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
VfatShutdown(
|
|
|
|
PDEVICE_OBJECT DeviceObject,
|
|
|
|
PIRP Irp);
|
2002-03-18 22:37:13 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* string.c */
|
2002-05-05 20:18:33 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
VOID
|
|
|
|
vfatSplitPathName(
|
|
|
|
PUNICODE_STRING PathNameU,
|
|
|
|
PUNICODE_STRING DirNameU,
|
|
|
|
PUNICODE_STRING FileNameU);
|
2003-02-09 18:02:56 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
BOOLEAN
|
|
|
|
vfatIsLongIllegal(
|
|
|
|
WCHAR c);
|
2003-02-09 18:02:56 +00:00
|
|
|
|
2020-09-26 22:39:15 +00:00
|
|
|
BOOLEAN
|
|
|
|
IsDotOrDotDot(
|
|
|
|
PCUNICODE_STRING Name);
|
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
/* volume.c */
|
2003-02-09 18:02:56 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatQueryVolumeInformation(
|
|
|
|
PVFAT_IRP_CONTEXT IrpContext);
|
[FASTFAT]
Make our FAT driver PNP aware.
On PNP requests it should handle, it will return STATUS_NOT_IMPLEMENTED.
On the others, it will pass them to lower driver.
This is the first step outside the kernel into getting IoGetRelatedTargetDevice (and so notifications) working.
It doesn't work at the moment, as class2 doesn't handle PNP.
[NTOSKRNL]
Some fixes to IRP cancelation process:
- Renamed IopRemoveThreadIrp() to IopDisassociateThreadIrp() to match Windows 2k3
- Made dead IRP global, to make its debug easier.
- IopDisassociateThreadIrp(), Handle dead IRP at dispatch level, using IoCompletionLock.
- IopDisassociateThreadIrp(), Use the proper error code to write the entry to logs.
- IoCancelIrp(), removed non needed ASSERT, which is even not present on Windows, removed corresponding var as well.
- IoCancelIrp(), fixed parameters to KeBugCheckEx() call.
- IoCancelThreadIo() is pageable.
- IoCancelThreadIo() under Windows isn't using given thread, but using current. Do the same here.
All that stuff doesn't fix bug #5550, it comes from outside.
Patch by Pierre Schweitzer, modified by me to make it compile. If it breaks anything, don't blame me!
svn path=/trunk/; revision=48560
2010-08-18 23:21:15 +00:00
|
|
|
|
2013-12-12 13:51:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatSetVolumeInformation(
|
|
|
|
PVFAT_IRP_CONTEXT IrpContext);
|
2003-10-11 17:51:56 +00:00
|
|
|
|
2014-02-06 12:28:49 +00:00
|
|
|
#endif /* _FASTFAT_PCH_ */
|