Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
1.8 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. Close.c
  5. Abstract:
  6. This module implements the File Close routine for Raw called by the
  7. dispatch driver.
  8. Author:
  9. David Goebel [DavidGoe] 18-Mar-91
  10. Revision History:
  11. --*/
  12. #include "RawProcs.h"
  13. #ifdef ALLOC_PRAGMA
  14. #pragma alloc_text(PAGE, RawClose)
  15. #endif
  16. NTSTATUS
  17. RawClose (
  18. IN PVCB Vcb,
  19. IN PIRP Irp,
  20. IN PIO_STACK_LOCATION IrpSp
  21. )
  22. /*++
  23. Routine Description:
  24. This is the routine for closing a volume.
  25. Arguments:
  26. Vcb - Supplies the volume being queried.
  27. Irp - Supplies the Irp being processed.
  28. IrpSp - Supplies parameters describing the read
  29. Return Value:
  30. NTSTATUS - The return status for the operation
  31. --*/
  32. {
  33. NTSTATUS Status;
  34. BOOLEAN DeleteVolume = FALSE;
  35. PAGED_CODE();
  36. //
  37. // This is a close operation. If it is the last one, dismount.
  38. //
  39. //
  40. // Skip stream files as they are unopened fileobjects.
  41. // This might be a close from IopInvalidateVolumesForDevice
  42. //
  43. if (IrpSp->FileObject->Flags & FO_STREAM_FILE) {
  44. RawCompleteRequest( Irp, STATUS_SUCCESS );
  45. return STATUS_SUCCESS;
  46. }
  47. Status = KeWaitForSingleObject( &Vcb->Mutex,
  48. Executive,
  49. KernelMode,
  50. FALSE,
  51. (PLARGE_INTEGER) NULL );
  52. ASSERT( NT_SUCCESS( Status ) );
  53. Vcb->OpenCount -= 1;
  54. if (Vcb->OpenCount == 0) {
  55. DeleteVolume = RawCheckForDismount( Vcb, FALSE );
  56. }
  57. if (!DeleteVolume) {
  58. (VOID)KeReleaseMutex( &Vcb->Mutex, FALSE );
  59. }
  60. RawCompleteRequest( Irp, STATUS_SUCCESS );
  61. return STATUS_SUCCESS;
  62. }