mirror of
https://github.com/reactos/reactos.git
synced 2024-08-06 03:14:36 +00:00
[CDFS]
Convert FCB pathname from simple buffer to unicode string. Please carefully review if I missed something svn path=/trunk/; revision=62779
This commit is contained in:
parent
bf1641e9b8
commit
81f368964f
|
@ -189,8 +189,9 @@ typedef struct _FCB
|
||||||
|
|
||||||
UNICODE_STRING ShortNameU;
|
UNICODE_STRING ShortNameU;
|
||||||
|
|
||||||
WCHAR *ObjectName; /* point on filename (250 chars max) in PathName */
|
WCHAR *ObjectName; /* point on filename (250 chars max) in PathName */
|
||||||
WCHAR PathName[MAX_PATH]; /* path+filename 260 max */
|
UNICODE_STRING PathName; /* path+filename 260 max */
|
||||||
|
WCHAR PathNameBuffer[MAX_PATH]; /* Buffer for PathName */
|
||||||
WCHAR ShortNameBuffer[13];
|
WCHAR ShortNameBuffer[13];
|
||||||
|
|
||||||
LIST_ENTRY FcbListEntry;
|
LIST_ENTRY FcbListEntry;
|
||||||
|
@ -198,8 +199,8 @@ typedef struct _FCB
|
||||||
|
|
||||||
ULONG DirIndex;
|
ULONG DirIndex;
|
||||||
|
|
||||||
LARGE_INTEGER IndexNumber; /* HighPart: Parent directory start sector */
|
LARGE_INTEGER IndexNumber; /* HighPart: Parent directory start sector */
|
||||||
/* LowPart: Directory record offset in the parent directory file */
|
/* LowPart: Directory record offset in the parent directory file */
|
||||||
|
|
||||||
LONG RefCount;
|
LONG RefCount;
|
||||||
ULONG Flags;
|
ULONG Flags;
|
||||||
|
|
|
@ -56,7 +56,7 @@ CdfsMakeAbsoluteFilename(PFILE_OBJECT FileObject,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* construct absolute path name */
|
/* construct absolute path name */
|
||||||
Length = (wcslen(Fcb->PathName) * sizeof(WCHAR)) +
|
Length = Fcb->PathName.Length +
|
||||||
sizeof(WCHAR) +
|
sizeof(WCHAR) +
|
||||||
RelativeFileName->Length +
|
RelativeFileName->Length +
|
||||||
sizeof(WCHAR);
|
sizeof(WCHAR);
|
||||||
|
@ -69,8 +69,8 @@ CdfsMakeAbsoluteFilename(PFILE_OBJECT FileObject,
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = RtlAppendUnicodeToString(AbsoluteFileName,
|
Status = RtlAppendUnicodeStringToString(AbsoluteFileName,
|
||||||
Fcb->PathName);
|
&Fcb->PathName);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
RtlFreeUnicodeString(AbsoluteFileName);
|
RtlFreeUnicodeString(AbsoluteFileName);
|
||||||
|
|
|
@ -216,17 +216,20 @@ CdfsFindFile(PDEVICE_EXTENSION DeviceExt,
|
||||||
/* it's root : complete essentials fields then return ok */
|
/* it's root : complete essentials fields then return ok */
|
||||||
RtlZeroMemory(Fcb, sizeof(FCB));
|
RtlZeroMemory(Fcb, sizeof(FCB));
|
||||||
|
|
||||||
Fcb->PathName[0] = '\\';
|
Fcb->PathNameBuffer[0] = '\\';
|
||||||
Fcb->ObjectName = &Fcb->PathName[1];
|
Fcb->ObjectName = &Fcb->PathNameBuffer[1];
|
||||||
Fcb->Entry.ExtentLocationL = DeviceExt->CdInfo.RootStart;
|
Fcb->Entry.ExtentLocationL = DeviceExt->CdInfo.RootStart;
|
||||||
Fcb->Entry.DataLengthL = DeviceExt->CdInfo.RootSize;
|
Fcb->Entry.DataLengthL = DeviceExt->CdInfo.RootSize;
|
||||||
Fcb->Entry.FileFlags = 0x02; //FILE_ATTRIBUTE_DIRECTORY;
|
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)
|
if (pDirIndex)
|
||||||
*pDirIndex = 0;
|
*pDirIndex = 0;
|
||||||
if (pOffset)
|
if (pOffset)
|
||||||
*pOffset = 0;
|
*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;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -303,12 +306,13 @@ CdfsFindFile(PDEVICE_EXTENSION DeviceExt,
|
||||||
if (FsRtlIsNameInExpression(&FileToFindUpcase, &LongName, TRUE, NULL) ||
|
if (FsRtlIsNameInExpression(&FileToFindUpcase, &LongName, TRUE, NULL) ||
|
||||||
FsRtlIsNameInExpression(&FileToFindUpcase, &ShortName, TRUE, NULL))
|
FsRtlIsNameInExpression(&FileToFindUpcase, &ShortName, TRUE, NULL))
|
||||||
{
|
{
|
||||||
if (Parent->PathName[0])
|
if (Parent->PathName.Buffer[0])
|
||||||
{
|
{
|
||||||
len = wcslen(Parent->PathName);
|
len = Parent->PathName.Length / sizeof(WCHAR);
|
||||||
memcpy(Fcb->PathName, Parent->PathName, len*sizeof(WCHAR));
|
memcpy(Fcb->PathName.Buffer, Parent->PathName.Buffer, Parent->PathName.Length);
|
||||||
Fcb->ObjectName=&Fcb->PathName[len];
|
Fcb->PathName.Length = Parent->PathName.Length;
|
||||||
if (len != 1 || Fcb->PathName[0] != '\\')
|
Fcb->ObjectName=&Fcb->PathName.Buffer[len];
|
||||||
|
if (len != 1 || Fcb->PathName.Buffer[0] != '\\')
|
||||||
{
|
{
|
||||||
Fcb->ObjectName[0] = '\\';
|
Fcb->ObjectName[0] = '\\';
|
||||||
Fcb->ObjectName = &Fcb->ObjectName[1];
|
Fcb->ObjectName = &Fcb->ObjectName[1];
|
||||||
|
@ -316,16 +320,16 @@ CdfsFindFile(PDEVICE_EXTENSION DeviceExt,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Fcb->ObjectName=Fcb->PathName;
|
Fcb->ObjectName=Fcb->PathName.Buffer;
|
||||||
Fcb->ObjectName[0]='\\';
|
Fcb->ObjectName[0]='\\';
|
||||||
Fcb->ObjectName=&Fcb->ObjectName[1];
|
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));
|
memcpy(&Fcb->Entry, Record, sizeof(DIR_RECORD));
|
||||||
wcsncpy(Fcb->ObjectName, name, min(wcslen(name) + 1,
|
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 */
|
/* Copy short name */
|
||||||
Fcb->ShortNameU.Length = ShortName.Length;
|
Fcb->ShortNameU.Length = ShortName.Length;
|
||||||
|
@ -338,8 +342,8 @@ CdfsFindFile(PDEVICE_EXTENSION DeviceExt,
|
||||||
if (pOffset)
|
if (pOffset)
|
||||||
*pOffset = Offset;
|
*pOffset = Offset;
|
||||||
|
|
||||||
DPRINT("FindFile: new Pathname %S, new Objectname %S, DirIndex %u\n",
|
DPRINT("FindFile: new Pathname %wZ, new Objectname %S, DirIndex %u\n",
|
||||||
Fcb->PathName, Fcb->ObjectName, DirIndex);
|
&Fcb->PathName, Fcb->ObjectName, DirIndex);
|
||||||
|
|
||||||
RtlFreeUnicodeString(&FileToFindUpcase);
|
RtlFreeUnicodeString(&FileToFindUpcase);
|
||||||
CcUnpinData(Context);
|
CcUnpinData(Context);
|
||||||
|
@ -572,6 +576,8 @@ CdfsQueryDirectory(PDEVICE_OBJECT DeviceObject,
|
||||||
DeviceExtension = DeviceObject->DeviceExtension;
|
DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
FileObject = Stack->FileObject;
|
FileObject = Stack->FileObject;
|
||||||
|
TempFcb.PathName.Buffer = TempFcb.PathNameBuffer;
|
||||||
|
TempFcb.PathName.MaximumLength = sizeof(TempFcb.PathNameBuffer);
|
||||||
|
|
||||||
Ccb = (PCCB)FileObject->FsContext2;
|
Ccb = (PCCB)FileObject->FsContext2;
|
||||||
Fcb = (PFCB)FileObject->FsContext;
|
Fcb = (PFCB)FileObject->FsContext;
|
||||||
|
@ -646,7 +652,7 @@ CdfsQueryDirectory(PDEVICE_OBJECT DeviceObject,
|
||||||
}
|
}
|
||||||
DPRINT("Buffer = %p tofind = %wZ\n", Buffer, &Ccb->DirectorySearchPattern);
|
DPRINT("Buffer = %p tofind = %wZ\n", Buffer, &Ccb->DirectorySearchPattern);
|
||||||
|
|
||||||
TempFcb.ObjectName = TempFcb.PathName;
|
TempFcb.ObjectName = TempFcb.PathName.Buffer;
|
||||||
while (Status == STATUS_SUCCESS && BufferLength > 0)
|
while (Status == STATUS_SUCCESS && BufferLength > 0)
|
||||||
{
|
{
|
||||||
Status = CdfsFindFile(DeviceExtension,
|
Status = CdfsFindFile(DeviceExtension,
|
||||||
|
@ -746,7 +752,6 @@ CdfsQueryDirectory(PDEVICE_OBJECT DeviceObject,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
CdfsDirectoryControl(PDEVICE_OBJECT DeviceObject,
|
CdfsDirectoryControl(PDEVICE_OBJECT DeviceObject,
|
||||||
PIRP Irp)
|
PIRP Irp)
|
||||||
|
|
|
@ -73,17 +73,19 @@ CdfsCreateFCB(PCWSTR FileName)
|
||||||
if(!Fcb) return NULL;
|
if(!Fcb) return NULL;
|
||||||
|
|
||||||
RtlZeroMemory(Fcb, sizeof(FCB));
|
RtlZeroMemory(Fcb, sizeof(FCB));
|
||||||
|
Fcb->PathName.Buffer = Fcb->PathNameBuffer;
|
||||||
|
Fcb->PathName.MaximumLength = sizeof(Fcb->PathNameBuffer);
|
||||||
|
|
||||||
if (FileName)
|
if (FileName)
|
||||||
{
|
{
|
||||||
CdfsWSubString(Fcb->PathName, FileName, sizeof(Fcb->PathName) / sizeof(Fcb->PathName[0]) - 1);
|
RtlAppendUnicodeToString(&Fcb->PathName, FileName);
|
||||||
if (wcsrchr(Fcb->PathName, '\\') != 0)
|
if (wcsrchr(Fcb->PathName.Buffer, '\\') != 0)
|
||||||
{
|
{
|
||||||
Fcb->ObjectName = wcsrchr(Fcb->PathName, '\\');
|
Fcb->ObjectName = wcsrchr(Fcb->PathName.Buffer, '\\');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Fcb->ObjectName = Fcb->PathName;
|
Fcb->ObjectName = Fcb->PathName.Buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +131,7 @@ CdfsFCBIsDirectory(PFCB Fcb)
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
CdfsFCBIsRoot(PFCB Fcb)
|
CdfsFCBIsRoot(PFCB Fcb)
|
||||||
{
|
{
|
||||||
return(wcscmp(Fcb->PathName, L"\\") == 0);
|
return (Fcb->PathName.Length = sizeof(WCHAR) && Fcb->PathName.Buffer[0] == L'\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,9 +158,9 @@ CdfsReleaseFCB(PDEVICE_EXTENSION Vcb,
|
||||||
{
|
{
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
|
|
||||||
DPRINT("releasing FCB at %p: %S, refCount:%d\n",
|
DPRINT("releasing FCB at %p: %wZ, refCount:%d\n",
|
||||||
Fcb,
|
Fcb,
|
||||||
Fcb->PathName,
|
&Fcb->PathName,
|
||||||
Fcb->RefCount);
|
Fcb->RefCount);
|
||||||
|
|
||||||
KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
|
KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
|
||||||
|
@ -209,8 +211,8 @@ CdfsGrabFCBFromTable(PDEVICE_EXTENSION Vcb,
|
||||||
{
|
{
|
||||||
Fcb = CONTAINING_RECORD(current_entry, FCB, FcbListEntry);
|
Fcb = CONTAINING_RECORD(current_entry, FCB, FcbListEntry);
|
||||||
|
|
||||||
DPRINT("Comparing '%wZ' and '%S'\n", FileName, Fcb->PathName);
|
DPRINT("Comparing '%wZ' and '%wZ'\n", FileName, &Fcb->PathName);
|
||||||
if (_wcsicmp(FileName->Buffer, Fcb->PathName) == 0)
|
if (RtlCompareUnicodeString(FileName, &Fcb->PathName, TRUE) == 0)
|
||||||
{
|
{
|
||||||
Fcb->RefCount++;
|
Fcb->RefCount++;
|
||||||
KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
|
KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
|
||||||
|
@ -365,12 +367,12 @@ CdfsMakeFCBFromDirEntry(PVCB Vcb,
|
||||||
|
|
||||||
/* Check if the full string would overflow the pathName buffer (the additional characters are for '\\' and '\0') */
|
/* Check if the full string would overflow the pathName buffer (the additional characters are for '\\' and '\0') */
|
||||||
if ((LongName[0] != 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);
|
return(STATUS_OBJECT_NAME_INVALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
wcscpy(pathName, DirectoryFCB->PathName);
|
wcscpy(pathName, DirectoryFCB->PathName.Buffer);
|
||||||
if (!CdfsFCBIsRoot(DirectoryFCB))
|
if (!CdfsFCBIsRoot(DirectoryFCB))
|
||||||
{
|
{
|
||||||
wcscat(pathName, L"\\");
|
wcscat(pathName, L"\\");
|
||||||
|
@ -488,7 +490,7 @@ CdfsDirFindFile(PDEVICE_EXTENSION DeviceExt,
|
||||||
DeviceExt,
|
DeviceExt,
|
||||||
DirectoryFcb,
|
DirectoryFcb,
|
||||||
FileToFind);
|
FileToFind);
|
||||||
DPRINT("Dir Path:%S\n", DirectoryFcb->PathName);
|
DPRINT("Dir Path:%wZ\n", &DirectoryFcb->PathName);
|
||||||
|
|
||||||
/* default to '.' if no filename specified */
|
/* default to '.' if no filename specified */
|
||||||
if (FileToFind->Length == 0)
|
if (FileToFind->Length == 0)
|
||||||
|
|
|
@ -164,7 +164,7 @@ CdfsGetNameInformation(PFILE_OBJECT FileObject,
|
||||||
return STATUS_BUFFER_OVERFLOW;
|
return STATUS_BUFFER_OVERFLOW;
|
||||||
|
|
||||||
/* Calculate file name length in bytes */
|
/* Calculate file name length in bytes */
|
||||||
NameLength = wcslen(Fcb->PathName) * sizeof(WCHAR);
|
NameLength = Fcb->PathName.Length;
|
||||||
NameInfo->FileNameLength = NameLength;
|
NameInfo->FileNameLength = NameLength;
|
||||||
|
|
||||||
/* Calculate amount of bytes to copy not to overflow the buffer */
|
/* Calculate amount of bytes to copy not to overflow the buffer */
|
||||||
|
@ -172,7 +172,7 @@ CdfsGetNameInformation(PFILE_OBJECT FileObject,
|
||||||
*BufferLength - FIELD_OFFSET(FILE_NAME_INFORMATION, FileName[0]));
|
*BufferLength - FIELD_OFFSET(FILE_NAME_INFORMATION, FileName[0]));
|
||||||
|
|
||||||
/* Fill in the bytes */
|
/* 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 */
|
/* Check if we could write more but are not able to */
|
||||||
if (*BufferLength < NameLength + FIELD_OFFSET(FILE_NAME_INFORMATION, FileName[0]))
|
if (*BufferLength < NameLength + FIELD_OFFSET(FILE_NAME_INFORMATION, FileName[0]))
|
||||||
|
@ -268,7 +268,7 @@ CdfsGetAllInformation(PFILE_OBJECT FileObject,
|
||||||
ASSERT(Info);
|
ASSERT(Info);
|
||||||
ASSERT(Fcb);
|
ASSERT(Fcb);
|
||||||
|
|
||||||
NameLength = wcslen(Fcb->PathName) * sizeof(WCHAR);
|
NameLength = Fcb->PathName.Length;
|
||||||
if (*BufferLength < sizeof(FILE_ALL_INFORMATION) + NameLength)
|
if (*BufferLength < sizeof(FILE_ALL_INFORMATION) + NameLength)
|
||||||
return(STATUS_BUFFER_OVERFLOW);
|
return(STATUS_BUFFER_OVERFLOW);
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ CdfsGetAllInformation(PFILE_OBJECT FileObject,
|
||||||
/* Name Information */
|
/* Name Information */
|
||||||
Info->NameInformation.FileNameLength = NameLength;
|
Info->NameInformation.FileNameLength = NameLength;
|
||||||
RtlCopyMemory(Info->NameInformation.FileName,
|
RtlCopyMemory(Info->NameInformation.FileName,
|
||||||
Fcb->PathName,
|
Fcb->PathName.Buffer,
|
||||||
NameLength + sizeof(WCHAR));
|
NameLength + sizeof(WCHAR));
|
||||||
|
|
||||||
*BufferLength -= (sizeof(FILE_ALL_INFORMATION) + NameLength + sizeof(WCHAR));
|
*BufferLength -= (sizeof(FILE_ALL_INFORMATION) + NameLength + sizeof(WCHAR));
|
||||||
|
|
|
@ -513,7 +513,7 @@ CdfsVerifyVolume(PDEVICE_OBJECT DeviceObject,
|
||||||
while (Entry != &DeviceExt->FcbListHead)
|
while (Entry != &DeviceExt->FcbListHead)
|
||||||
{
|
{
|
||||||
Fcb = (PFCB)CONTAINING_RECORD(Entry, FCB, FcbListEntry);
|
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;
|
Entry = Entry->Flink;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue