DPRINT("'%wZ'\n", &FileObject->RelatedFileObject->FileName);
*ParentFcb = FileObject->RelatedFileObject->FsContext;
- vfatGrabFCB(DeviceExt, *ParentFcb);
}
else
{
PVFATFCB pFcb = NULL;
PVFATFCB ParentFcb = NULL;
PWCHAR c, last;
- BOOLEAN PagingFileCreate = FALSE;
+ BOOLEAN PagingFileCreate;
BOOLEAN Dots;
- BOOLEAN OpenTargetDir = FALSE;
+ BOOLEAN OpenTargetDir;
UNICODE_STRING FileNameU;
UNICODE_STRING PathNameU;
ULONG Attributes;
return STATUS_INVALID_PARAMETER;
}
+ /* Deny create if the volume is locked */
+ if (DeviceExt->Flags & VCB_VOLUME_LOCKED)
+ {
+ return STATUS_ACCESS_DENIED;
+ }
+
/* This a open operation for the volume itself */
if (FileObject->FileName.Length == 0 &&
(FileObject->RelatedFileObject == NULL || FileObject->RelatedFileObject->FsContext2 != NULL))
{
+ DPRINT("Volume opening\n");
+
if (RequestedDisposition != FILE_OPEN &&
RequestedDisposition != FILE_OPEN_IF)
{
}
pFcb = DeviceExt->VolumeFcb;
+
+ if (pFcb->OpenHandleCount == 0)
+ {
+ IoSetShareAccess(Stack->Parameters.Create.SecurityContext->DesiredAccess,
+ Stack->Parameters.Create.ShareAccess,
+ FileObject,
+ &pFcb->FCBShareAccess);
+ }
+ else
+ {
+ Status = IoCheckShareAccess(Stack->Parameters.Create.SecurityContext->DesiredAccess,
+ Stack->Parameters.Create.ShareAccess,
+ FileObject,
+ &pFcb->FCBShareAccess,
+ FALSE);
+ if (!NT_SUCCESS(Status))
+ {
+ return Status;
+ }
+ }
+
vfatAttachFCBToFileObject(DeviceExt, pFcb, FileObject);
- vfatGrabFCB(DeviceExt, pFcb);
+ DeviceExt->OpenHandleCount++;
Irp->IoStatus.Information = FILE_OPENED;
return STATUS_SUCCESS;
LONG idx, FileNameLen;
ParentFcb = (FileObject->RelatedFileObject != NULL) ? FileObject->RelatedFileObject->FsContext : NULL;
+ if (ParentFcb)
+ {
+ vfatGrabFCB(DeviceExt, ParentFcb);
+ }
Status = vfatGetFCBForFile(DeviceExt, &ParentFcb, &TargetFcb, &PathNameU);
- if (Status == STATUS_SUCCESS)
+ if (NT_SUCCESS(Status))
{
- vfatGrabFCB(DeviceExt, ParentFcb);
vfatReleaseFCB(DeviceExt, TargetFcb);
Irp->IoStatus.Information = FILE_EXISTS;
}
idx = FileObject->FileName.Length / sizeof(WCHAR) - 1;
- /* Skip tailing \ - if any */
+ /* Skip trailing \ - if any */
if (PathNameU.Buffer[idx] == L'\\')
{
--idx;
if (NT_SUCCESS(Status))
{
pFcb = FileObject->FsContext;
+ ASSERT(pFcb == ParentFcb);
if (pFcb->OpenHandleCount == 0)
{
}
pFcb->OpenHandleCount++;
+ DeviceExt->OpenHandleCount++;
}
else if (ParentFcb != NULL)
{
}
pFcb->OpenHandleCount++;
+ DeviceExt->OpenHandleCount++;
/* FIXME : test write access if requested */