1 /* $Id: finfo.c,v 1.1 1999/12/11 21:14:48 dwelch Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: services/fs/vfat/finfo.c
6 * PURPOSE: VFAT Filesystem
7 * PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
11 /* INCLUDES *****************************************************************/
14 #include <internal/string.h>
15 #include <ddk/ntddk.h>
16 #include <ddk/cctypes.h>
19 #include <internal/debug.h>
23 /* FUNCTIONS ****************************************************************/
25 NTSTATUS
FsdGetStandardInformation(PVFATFCB FCB
, PDEVICE_OBJECT DeviceObject
,
26 PFILE_STANDARD_INFORMATION StandardInfo
)
28 * FUNCTION: Retrieve the standard file information
31 PDEVICE_EXTENSION DeviceExtension
;
32 unsigned long AllocSize
;
34 DeviceExtension
= DeviceObject
->DeviceExtension
;
36 assert(DeviceExtension
!= NULL
);
37 assert(DeviceExtension
->BytesPerCluster
!= 0);
38 assert(StandardInfo
!= NULL
);
41 RtlZeroMemory(StandardInfo
, sizeof(FILE_STANDARD_INFORMATION
));
43 /* Make allocsize a rounded up multiple of BytesPerCluster */
44 AllocSize
= ((FCB
->entry
.FileSize
+ DeviceExtension
->BytesPerCluster
- 1) /
45 DeviceExtension
->BytesPerCluster
) *
46 DeviceExtension
->BytesPerCluster
;
48 StandardInfo
->AllocationSize
= RtlConvertUlongToLargeInteger(AllocSize
);
49 StandardInfo
->EndOfFile
= RtlConvertUlongToLargeInteger(FCB
->entry
.FileSize
);
50 StandardInfo
->NumberOfLinks
= 0;
51 StandardInfo
->DeletePending
= FALSE
;
52 if((FCB
->entry
.Attrib
& 0x10)>0) {
53 StandardInfo
->Directory
= TRUE
;
55 StandardInfo
->Directory
= FALSE
;
58 return STATUS_SUCCESS
;
61 NTSTATUS
FsdSetPositionInformation(PFILE_OBJECT FileObject
,
63 PDEVICE_OBJECT DeviceObject
,
64 PFILE_POSITION_INFORMATION PositionInfo
)
66 DPRINT("FsdSetPositionInformation()\n");
68 DPRINT("PositionInfo %x\n", PositionInfo
);
69 DPRINT("Setting position %d\n", PositionInfo
->CurrentByteOffset
.u
.LowPart
);
70 memcpy(&FileObject
->CurrentByteOffset
,&PositionInfo
->CurrentByteOffset
,
71 sizeof(LARGE_INTEGER
));
73 return(STATUS_SUCCESS
);
76 NTSTATUS
FsdGetPositionInformation(PFILE_OBJECT FileObject
,
78 PDEVICE_OBJECT DeviceObject
,
79 PFILE_POSITION_INFORMATION PositionInfo
)
81 DPRINT("FsdGetPositionInformation()\n");
83 memcpy(&PositionInfo
->CurrentByteOffset
, &FileObject
->CurrentByteOffset
,
84 sizeof(LARGE_INTEGER
));
85 DPRINT("Getting position %x\n", PositionInfo
->CurrentByteOffset
.u
.LowPart
);
86 return(STATUS_SUCCESS
);
89 NTSTATUS
FsdGetBasicInformation(PFILE_OBJECT FileObject
,
91 PDEVICE_OBJECT DeviceObject
,
92 PFILE_BASIC_INFORMATION BasicInfo
)
94 DPRINT("FsdGetBasicInformation()\n");
96 FsdDosDateTimeToFileTime(FCB
->entry
.CreationDate
,FCB
->entry
.CreationTime
,
97 &BasicInfo
->CreationTime
);
98 FsdDosDateTimeToFileTime(FCB
->entry
.AccessDate
,0,
99 &BasicInfo
->LastAccessTime
);
100 FsdDosDateTimeToFileTime(FCB
->entry
.UpdateDate
,FCB
->entry
.UpdateTime
,
101 &BasicInfo
->LastWriteTime
);
102 FsdDosDateTimeToFileTime(FCB
->entry
.UpdateDate
,FCB
->entry
.UpdateTime
,
103 &BasicInfo
->ChangeTime
);
105 BasicInfo
->FileAttributes
= FCB
->entry
.Attrib
;
107 DPRINT("Getting attributes %x\n", BasicInfo
->FileAttributes
);
109 return(STATUS_SUCCESS
);
113 NTSTATUS
FsdSetDispositionInformation(PFILE_OBJECT FileObject
,
115 PDEVICE_OBJECT DeviceObject
,
116 PFILE_DISPOSITION_INFORMATION DispositionInfo
)
118 DPRINT("FsdSetDispositionInformation()\n");
120 FileObject
->DeletePending
= DispositionInfo
->DeleteFile
;
122 return(STATUS_SUCCESS
);
126 NTSTATUS
FsdQueryInformation(PDEVICE_OBJECT DeviceObject
, PIRP Irp
)
128 * FUNCTION: Retrieve the specified file information
131 PIO_STACK_LOCATION Stack
= IoGetCurrentIrpStackLocation(Irp
);
132 FILE_INFORMATION_CLASS FileInformationClass
=
133 Stack
->Parameters
.QueryFile
.FileInformationClass
;
134 PFILE_OBJECT FileObject
= NULL
;
136 // PVFATCCB CCB = NULL;
138 NTSTATUS RC
= STATUS_SUCCESS
;
142 assert(DeviceObject
!= NULL
);
146 Stack
= IoGetCurrentIrpStackLocation(Irp
);
147 FileInformationClass
= Stack
->Parameters
.QueryFile
.FileInformationClass
;
148 FileObject
= Stack
->FileObject
;
149 // CCB = (PVFATCCB)(FileObject->FsContext2);
150 // FCB = CCB->Buffer; // Should be CCB->FCB???
151 FCB
= ((PVFATCCB
)(FileObject
->FsContext2
))->pFcb
;
153 // FIXME : determine Buffer for result :
155 SystemBuffer
= MmGetSystemAddressForMdl(Irp
->MdlAddress
);
157 SystemBuffer
= Irp
->UserBuffer
;
158 // SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
160 switch(FileInformationClass
) {
161 case FileStandardInformation
:
162 RC
= FsdGetStandardInformation(FCB
, DeviceObject
, SystemBuffer
);
164 case FilePositionInformation
:
165 RC
= FsdGetPositionInformation(FileObject
,
170 case FileBasicInformation
:
171 RC
= FsdGetBasicInformation(FileObject
,
177 RC
=STATUS_NOT_IMPLEMENTED
;
180 Irp
->IoStatus
.Status
= RC
;
181 Irp
->IoStatus
.Information
= 0;
182 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
187 NTSTATUS
VfatSetInformation(PDEVICE_OBJECT DeviceObject
, PIRP Irp
)
189 * FUNCTION: Retrieve the specified file information
192 PIO_STACK_LOCATION Stack
= IoGetCurrentIrpStackLocation(Irp
);
193 FILE_INFORMATION_CLASS FileInformationClass
;
194 PFILE_OBJECT FileObject
= NULL
;
196 // PVFATCCB CCB = NULL;
197 NTSTATUS RC
= STATUS_SUCCESS
;
201 assert(DeviceObject
!= NULL
);
204 DPRINT("FsdSetInformation(DeviceObject %x, Irp %x)\n",
208 Stack
= IoGetCurrentIrpStackLocation(Irp
);
209 FileInformationClass
= Stack
->Parameters
.SetFile
.FileInformationClass
;
210 FileObject
= Stack
->FileObject
;
211 FCB
= ((PVFATCCB
)(FileObject
->FsContext2
))->pFcb
;
213 // FIXME : determine Buffer for result :
215 SystemBuffer
= MmGetSystemAddressForMdl(Irp
->MdlAddress
);
217 SystemBuffer
= Irp
->UserBuffer
;
218 // SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
220 DPRINT("FileInformationClass %d\n",FileInformationClass
);
221 DPRINT("SystemBuffer %x\n",SystemBuffer
);
223 switch(FileInformationClass
)
225 case FilePositionInformation
:
226 RC
= FsdSetPositionInformation(FileObject
,
231 case FileDispositionInformation
:
232 RC
= FsdSetDispositionInformation(FileObject
,
238 RC
= STATUS_NOT_IMPLEMENTED
;
241 Irp
->IoStatus
.Status
= RC
;
242 Irp
->IoStatus
.Information
= 0;
243 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);