Commit in reactos/drivers/fs/vfat on MAIN
blockdev.c+1-11.29 -> 1.30
create.c+52-11.66 -> 1.67
fsctl.c+28-111.28 -> 1.29
rw.c+8-71.64 -> 1.65
+89-20
4 modified files
Added removable mediachange support.

reactos/drivers/fs/vfat
blockdev.c 1.29 -> 1.30
diff -u -r1.29 -r1.30
--- blockdev.c	31 Dec 2003 15:07:10 -0000	1.29
+++ blockdev.c	31 Mar 2004 03:30:36 -0000	1.30
@@ -161,7 +161,7 @@
 
   if (!NT_SUCCESS (Status))
     {
-      DPRINT1 ("IO failed!!! VfatWriteSectors : Error code: %x\n", Status);
+      DPRINT ("IO failed!!! VfatWriteSectors : Error code: %x\n", Status);
       return (Status);
     }
 

reactos/drivers/fs/vfat
create.c 1.66 -> 1.67
diff -u -r1.66 -r1.67
--- create.c	18 Jan 2004 22:31:23 -0000	1.66
+++ create.c	31 Mar 2004 03:30:36 -0000	1.67
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: create.c,v 1.66 2004/01/18 22:31:23 hbirr Exp $
+/* $Id: create.c,v 1.67 2004/03/31 03:30:36 jimtabor Exp $
  *
  * PROJECT:          ReactOS kernel
  * FILE:             drivers/fs/vfat/create.c
@@ -338,10 +338,14 @@
 {
   PVFATFCB ParentFcb;
   PVFATFCB Fcb;
+  DISK_GEOMETRY DiskGeometry;
   NTSTATUS Status;
   UNICODE_STRING NameU;
   WCHAR Name[MAX_PATH];
+  ULONG Size;
 
+//  PDEVICE_OBJECT DeviceObject = DeviceExt->StorageDevice->Vpb->DeviceObject;
+  
   DPRINT ("VfatOpenFile(%08lx, %08lx, '%wZ')\n", DeviceExt, FileObject, FileNameU);
 
   if (FileObject->RelatedFileObject)
@@ -366,6 +370,53 @@
 
   DPRINT ("PathName to open: '%wZ'\n", FileNameU);
 
+   Size = sizeof(DISK_GEOMETRY);
+   Status = VfatBlockDeviceIoControl(DeviceExt->StorageDevice,
+				     IOCTL_DISK_GET_DRIVE_GEOMETRY,
+				     NULL,
+				     0,
+				     &DiskGeometry,
+				     &Size,
+				     FALSE);
+
+  if (DiskGeometry.MediaType != FixedMedia )
+     {
+
+  	Status = VfatBlockDeviceIoControl (DeviceExt->StorageDevice,
+					IOCTL_DISK_CHECK_VERIFY,
+					NULL,
+					0,
+					NULL,
+					0,
+					TRUE);
+
+      if (Status == STATUS_VERIFY_REQUIRED)
+    	    {
+      PDEVICE_OBJECT DeviceToVerify;
+
+      DPRINT ("Media change detected!\n");
+      DPRINT ("Device %p\n", DeviceObject);
+
+      DeviceToVerify = IoGetDeviceToVerify (PsGetCurrentThread ());
+      IoSetDeviceToVerify (PsGetCurrentThread (),
+			   NULL);
+
+      Status = IoVerifyVolume (DeviceToVerify,
+			       FALSE);
+      if (!NT_SUCCESS(Status))
+	{
+	  DPRINT ("Status %lx\n", Status);
+	  return Status;
+	}
+    }
+  else if (!NT_SUCCESS(Status))
+    {
+      DPRINT ("Status %lx\n", Status);
+      return Status;
+    }
+    }
+
+
   /*  try first to find an existing FCB in memory  */
   DPRINT ("Checking for existing FCB in memory\n");
   Fcb = vfatGrabFCBFromTable (DeviceExt, FileNameU);

reactos/drivers/fs/vfat
fsctl.c 1.28 -> 1.29
diff -u -r1.28 -r1.29
--- fsctl.c	16 Mar 2004 08:30:28 -0000	1.28
+++ fsctl.c	31 Mar 2004 03:30:36 -0000	1.29
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: fsctl.c,v 1.28 2004/03/16 08:30:28 arty Exp $
+/* $Id: fsctl.c,v 1.29 2004/03/31 03:30:36 jimtabor Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -66,12 +66,15 @@
 				     &DiskGeometry,
 				     &Size,
 				     FALSE);
+  DPRINT("VfatHasFileSystem start\n");
+  
+
    if (!NT_SUCCESS(Status))
    {
       DPRINT("VfatBlockDeviceIoControl faild (%x)\n", Status);
       return Status;
    }
-   if (DiskGeometry.MediaType == FixedMedia)
+   if (DiskGeometry.MediaType == FixedMedia || RemovableMedia)
    {
       // We have found a hard disk
       Size = sizeof(PARTITION_INFORMATION);
@@ -87,7 +90,7 @@
          DPRINT("VfatBlockDeviceIoControl faild (%x)\n", Status);
          return Status;
       }
-#ifndef NDEBUG
+/*#ifndef NDEBUG*/
       DbgPrint("Partition Information:\n");
       DbgPrint("StartingOffset      %u\n", PartitionInfo.StartingOffset.QuadPart  / 512);
       DbgPrint("PartitionLength     %u\n", PartitionInfo.PartitionLength.QuadPart / 512);
@@ -97,7 +100,7 @@
       DbgPrint("BootIndicator       %u\n", PartitionInfo.BootIndicator);
       DbgPrint("RecognizedPartition %u\n", PartitionInfo.RecognizedPartition);
       DbgPrint("RewritePartition    %u\n", PartitionInfo.RewritePartition);
-#endif
+/*#endif*/
       if (PartitionInfo.PartitionType == PARTITION_FAT_12       ||
           PartitionInfo.PartitionType == PARTITION_FAT_16       ||
           PartitionInfo.PartitionType == PARTITION_HUGE         ||
@@ -108,7 +111,7 @@
          *RecognizedFS = TRUE;
       }
    }
-   else if (DiskGeometry.MediaType > Unknown && DiskGeometry.MediaType <= RemovableMedia)
+   else if (DiskGeometry.MediaType > Unknown && DiskGeometry.MediaType <= RemovableMedia )
    {
       *RecognizedFS = TRUE;
    }
@@ -120,13 +123,19 @@
    Boot = ExAllocatePool(NonPagedPool, DiskGeometry.BytesPerSector);
    if (Boot == NULL)
    {
+  DPRINT("VfatHasFileSystem 1\n");
+
       *RecognizedFS=FALSE;
       return STATUS_INSUFFICIENT_RESOURCES;
    }
+
    Offset.QuadPart = 0;
+
    Status = VfatReadDisk(DeviceToMount, &Offset, DiskGeometry.BytesPerSector, (PUCHAR) Boot, FALSE);
    if (NT_SUCCESS(Status))
    {
+      DPRINT("VfatHasFileSystem 2\n");
+
       if (Boot->BytesPerSector != 0)
       {
          FatInfo.VolumeID = Boot->VolumeID;
@@ -167,9 +176,13 @@
       }
       else
       {
+        DPRINT("VfatHasFileSystem 3\n");
+
       	Status = STATUS_INSUFFICIENT_RESOURCES;
       }
    }
+     DPRINT("VfatHasFileSystem end\n");
+
    ExFreePool(Boot);
    return Status;
 }
@@ -191,6 +204,7 @@
    {
       return(Status);
    }
+   DPRINT("MountVfatdev %d, PAGE_SIZE = %d\n", DeviceExt->FatInfo.BytesPerCluster, PAGE_SIZE);
 
    if (DeviceExt->FatInfo.BytesPerCluster >= PAGE_SIZE &&
       (DeviceExt->FatInfo.BytesPerCluster % PAGE_SIZE) != 0)
@@ -398,7 +412,8 @@
  */
 {
   PDEVICE_OBJECT DeviceToVerify;
-  NTSTATUS Status;
+  NTSTATUS Status = STATUS_SUCCESS;
+
 
   DPRINT("VfatVerify(IrpContext %x)\n", IrpContext);
 
@@ -412,16 +427,17 @@
 				    FALSE);
   if (!NT_SUCCESS(Status))
     {
-      DPRINT1("VfatBlockDeviceIoControl() failed (Status %lx)\n", Status);
+      DPRINT("VfatBlockDeviceIoControl() failed (Status %lx)\n", Status);
 
       /* FIXME: Compare volume label */
 
-      DPRINT1("  returning STATUS_WRONG_VOLUME\n");
+      DPRINT("  returning STATUS_WRONG_VOLUME\n");
 
-      return STATUS_WRONG_VOLUME;
+      Status = STATUS_WRONG_VOLUME;
     }
-
-  return STATUS_SUCCESS;
+  DeviceToVerify->Flags &= ~DO_VERIFY_VOLUME;
+    
+  return Status;
 }
 
 
@@ -598,6 +614,7 @@
 	 break;
 
       case IRP_MN_VERIFY_VOLUME:
+	DPRINT("VFATFS: IRP_MN_VERIFY_VOLUME\n");
 	 Status = VfatVerify(IrpContext);
 	 break;
 

reactos/drivers/fs/vfat
rw.c 1.64 -> 1.65
diff -u -r1.64 -r1.65
--- rw.c	28 Jan 2004 20:53:46 -0000	1.64
+++ rw.c	31 Mar 2004 03:30:36 -0000	1.65
@@ -1,5 +1,5 @@
 
-/* $Id: rw.c,v 1.64 2004/01/28 20:53:46 ekohl Exp $
+/* $Id: rw.c,v 1.65 2004/03/31 03:30:36 jimtabor Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -460,7 +460,7 @@
    PERESOURCE Resource = NULL;
    LARGE_INTEGER ByteOffset;
    PVOID Buffer;
-   /*PDEVICE_OBJECT DeviceToVerify;*/
+   PDEVICE_OBJECT DeviceToVerify;
    ULONG BytesPerSector;
 
    assert(IrpContext);
@@ -629,21 +629,22 @@
       }
 
       Status = VfatReadFileData(IrpContext, Buffer, Length, ByteOffset, &ReturnedLength);
-/*
+/**/
       if (Status == STATUS_VERIFY_REQUIRED)
       {
          DPRINT("VfatReadFile returned STATUS_VERIFY_REQUIRED\n");
-         DeviceToVerify = IoGetDeviceToVerify(KeGetCurrentThread());
-         IoSetDeviceToVerify(KeGetCurrentThread(), NULL);
+         DeviceToVerify = IoGetDeviceToVerify((struct _ETHREAD*)KeGetCurrentThread());
+         IoSetDeviceToVerify((struct _ETHREAD*)KeGetCurrentThread(), NULL);
          Status = IoVerifyVolume (DeviceToVerify, FALSE);
 
          if (NT_SUCCESS(Status))
          {
             Status = VfatReadFileData(IrpContext, Buffer, Length,
-                                      ByteOffset.u.LowPart, &ReturnedLength);
+                                      ByteOffset, &ReturnedLength);
          }
+
       }
-*/
+/**/
       if (NT_SUCCESS(Status))
       {
          IrpContext->Irp->IoStatus.Information = ReturnedLength;
CVSspam 0.2.8