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

volinfo.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/volume.c
00022  * PURPOSE:          NTFS filesystem driver
00023  * PROGRAMMER:       Eric Kohl
00024  */
00025 
00026 /* INCLUDES *****************************************************************/
00027 
00028 #include "ntfs.h"
00029 
00030 #define NDEBUG
00031 #include <debug.h>
00032 
00033 /* FUNCTIONS ****************************************************************/
00034 
00035 static NTSTATUS
00036 NtfsGetFsVolumeInformation(PDEVICE_OBJECT DeviceObject,
00037                            PFILE_FS_VOLUME_INFORMATION FsVolumeInfo,
00038                            PULONG BufferLength)
00039 {
00040   DPRINT("NtfsGetFsVolumeInformation() called\n");
00041   DPRINT("FsVolumeInfo = %p\n", FsVolumeInfo);
00042   DPRINT("BufferLength %lu\n", *BufferLength);
00043 
00044   DPRINT("Vpb %p\n", DeviceObject->Vpb);
00045 
00046   DPRINT("Required length %lu\n",
00047          sizeof(FILE_FS_VOLUME_INFORMATION) + DeviceObject->Vpb->VolumeLabelLength);
00048   DPRINT("LabelLength %hu\n",
00049          DeviceObject->Vpb->VolumeLabelLength);
00050   DPRINT("Label %*.S\n",
00051          DeviceObject->Vpb->VolumeLabelLength / sizeof(WCHAR),
00052          DeviceObject->Vpb->VolumeLabel);
00053 
00054   if (*BufferLength < sizeof(FILE_FS_VOLUME_INFORMATION))
00055     return STATUS_INFO_LENGTH_MISMATCH;
00056 
00057   if (*BufferLength < (sizeof(FILE_FS_VOLUME_INFORMATION) + DeviceObject->Vpb->VolumeLabelLength))
00058     return STATUS_BUFFER_OVERFLOW;
00059 
00060   /* valid entries */
00061   FsVolumeInfo->VolumeSerialNumber = DeviceObject->Vpb->SerialNumber;
00062   FsVolumeInfo->VolumeLabelLength = DeviceObject->Vpb->VolumeLabelLength;
00063   memcpy(FsVolumeInfo->VolumeLabel,
00064          DeviceObject->Vpb->VolumeLabel,
00065          DeviceObject->Vpb->VolumeLabelLength);
00066 
00067   /* dummy entries */
00068   FsVolumeInfo->VolumeCreationTime.QuadPart = 0;
00069   FsVolumeInfo->SupportsObjects = FALSE;
00070 
00071   *BufferLength -= (sizeof(FILE_FS_VOLUME_INFORMATION) + DeviceObject->Vpb->VolumeLabelLength);
00072 
00073   DPRINT("BufferLength %lu\n", *BufferLength);
00074   DPRINT("NtfsGetFsVolumeInformation() done\n");
00075 
00076   return STATUS_SUCCESS;
00077 }
00078 
00079 
00080 static NTSTATUS
00081 NtfsGetFsAttributeInformation(PDEVICE_EXTENSION DeviceExt,
00082                               PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo,
00083                               PULONG BufferLength)
00084 {
00085   DPRINT("NtfsGetFsAttributeInformation()\n");
00086   DPRINT("FsAttributeInfo = %p\n", FsAttributeInfo);
00087   DPRINT("BufferLength %lu\n", *BufferLength);
00088   DPRINT("Required length %lu\n", (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8));
00089 
00090   if (*BufferLength < sizeof (FILE_FS_ATTRIBUTE_INFORMATION))
00091     return(STATUS_INFO_LENGTH_MISMATCH);
00092 
00093   if (*BufferLength < (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8))
00094     return(STATUS_BUFFER_OVERFLOW);
00095 
00096   FsAttributeInfo->FileSystemAttributes =
00097     FILE_CASE_PRESERVED_NAMES | FILE_UNICODE_ON_DISK;
00098   FsAttributeInfo->MaximumComponentNameLength = 255;
00099   FsAttributeInfo->FileSystemNameLength = 8;
00100 
00101   memcpy(FsAttributeInfo->FileSystemName, L"NTFS", 8);
00102 
00103   DPRINT("Finished NtfsGetFsAttributeInformation()\n");
00104 
00105   *BufferLength -= (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8);
00106   DPRINT("BufferLength %lu\n", *BufferLength);
00107 
00108   return(STATUS_SUCCESS);
00109 }
00110 
00111 
00112 static NTSTATUS
00113 NtfsGetFsSizeInformation(PDEVICE_OBJECT DeviceObject,
00114                          PFILE_FS_SIZE_INFORMATION FsSizeInfo,
00115                          PULONG BufferLength)
00116 {
00117   PDEVICE_EXTENSION DeviceExt;
00118   NTSTATUS Status = STATUS_SUCCESS;
00119 
00120   DPRINT("NtfsGetFsSizeInformation()\n");
00121   DPRINT("FsSizeInfo = %p\n", FsSizeInfo);
00122 
00123   if (*BufferLength < sizeof(FILE_FS_SIZE_INFORMATION))
00124     return(STATUS_BUFFER_OVERFLOW);
00125 
00126   DeviceExt = DeviceObject->DeviceExtension;
00127 
00128   FsSizeInfo->AvailableAllocationUnits.QuadPart = 0;
00129   FsSizeInfo->TotalAllocationUnits.QuadPart = DeviceExt->NtfsInfo.SectorCount; /* ?? */
00130   FsSizeInfo->SectorsPerAllocationUnit = DeviceExt->NtfsInfo.SectorsPerCluster;
00131   FsSizeInfo->BytesPerSector = DeviceExt->NtfsInfo.BytesPerSector;
00132 
00133   DPRINT("Finished NtfsGetFsSizeInformation()\n");
00134   if (NT_SUCCESS(Status))
00135     *BufferLength -= sizeof(FILE_FS_SIZE_INFORMATION);
00136 
00137   return(Status);
00138 }
00139 
00140 
00141 static NTSTATUS
00142 NtfsGetFsDeviceInformation(PFILE_FS_DEVICE_INFORMATION FsDeviceInfo,
00143                            PULONG BufferLength)
00144 {
00145   DPRINT("NtfsGetFsDeviceInformation()\n");
00146   DPRINT("FsDeviceInfo = %p\n", FsDeviceInfo);
00147   DPRINT("BufferLength %lu\n", *BufferLength);
00148   DPRINT("Required length %lu\n", sizeof(FILE_FS_DEVICE_INFORMATION));
00149 
00150   if (*BufferLength < sizeof(FILE_FS_DEVICE_INFORMATION))
00151     return(STATUS_BUFFER_OVERFLOW);
00152 
00153   FsDeviceInfo->DeviceType = FILE_DEVICE_DISK;
00154   FsDeviceInfo->Characteristics = 0; /* FIXME: fix this !! */
00155 
00156   DPRINT("NtfsGetFsDeviceInformation() finished.\n");
00157 
00158   *BufferLength -= sizeof(FILE_FS_DEVICE_INFORMATION);
00159   DPRINT("BufferLength %lu\n", *BufferLength);
00160 
00161   return(STATUS_SUCCESS);
00162 }
00163 
00164 
00165 
00166 NTSTATUS
00167 NtfsQueryVolumeInformation(PNTFS_IRP_CONTEXT IrpContext)
00168 {
00169   PIRP Irp;
00170   PDEVICE_OBJECT DeviceObject;
00171   FS_INFORMATION_CLASS FsInformationClass;
00172   PIO_STACK_LOCATION Stack;
00173   NTSTATUS Status = STATUS_SUCCESS;
00174   PVOID SystemBuffer;
00175   ULONG BufferLength;
00176 
00177   DPRINT("NtfsQueryVolumeInformation() called\n");
00178 
00179   ASSERT(IrpContext);
00180 
00181   Irp = IrpContext->Irp;
00182   DeviceObject = IrpContext->DeviceObject;
00183   Stack = IoGetCurrentIrpStackLocation(Irp);
00184   FsInformationClass = Stack->Parameters.QueryVolume.FsInformationClass;
00185   BufferLength = Stack->Parameters.QueryVolume.Length;
00186   SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
00187   RtlZeroMemory(SystemBuffer, BufferLength);
00188 
00189   DPRINT("FsInformationClass %d\n", FsInformationClass);
00190   DPRINT("SystemBuffer %p\n", SystemBuffer);
00191 
00192   switch (FsInformationClass)
00193   {
00194     case FileFsVolumeInformation:
00195       Status = NtfsGetFsVolumeInformation(DeviceObject,
00196                                           SystemBuffer,
00197                                           &BufferLength);
00198       break;
00199 
00200     case FileFsAttributeInformation:
00201       Status = NtfsGetFsAttributeInformation(DeviceObject->DeviceExtension,
00202                                              SystemBuffer,
00203                                              &BufferLength);
00204       break;
00205 
00206     case FileFsSizeInformation:
00207       Status = NtfsGetFsSizeInformation(DeviceObject,
00208                                         SystemBuffer,
00209                                         &BufferLength);
00210       break;
00211 
00212     case FileFsDeviceInformation:
00213       Status = NtfsGetFsDeviceInformation(SystemBuffer,
00214                                           &BufferLength);
00215       break;
00216 
00217     default:
00218       Status = STATUS_NOT_SUPPORTED;
00219   }
00220 
00221   if (NT_SUCCESS(Status))
00222     Irp->IoStatus.Information =
00223       Stack->Parameters.QueryVolume.Length - BufferLength;
00224   else
00225     Irp->IoStatus.Information = 0;
00226 
00227   return Status;
00228 }
00229 
00230 
00231 NTSTATUS
00232 NtfsSetVolumeInformation(PNTFS_IRP_CONTEXT IrpContext)
00233 {
00234   PIRP Irp;
00235   
00236   DPRINT("NtfsSetVolumeInformation() called\n");
00237 
00238   ASSERT(IrpContext);
00239 
00240   Irp = IrpContext->Irp;
00241   Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
00242   Irp->IoStatus.Information = 0;
00243 
00244   return STATUS_NOT_SUPPORTED;
00245 }
00246 
00247 /* EOF */

Generated on Fri May 25 2012 04:25:50 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.