mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 19:55:41 +00:00
-move FCB_TAG to header
-use ExAllocatePoolWithTag / ExFreePoolWithTag -free the NameListResource when destroying an FCB -get rid of CdfsWriteNumberInShortName svn path=/trunk/; revision=39571
This commit is contained in:
parent
b251557b6a
commit
3215261518
3 changed files with 7 additions and 32 deletions
|
@ -232,6 +232,7 @@ typedef struct _CCB
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TAG_CCB TAG('I', 'C', 'C', 'B')
|
#define TAG_CCB TAG('I', 'C', 'C', 'B')
|
||||||
|
#define TAG_FCB TAG('I', 'F', 'C', 'B')
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,8 +35,6 @@
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
#define TAG_FCB TAG('I', 'F', 'C', 'B')
|
|
||||||
|
|
||||||
#define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
|
#define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,10 +112,11 @@ CdfsDestroyFCB(PFCB Fcb)
|
||||||
{
|
{
|
||||||
Entry = Fcb->ShortNameList.Flink;
|
Entry = Fcb->ShortNameList.Flink;
|
||||||
RemoveEntryList(Entry);
|
RemoveEntryList(Entry);
|
||||||
ExFreePool(Entry);
|
ExFreePoolWithTag(Entry, TAG_FCB);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExFreePool(Fcb);
|
ExDeleteResourceLite(&Fcb->NameListResource);
|
||||||
|
ExFreePoolWithTag(Fcb, TAG_FCB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -95,21 +95,6 @@ CdfsFileFlagsToAttributes(PFCB Fcb,
|
||||||
((Fcb->Entry.FileFlags & FILE_FLAG_READONLY) ? FILE_ATTRIBUTE_READONLY : 0);
|
((Fcb->Entry.FileFlags & FILE_FLAG_READONLY) ? FILE_ATTRIBUTE_READONLY : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Writes a number into a string, ending at the target position. */
|
|
||||||
static PWCHAR
|
|
||||||
CdfsWriteNumberInShortName
|
|
||||||
(PWCHAR EndOfNumberTarget,
|
|
||||||
ULONG Number)
|
|
||||||
{
|
|
||||||
while (Number)
|
|
||||||
{
|
|
||||||
*EndOfNumberTarget = '0' + (Number % 10);
|
|
||||||
EndOfNumberTarget--;
|
|
||||||
Number /= 10;
|
|
||||||
}
|
|
||||||
return EndOfNumberTarget;
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
CdfsShortNameCacheGet
|
CdfsShortNameCacheGet
|
||||||
(PFCB DirectoryFcb,
|
(PFCB DirectoryFcb,
|
||||||
|
@ -118,11 +103,9 @@ CdfsShortNameCacheGet
|
||||||
PUNICODE_STRING ShortName)
|
PUNICODE_STRING ShortName)
|
||||||
{
|
{
|
||||||
BOOLEAN HasSpaces;
|
BOOLEAN HasSpaces;
|
||||||
PWCHAR LastDot, Scan;
|
|
||||||
ULONG Number = 1;
|
|
||||||
PLIST_ENTRY Entry;
|
PLIST_ENTRY Entry;
|
||||||
PCDFS_SHORT_NAME ShortNameEntry;
|
PCDFS_SHORT_NAME ShortNameEntry;
|
||||||
GENERATE_NAME_CONTEXT Context = { };
|
GENERATE_NAME_CONTEXT Context = { 0 };
|
||||||
|
|
||||||
DPRINT("CdfsShortNameCacheGet(%I64u,%wZ)\n", StreamOffset->QuadPart, LongName);
|
DPRINT("CdfsShortNameCacheGet(%I64u,%wZ)\n", StreamOffset->QuadPart, LongName);
|
||||||
|
|
||||||
|
@ -165,13 +148,6 @@ CdfsShortNameCacheGet
|
||||||
|
|
||||||
DPRINT("Initial Guess %wZ\n", ShortName);
|
DPRINT("Initial Guess %wZ\n", ShortName);
|
||||||
|
|
||||||
/* Find the part that'll be numberified */
|
|
||||||
LastDot = &ShortName->Buffer[(ShortName->Length / sizeof(WCHAR)) - 1];
|
|
||||||
for (Scan = ShortName->Buffer;
|
|
||||||
Scan - ShortName->Buffer < ShortName->Length;
|
|
||||||
Scan++)
|
|
||||||
if (*Scan == '.') LastDot = Scan - 1;
|
|
||||||
|
|
||||||
/* Make it unique by scanning the cache and bumping */
|
/* Make it unique by scanning the cache and bumping */
|
||||||
/* Note that incrementing the ambiguous name is enough, since we add new
|
/* Note that incrementing the ambiguous name is enough, since we add new
|
||||||
* entries at the tail. We'll scan over all collisions. */
|
* entries at the tail. We'll scan over all collisions. */
|
||||||
|
@ -186,14 +162,13 @@ CdfsShortNameCacheGet
|
||||||
&ShortNameEntry->Name,
|
&ShortNameEntry->Name,
|
||||||
TRUE) == 0) /* Match */
|
TRUE) == 0) /* Match */
|
||||||
{
|
{
|
||||||
Scan = CdfsWriteNumberInShortName(LastDot, ++Number);
|
RtlGenerate8dot3Name(LongName, FALSE, &Context, ShortName);
|
||||||
*Scan = '~';
|
|
||||||
DPRINT("Collide; try %wZ\n", ShortName);
|
DPRINT("Collide; try %wZ\n", ShortName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We've scanned over all entries and now have a unique one. Cache it. */
|
/* We've scanned over all entries and now have a unique one. Cache it. */
|
||||||
ShortNameEntry = ExAllocatePool(PagedPool, sizeof(CDFS_SHORT_NAME));
|
ShortNameEntry = ExAllocatePoolWithTag(PagedPool, sizeof(CDFS_SHORT_NAME), TAG_FCB);
|
||||||
if (!ShortNameEntry)
|
if (!ShortNameEntry)
|
||||||
{
|
{
|
||||||
/* We couldn't cache it, but we can return it. We run the risk of
|
/* We couldn't cache it, but we can return it. We run the risk of
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue