mirror of
https://github.com/reactos/reactos.git
synced 2024-10-06 09:24:11 +00:00
Fixed file creation date and time
Implemented synchronization of all FATs (FAT16 only) Fixed bug in directory creation svn path=/trunk/; revision=1052
This commit is contained in:
parent
15094179f1
commit
6865b783cc
|
@ -1,10 +1,10 @@
|
|||
/* $Id: dirwr.c,v 1.9 2000/03/01 23:41:35 ea Exp $
|
||||
/* $Id: dirwr.c,v 1.10 2000/03/12 23:28:59 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: services/fs/vfat/dirwr.c
|
||||
* PURPOSE: VFAT Filesystem : write in directory
|
||||
|
||||
*
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
@ -72,8 +72,10 @@ DPRINT("open directory %S for update of entry %S\n",DirName,FileName);
|
|||
return status;
|
||||
}
|
||||
|
||||
NTSTATUS addEntry(PDEVICE_EXTENSION DeviceExt
|
||||
,PFILE_OBJECT pFileObject,ULONG RequestedOptions,UCHAR ReqAttr)
|
||||
NTSTATUS addEntry(PDEVICE_EXTENSION DeviceExt,
|
||||
PFILE_OBJECT pFileObject,
|
||||
ULONG RequestedOptions,
|
||||
UCHAR ReqAttr)
|
||||
/*
|
||||
create a new FAT entry
|
||||
*/
|
||||
|
@ -93,6 +95,7 @@ NTSTATUS addEntry(PDEVICE_EXTENSION DeviceExt
|
|||
PVFATCCB newCCB;
|
||||
ULONG CurrentCluster;
|
||||
KIRQL oldIrql;
|
||||
LARGE_INTEGER SystemTime, LocalTime;
|
||||
|
||||
PathFileName=pFileObject->FileName.Buffer;
|
||||
DPRINT("addEntry: Pathname=%S\n",PathFileName);
|
||||
|
@ -226,13 +229,23 @@ DPRINT("i=%d,j=%d,%d,%d\n",i,j,pEntry->Filename[i],FileName[i]);
|
|||
DirName[NameLen]=0;
|
||||
}
|
||||
DPRINT("dos name=%11.11s\n",pEntry->Filename);
|
||||
//FIXME : set attributes, dates, times
|
||||
pEntry->Attrib=ReqAttr;
|
||||
|
||||
/* set attributes */
|
||||
pEntry->Attrib=ReqAttr;
|
||||
if(RequestedOptions&FILE_DIRECTORY_FILE)
|
||||
pEntry->Attrib |= FILE_ATTRIBUTE_DIRECTORY;
|
||||
pEntry->CreationDate=0x21;
|
||||
pEntry->UpdateDate=0x21;
|
||||
|
||||
/* set dates and times */
|
||||
KeQuerySystemTime (&SystemTime);
|
||||
ExSystemTimeToLocalTime (&SystemTime,
|
||||
&LocalTime);
|
||||
FsdFileTimeToDosDateTime ((TIME*)&LocalTime,
|
||||
&pEntry->CreationDate,
|
||||
&pEntry->CreationTime);
|
||||
pEntry->UpdateDate = pEntry->CreationDate;
|
||||
pEntry->UpdateTime = pEntry->CreationTime;
|
||||
pEntry->AccessDate = pEntry->CreationDate;
|
||||
|
||||
// calculate checksum for 8.3 name
|
||||
for(pSlots[0].alias_checksum=i=0;i<11;i++)
|
||||
{
|
||||
|
@ -258,6 +271,7 @@ DPRINT("i=%d,j=%d,%d,%d\n",i,j,pEntry->Filename[i],FileName[i]);
|
|||
memcpy(pSlots[i].name11_12,FileName+(nbSlots-i-2)*13+11
|
||||
,2*sizeof(WCHAR));
|
||||
}
|
||||
|
||||
//try to find nbSlots contiguous entries frees in directory
|
||||
for(i=0,status=STATUS_SUCCESS;status==STATUS_SUCCESS;i++)
|
||||
{
|
||||
|
@ -265,11 +279,17 @@ DPRINT("i=%d,j=%d,%d,%d\n",i,j,pEntry->Filename[i],FileName[i]);
|
|||
,sizeof(FATDirEntry),i*sizeof(FATDirEntry),&LengthRead);
|
||||
if(IsLastEntry(&FatEntry,0))
|
||||
break;
|
||||
if(IsDeletedEntry(&FatEntry,0)) nbFree++;
|
||||
else nbFree=0;
|
||||
if (nbFree==nbSlots) break;
|
||||
|
||||
if(IsDeletedEntry(&FatEntry,0))
|
||||
nbFree++;
|
||||
else
|
||||
nbFree=0;
|
||||
|
||||
if (nbFree==nbSlots)
|
||||
break;
|
||||
}
|
||||
DPRINT("NbFree %d, entry number %d\n",nbFree,i);
|
||||
DPRINT("nbSlots %d nbFree %d, entry number %d\n",nbSlots,nbFree,i);
|
||||
|
||||
if(RequestedOptions&FILE_DIRECTORY_FILE)
|
||||
{
|
||||
CurrentCluster=GetNextWriteCluster(DeviceExt,0);
|
||||
|
@ -345,3 +365,4 @@ DPRINT("addentry ok\n");
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: fat.c,v 1.3 2000/02/22 02:02:08 ekohl Exp $
|
||||
* $Id: fat.c,v 1.4 2000/03/12 23:28:59 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -339,6 +339,8 @@ void FAT16WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
|
|||
{
|
||||
ULONG FATsector;
|
||||
PUSHORT Block;
|
||||
ULONG Start;
|
||||
int i;
|
||||
|
||||
DbgPrint("FAT16WriteCluster %u : %u\n", ClusterToWrite, NewValue);
|
||||
|
||||
|
@ -347,11 +349,17 @@ void FAT16WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
|
|||
|
||||
/* Update the in-memory FAT */
|
||||
Block[ClusterToWrite] = NewValue;
|
||||
/* Write the changed FAT sector to disk */
|
||||
|
||||
/* Write the changed FAT sector to disk (all FAT's) */
|
||||
Start = DeviceExt->FATStart + FATsector;
|
||||
for (i = 0; i < DeviceExt->Boot->FATCount; i++)
|
||||
{
|
||||
VFATWriteSectors(DeviceExt->StorageDevice,
|
||||
DeviceExt->FATStart+FATsector,
|
||||
Start,
|
||||
1,
|
||||
(UCHAR *)Block);
|
||||
Start += DeviceExt->Boot->FATSectors;
|
||||
}
|
||||
}
|
||||
|
||||
void FAT32WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: rw.c,v 1.3 2000/02/22 02:02:08 ekohl Exp $
|
||||
/* $Id: rw.c,v 1.4 2000/03/12 23:28:59 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -55,11 +55,6 @@ NTSTATUS FsdReadFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
|||
FirstCluster=CurrentCluster;
|
||||
DPRINT("DeviceExt->BytesPerCluster %x\n",DeviceExt->BytesPerCluster);
|
||||
|
||||
if (Fcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
return(STATUS_FILE_IS_A_DIRECTORY);
|
||||
}
|
||||
|
||||
if (ReadOffset >= Fcb->entry.FileSize
|
||||
&& !(Fcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY))
|
||||
{
|
||||
|
@ -167,6 +162,7 @@ NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
|||
PVFATCCB pCcb;
|
||||
PVOID Temp;
|
||||
ULONG TempLength,Length2=Length;
|
||||
LARGE_INTEGER SystemTime, LocalTime;
|
||||
|
||||
DPRINT1("FsdWriteFile(FileObject %x, Buffer %x, Length %x, "
|
||||
"WriteOffset %x\n", FileObject, Buffer, Length, WriteOffset);
|
||||
|
@ -341,9 +337,16 @@ NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
|||
CHECKPOINT;
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME : set last write time and date
|
||||
*/
|
||||
|
||||
/* set dates and times */
|
||||
KeQuerySystemTime (&SystemTime);
|
||||
ExSystemTimeToLocalTime (&SystemTime,
|
||||
&LocalTime);
|
||||
FsdFileTimeToDosDateTime ((TIME*)&LocalTime,
|
||||
&Fcb->entry.UpdateDate,
|
||||
&Fcb->entry.UpdateTime);
|
||||
Fcb->entry.AccessDate = Fcb->entry.UpdateDate;
|
||||
|
||||
if (Fcb->entry.FileSize < WriteOffset+Length
|
||||
&& !(Fcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY))
|
||||
{
|
||||
|
@ -399,6 +402,7 @@ NTSTATUS FsdRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
PDEVICE_EXTENSION DeviceExt;
|
||||
NTSTATUS Status;
|
||||
ULONG LengthRead;
|
||||
PVFATFCB Fcb;
|
||||
|
||||
DPRINT("FsdRead(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
|
||||
|
||||
|
@ -415,8 +419,21 @@ NTSTATUS FsdRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
|
||||
Offset = Stack->Parameters.Read.ByteOffset.u.LowPart;
|
||||
|
||||
Status = FsdReadFile(DeviceExt,FileObject,Buffer,Length,Offset,
|
||||
/* fail if file is a directory */
|
||||
Fcb = ((PVFATCCB)(FileObject->FsContext2))->pFcb;
|
||||
if (Fcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
Status = STATUS_FILE_IS_A_DIRECTORY;
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = FsdReadFile(DeviceExt,
|
||||
FileObject,
|
||||
Buffer,
|
||||
Length,
|
||||
Offset,
|
||||
&LengthRead);
|
||||
}
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = LengthRead;
|
||||
|
|
Loading…
Reference in a new issue