NTSTATUS
NtfsOpenFile(PDEVICE_EXTENSION DeviceExt,
PFILE_OBJECT FileObject,
- PWSTR FileName)
+ PWSTR FileName,
+ PNTFS_FCB * FoundFCB)
{
PNTFS_FCB ParentFcb;
PNTFS_FCB Fcb;
NTSTATUS Status;
PWSTR AbsFileName = NULL;
- DPRINT("NtfsOpenFile(%p, %p, %S)\n", DeviceExt, FileObject, FileName);
+ DPRINT1("NtfsOpenFile(%p, %p, %S, %p)\n", DeviceExt, FileObject, FileName, FoundFCB);
+
+ *FoundFCB = NULL;
if (FileObject->RelatedFileObject)
{
if (AbsFileName)
ExFreePool(AbsFileName);
+ *FoundFCB = Fcb;
+
return Status;
}
PIO_STACK_LOCATION Stack;
PFILE_OBJECT FileObject;
ULONG RequestedDisposition;
-// ULONG RequestedOptions;
-// PFCB Fcb;
+ ULONG RequestedOptions;
+ PNTFS_FCB Fcb;
// PWSTR FileName;
NTSTATUS Status;
- DPRINT("NtfsCreateFile() called\n");
+ DPRINT1("NtfsCreateFile(%p, %p) called\n", DeviceObject, Irp);
DeviceExt = DeviceObject->DeviceExtension;
ASSERT(DeviceExt);
ASSERT(Stack);
RequestedDisposition = ((Stack->Parameters.Create.Options >> 24) & 0xff);
-// RequestedOptions =
-// Stack->Parameters.Create.Options & FILE_VALID_OPTION_FLAGS;
+ RequestedOptions = Stack->Parameters.Create.Options & FILE_VALID_OPTION_FLAGS;
// PagingFileCreate = (Stack->Flags & SL_OPEN_PAGING_FILE) ? TRUE : FALSE;
-// if ((RequestedOptions & FILE_DIRECTORY_FILE)
-// && RequestedDisposition == FILE_SUPERSEDE)
-// return STATUS_INVALID_PARAMETER;
+ if (RequestedOptions & FILE_DIRECTORY_FILE &&
+ RequestedDisposition == FILE_SUPERSEDE)
+ {
+ return STATUS_INVALID_PARAMETER;
+ }
FileObject = Stack->FileObject;
return STATUS_ACCESS_DENIED;
}
+ /* This a open operation for the volume itself */
+ if (FileObject->FileName.Length == 0 &&
+ (FileObject->RelatedFileObject == NULL || FileObject->RelatedFileObject->FsContext2 != NULL))
+ {
+ if (RequestedDisposition != FILE_OPEN &&
+ RequestedDisposition != FILE_OPEN_IF)
+ {
+ return STATUS_ACCESS_DENIED;
+ }
+
+ if (RequestedOptions & FILE_DIRECTORY_FILE)
+ {
+ return STATUS_NOT_A_DIRECTORY;
+ }
+
+ NtfsAttachFCBToFileObject(DeviceExt, DeviceExt->VolumeFcb, FileObject);
+ DeviceExt->VolumeFcb->RefCount++;
+
+ Irp->IoStatus.Information = FILE_OPENED;
+ return STATUS_SUCCESS;
+ }
+
Status = NtfsOpenFile(DeviceExt,
FileObject,
- FileObject->FileName.Buffer);
+ FileObject->FileName.Buffer,
+ &Fcb);
/*
* If the directory containing the file to open doesn't exist then