Author: pschweitzer
Date: Fri Apr 18 21:40:02 2014
New Revision: 62779
URL:
http://svn.reactos.org/svn/reactos?rev=62779&view=rev
Log:
[CDFS]
Convert FCB pathname from simple buffer to unicode string.
Please carefully review if I missed something
Modified:
trunk/reactos/drivers/filesystems/cdfs/cdfs.h
trunk/reactos/drivers/filesystems/cdfs/create.c
trunk/reactos/drivers/filesystems/cdfs/dirctl.c
trunk/reactos/drivers/filesystems/cdfs/fcb.c
trunk/reactos/drivers/filesystems/cdfs/finfo.c
trunk/reactos/drivers/filesystems/cdfs/fsctl.c
Modified: trunk/reactos/drivers/filesystems/cdfs/cdfs.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/c…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/cdfs.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/cdfs.h [iso-8859-1] Fri Apr 18 21:40:02 2014
@@ -189,8 +189,9 @@
UNICODE_STRING ShortNameU;
- WCHAR *ObjectName; /* point on filename (250 chars max) in PathName */
- WCHAR PathName[MAX_PATH]; /* path+filename 260 max */
+ WCHAR *ObjectName; /* point on filename (250 chars max) in PathName */
+ UNICODE_STRING PathName; /* path+filename 260 max */
+ WCHAR PathNameBuffer[MAX_PATH]; /* Buffer for PathName */
WCHAR ShortNameBuffer[13];
LIST_ENTRY FcbListEntry;
@@ -198,8 +199,8 @@
ULONG DirIndex;
- LARGE_INTEGER IndexNumber; /* HighPart: Parent directory start sector */
- /* LowPart: Directory record offset in the parent directory file */
+ LARGE_INTEGER IndexNumber; /* HighPart: Parent directory start sector */
+ /* LowPart: Directory record offset in the parent directory file */
LONG RefCount;
ULONG Flags;
Modified: trunk/reactos/drivers/filesystems/cdfs/create.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/c…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/create.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/create.c [iso-8859-1] Fri Apr 18 21:40:02 2014
@@ -56,7 +56,7 @@
}
/* construct absolute path name */
- Length = (wcslen(Fcb->PathName) * sizeof(WCHAR)) +
+ Length = Fcb->PathName.Length +
sizeof(WCHAR) +
RelativeFileName->Length +
sizeof(WCHAR);
@@ -69,8 +69,8 @@
return STATUS_INSUFFICIENT_RESOURCES;
}
- Status = RtlAppendUnicodeToString(AbsoluteFileName,
- Fcb->PathName);
+ Status = RtlAppendUnicodeStringToString(AbsoluteFileName,
+ &Fcb->PathName);
if (!NT_SUCCESS(Status))
{
RtlFreeUnicodeString(AbsoluteFileName);
Modified: trunk/reactos/drivers/filesystems/cdfs/dirctl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/d…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/dirctl.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/dirctl.c [iso-8859-1] Fri Apr 18 21:40:02 2014
@@ -216,17 +216,20 @@
/* it's root : complete essentials fields then return ok */
RtlZeroMemory(Fcb, sizeof(FCB));
- Fcb->PathName[0] = '\\';
- Fcb->ObjectName = &Fcb->PathName[1];
+ Fcb->PathNameBuffer[0] = '\\';
+ Fcb->ObjectName = &Fcb->PathNameBuffer[1];
Fcb->Entry.ExtentLocationL = DeviceExt->CdInfo.RootStart;
Fcb->Entry.DataLengthL = DeviceExt->CdInfo.RootSize;
Fcb->Entry.FileFlags = 0x02; //FILE_ATTRIBUTE_DIRECTORY;
+ Fcb->PathName.Length = sizeof(WCHAR);
+ Fcb->PathName.MaximumLength = sizeof(Fcb->PathNameBuffer);
+ Fcb->PathName.Buffer = Fcb->PathNameBuffer;
if (pDirIndex)
*pDirIndex = 0;
if (pOffset)
*pOffset = 0;
- DPRINT("CdfsFindFile: new Pathname %S, new Objectname
%S)\n",Fcb->PathName, Fcb->ObjectName);
+ DPRINT("CdfsFindFile: new Pathname %wZ, new Objectname
%S)\n",&Fcb->PathName, Fcb->ObjectName);
return STATUS_SUCCESS;
}
}
@@ -303,12 +306,13 @@
if (FsRtlIsNameInExpression(&FileToFindUpcase, &LongName, TRUE, NULL) ||
FsRtlIsNameInExpression(&FileToFindUpcase, &ShortName, TRUE, NULL))
{
- if (Parent->PathName[0])
- {
- len = wcslen(Parent->PathName);
- memcpy(Fcb->PathName, Parent->PathName, len*sizeof(WCHAR));
- Fcb->ObjectName=&Fcb->PathName[len];
- if (len != 1 || Fcb->PathName[0] != '\\')
+ if (Parent->PathName.Buffer[0])
+ {
+ len = Parent->PathName.Length / sizeof(WCHAR);
+ memcpy(Fcb->PathName.Buffer, Parent->PathName.Buffer,
Parent->PathName.Length);
+ Fcb->PathName.Length = Parent->PathName.Length;
+ Fcb->ObjectName=&Fcb->PathName.Buffer[len];
+ if (len != 1 || Fcb->PathName.Buffer[0] != '\\')
{
Fcb->ObjectName[0] = '\\';
Fcb->ObjectName = &Fcb->ObjectName[1];
@@ -316,16 +320,16 @@
}
else
{
- Fcb->ObjectName=Fcb->PathName;
+ Fcb->ObjectName=Fcb->PathName.Buffer;
Fcb->ObjectName[0]='\\';
Fcb->ObjectName=&Fcb->ObjectName[1];
}
- DPRINT("PathName '%S' ObjectName '%S'\n",
Fcb->PathName, Fcb->ObjectName);
+ DPRINT("PathName '%wZ' ObjectName '%S'\n",
&Fcb->PathName, Fcb->ObjectName);
memcpy(&Fcb->Entry, Record, sizeof(DIR_RECORD));
wcsncpy(Fcb->ObjectName, name, min(wcslen(name) + 1,
- MAX_PATH - wcslen(Fcb->PathName) + wcslen(Fcb->ObjectName)));
+ MAX_PATH - (Fcb->PathName.Length / sizeof(WCHAR)) +
wcslen(Fcb->ObjectName)));
/* Copy short name */
Fcb->ShortNameU.Length = ShortName.Length;
@@ -338,8 +342,8 @@
if (pOffset)
*pOffset = Offset;
- DPRINT("FindFile: new Pathname %S, new Objectname %S, DirIndex
%u\n",
- Fcb->PathName, Fcb->ObjectName, DirIndex);
+ DPRINT("FindFile: new Pathname %wZ, new Objectname %S, DirIndex
%u\n",
+ &Fcb->PathName, Fcb->ObjectName, DirIndex);
RtlFreeUnicodeString(&FileToFindUpcase);
CcUnpinData(Context);
@@ -572,6 +576,8 @@
DeviceExtension = DeviceObject->DeviceExtension;
Stack = IoGetCurrentIrpStackLocation(Irp);
FileObject = Stack->FileObject;
+ TempFcb.PathName.Buffer = TempFcb.PathNameBuffer;
+ TempFcb.PathName.MaximumLength = sizeof(TempFcb.PathNameBuffer);
Ccb = (PCCB)FileObject->FsContext2;
Fcb = (PFCB)FileObject->FsContext;
@@ -646,7 +652,7 @@
}
DPRINT("Buffer = %p tofind = %wZ\n", Buffer,
&Ccb->DirectorySearchPattern);
- TempFcb.ObjectName = TempFcb.PathName;
+ TempFcb.ObjectName = TempFcb.PathName.Buffer;
while (Status == STATUS_SUCCESS && BufferLength > 0)
{
Status = CdfsFindFile(DeviceExtension,
@@ -746,7 +752,6 @@
}
-
NTSTATUS NTAPI
CdfsDirectoryControl(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
Modified: trunk/reactos/drivers/filesystems/cdfs/fcb.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/f…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/fcb.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/fcb.c [iso-8859-1] Fri Apr 18 21:40:02 2014
@@ -73,17 +73,19 @@
if(!Fcb) return NULL;
RtlZeroMemory(Fcb, sizeof(FCB));
+ Fcb->PathName.Buffer = Fcb->PathNameBuffer;
+ Fcb->PathName.MaximumLength = sizeof(Fcb->PathNameBuffer);
if (FileName)
{
- CdfsWSubString(Fcb->PathName, FileName, sizeof(Fcb->PathName) /
sizeof(Fcb->PathName[0]) - 1);
- if (wcsrchr(Fcb->PathName, '\\') != 0)
- {
- Fcb->ObjectName = wcsrchr(Fcb->PathName, '\\');
+ RtlAppendUnicodeToString(&Fcb->PathName, FileName);
+ if (wcsrchr(Fcb->PathName.Buffer, '\\') != 0)
+ {
+ Fcb->ObjectName = wcsrchr(Fcb->PathName.Buffer, '\\');
}
else
{
- Fcb->ObjectName = Fcb->PathName;
+ Fcb->ObjectName = Fcb->PathName.Buffer;
}
}
@@ -129,7 +131,7 @@
BOOLEAN
CdfsFCBIsRoot(PFCB Fcb)
{
- return(wcscmp(Fcb->PathName, L"\\") == 0);
+ return (Fcb->PathName.Length = sizeof(WCHAR) && Fcb->PathName.Buffer[0]
== L'\\');
}
@@ -156,9 +158,9 @@
{
KIRQL oldIrql;
- DPRINT("releasing FCB at %p: %S, refCount:%d\n",
+ DPRINT("releasing FCB at %p: %wZ, refCount:%d\n",
Fcb,
- Fcb->PathName,
+ &Fcb->PathName,
Fcb->RefCount);
KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
@@ -209,8 +211,8 @@
{
Fcb = CONTAINING_RECORD(current_entry, FCB, FcbListEntry);
- DPRINT("Comparing '%wZ' and '%S'\n", FileName,
Fcb->PathName);
- if (_wcsicmp(FileName->Buffer, Fcb->PathName) == 0)
+ DPRINT("Comparing '%wZ' and '%wZ'\n", FileName,
&Fcb->PathName);
+ if (RtlCompareUnicodeString(FileName, &Fcb->PathName, TRUE) == 0)
{
Fcb->RefCount++;
KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
@@ -365,12 +367,12 @@
/* Check if the full string would overflow the pathName buffer (the additional
characters are for '\\' and '\0') */
if ((LongName[0] != 0) &&
- (wcslen(DirectoryFCB->PathName) + 1 + wcslen(LongName) + 1 > MAX_PATH))
+ ((DirectoryFCB->PathName.Length / sizeof(WCHAR)) + 1 + wcslen(LongName) + 1
> MAX_PATH))
{
return(STATUS_OBJECT_NAME_INVALID);
}
- wcscpy(pathName, DirectoryFCB->PathName);
+ wcscpy(pathName, DirectoryFCB->PathName.Buffer);
if (!CdfsFCBIsRoot(DirectoryFCB))
{
wcscat(pathName, L"\\");
@@ -488,7 +490,7 @@
DeviceExt,
DirectoryFcb,
FileToFind);
- DPRINT("Dir Path:%S\n", DirectoryFcb->PathName);
+ DPRINT("Dir Path:%wZ\n", &DirectoryFcb->PathName);
/* default to '.' if no filename specified */
if (FileToFind->Length == 0)
Modified: trunk/reactos/drivers/filesystems/cdfs/finfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/f…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/finfo.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/finfo.c [iso-8859-1] Fri Apr 18 21:40:02 2014
@@ -164,7 +164,7 @@
return STATUS_BUFFER_OVERFLOW;
/* Calculate file name length in bytes */
- NameLength = wcslen(Fcb->PathName) * sizeof(WCHAR);
+ NameLength = Fcb->PathName.Length;
NameInfo->FileNameLength = NameLength;
/* Calculate amount of bytes to copy not to overflow the buffer */
@@ -172,7 +172,7 @@
*BufferLength - FIELD_OFFSET(FILE_NAME_INFORMATION, FileName[0]));
/* Fill in the bytes */
- RtlCopyMemory(NameInfo->FileName, Fcb->PathName, BytesToCopy);
+ RtlCopyMemory(NameInfo->FileName, Fcb->PathName.Buffer, BytesToCopy);
/* Check if we could write more but are not able to */
if (*BufferLength < NameLength + FIELD_OFFSET(FILE_NAME_INFORMATION,
FileName[0]))
@@ -268,7 +268,7 @@
ASSERT(Info);
ASSERT(Fcb);
- NameLength = wcslen(Fcb->PathName) * sizeof(WCHAR);
+ NameLength = Fcb->PathName.Length;
if (*BufferLength < sizeof(FILE_ALL_INFORMATION) + NameLength)
return(STATUS_BUFFER_OVERFLOW);
@@ -321,7 +321,7 @@
/* Name Information */
Info->NameInformation.FileNameLength = NameLength;
RtlCopyMemory(Info->NameInformation.FileName,
- Fcb->PathName,
+ Fcb->PathName.Buffer,
NameLength + sizeof(WCHAR));
*BufferLength -= (sizeof(FILE_ALL_INFORMATION) + NameLength + sizeof(WCHAR));
Modified: trunk/reactos/drivers/filesystems/cdfs/fsctl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/cdfs/f…
==============================================================================
--- trunk/reactos/drivers/filesystems/cdfs/fsctl.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/cdfs/fsctl.c [iso-8859-1] Fri Apr 18 21:40:02 2014
@@ -513,7 +513,7 @@
while (Entry != &DeviceExt->FcbListHead)
{
Fcb = (PFCB)CONTAINING_RECORD(Entry, FCB, FcbListEntry);
- DPRINT1("OpenFile %S RefCount %ld\n", Fcb->PathName,
Fcb->RefCount);
+ DPRINT1("OpenFile %wZ RefCount %ld\n", &Fcb->PathName,
Fcb->RefCount);
Entry = Entry->Flink;
}