ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

shutdown.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:        See COPYING in the top level directory
00003  * PROJECT:          ReactOS kernel
00004  * FILE:             drivers/fs/vfat/shutdown.c
00005  * PURPOSE:          VFAT Filesystem
00006  * PROGRAMMER:       Eric Kohl
00007  */
00008 
00009 /* INCLUDES *****************************************************************/
00010 
00011 #define NDEBUG
00012 #include "vfat.h"
00013 
00014 /* FUNCTIONS ****************************************************************/
00015 
00016 static NTSTATUS
00017 VfatDiskShutDown(PVCB Vcb)
00018 {
00019    PIRP Irp;
00020    KEVENT Event;
00021    NTSTATUS Status;
00022    IO_STATUS_BLOCK IoStatus;
00023 
00024    KeInitializeEvent(&Event, NotificationEvent, FALSE);
00025    Irp = IoBuildSynchronousFsdRequest(IRP_MJ_SHUTDOWN, Vcb->StorageDevice,
00026                                       NULL, 0, NULL, &Event, &IoStatus);
00027    if (Irp)
00028    {
00029       Status = IoCallDriver(Vcb->StorageDevice, Irp);
00030       if (Status == STATUS_PENDING)
00031       {
00032          KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
00033          Status = IoStatus.Status;
00034       }
00035    }
00036    else
00037    {
00038       Status = IoStatus.Status;
00039    }
00040 
00041    return Status;
00042 }
00043 
00044 NTSTATUS NTAPI
00045 VfatShutdown(PDEVICE_OBJECT DeviceObject, PIRP Irp)
00046 {
00047    NTSTATUS Status;
00048    PLIST_ENTRY ListEntry;
00049    PDEVICE_EXTENSION DeviceExt;
00050    ULONG eocMark;
00051 
00052    DPRINT("VfatShutdown(DeviceObject %p, Irp %p)\n",DeviceObject, Irp);
00053 
00054    FsRtlEnterFileSystem();
00055 
00056    /* FIXME: block new mount requests */
00057 
00058    if (DeviceObject == VfatGlobalData->DeviceObject)
00059    {
00060       Irp->IoStatus.Status = STATUS_SUCCESS;
00061       ExAcquireResourceExclusiveLite(&VfatGlobalData->VolumeListLock, TRUE);
00062       ListEntry = VfatGlobalData->VolumeListHead.Flink;
00063       while (ListEntry != &VfatGlobalData->VolumeListHead)
00064       {
00065          DeviceExt = CONTAINING_RECORD(ListEntry, VCB, VolumeListEntry);
00066          ListEntry = ListEntry->Flink;
00067 
00068      ExAcquireResourceExclusiveLite(&DeviceExt->DirResource, TRUE);
00069          if (DeviceExt->VolumeFcb->Flags & VCB_CLEAR_DIRTY)
00070          {
00071             /* set clean shutdown bit */
00072             Status = GetNextCluster(DeviceExt, 1, &eocMark);
00073             if (NT_SUCCESS(Status))
00074             {
00075                eocMark |= DeviceExt->CleanShutBitMask;
00076                if (NT_SUCCESS(WriteCluster(DeviceExt, 1, eocMark)))
00077                   DeviceExt->VolumeFcb->Flags &= ~VCB_IS_DIRTY;
00078             }
00079          }
00080          Status = VfatFlushVolume(DeviceExt, DeviceExt->VolumeFcb);
00081          if (NT_SUCCESS(Status))
00082          {
00083             Status = VfatDiskShutDown(DeviceExt);
00084             if (!NT_SUCCESS(Status))
00085            DPRINT1("VfatDiskShutDown failed, status = %x\n", Status);
00086          }
00087          else
00088          {
00089         DPRINT1("VfatFlushVolume failed, status = %x\n", Status);
00090      }
00091          ExReleaseResourceLite(&DeviceExt->DirResource);
00092 
00093          /* FIXME: Unmount the logical volume */
00094 
00095          if (!NT_SUCCESS(Status))
00096             Irp->IoStatus.Status = Status;
00097       }
00098       ExReleaseResourceLite(&VfatGlobalData->VolumeListLock);
00099 
00100       /* FIXME: Free all global acquired resources */
00101 
00102       Status = Irp->IoStatus.Status;
00103    }
00104    else
00105    {
00106       Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
00107       Status = STATUS_INVALID_DEVICE_REQUEST;
00108    }
00109 
00110    Irp->IoStatus.Information = 0;
00111    IoCompleteRequest(Irp, IO_NO_INCREMENT);
00112 
00113    FsRtlExitFileSystem();
00114 
00115    return(Status);
00116 }
00117 
00118 /* EOF */

Generated on Fri May 25 2012 04:15:49 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.