1 /* $Id: volume.c,v 1.4 2000/09/12 10:12:13 jean Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: services/fs/vfat/volume.c
6 * PURPOSE: VFAT Filesystem
7 * PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
10 /* INCLUDES *****************************************************************/
12 #include <ddk/ntddk.h>
14 #include <ddk/cctypes.h>
21 /* FUNCTIONS ****************************************************************/
23 NTSTATUS
FsdGetFsVolumeInformation(PFILE_OBJECT FileObject
,
25 PDEVICE_OBJECT DeviceObject
,
26 PFILE_FS_VOLUME_INFORMATION FsVolumeInfo
)
28 DPRINT("FsdGetFsVolumeInformation()\n");
29 DPRINT("FsVolumeInfo = %p\n", FsVolumeInfo
);
32 return(STATUS_SUCCESS
);
36 FsVolumeInfo
->VolumeSerialNumber
= DeviceObject
->Vpb
->SerialNumber
;
37 FsVolumeInfo
->VolumeLabelLength
= DeviceObject
->Vpb
->VolumeLabelLength
;
38 wcscpy (FsVolumeInfo
->VolumeLabel
, DeviceObject
->Vpb
->VolumeLabel
);
41 FsVolumeInfo
->VolumeCreationTime
.QuadPart
= 0;
42 FsVolumeInfo
->SupportsObjects
= FALSE
;
44 DPRINT("Finished FsdGetFsVolumeInformation()\n");
46 return(STATUS_SUCCESS
);
50 NTSTATUS
FsdGetFsAttributeInformation(PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo
)
52 DPRINT("FsdGetFsAttributeInformation()\n");
53 DPRINT("FsAttributeInfo = %p\n", FsAttributeInfo
);
56 return(STATUS_SUCCESS
);
58 FsAttributeInfo
->FileSystemAttributes
= FS_CASE_IS_PRESERVED
;
59 FsAttributeInfo
->MaximumComponentNameLength
= 255;
60 FsAttributeInfo
->FileSystemNameLength
= 3;
61 wcscpy (FsAttributeInfo
->FileSystemName
, L
"FAT");
63 DPRINT("Finished FsdGetFsAttributeInformation()\n");
65 return(STATUS_SUCCESS
);
68 NTSTATUS
FsdGetFsSizeInformation(PDEVICE_OBJECT DeviceObject
,
69 PFILE_FS_SIZE_INFORMATION FsSizeInfo
)
71 PDEVICE_EXTENSION DeviceExt
= DeviceObject
->DeviceExtension
;
73 DPRINT("FsdGetFsSizeInformation()\n");
74 DPRINT("FsSizeInfo = %p\n", FsSizeInfo
);
77 return(STATUS_SUCCESS
);
79 if (DeviceExt
->FatType
== FAT32
)
81 struct _BootSector32
*BootSect
= (struct _BootSector32
*)DeviceExt
->Boot
;
83 if (BootSect
->Sectors
)
84 FsSizeInfo
->TotalAllocationUnits
.QuadPart
= BootSect
->Sectors
;
86 FsSizeInfo
->TotalAllocationUnits
.QuadPart
= BootSect
->SectorsHuge
;
88 FsSizeInfo
->AvailableAllocationUnits
.QuadPart
=
89 FAT32CountAvailableClusters(DeviceExt
);
91 FsSizeInfo
->SectorsPerAllocationUnit
= BootSect
->SectorsPerCluster
;
92 FsSizeInfo
->BytesPerSector
= BootSect
->BytesPerSector
;
96 struct _BootSector
*BootSect
= (struct _BootSector
*)DeviceExt
->Boot
;
98 if (BootSect
->Sectors
)
99 FsSizeInfo
->TotalAllocationUnits
.QuadPart
= BootSect
->Sectors
;
101 FsSizeInfo
->TotalAllocationUnits
.QuadPart
= BootSect
->SectorsHuge
;
103 if (DeviceExt
->FatType
== FAT16
)
104 FsSizeInfo
->AvailableAllocationUnits
.QuadPart
=
105 FAT16CountAvailableClusters(DeviceExt
);
107 FsSizeInfo
->AvailableAllocationUnits
.QuadPart
=
108 FAT12CountAvailableClusters(DeviceExt
);
110 FsSizeInfo
->SectorsPerAllocationUnit
= BootSect
->SectorsPerCluster
;
111 FsSizeInfo
->BytesPerSector
= BootSect
->BytesPerSector
;
114 DPRINT("Finished FsdGetFsSizeInformation()\n");
116 return(STATUS_SUCCESS
);
120 NTSTATUS STDCALL
VfatQueryVolumeInformation(PDEVICE_OBJECT DeviceObject
, PIRP Irp
)
122 * FUNCTION: Retrieve the specified file information
125 PIO_STACK_LOCATION Stack
= IoGetCurrentIrpStackLocation(Irp
);
126 FILE_INFORMATION_CLASS FileInformationClass
=
127 Stack
->Parameters
.QueryVolume
.FileInformationClass
;
128 PFILE_OBJECT FileObject
= NULL
;
130 // PVfatCCB CCB = NULL;
132 NTSTATUS RC
= STATUS_SUCCESS
;
136 assert(DeviceObject
!= NULL
);
139 DPRINT("FsdQueryVolumeInformation(DeviceObject %x, Irp %x)\n",
143 Stack
= IoGetCurrentIrpStackLocation(Irp
);
144 FileInformationClass
= Stack
->Parameters
.QueryVolume
.FileInformationClass
;
145 FileObject
= Stack
->FileObject
;
146 // CCB = (PVfatCCB)(FileObject->FsContext2);
147 // FCB = CCB->Buffer; // Should be CCB->FCB???
148 FCB
= ((PVFATCCB
)(FileObject
->FsContext2
))->pFcb
;
150 // FIXME : determine Buffer for result :
152 SystemBuffer
= MmGetSystemAddressForMdl(Irp
->MdlAddress
);
154 SystemBuffer
= Irp
->UserBuffer
;
155 // SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
157 DPRINT("FileInformationClass %d\n",FileInformationClass
);
158 DPRINT("SystemBuffer %x\n",SystemBuffer
);
160 switch (FileInformationClass
)
162 case FileFsVolumeInformation
:
163 RC
= FsdGetFsVolumeInformation(FileObject
,
169 case FileFsAttributeInformation
:
170 RC
= FsdGetFsAttributeInformation(SystemBuffer
);
173 case FileFsSizeInformation
:
174 RC
= FsdGetFsSizeInformation(DeviceObject
, SystemBuffer
);
178 RC
=STATUS_NOT_IMPLEMENTED
;
181 Irp
->IoStatus
.Status
= RC
;
182 Irp
->IoStatus
.Information
= 0;
183 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);