mirror of
https://github.com/reactos/reactos.git
synced 2025-01-01 03:54:02 +00:00
[NPFS]
Add an FCB that represents the file system (volume/device) and support absolute and relative open, cleanup and close. svn path=/trunk/; revision=49713
This commit is contained in:
parent
e69e3b27ee
commit
d828ba929b
3 changed files with 78 additions and 3 deletions
|
@ -105,6 +105,35 @@ NpfsSignalAndRemoveListeningServerInstance(PNPFS_FCB Fcb,
|
|||
}
|
||||
|
||||
|
||||
static VOID
|
||||
NpfsOpenFileSystem(PNPFS_FCB Fcb,
|
||||
PFILE_OBJECT FileObject,
|
||||
PIO_STATUS_BLOCK IoStatus)
|
||||
{
|
||||
PNPFS_CCB Ccb;
|
||||
|
||||
DPRINT("NpfsOpenFileSystem()\n");
|
||||
|
||||
Ccb = ExAllocatePool(NonPagedPool, sizeof(NPFS_CCB));
|
||||
if (Ccb == NULL)
|
||||
{
|
||||
IoStatus->Status = STATUS_NO_MEMORY;
|
||||
return;
|
||||
}
|
||||
|
||||
Ccb->Type = CCB_DEVICE;
|
||||
Ccb->Fcb = Fcb;
|
||||
|
||||
FileObject->FsContext = Fcb;
|
||||
FileObject->FsContext2 = Ccb;
|
||||
|
||||
IoStatus->Information = FILE_OPENED;
|
||||
IoStatus->Status = STATUS_SUCCESS;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static VOID
|
||||
NpfsOpenRootDirectory(PNPFS_FCB Fcb,
|
||||
PFILE_OBJECT FileObject,
|
||||
|
@ -174,6 +203,24 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
|
|||
}
|
||||
#endif
|
||||
|
||||
DPRINT("FileName->Length: %hu RelatedFileObject: %p\n", FileName->Length, RelatedFileObject);
|
||||
|
||||
/* Open the file system */
|
||||
if (FileName->Length == 0 &&
|
||||
(RelatedFileObject == NULL || ((PNPFS_CCB)RelatedFileObject->FsContext2)->Type == CCB_DEVICE))
|
||||
{
|
||||
DPRINT("Open the file system\n");
|
||||
|
||||
NpfsOpenFileSystem(Vcb->DeviceFcb,
|
||||
FileObject,
|
||||
&Irp->IoStatus);
|
||||
|
||||
Status = Irp->IoStatus.Status;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Open the root directory */
|
||||
if (FileName->Length == 2 && FileName->Buffer[0] == L'\\' && RelatedFileObject == NULL)
|
||||
{
|
||||
DPRINT("Open the root directory\n");
|
||||
|
@ -662,6 +709,15 @@ NpfsCleanup(PDEVICE_OBJECT DeviceObject,
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (Ccb->Type == CCB_DEVICE)
|
||||
{
|
||||
DPRINT("Cleanup the file system!\n");
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
Irp->IoStatus.Information = 0;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (Ccb->Type == CCB_DIRECTORY)
|
||||
{
|
||||
DPRINT("Cleanup the root directory!\n");
|
||||
|
@ -806,6 +862,20 @@ NpfsClose(PDEVICE_OBJECT DeviceObject,
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (Ccb->Type == CCB_DEVICE)
|
||||
{
|
||||
DPRINT("Closing the file system!\n");
|
||||
|
||||
ExFreePool(Ccb);
|
||||
FileObject->FsContext = NULL;
|
||||
FileObject->FsContext2 = NULL;
|
||||
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
Irp->IoStatus.Information = 0;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (Ccb->Type == CCB_DIRECTORY)
|
||||
{
|
||||
DPRINT("Closing the root directory!\n");
|
||||
|
|
|
@ -85,12 +85,16 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
|
|||
Vcb->DefaultQuota = 8 * PAGE_SIZE;
|
||||
Vcb->MaxQuota = 64 * PAGE_SIZE;
|
||||
|
||||
/* Create the device FCB */
|
||||
Fcb = ExAllocatePool(NonPagedPool, sizeof(NPFS_FCB));
|
||||
Fcb->Type = FCB_DEVICE;
|
||||
Fcb->Vcb = Vcb;
|
||||
Vcb->DeviceFcb = Fcb;
|
||||
|
||||
/* Create the root directory FCB */
|
||||
Fcb = ExAllocatePool(NonPagedPool, sizeof(NPFS_FCB));
|
||||
Fcb->Type = FCB_DIRECTORY;
|
||||
Fcb->Vcb = Vcb;
|
||||
|
||||
|
||||
|
||||
Vcb->RootFcb = Fcb;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
|
|
|
@ -28,6 +28,7 @@ typedef struct _NPFS_VCB
|
|||
ULONG MinQuota;
|
||||
ULONG DefaultQuota;
|
||||
ULONG MaxQuota;
|
||||
struct _NPFS_FCB *DeviceFcb;
|
||||
struct _NPFS_FCB *RootFcb;
|
||||
} NPFS_VCB, *PNPFS_VCB;
|
||||
|
||||
|
|
Loading…
Reference in a new issue