- Fixed a TODO.
authorPierre Schweitzer <pierre@reactos.org>
Sun, 25 Jan 2009 08:55:52 +0000 (08:55 +0000)
committerPierre Schweitzer <pierre@reactos.org>
Sun, 25 Jan 2009 08:55:52 +0000 (08:55 +0000)
- Added volume mount notification

svn path=/trunk/; revision=39077

reactos/drivers/filesystems/fastfat_new/fatstruc.h
reactos/drivers/filesystems/fastfat_new/fsctl.c

index a9b0f0c..a193762 100644 (file)
@@ -111,6 +111,8 @@ typedef struct _VCB
     FAT_METHODS Methods;
     /*  Root Directory Fcb: */
     struct _FCB *RootFcb;
+
+    ULONG MediaChangeCount;
 } VCB, *PVCB;
 
 #define VcbToVolumeDeviceObject(xVcb) \
index e3c4a04..adfc14d 100644 (file)
@@ -56,6 +56,7 @@ FatMountVolume(PFAT_IRP_CONTEXT IrpContext,
 {
     NTSTATUS Status;
     DISK_GEOMETRY DiskGeometry;
+    ULONG MediaChangeCount = 0;
     PVOLUME_DEVICE_OBJECT VolumeDevice;
 
     DPRINT1("FatMountVolume()\n");
@@ -63,7 +64,17 @@ FatMountVolume(PFAT_IRP_CONTEXT IrpContext,
     /* Make sure this IRP is waitable */
     ASSERT(IrpContext->Flags & IRPCONTEXT_CANWAIT);
 
-    /* TODO: IOCTL_DISK_CHECK_VERIFY */
+    /* Request media changes count, mostly usefull for removable devices */
+    Status = FatPerformDevIoCtrl(TargetDeviceObject,
+                                 IOCTL_STORAGE_CHECK_VERIFY,
+                                 NULL,
+                                 0,
+                                 &MediaChangeCount,
+                                 sizeof(ULONG),
+                                 TRUE);
+
+    if (!NT_SUCCESS(Status)) return Status;
+
     /* TODO: Check if data-track present in case of a CD drive */
     /* TODO: IOCTL_DISK_GET_PARTITION_INFO_EX */
 
@@ -113,6 +124,12 @@ FatMountVolume(PFAT_IRP_CONTEXT IrpContext,
     Status = FatInitializeVcb(&VolumeDevice->Vcb, TargetDeviceObject, Vpb);
     if (!NT_SUCCESS(Status)) goto FatMountVolumeCleanup;
 
+    /* Keep trace of media changes */
+    VolumeDevice->Vcb.MediaChangeCount = MediaChangeCount;
+
+    /* Notify about volume mount */
+    FsRtlNotifyVolumeEvent(VolumeDevice->Vcb.VolumeFileObject, FSRTL_VOLUME_MOUNT);
+
     /* Return success */
     return STATUS_SUCCESS;