mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 18:46:29 +00:00
- Implement file sharing checks.
svn path=/trunk/; revision=10728
This commit is contained in:
parent
3a31604b7d
commit
28c8c91905
5 changed files with 44 additions and 15 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: cleanup.c,v 1.14 2003/10/11 17:51:56 hbirr Exp $
|
||||
/* $Id: cleanup.c,v 1.15 2004/08/28 22:19:12 navaraf Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -55,6 +55,9 @@ VfatCleanupFile(PVFAT_IRP_CONTEXT IrpContext)
|
|||
{
|
||||
CcRosReleaseFileCache (FileObject);
|
||||
}
|
||||
|
||||
pFcb->OpenHandleCount--;
|
||||
IoRemoveShareAccess(FileObject, &pFcb->FCBShareAccess);
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -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: create.c,v 1.72 2004/08/05 02:48:18 navaraf Exp $
|
||||
/* $Id: create.c,v 1.73 2004/08/28 22:19:12 navaraf Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: drivers/fs/vfat/create.c
|
||||
|
@ -615,10 +615,6 @@ VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
VfatSetExtendedAttributes(FileObject,
|
||||
Irp->AssociatedIrp.SystemBuffer,
|
||||
Stack->Parameters.Create.EaLength);
|
||||
IoSetShareAccess(0 /*DesiredAccess*/,
|
||||
Stack->Parameters.Create.ShareAccess,
|
||||
FileObject,
|
||||
&pFcb->FCBShareAccess);
|
||||
|
||||
if (PagingFileCreate)
|
||||
{
|
||||
|
@ -647,6 +643,20 @@ VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
|
||||
pFcb = FileObject->FsContext;
|
||||
|
||||
if (pFcb->OpenHandleCount != 0)
|
||||
{
|
||||
Status = IoCheckShareAccess(Stack->Parameters.Create.SecurityContext->DesiredAccess,
|
||||
Stack->Parameters.Create.ShareAccess,
|
||||
FileObject,
|
||||
&pFcb->FCBShareAccess,
|
||||
FALSE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
VfatCloseFile (DeviceExt, FileObject);
|
||||
return(Status);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check the file has the requested attributes
|
||||
*/
|
||||
|
@ -719,16 +729,21 @@ VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
Irp->IoStatus.Information = FILE_SUPERSEDED;
|
||||
}
|
||||
else if (RequestedDisposition == FILE_OVERWRITE || RequestedDisposition == FILE_OVERWRITE_IF)
|
||||
{
|
||||
Irp->IoStatus.Information = FILE_OVERWRITTEN;
|
||||
}
|
||||
{
|
||||
Irp->IoStatus.Information = FILE_OVERWRITTEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
Irp->IoStatus.Information = FILE_OPENED;
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME : test share access */
|
||||
|
||||
pFcb->OpenHandleCount++;
|
||||
IoSetShareAccess(Stack->Parameters.Create.SecurityContext->DesiredAccess,
|
||||
Stack->Parameters.Create.ShareAccess,
|
||||
FileObject,
|
||||
&pFcb->FCBShareAccess);
|
||||
|
||||
/* FIXME : test write access if requested */
|
||||
|
||||
return(Status);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: fcb.c,v 1.40 2004/08/01 21:57:17 navaraf Exp $
|
||||
/* $Id: fcb.c,v 1.41 2004/08/28 22:19:12 navaraf Exp $
|
||||
*
|
||||
*
|
||||
* FILE: drivers/fs/vfat/fcb.c
|
||||
|
@ -88,6 +88,8 @@ vfatInitFcb(PVFATFCB Fcb, PUNICODE_STRING NameU)
|
|||
Fcb->DirNameU.MaximumLength = Fcb->DirNameU.Length = 0;
|
||||
Fcb->LongNameU.MaximumLength = Fcb->LongNameU.Length = 0;
|
||||
}
|
||||
RtlZeroMemory(&Fcb->FCBShareAccess, sizeof(SHARE_ACCESS));
|
||||
Fcb->OpenHandleCount = 0;
|
||||
}
|
||||
|
||||
PVFATFCB
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: finfo.c,v 1.36 2004/08/01 21:57:18 navaraf Exp $
|
||||
/* $Id: finfo.c,v 1.37 2004/08/28 22:19:12 navaraf Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -187,6 +187,11 @@ VfatSetDispositionInformation(PFILE_OBJECT FileObject,
|
|||
assert (DeviceExt->FatInfo.BytesPerCluster != 0);
|
||||
assert (FCB != NULL);
|
||||
|
||||
if (FCB->entry.Attrib & FILE_ATTRIBUTE_READONLY)
|
||||
{
|
||||
return STATUS_CANNOT_DELETE;
|
||||
}
|
||||
|
||||
if (vfatFCBIsRoot(FCB) ||
|
||||
(FCB->LongNameU.Length == sizeof(WCHAR) && FCB->LongNameU.Buffer[0] == L'.') ||
|
||||
(FCB->LongNameU.Length == 2 * sizeof(WCHAR) && FCB->LongNameU.Buffer[0] == L'.' && FCB->LongNameU.Buffer[1] == L'.'))
|
||||
|
@ -194,6 +199,7 @@ VfatSetDispositionInformation(PFILE_OBJECT FileObject,
|
|||
// we cannot delete a '.', '..' or the root directory
|
||||
return STATUS_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
if (DispositionInfo->DoDeleteFile)
|
||||
{
|
||||
if (MmFlushImageSection (FileObject->SectionObjectPointer, MmFlushForDelete))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: vfat.h,v 1.67 2004/08/05 02:48:18 navaraf Exp $ */
|
||||
/* $Id: vfat.h,v 1.68 2004/08/28 22:19:12 navaraf Exp $ */
|
||||
|
||||
#include <ddk/ntifs.h>
|
||||
|
||||
|
@ -251,6 +251,9 @@ typedef struct _VFATFCB
|
|||
/* Share access for the file object */
|
||||
SHARE_ACCESS FCBShareAccess;
|
||||
|
||||
/* Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLEANUP */
|
||||
ULONG OpenHandleCount;
|
||||
|
||||
/* Entry into the hash table for the path + long name */
|
||||
HASHENTRY Hash;
|
||||
|
||||
|
|
Loading…
Reference in a new issue