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

ntfs.c
Go to the documentation of this file.
00001 /*
00002  *  ReactOS kernel
00003  *  Copyright (C) 2002 ReactOS Team
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
00018  *
00019  * COPYRIGHT:        See COPYING in the top level directory
00020  * PROJECT:          ReactOS kernel
00021  * FILE:             drivers/filesystem/ntfs/ntfs.c
00022  * PURPOSE:          NTFS filesystem driver
00023  * PROGRAMMER:       Eric Kohl
00024  *                   Pierre Schweitzer 
00025  */
00026 
00027 /* INCLUDES *****************************************************************/
00028 
00029 #include "ntfs.h"
00030 
00031 #define NDEBUG
00032 #include <debug.h>
00033 
00034 /* GLOBALS *****************************************************************/
00035 
00036 PNTFS_GLOBAL_DATA NtfsGlobalData = NULL;
00037 
00038 
00039 /* FUNCTIONS ****************************************************************/
00040 
00041 NTSTATUS NTAPI
00042 DriverEntry(PDRIVER_OBJECT DriverObject,
00043             PUNICODE_STRING RegistryPath)
00044 /*
00045  * FUNCTION: Called by the system to initalize the driver
00046  * ARGUMENTS:
00047  *           DriverObject = object describing this driver
00048  *           RegistryPath = path to our configuration entries
00049  * RETURNS: Success or failure
00050  */
00051 {
00052   NTSTATUS Status;
00053   UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(DEVICE_NAME);
00054 
00055   TRACE_(NTFS, "DriverEntry(%p, '%wZ')\n", DriverObject, RegistryPath);
00056 
00057   /* Initialize global data */
00058   NtfsGlobalData = ExAllocatePoolWithTag(NonPagedPool, sizeof(NTFS_GLOBAL_DATA), 'GRDN');
00059   if (!NtfsGlobalData)
00060   {
00061     Status = STATUS_INSUFFICIENT_RESOURCES;
00062     goto ErrorEnd;
00063   }
00064   RtlZeroMemory(NtfsGlobalData, sizeof(NTFS_GLOBAL_DATA));
00065   NtfsGlobalData->Identifier.Type = NTFS_TYPE_GLOBAL_DATA;
00066   NtfsGlobalData->Identifier.Size = sizeof(NTFS_GLOBAL_DATA);
00067   
00068   ExInitializeResourceLite(&NtfsGlobalData->Resource);
00069 
00070   /* Keep trace of Driver Object */
00071   NtfsGlobalData->DriverObject = DriverObject;
00072 
00073   /* Initialize IRP functions array */
00074   NtfsInitializeFunctionPointers(DriverObject);
00075   
00076   /* Initialize CC functions array */
00077   NtfsGlobalData->CacheMgrCallbacks.AcquireForLazyWrite = NtfsAcqLazyWrite; 
00078   NtfsGlobalData->CacheMgrCallbacks.ReleaseFromLazyWrite = NtfsRelLazyWrite; 
00079   NtfsGlobalData->CacheMgrCallbacks.AcquireForReadAhead = NtfsAcqReadAhead; 
00080   NtfsGlobalData->CacheMgrCallbacks.ReleaseFromReadAhead = NtfsRelReadAhead; 
00081 
00082   /* Driver can't be unloaded */
00083   DriverObject->DriverUnload = NULL;
00084 
00085   Status = IoCreateDevice(DriverObject,
00086                           sizeof(NTFS_GLOBAL_DATA),
00087                           &DeviceName,
00088                           FILE_DEVICE_DISK_FILE_SYSTEM,
00089                           0,
00090                           FALSE,
00091                           &NtfsGlobalData->DeviceObject);
00092   if (!NT_SUCCESS(Status))
00093   {
00094     WARN_(NTFS, "IoCreateDevice failed with status: %lx\n", Status);
00095     goto ErrorEnd;
00096   }
00097   
00098   NtfsGlobalData->DeviceObject->Flags |= DO_DIRECT_IO;
00099 
00100   /* Register file system */
00101   IoRegisterFileSystem(NtfsGlobalData->DeviceObject);
00102   ObReferenceObject(NtfsGlobalData->DeviceObject);
00103 
00104 ErrorEnd:
00105   if (!NT_SUCCESS(Status))
00106   {
00107     if (NtfsGlobalData)
00108     {
00109       ExDeleteResourceLite(&NtfsGlobalData->Resource);
00110       ExFreePoolWithTag(NtfsGlobalData, 'GRDN');
00111     }
00112   }
00113 
00114   return Status;
00115 }
00116 
00117 VOID NTAPI 
00118 NtfsInitializeFunctionPointers(PDRIVER_OBJECT DriverObject)
00119 /*
00120  * FUNCTION: Called within the driver entry to initialize the IRP functions array 
00121  * ARGUMENTS:
00122  *           DriverObject = object describing this driver
00123  * RETURNS: Nothing
00124  */
00125 {
00126   DriverObject->MajorFunction[IRP_MJ_CREATE]                   = NtfsFsdCreate;
00127   DriverObject->MajorFunction[IRP_MJ_CLOSE]                    = NtfsFsdClose;
00128   DriverObject->MajorFunction[IRP_MJ_READ]                     = NtfsFsdRead;
00129   DriverObject->MajorFunction[IRP_MJ_WRITE]                    = NtfsFsdWrite;
00130   DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION]        = NtfsFsdQueryInformation;
00131   DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] = NtfsFsdDispatch;
00132   DriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION]   = NtfsFsdDispatch;
00133   DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL]        = NtfsFsdDirectoryControl;
00134   DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL]      = NtfsFsdFileSystemControl;
00135     
00136   return;
00137 }
00138 

Generated on Thu May 24 2012 04:19:15 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.