From 924e3b2bea2630ed2876f920641230b3460280f5 Mon Sep 17 00:00:00 2001 From: Hartmut Birr Date: Sun, 23 May 2004 13:34:32 +0000 Subject: [PATCH] - Don't return a file or allocation size for directories. svn path=/trunk/; revision=9481 --- reactos/drivers/fs/cdfs/dirctl.c | 45 ++++++++++++++++++++------- reactos/drivers/fs/cdfs/finfo.c | 44 ++++++++++++++++++++------ reactos/drivers/fs/vfat/dir.c | 46 ++++++++++++++++++--------- reactos/drivers/fs/vfat/finfo.c | 53 +++++++++++++++++++++++--------- 4 files changed, 138 insertions(+), 50 deletions(-) diff --git a/reactos/drivers/fs/cdfs/dirctl.c b/reactos/drivers/fs/cdfs/dirctl.c index 3baf171678b..62627b365c2 100644 --- a/reactos/drivers/fs/cdfs/dirctl.c +++ b/reactos/drivers/fs/cdfs/dirctl.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: dirctl.c,v 1.14 2003/11/13 15:25:08 ekohl Exp $ +/* $Id: dirctl.c,v 1.15 2004/05/23 13:31:25 hbirr Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -420,11 +420,18 @@ CdfsGetDirectoryInformation(PFCB Fcb, /* Convert file flags */ CdfsFileFlagsToAttributes(Fcb, &Info->FileAttributes); + if (CdfsFCBIsDirectory(Fcb)) + { + Info->EndOfFile.QuadPart = 0LL; + Info->AllocationSize.QuadPart = 0LL; + } + else + { + Info->EndOfFile.QuadPart = Fcb->Entry.DataLengthL; - Info->EndOfFile.QuadPart = Fcb->Entry.DataLengthL; - - /* Make AllocSize a rounded up multiple of the sector size */ - Info->AllocationSize.QuadPart = ROUND_UP(Fcb->Entry.DataLengthL, BLOCKSIZE); + /* Make AllocSize a rounded up multiple of the sector size */ + Info->AllocationSize.QuadPart = ROUND_UP(Fcb->Entry.DataLengthL, BLOCKSIZE); + } // Info->FileIndex=; @@ -465,10 +472,18 @@ CdfsGetFullDirectoryInformation(PFCB Fcb, CdfsFileFlagsToAttributes(Fcb, &Info->FileAttributes); - Info->EndOfFile.QuadPart = Fcb->Entry.DataLengthL; + if (CdfsFCBIsDirectory(Fcb)) + { + Info->EndOfFile.QuadPart = 0LL; + Info->AllocationSize.QuadPart = 0LL; + } + else + { + Info->EndOfFile.QuadPart = Fcb->Entry.DataLengthL; - /* Make AllocSize a rounded up multiple of the sector size */ - Info->AllocationSize.QuadPart = ROUND_UP(Fcb->Entry.DataLengthL, BLOCKSIZE); + /* Make AllocSize a rounded up multiple of the sector size */ + Info->AllocationSize.QuadPart = ROUND_UP(Fcb->Entry.DataLengthL, BLOCKSIZE); + } // Info->FileIndex=; Info->EaSize = 0; @@ -510,10 +525,18 @@ CdfsGetBothDirectoryInformation(PFCB Fcb, CdfsFileFlagsToAttributes(Fcb, &Info->FileAttributes); - Info->EndOfFile.QuadPart = Fcb->Entry.DataLengthL; + if (CdfsFCBIsDirectory(Fcb)) + { + Info->EndOfFile.QuadPart = 0LL; + Info->AllocationSize.QuadPart = 0LL; + } + else + { + Info->EndOfFile.QuadPart = Fcb->Entry.DataLengthL; - /* Make AllocSize a rounded up multiple of the sector size */ - Info->AllocationSize.QuadPart = ROUND_UP(Fcb->Entry.DataLengthL, BLOCKSIZE); + /* Make AllocSize a rounded up multiple of the sector size */ + Info->AllocationSize.QuadPart = ROUND_UP(Fcb->Entry.DataLengthL, BLOCKSIZE); + } // Info->FileIndex=; Info->EaSize = 0; diff --git a/reactos/drivers/fs/cdfs/finfo.c b/reactos/drivers/fs/cdfs/finfo.c index e81889a308f..e0e798528f0 100644 --- a/reactos/drivers/fs/cdfs/finfo.c +++ b/reactos/drivers/fs/cdfs/finfo.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: finfo.c,v 1.9 2004/03/08 08:51:26 ekohl Exp $ +/* $Id: finfo.c,v 1.10 2004/05/23 13:31:25 hbirr Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -60,11 +60,20 @@ CdfsGetStandardInformation(PFCB Fcb, RtlZeroMemory(StandardInfo, sizeof(FILE_STANDARD_INFORMATION)); - StandardInfo->AllocationSize = Fcb->RFCB.AllocationSize; - StandardInfo->EndOfFile = Fcb->RFCB.FileSize; + if (CdfsFCBIsDirectory(Fcb)) + { + StandardInfo->AllocationSize.QuadPart = 0LL;; + StandardInfo->EndOfFile.QuadPart = 0LL; + StandardInfo->Directory = TRUE; + } + else + { + StandardInfo->AllocationSize = Fcb->RFCB.AllocationSize; + StandardInfo->EndOfFile = Fcb->RFCB.FileSize; + StandardInfo->Directory = TRUE; + } StandardInfo->NumberOfLinks = 0; StandardInfo->DeletePending = FALSE; - StandardInfo->Directory = Fcb->Entry.FileFlags & 0x02 ? TRUE : FALSE; *BufferLength -= sizeof(FILE_STANDARD_INFORMATION); return(STATUS_SUCCESS); @@ -207,8 +216,16 @@ CdfsGetNetworkOpenInformation(PFCB Fcb, &NetworkInfo->LastWriteTime); CdfsDateTimeToFileTime(Fcb, &NetworkInfo->ChangeTime); - NetworkInfo->AllocationSize = Fcb->RFCB.AllocationSize; - NetworkInfo->EndOfFile = Fcb->RFCB.FileSize; + if (CdfsFCBIsDirectory(Fcb)) + { + NetworkInfo->AllocationSize.QuadPart = 0LL;; + NetworkInfo->EndOfFile.QuadPart = 0LL; + } + else + { + NetworkInfo->AllocationSize = Fcb->RFCB.AllocationSize; + NetworkInfo->EndOfFile = Fcb->RFCB.FileSize; + } CdfsFileFlagsToAttributes(Fcb, &NetworkInfo->FileAttributes); @@ -249,11 +266,20 @@ CdfsGetAllInformation(PFILE_OBJECT FileObject, &Info->BasicInformation.FileAttributes); /* Standard Information */ - Info->StandardInformation.AllocationSize = Fcb->RFCB.AllocationSize; - Info->StandardInformation.EndOfFile = Fcb->RFCB.FileSize; + if (CdfsFCBIsDirectory(Fcb)) + { + Info->StandardInformation.AllocationSize.QuadPart = 0LL; + Info->StandardInformation.EndOfFile.QuadPart = 0LL; + Info->StandardInformation.Directory = TRUE; + } + else + { + Info->StandardInformation.AllocationSize = Fcb->RFCB.AllocationSize; + Info->StandardInformation.EndOfFile = Fcb->RFCB.FileSize; + Info->StandardInformation.Directory = FALSE; + } Info->StandardInformation.NumberOfLinks = 0; Info->StandardInformation.DeletePending = FALSE; - Info->StandardInformation.Directory = Fcb->Entry.FileFlags & FILE_FLAG_DIRECTORY ? TRUE : FALSE; /* Internal Information */ Info->InternalInformation.IndexNumber.QuadPart = Fcb->IndexNumber.QuadPart; diff --git a/reactos/drivers/fs/vfat/dir.c b/reactos/drivers/fs/vfat/dir.c index ac5434d7a46..e7e99f23aba 100644 --- a/reactos/drivers/fs/vfat/dir.c +++ b/reactos/drivers/fs/vfat/dir.c @@ -1,5 +1,5 @@ /* - * $Id: dir.c,v 1.33 2003/12/13 14:25:04 ekohl Exp $ + * $Id: dir.c,v 1.34 2004/05/23 13:34:32 hbirr Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -110,12 +110,20 @@ VfatGetFileDirectoryInformation (PVFAT_DIRENTRY_CONTEXT DirContext, FsdDosDateTimeToFileTime (DirContext->FatDirEntry.UpdateDate, DirContext->FatDirEntry.UpdateTime, &pInfo->LastWriteTime); pInfo->ChangeTime = pInfo->LastWriteTime; - pInfo->EndOfFile.u.HighPart = 0; - pInfo->EndOfFile.u.LowPart = DirContext->FatDirEntry.FileSize; - /* Make allocsize a rounded up multiple of BytesPerCluster */ - pInfo->AllocationSize.u.HighPart = 0; - pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->FatDirEntry.FileSize, DeviceExt->FatInfo.BytesPerCluster); - pInfo->FileAttributes = DirContext->FatDirEntry.Attrib; + if (DirContext->FatDirEntry.Attrib & FILE_ATTRIBUTE_DIRECTORY) + { + pInfo->EndOfFile.QuadPart = 0LL; + pInfo->AllocationSize.QuadPart = 0LL; + } + else + { + pInfo->EndOfFile.u.HighPart = 0; + pInfo->EndOfFile.u.LowPart = DirContext->FatDirEntry.FileSize; + /* Make allocsize a rounded up multiple of BytesPerCluster */ + pInfo->AllocationSize.u.HighPart = 0; + pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->FatDirEntry.FileSize, DeviceExt->FatInfo.BytesPerCluster); + } + pInfo->FileAttributes = DirContext->FatDirEntry.Attrib & 0x3f; return STATUS_SUCCESS; } @@ -145,7 +153,7 @@ VfatGetFileFullDirectoryInformation (PVFAT_DIRENTRY_CONTEXT DirContext, /* Make allocsize a rounded up multiple of BytesPerCluster */ pInfo->AllocationSize.u.HighPart = 0; pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->FatDirEntry.FileSize, DeviceExt->FatInfo.BytesPerCluster); - pInfo->FileAttributes = DirContext->FatDirEntry.Attrib; + pInfo->FileAttributes = DirContext->FatDirEntry.Attrib & 0x3f; // pInfo->EaSize=; return STATUS_SUCCESS; } @@ -172,13 +180,21 @@ VfatGetFileBothInformation (PVFAT_DIRENTRY_CONTEXT DirContext, FsdDosDateTimeToFileTime (DirContext->FatDirEntry.UpdateDate, DirContext->FatDirEntry.UpdateTime, &pInfo->LastWriteTime); pInfo->ChangeTime = pInfo->LastWriteTime; - pInfo->EndOfFile.u.HighPart = 0; - pInfo->EndOfFile.u.LowPart = DirContext->FatDirEntry.FileSize; - /* Make allocsize a rounded up multiple of BytesPerCluster */ - pInfo->AllocationSize.u.HighPart = 0; - pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->FatDirEntry.FileSize, DeviceExt->FatInfo.BytesPerCluster); - pInfo->FileAttributes = DirContext->FatDirEntry.Attrib; -// pInfo->EaSize=; + if (DirContext->FatDirEntry.Attrib & FILE_ATTRIBUTE_DIRECTORY) + { + pInfo->EndOfFile.QuadPart = 0LL; + pInfo->AllocationSize.QuadPart = 0LL; + } + else + { + pInfo->EndOfFile.u.HighPart = 0; + pInfo->EndOfFile.u.LowPart = DirContext->FatDirEntry.FileSize; + /* Make allocsize a rounded up multiple of BytesPerCluster */ + pInfo->AllocationSize.u.HighPart = 0; + pInfo->AllocationSize.u.LowPart = ROUND_UP(DirContext->FatDirEntry.FileSize, DeviceExt->FatInfo.BytesPerCluster); + } + pInfo->FileAttributes = DirContext->FatDirEntry.Attrib & 0x3f; + pInfo->EaSize=0; return STATUS_SUCCESS; } diff --git a/reactos/drivers/fs/vfat/finfo.c b/reactos/drivers/fs/vfat/finfo.c index ed92d52c68d..94546f58632 100644 --- a/reactos/drivers/fs/vfat/finfo.c +++ b/reactos/drivers/fs/vfat/finfo.c @@ -1,4 +1,4 @@ -/* $Id: finfo.c,v 1.34 2003/10/11 17:51:56 hbirr Exp $ +/* $Id: finfo.c,v 1.35 2004/05/23 13:34:32 hbirr Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -37,14 +37,20 @@ VfatGetStandardInformation(PVFATFCB FCB, assert (StandardInfo != NULL); assert (FCB != NULL); - RtlZeroMemory(StandardInfo, - sizeof(FILE_STANDARD_INFORMATION)); - - StandardInfo->AllocationSize = FCB->RFCB.AllocationSize; - StandardInfo->EndOfFile = FCB->RFCB.FileSize; + if (vfatFCBIsDirectory(FCB)) + { + StandardInfo->AllocationSize.QuadPart = 0LL; + StandardInfo->EndOfFile.QuadPart = 0LL; + StandardInfo->Directory = TRUE; + } + else + { + StandardInfo->AllocationSize = FCB->RFCB.AllocationSize; + StandardInfo->EndOfFile = FCB->RFCB.FileSize; + StandardInfo->Directory = FALSE; + } StandardInfo->NumberOfLinks = 0; StandardInfo->DeletePending = FCB->Flags & FCB_DELETE_PENDING ? TRUE : FALSE; - StandardInfo->Directory = FCB->entry.Attrib & 0x10 ? TRUE : FALSE; *BufferLength -= sizeof(FILE_STANDARD_INFORMATION); return(STATUS_SUCCESS); @@ -148,7 +154,7 @@ VfatGetBasicInformation(PFILE_OBJECT FileObject, (TIME *)&BasicInfo->LastWriteTime); BasicInfo->ChangeTime = BasicInfo->LastWriteTime; - BasicInfo->FileAttributes = FCB->entry.Attrib; + BasicInfo->FileAttributes = FCB->entry.Attrib & 0x3f; /* Synthesize FILE_ATTRIBUTE_NORMAL */ if (0 == (BasicInfo->FileAttributes & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_ARCHIVE | @@ -299,9 +305,17 @@ VfatGetNetworkOpenInformation(PVFATFCB Fcb, Fcb->entry.UpdateTime, &NetworkInfo->LastWriteTime); NetworkInfo->ChangeTime = NetworkInfo->LastWriteTime; - NetworkInfo->AllocationSize = Fcb->RFCB.AllocationSize; - NetworkInfo->EndOfFile = Fcb->RFCB.FileSize; - NetworkInfo->FileAttributes = Fcb->entry.Attrib; + if (vfatFCBIsDirectory(Fcb)) + { + NetworkInfo->EndOfFile.QuadPart = 0L; + NetworkInfo->AllocationSize.QuadPart = 0L; + } + else + { + NetworkInfo->AllocationSize = Fcb->RFCB.AllocationSize; + NetworkInfo->EndOfFile = Fcb->RFCB.FileSize; + } + NetworkInfo->FileAttributes = Fcb->entry.Attrib & 0x3f; *BufferLength -= sizeof(FILE_NETWORK_OPEN_INFORMATION); return STATUS_SUCCESS; @@ -335,14 +349,23 @@ VfatGetAllInformation(PFILE_OBJECT FileObject, Fcb->entry.UpdateTime, (TIME *)&Info->BasicInformation.LastWriteTime); Info->BasicInformation.ChangeTime = Info->BasicInformation.LastWriteTime; - Info->BasicInformation.FileAttributes = Fcb->entry.Attrib; + Info->BasicInformation.FileAttributes = Fcb->entry.Attrib & 0x3f; /* Standard Information */ - Info->StandardInformation.AllocationSize = Fcb->RFCB.AllocationSize; - Info->StandardInformation.EndOfFile = Fcb->RFCB.FileSize; + if (vfatFCBIsDirectory(Fcb)) + { + Info->StandardInformation.AllocationSize.QuadPart = 0LL; + Info->StandardInformation.EndOfFile.QuadPart = 0LL; + Info->StandardInformation.Directory = TRUE; + } + else + { + Info->StandardInformation.AllocationSize = Fcb->RFCB.AllocationSize; + Info->StandardInformation.EndOfFile = Fcb->RFCB.FileSize; + Info->StandardInformation.Directory = FALSE; + } Info->StandardInformation.NumberOfLinks = 0; Info->StandardInformation.DeletePending = Fcb->Flags & FCB_DELETE_PENDING ? TRUE : FALSE; - Info->StandardInformation.Directory = Fcb->entry.Attrib & 0x10 ? TRUE : FALSE; /* Internal Information */ /* FIXME: get a real index, that can be used in a create operation */