ReactOS  0.4.14-dev-49-gfb4591c
fsctl.c File Reference
#include "ext2fs.h"
Include dependency graph for fsctl.c:

Go to the source code of this file.

Functions

VOID Ext2SetVpbFlag (IN PVPB Vpb, IN USHORT Flag)
 
VOID Ext2ClearVpbFlag (IN PVPB Vpb, IN USHORT Flag)
 
BOOLEAN Ext2IsHandleCountZero (IN PEXT2_VCB Vcb)
 
NTSTATUS Ext2LockVcb (IN PEXT2_VCB Vcb, IN PFILE_OBJECT FileObject)
 
NTSTATUS Ext2LockVolume (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2UnlockVcb (IN PEXT2_VCB Vcb, IN PFILE_OBJECT FileObject)
 
NTSTATUS Ext2UnlockVolume (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2InvalidateVolumes (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2AllowExtendedDasdIo (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2OplockRequest (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2IsVolumeDirty (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2QueryExtentMappings (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Fcb, IN PLARGE_INTEGER RequestVbn, OUT PLARGE_INTEGER *pMappedRuns)
 
NTSTATUS Ext2QueryRetrievalPointers (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2GetRetrievalPointers (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2GetRetrievalPointerBase (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2InspectReparseData (IN PREPARSE_DATA_BUFFER RDB, IN ULONG InputBufferLength)
 
VOID Ext2InitializeReparseData (IN PREPARSE_DATA_BUFFER RDB, USHORT PathBufferLength)
 
NTSTATUS Ext2ReadSymlink (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN PVOID Buffer, IN ULONG Size, OUT PULONG BytesRead)
 
NTSTATUS Ext2GetReparsePoint (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2WriteSymlink (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN PVOID Buffer, IN ULONG Size, OUT PULONG BytesWritten)
 
NTSTATUS Ext2SetReparsePoint (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2TruncateSymlink (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, ULONG Size)
 
NTSTATUS Ext2DeleteReparsePoint (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2UserFsRequest (IN PEXT2_IRP_CONTEXT IrpContext)
 
BOOLEAN Ext2IsMediaWriteProtected (IN PEXT2_IRP_CONTEXT IrpContext, IN PDEVICE_OBJECT TargetDevice)
 
NTSTATUS Ext2MountVolume (IN PEXT2_IRP_CONTEXT IrpContext)
 
VOID Ext2VerifyVcb (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
 
NTSTATUS Ext2VerifyVolume (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2IsVolumeMounted (IN PEXT2_IRP_CONTEXT IrpContext)
 
NTSTATUS Ext2DismountVolume (IN PEXT2_IRP_CONTEXT IrpContext)
 
BOOLEAN Ext2CheckDismount (IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bForce)
 
NTSTATUS Ext2PurgeVolume (IN PEXT2_VCB Vcb, IN BOOLEAN FlushBeforePurge)
 
NTSTATUS Ext2PurgeFile (IN PEXT2_FCB Fcb, IN BOOLEAN FlushBeforePurge)
 
NTSTATUS Ext2FileSystemControl (IN PEXT2_IRP_CONTEXT IrpContext)
 

Variables

PEXT2_GLOBAL Ext2Global
 

Function Documentation

◆ Ext2AllowExtendedDasdIo()

NTSTATUS Ext2AllowExtendedDasdIo ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 407 of file fsctl.c.

408 {
410  PEXT2_VCB Vcb;
411  PEXT2_CCB Ccb;
413 
414  IrpSp = IoGetCurrentIrpStackLocation(IrpContext->Irp);
415 
416  Vcb = (PEXT2_VCB) IrpSp->FileObject->FsContext;
417  Ccb = (PEXT2_CCB) IrpSp->FileObject->FsContext2;
418 
419  ASSERT(Vcb != NULL);
420 
421  ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
422  (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
423 
424  ASSERT(IsMounted(Vcb));
425 
426  if (Ccb) {
429  } else {
431  }
432 
433  Ext2CompleteIrpContext(IrpContext, status);
434  return status;
435 }
#define IsMounted(Vcb)
Definition: ext2fs.h:803
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define CCB_ALLOW_EXTENDED_DASD_IO
Definition: ext2fs.h:1028
smooth NULL
Definition: ftsmooth.c:416
#define Vcb
Definition: cdprocs.h:1425
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG Flags
Definition: ntfs.h:532
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
#define SetLongFlag(_F, _SF)
Definition: ext2fs.h:253
struct _EXT2_VCB * PEXT2_VCB
return STATUS_SUCCESS
Definition: btrfs.c:2966
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by Ext2UserFsRequest().

◆ Ext2CheckDismount()

BOOLEAN Ext2CheckDismount ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN BOOLEAN  bForce 
)

Definition at line 2592 of file fsctl.c.

2596 {
2597  KIRQL Irql;
2598  PVPB Vpb = Vcb->Vpb, NewVpb = NULL;
2599  BOOLEAN bDeleted = FALSE, bTearDown = FALSE;
2600  ULONG UnCleanCount = 0;
2601 
2603  if (NewVpb == NULL) {
2604  DEBUG(DL_ERR, ( "Ex2CheckDismount: failed to allocate NewVpb.\n"));
2605  return FALSE;
2606  }
2607  DEBUG(DL_DBG, ("Ext2CheckDismount: NewVpb allocated: %p\n", NewVpb));
2608  INC_MEM_COUNT(PS_VPB, NewVpb, sizeof(VPB));
2609  memset(NewVpb, '_', VPB_SIZE);
2610  RtlZeroMemory(NewVpb, sizeof(VPB));
2611 
2613  &Ext2Global->Resource, TRUE );
2614 
2616  &Vcb->MainResource, TRUE );
2617 
2618  if (IrpContext &&
2619  IrpContext->MajorFunction == IRP_MJ_CREATE &&
2620  IrpContext->RealDevice == Vcb->RealDevice) {
2621  UnCleanCount = 2;
2622  } else {
2623  UnCleanCount = 1;
2624  }
2625 
2627 
2628  DEBUG(DL_DBG, ("Ext2CheckDismount: Vpb %p ioctl=%d Device %p\n",
2629  Vpb, Vpb->ReferenceCount, Vpb->RealDevice));
2630 
2631  if (Vpb->ReferenceCount <= UnCleanCount) {
2632 
2633  if (!IsFlagOn(Vcb->Flags, VCB_DISMOUNT_PENDING)) {
2634 
2635  ClearFlag(Vpb->Flags, VPB_MOUNTED);
2636  ClearFlag(Vpb->Flags, VPB_LOCKED);
2637 
2638  if ((Vcb->RealDevice != Vpb->RealDevice) &&
2639  (Vcb->RealDevice->Vpb == Vpb)) {
2640  SetFlag(Vcb->RealDevice->Flags, DO_DEVICE_INITIALIZING);
2641  SetFlag(Vpb->Flags, VPB_PERSISTENT );
2642  }
2643 
2644  Ext2RemoveVcb(Vcb);
2646  }
2647 
2648  if (Vpb->ReferenceCount) {
2649  bTearDown = TRUE;
2650  } else {
2651  bDeleted = TRUE;
2652  Vpb->DeviceObject = NULL;
2653  }
2654 
2655  DEBUG(DL_DBG, ("Ext2CheckDismount: Vpb: %p bDeleted=%d bTearDown=%d\n",
2656  Vpb, bDeleted, bTearDown));
2657 
2658 
2659  } else if (bForce) {
2660 
2661  DEBUG(DL_DBG, ( "Ext2CheckDismount: New/Old Vpb %p/%p Realdevice = %p\n",
2662  NewVpb, Vcb->Vpb, Vpb->RealDevice));
2663 
2664  /* keep vpb president and later we'll free it */
2665  SetFlag(Vpb->Flags, VPB_PERSISTENT);
2666 
2667  Vcb->Vpb2 = Vcb->Vpb;
2668  NewVpb->Type = IO_TYPE_VPB;
2669  NewVpb->Size = sizeof(VPB);
2670  NewVpb->Flags = Vpb->Flags & VPB_REMOVE_PENDING;
2671  NewVpb->RealDevice = Vpb->RealDevice;
2672  NewVpb->RealDevice->Vpb = NewVpb;
2673  NewVpb = NULL;
2674  ClearFlag(Vpb->Flags, VPB_MOUNTED);
2675  SetLongFlag(Vcb->Flags, VCB_NEW_VPB);
2676  ClearLongFlag(Vcb->Flags, VCB_MOUNTED);
2677  }
2678 
2680 
2681  ExReleaseResourceLite(&Vcb->MainResource);
2683 
2684  if (bTearDown) {
2685  DEBUG(DL_DBG, ( "Ext2CheckDismount: Tearing vcb %p ...\n", Vcb));
2687  }
2688 
2689  if (bDeleted) {
2690  DEBUG(DL_DBG, ( "Ext2CheckDismount: Deleting vcb %p ...\n", Vcb));
2692  }
2693 
2694  if (NewVpb != NULL) {
2695  DEBUG(DL_DBG, ( "Ext2CheckDismount: freeing new Vpb %p\n", NewVpb));
2696  ExFreePoolWithTag(NewVpb, TAG_VPB);
2697  DEC_MEM_COUNT(PS_VPB, NewVpb, sizeof(VPB));
2698  }
2699 
2700  return bDeleted;
2701 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define TRUE
Definition: types.h:120
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define DEC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:599
#define VCB_MOUNTED
Definition: ext2fs.h:781
ERESOURCE Resource
Definition: ext2fs.h:510
VOID Ext2DestroyVcb(IN PEXT2_VCB Vcb)
Definition: memory.c:2813
VOID NTAPI IoAcquireVpbSpinLock(OUT PKIRQL Irql)
Definition: volume.c:1209
PVPB Vpb
Definition: cdstruc.h:517
#define VPB_PERSISTENT
Definition: iotypes.h:1766
_Out_ PKIRQL Irql
Definition: csq.h:179
#define TAG_VPB
Definition: cdprocs.h:98
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define PS_VPB
Definition: common.h:23
#define VPB_LOCKED
Definition: iotypes.h:1765
#define VCB_NEW_VPB
Definition: ext2fs.h:783
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define INC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:598
#define ClearLongFlag(_F, _SF)
Definition: ext2fs.h:254
#define VPB_REMOVE_PENDING
Definition: ntifs_ex.h:428
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
#define Vcb
Definition: cdprocs.h:1425
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define VCB_DISMOUNT_PENDING
Definition: ext2fs.h:782
VOID Ext2TearDownStream(IN PEXT2_VCB Vcb)
Definition: memory.c:2786
#define IO_TYPE_VPB
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
struct _VPB VPB
VOID Ext2RemoveVcb(PEXT2_VCB Vcb)
Definition: memory.c:1939
#define DL_ERR
Definition: ext2fs.h:1397
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define VPB_SIZE
Definition: ext2fs.h:289
#define SetLongFlag(_F, _SF)
Definition: ext2fs.h:253
Definition: iotypes.h:166
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define DL_DBG
Definition: ext2fs.h:1398
#define DEBUG(args)
Definition: rdesktop.h:129
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define memset(x, y, z)
Definition: compat.h:39
#define VPB_MOUNTED
Definition: iotypes.h:1764
VOID NTAPI IoReleaseVpbSpinLock(IN KIRQL Irql)
Definition: volume.c:1220
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1664

Referenced by Ext2DismountVolume(), Ext2ExceptionHandler(), Ext2FreeFcb(), and Ext2InvalidateVolumes().

◆ Ext2ClearVpbFlag()

VOID Ext2ClearVpbFlag ( IN PVPB  Vpb,
IN USHORT  Flag 
)

Definition at line 56 of file fsctl.c.

59 {
60  KIRQL OldIrql;
61 
63  Vpb->Flags &= ~Flag;
65 }
VOID NTAPI IoAcquireVpbSpinLock(OUT PKIRQL Irql)
Definition: volume.c:1209
UCHAR KIRQL
Definition: env_spec_w32.h:591
Definition: xml2sdb.h:79
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
VOID NTAPI IoReleaseVpbSpinLock(IN KIRQL Irql)
Definition: volume.c:1220
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1664

Referenced by Ext2Cleanup(), and Ext2UnlockVcb().

◆ Ext2DeleteReparsePoint()

NTSTATUS Ext2DeleteReparsePoint ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 1784 of file fsctl.c.

1785 {
1786  PIRP Irp = NULL;
1787 
1789 
1790  PEXT2_VCB Vcb = NULL;
1791  PEXT2_FCB Fcb = NULL;
1792  PEXT2_CCB Ccb = NULL;
1793  PEXT2_MCB Mcb = NULL;
1794 
1795  PEXT2_FCB ParentDcb = NULL; /* Dcb of it's current parent */
1796  PEXT2_MCB ParentMcb = NULL;
1797 
1799 
1800  BOOLEAN FcbLockAcquired = FALSE;
1801  BOOLEAN MainResourceAcquired = FALSE;
1802 
1803 
1804  _SEH2_TRY {
1805 
1806  Ccb = IrpContext->Ccb;
1807  ASSERT(Ccb != NULL);
1808  ASSERT((Ccb->Identifier.Type == EXT2CCB) &&
1809  (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
1810  DeviceObject = IrpContext->DeviceObject;
1812  Mcb = IrpContext->Fcb->Mcb;
1813  Irp = IrpContext->Irp;
1814 
1816  FcbLockAcquired = TRUE;
1817 
1818  ParentMcb = Mcb->Parent;
1819  ParentDcb = ParentMcb->Fcb;
1820  if (ParentDcb == NULL) {
1821  ParentDcb = Ext2AllocateFcb(Vcb, ParentMcb);
1822  }
1823  if (ParentDcb) {
1824  Ext2ReferXcb(&ParentDcb->ReferenceCount);
1825  }
1826 
1827  if (!Mcb || !IsInodeSymLink(&Mcb->Inode) ||
1830  _SEH2_LEAVE;
1831  }
1832 
1833  Fcb = Ext2AllocateFcb (Vcb, Mcb);
1834  if (Fcb) {
1835  Ext2ReferXcb(&Fcb->ReferenceCount);
1836  } else {
1838  _SEH2_LEAVE;
1839  }
1840 
1841  if (FcbLockAcquired) {
1842  ExReleaseResourceLite(&Vcb->FcbLock);
1843  FcbLockAcquired = FALSE;
1844  }
1845 
1847  &Fcb->MainResource,
1848  IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT) )) {
1850  _SEH2_LEAVE;
1851  }
1852  MainResourceAcquired = TRUE;
1853 
1854  Status = Ext2TruncateSymlink(IrpContext, Vcb, Mcb, 0);
1855  if (!NT_SUCCESS(Status)) {
1856  _SEH2_LEAVE;
1857  }
1858 
1859  /* inode is to be removed */
1861 
1862  } _SEH2_FINALLY {
1863 
1864  if (FcbLockAcquired) {
1865  ExReleaseResourceLite(&Vcb->FcbLock);
1866  }
1867 
1868  if (MainResourceAcquired) {
1870  }
1871 
1872  if (NT_SUCCESS(Status)) {
1874  IrpContext,
1875  Vcb,
1876  Mcb,
1879 
1880  }
1881 
1882  if (!_SEH2_AbnormalTermination()) {
1884  Status = Ext2QueueRequest(IrpContext);
1885  } else {
1886  Ext2CompleteIrpContext(IrpContext, Status);
1887  }
1888  }
1889 
1890  if (ParentDcb) {
1892  }
1893 
1894  if (Fcb) {
1896  }
1897  } _SEH2_END;
1898 
1899  return Status;
1900 }
#define IsInodeSymLink(I)
Definition: ext2fs.h:281
NTSTATUS Ext2TruncateSymlink(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, ULONG Size)
Definition: fsctl.c:1751
#define TRUE
Definition: types.h:120
#define IRP_CONTEXT_FLAG_WAIT
Definition: cdstruc.h:1221
PEXT2_FCB Fcb
Definition: ext2fs.h:905
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define CCB_DELETE_ON_CLOSE
Definition: ext2fs.h:1026
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB ParentDcb
Definition: create.c:4157
_SEH2_TRY
Definition: create.c:4250
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
NTFSIDENTIFIER Identifier
Definition: ntfs.h:511
NTSTATUS Ext2QueueRequest(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: dispatch.c:150
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
#define FILE_ACTION_MODIFIED
VOID Ext2NotifyReportChange(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Filter, IN ULONG Action)
Definition: dirctl.c:1209
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define _SEH2_AbnormalTermination()
Definition: pseh2_64.h:13
PEXT2_FCB Ext2AllocateFcb(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb)
Definition: memory.c:131
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define Vcb
Definition: cdprocs.h:1425
#define CCB_OPEN_REPARSE_POINT
Definition: ext2fs.h:1025
#define Ext2ReferXcb(_C)
Definition: ext2fs.h:967
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
ULONG Flags
Definition: ntfs.h:532
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
ULONG Type
Definition: ntfs.h:95
#define STATUS_NOT_A_REPARSE_POINT
Definition: ntstatus.h:739
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
ERESOURCE MainResource
Definition: ntfs.h:524
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_SEH2_END
Definition: create.c:4424
#define FILE_NOTIFY_CHANGE_ATTRIBUTES
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
_SEH2_FINALLY
Definition: create.c:4395
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
VOID Ext2ReleaseFcb(IN PEXT2_FCB Fcb)
Definition: memory.c:276
struct _EXT2_VCB * PEXT2_VCB
#define _SEH2_LEAVE
Definition: filesup.c:20
_In_ PFCB Fcb
Definition: cdprocs.h:151
ULONG Size
Definition: ntfs.h:96
#define STATUS_CANT_WAIT
Definition: ntstatus.h:438

Referenced by Ext2UserFsRequest().

◆ Ext2DismountVolume()

NTSTATUS Ext2DismountVolume ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 2521 of file fsctl.c.

2522 {
2525  PEXT2_VCB Vcb = NULL;
2526  BOOLEAN VcbResourceAcquired = FALSE;
2527 
2528  _SEH2_TRY {
2529 
2530  ASSERT(IrpContext != NULL);
2531 
2532  ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
2533  (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
2534 
2535  DeviceObject = IrpContext->DeviceObject;
2536 
2537  //
2538  // This request is not allowed on the main device object
2539  //
2542  _SEH2_LEAVE;
2543  }
2544 
2546 
2547  ASSERT(Vcb != NULL);
2548 
2549  ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
2550  (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
2551 
2552  ASSERT(IsMounted(Vcb));
2553 
2555  &Vcb->MainResource,
2556  TRUE );
2557 
2558  VcbResourceAcquired = TRUE;
2559 
2560  if ( IsFlagOn(Vcb->Flags, VCB_DISMOUNT_PENDING)) {
2562  _SEH2_LEAVE;
2563  }
2564 
2565  Ext2FlushFiles(IrpContext, Vcb, FALSE);
2566  Ext2FlushVolume(IrpContext, Vcb, FALSE);
2567 
2568  ExReleaseResourceLite(&Vcb->MainResource);
2569  VcbResourceAcquired = FALSE;
2570 
2572  Ext2CheckDismount(IrpContext, Vcb, TRUE);
2573 
2574  DEBUG(DL_INF, ( "Ext2Dismount: Volume dismount pending.\n"));
2576 
2577  } _SEH2_FINALLY {
2578 
2579  if (VcbResourceAcquired) {
2580  ExReleaseResourceLite(&Vcb->MainResource);
2581  }
2582 
2583  if (!IrpContext->ExceptionInProgress) {
2584  Ext2CompleteIrpContext(IrpContext, Status);
2585  }
2586  } _SEH2_END;
2587 
2588  return Status;
2589 }
#define IsMounted(Vcb)
Definition: ext2fs.h:803
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
NTSTATUS Ext2FlushVolume(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bShutDown)
Definition: flush.c:39
_SEH2_TRY
Definition: create.c:4250
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
BOOLEAN Ext2CheckDismount(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bForce)
Definition: fsctl.c:2592
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS Ext2PurgeVolume(IN PEXT2_VCB Vcb, IN BOOLEAN FlushBeforePurge)
Definition: fsctl.c:2704
#define DL_INF
Definition: ext2fs.h:1399
#define Vcb
Definition: cdprocs.h:1425
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define VCB_DISMOUNT_PENDING
Definition: ext2fs.h:782
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_SEH2_END
Definition: create.c:4424
NTSTATUS Ext2FlushFiles(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bShutDown)
Definition: flush.c:108
_SEH2_FINALLY
Definition: create.c:4395
#define STATUS_VOLUME_DISMOUNTED
Definition: ntstatus.h:733
#define IsExt2FsDevice(DO)
Definition: ext2fs.h:607
struct _EXT2_VCB * PEXT2_VCB
#define DEBUG(args)
Definition: rdesktop.h:129
#define _SEH2_LEAVE
Definition: filesup.c:20
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by Ext2UserFsRequest().

◆ Ext2FileSystemControl()

NTSTATUS Ext2FileSystemControl ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 2848 of file fsctl.c.

2849 {
2850  NTSTATUS Status;
2851 
2852  ASSERT(IrpContext);
2853 
2854  ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
2855  (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
2856 
2857  switch (IrpContext->MinorFunction) {
2858 
2860  Status = Ext2UserFsRequest(IrpContext);
2861  break;
2862 
2863  case IRP_MN_MOUNT_VOLUME:
2864  Status = Ext2MountVolume(IrpContext);
2865  break;
2866 
2867  case IRP_MN_VERIFY_VOLUME:
2868  Status = Ext2VerifyVolume(IrpContext);
2869  break;
2870 
2871  default:
2872 
2873  DEBUG(DL_ERR, ( "Ext2FilsSystemControl: Invalid Device Request.\n"));
2875  Ext2CompleteIrpContext(IrpContext, Status);
2876  }
2877 
2878  return Status;
2879 }
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
NTSTATUS Ext2VerifyVolume(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:2378
#define IRP_MN_VERIFY_VOLUME
Definition: iotypes.h:4049
NTSTATUS Ext2UserFsRequest(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:1903
#define IRP_MN_MOUNT_VOLUME
Definition: iotypes.h:4048
#define IRP_MN_USER_FS_REQUEST
Definition: iotypes.h:4047
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
Status
Definition: gdiplustypes.h:24
#define DL_ERR
Definition: ext2fs.h:1397
NTSTATUS Ext2MountVolume(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: fsctl.c:2050
#define DEBUG(args)
Definition: rdesktop.h:129

Referenced by Ext2DispatchRequest().

◆ Ext2GetReparsePoint()

NTSTATUS Ext2GetReparsePoint ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 1386 of file fsctl.c.

1387 {
1388  PIRP Irp = NULL;
1391 
1393 
1394  PEXT2_VCB Vcb = NULL;
1395  PEXT2_CCB Ccb = NULL;
1396  PEXT2_MCB Mcb = NULL;
1397 
1399  BOOLEAN MainResourceAcquired = FALSE;
1400 
1403  ULONG BytesRead = 0;
1404 
1406 
1407  UNICODE_STRING UniName;
1409 
1410  PCHAR OemNameBuffer = NULL;
1411  int OemNameLength = 0, i;
1412 
1413  Ccb = IrpContext->Ccb;
1414  ASSERT(Ccb != NULL);
1415  ASSERT((Ccb->Identifier.Type == EXT2CCB) &&
1416  (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
1417  DeviceObject = IrpContext->DeviceObject;
1419  Mcb = IrpContext->Fcb->Mcb;
1420  Irp = IrpContext->Irp;
1422 
1423  _SEH2_TRY {
1424 
1425  if (!Mcb || !IsInodeSymLink(&Mcb->Inode) ||
1428  _SEH2_LEAVE;
1429  }
1430 
1431  OutputBuffer = (PVOID)Irp->AssociatedIrp.SystemBuffer;
1432  OutputBufferLength = IrpSp->Parameters.FileSystemControl.OutputBufferLength;
1433 
1435  if (!RDB) {
1437  _SEH2_LEAVE;
1438  }
1439  if (OutputBufferLength < sizeof(REPARSE_DATA_BUFFER)) {
1441  _SEH2_LEAVE;
1442  }
1443 
1444  OemNameLength = (ULONG)Mcb->Inode.i_size;
1445  if (OemNameLength > USHRT_MAX) {
1447  _SEH2_LEAVE;
1448  }
1449  OemName.Length = (USHORT)OemNameLength;
1450  OemName.MaximumLength = OemNameLength + 1;
1451  OemNameBuffer = OemName.Buffer = Ext2AllocatePool(NonPagedPool,
1452  OemName.MaximumLength,
1453  'NL2E');
1454  if (!OemNameBuffer) {
1456  _SEH2_LEAVE;
1457  }
1458 
1459  Status = Ext2ReadSymlink(IrpContext,
1460  Vcb,
1461  Mcb,
1462  OemNameBuffer,
1463  OemNameLength,
1464  &BytesRead
1465  );
1466  OemName.Buffer[OemName.Length] = '\0';
1467  for (i = 0;i < OemName.Length;i++) {
1468  if (OemName.Buffer[i] == '/') {
1469  OemName.Buffer[i] = '\\';
1470  }
1471  }
1472 
1473  if (OutputBufferLength - FIELD_OFFSET(REPARSE_DATA_BUFFER, SymbolicLinkReparseBuffer.PathBuffer) > USHRT_MAX) {
1474  UniName.Length = USHRT_MAX;
1475  } else {
1476  UniName.Length = (USHORT)OutputBufferLength - FIELD_OFFSET(REPARSE_DATA_BUFFER, SymbolicLinkReparseBuffer.PathBuffer);
1477  }
1478  UniName.MaximumLength = UniName.Length;
1480  Irp->IoStatus.Information = FIELD_OFFSET(REPARSE_DATA_BUFFER, SymbolicLinkReparseBuffer.PathBuffer) + 2 * UniName.Length;
1481  if (UniName.MaximumLength < 2*UniName.Length) {
1483  _SEH2_LEAVE;
1484  }
1485 
1486  Ext2InitializeReparseData(RDB, UniName.Length);
1487  UniName.Buffer = RDB->SymbolicLinkReparseBuffer.PathBuffer;
1488  /*
1489  (PWCHAR)((PUCHAR)&
1490  + RDB->SymbolicLinkReparseBuffer.SubstituteNameOffset);
1491  */
1492  Ext2OEMToUnicode(Vcb, &UniName, &OemName);
1493  RtlMoveMemory( (PUCHAR)RDB->SymbolicLinkReparseBuffer.PathBuffer +
1494  RDB->SymbolicLinkReparseBuffer.SubstituteNameOffset,
1495  UniName.Buffer, UniName.Length);
1496 
1498 
1499  } _SEH2_FINALLY {
1500 
1501  if (OemNameBuffer) {
1502  Ext2FreePool(OemNameBuffer, 'NL2E');
1503  }
1504 
1505  if (!_SEH2_AbnormalTermination()) {
1507  Status = Ext2QueueRequest(IrpContext);
1508  } else {
1509  Ext2CompleteIrpContext(IrpContext, Status);
1510  }
1511  }
1512  } _SEH2_END;
1513 
1514  return Status;
1515 }
signed char * PCHAR
Definition: retypes.h:7
#define IsInodeSymLink(I)
Definition: ext2fs.h:281
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
USHORT MaximumLength
Definition: env_spec_w32.h:370
VOID Ext2InitializeReparseData(IN PREPARSE_DATA_BUFFER RDB, USHORT PathBufferLength)
Definition: fsctl.c:1346
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS Ext2ReadSymlink(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN PVOID Buffer, IN ULONG Size, OUT PULONG BytesRead)
Definition: fsctl.c:1364
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG _In_ ULONG OutputBufferLength
Definition: fltkernel.h:1374
STRING OEM_STRING
Definition: umtypes.h:203
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
_SEH2_TRY
Definition: create.c:4250
#define USHRT_MAX
Definition: limits.h:38
WCHAR PathBuffer[1]
Definition: shellext.h:152
NTFSIDENTIFIER Identifier
Definition: ntfs.h:511
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSTATUS Ext2QueueRequest(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: dispatch.c:150
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define _SEH2_AbnormalTermination()
Definition: pseh2_64.h:13
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID OutputBuffer
Definition: iofuncs.h:713
void * PVOID
Definition: retypes.h:9
ULONG Ext2OEMToUnicodeSize(IN PEXT2_VCB Vcb, IN PANSI_STRING Oem)
Definition: misc.c:183
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define STATUS_PENDING
Definition: ntstatus.h:82
#define Vcb
Definition: cdprocs.h:1425
#define CCB_OPEN_REPARSE_POINT
Definition: ext2fs.h:1025
struct _REPARSE_DATA_BUFFER::@301::@303 SymbolicLinkReparseBuffer
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
ULONG Flags
Definition: ntfs.h:532
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
ULONG Type
Definition: ntfs.h:95
#define STATUS_NOT_A_REPARSE_POINT
Definition: ntstatus.h:739
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
NTSTATUS Ext2OEMToUnicode(IN PEXT2_VCB Vcb, IN OUT PUNICODE_STRING Oem, IN POEM_STRING Unicode)
Definition: misc.c:206
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
_SEH2_END
Definition: create.c:4424
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
unsigned short USHORT
Definition: pedump.c:61
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
_SEH2_FINALLY
Definition: create.c:4395
unsigned int ULONG
Definition: retypes.h:1
VOID Ext2FreePool(IN PVOID P, IN ULONG Tag)
Definition: debug.c:2697
struct _EXT2_VCB * PEXT2_VCB
#define _SEH2_LEAVE
Definition: filesup.c:20
IN PDCB IN POEM_STRING OemName
Definition: fatprocs.h:1294
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2966
PVOID Ext2AllocatePool(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
Definition: debug.c:2684
ULONG Size
Definition: ntfs.h:96
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255
#define STATUS_CANT_WAIT
Definition: ntstatus.h:438

Referenced by Ext2UserFsRequest().

◆ Ext2GetRetrievalPointerBase()

NTSTATUS Ext2GetRetrievalPointerBase ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 1160 of file fsctl.c.

1163 {
1164  PIRP Irp = NULL;
1167 
1170 
1171  PEXT2_VCB Vcb = NULL;
1172  PEXT2_FCB Fcb = NULL;
1173  PEXT2_CCB Ccb = NULL;
1174 
1175  PLARGE_INTEGER FileAreaOffset;
1176 
1177  ULONG OutputSize;
1178 
1180 
1181  BOOLEAN FcbResourceAcquired = FALSE;
1182 
1183  _SEH2_TRY {
1184 
1185  ASSERT(IrpContext);
1186  Irp = IrpContext->Irp;
1187  ASSERT(Irp);
1188 
1191  ASSERT(IrpSp);
1192 
1193  OutputSize = EIrpSp->Parameters.FileSystemControl.OutputBufferLength;
1194 
1195  ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
1196  (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
1197 
1198  DeviceObject = IrpContext->DeviceObject;
1199 
1200  /* This request is not allowed on the main device object */
1203  _SEH2_LEAVE;
1204  }
1205 
1207  ASSERT(Vcb != NULL);
1208  ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
1209  (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
1210  ASSERT(IsMounted(Vcb));
1211 
1212  FileObject = IrpContext->FileObject;
1213  Fcb = (PEXT2_FCB) FileObject->FsContext;
1214 
1215  /* check Fcb is valid or not */
1216  if (Fcb == NULL || Fcb->Identifier.Type == EXT2VCB) {
1218  _SEH2_LEAVE;
1219  }
1220 
1221  ASSERT((Fcb->Identifier.Type == EXT2FCB) &&
1222  (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
1223 
1224  if (IsFlagOn(Fcb->Mcb->Flags, MCB_FILE_DELETED)) {
1226  _SEH2_LEAVE;
1227  }
1228 
1229  Ccb = (PEXT2_CCB) FileObject->FsContext2;
1230  if (Ccb == NULL) {
1232  _SEH2_LEAVE;
1233  }
1234 
1235  ASSERT((Ccb->Identifier.Type == EXT2CCB) &&
1236  (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
1237 
1238  if (OutputSize < sizeof(LARGE_INTEGER)) {
1240  _SEH2_LEAVE;
1241  }
1242 
1244  &Fcb->MainResource, Ext2CanIWait())) {
1246  _SEH2_LEAVE;
1247  }
1248  FcbResourceAcquired = TRUE;
1249 
1250  FileAreaOffset = (PLARGE_INTEGER) Ext2GetUserBuffer(Irp);
1251 
1252  /* probe user buffer */
1253 
1254  _SEH2_TRY {
1255  if (Irp->RequestorMode != KernelMode) {
1256  ProbeForWrite(FileAreaOffset, OutputSize, sizeof(UCHAR));
1257  }
1258 
1260 
1262  } _SEH2_END;
1263 
1264  if (!NT_SUCCESS(Status)) {
1265  _SEH2_LEAVE;
1266  }
1267 
1268  DEBUG(DL_DBG, ("Ext2GetRetrievalPointerBase: FileAreaOffset is 0.\n"));
1269 
1270  FileAreaOffset->QuadPart = 0; // sector offset to the first allocatable unit on the filesystem
1271 
1272  Irp->IoStatus.Information = sizeof(LARGE_INTEGER);
1273 
1274  } _SEH2_FINALLY {
1275 
1276  if (FcbResourceAcquired) {
1278  }
1279 
1280  if (!_SEH2_AbnormalTermination()) {
1282  Status = Ext2QueueRequest(IrpContext);
1283  } else {
1284  Ext2CompleteIrpContext(IrpContext, Status);
1285  }
1286  }
1287  } _SEH2_END;
1288 
1289  return Status;
1290 }
struct _EXT2_FCB * PEXT2_FCB
#define IsMounted(Vcb)
Definition: ext2fs.h:803
#define TRUE
Definition: types.h:120
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
_SEH2_TRY
Definition: create.c:4250
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define MCB_FILE_DELETED
Definition: ext2fs.h:946
NTFSIDENTIFIER Identifier
Definition: ntfs.h:511
NTSTATUS Ext2QueueRequest(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: dispatch.c:150
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
#define STATUS_INVALID_USER_BUFFER
Definition: udferr_usr.h:166
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define _SEH2_AbnormalTermination()
Definition: pseh2_64.h:13
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define STATUS_FILE_DELETED
Definition: udferr_usr.h:172
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define Vcb
Definition: cdprocs.h:1425
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
* PFILE_OBJECT
Definition: iotypes.h:1955
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CD_MCB Mcb
Definition: cdstruc.h:1022
unsigned char UCHAR
Definition: xmlstorage.h:181
union _LARGE_INTEGER LARGE_INTEGER
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
ULONG Type
Definition: ntfs.h:95
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
ERESOURCE MainResource
Definition: ntfs.h:524
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
_SEH2_END
Definition: create.c:4424
#define Ext2CanIWait()
Definition: ext2fs.h:1091
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
_SEH2_FINALLY
Definition: create.c:4395
#define IsExt2FsDevice(DO)
Definition: ext2fs.h:607
unsigned int ULONG
Definition: retypes.h:1
#define DL_DBG
Definition: ext2fs.h:1398
struct _EXT2_VCB * PEXT2_VCB
#define DEBUG(args)
Definition: rdesktop.h:129
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
IO_STACK_LOCATION * PEXTENDED_IO_STACK_LOCATION
Definition: ext2fs.h:174
#define _SEH2_LEAVE
Definition: filesup.c:20
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
_In_ PFCB Fcb
Definition: cdprocs.h:151
return STATUS_SUCCESS
Definition: btrfs.c:2966
struct _EXT2_CCB * PEXT2_CCB
ULONG Size
Definition: ntfs.h:96
union _LARGE_INTEGER * PLARGE_INTEGER
Definition: file.c:85
PVOID Ext2GetUserBuffer(IN PIRP Irp)
Definition: block.c:134
LONGLONG QuadPart
Definition: typedefs.h:112
#define STATUS_CANT_WAIT
Definition: ntstatus.h:438

Referenced by Ext2UserFsRequest().

◆ Ext2GetRetrievalPointers()

NTSTATUS Ext2GetRetrievalPointers ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 911 of file fsctl.c.

914 {
915  PIRP Irp = NULL;
918 
921 
922  PEXT2_VCB Vcb = NULL;
923  PEXT2_FCB Fcb = NULL;
924  PEXT2_CCB Ccb = NULL;
925 
928 
929  PEXT2_EXTENT Chain = NULL;
931 
932  LONGLONG Vbn = 0;
933  ULONG Length = 0;
934  ULONG i = 0;
935 
936  ULONG UsedSize = 0;
937  ULONG InputSize;
938  ULONG OutputSize;
939 
941 
942  BOOLEAN FcbResourceAcquired = FALSE;
943 
944  _SEH2_TRY {
945 
946  ASSERT(IrpContext);
947  Irp = IrpContext->Irp;
948  ASSERT(Irp);
949 
952  ASSERT(IrpSp);
953 
954  InputSize = EIrpSp->Parameters.FileSystemControl.InputBufferLength;
955  OutputSize = EIrpSp->Parameters.FileSystemControl.OutputBufferLength;
956 
957  ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
958  (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
959 
960  DeviceObject = IrpContext->DeviceObject;
961 
962  /* This request is not allowed on the main device object */
965  _SEH2_LEAVE;
966  }
967 
969  ASSERT(Vcb != NULL);
970  ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
971  (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
972  ASSERT(IsMounted(Vcb));
973 
974  FileObject = IrpContext->FileObject;
975  Fcb = (PEXT2_FCB) FileObject->FsContext;
976 
977  /* check Fcb is valid or not */
978  if (Fcb == NULL || Fcb->Identifier.Type == EXT2VCB) {
980  _SEH2_LEAVE;
981  }
982 
983  ASSERT((Fcb->Identifier.Type == EXT2FCB) &&
984  (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
985 
986  if (IsFlagOn(Fcb->Mcb->Flags, MCB_FILE_DELETED)) {
988  _SEH2_LEAVE;
989  }
990 
991  Ccb = (PEXT2_CCB) FileObject->FsContext2;
992  if (Ccb == NULL) {
994  _SEH2_LEAVE;
995  }
996 
997  ASSERT((Ccb->Identifier.Type == EXT2CCB) &&
998  (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
999 
1000  if (InputSize < sizeof(STARTING_VCN_INPUT_BUFFER) ||
1001  OutputSize < sizeof(RETRIEVAL_POINTERS_BUFFER) ) {
1003  _SEH2_LEAVE;
1004  }
1005 
1007  &Fcb->MainResource, Ext2CanIWait())) {
1009  _SEH2_LEAVE;
1010  }
1011  FcbResourceAcquired = TRUE;
1012 
1014  EIrpSp->Parameters.FileSystemControl.Type3InputBuffer;
1016 
1017  /* probe user buffer */
1018 
1019  _SEH2_TRY {
1020  if (Irp->RequestorMode != KernelMode) {
1021  ProbeForRead (SVIB, InputSize, sizeof(UCHAR));
1022  ProbeForWrite(RPSB, OutputSize, sizeof(UCHAR));
1023  }
1026  } _SEH2_END;
1027 
1028  if (!NT_SUCCESS(Status)) {
1029  _SEH2_LEAVE;
1030  }
1031 
1032  UsedSize = FIELD_OFFSET(RETRIEVAL_POINTERS_BUFFER, Extents[0]);
1033 
1034  /* request size beyonds whole file size ? */
1035  DEBUG(DL_DBG, ("Ext2GetRetrievalPointers: Startin from Vbn: %I64xh\n",
1036  SVIB->StartingVcn.QuadPart));
1037  Vbn = (SVIB->StartingVcn.QuadPart << BLOCK_BITS);
1038  if (Vbn >= Fcb->Header.AllocationSize.QuadPart ) {
1040  _SEH2_LEAVE;
1041  }
1042 
1043  /* now building all the request extents */
1044  while (Vbn < Fcb->Header.AllocationSize.QuadPart) {
1045 
1046  ASSERT(Chain == NULL);
1047  Length = 0x80000000; /* 2g bytes */
1048  if (Fcb->Header.AllocationSize.QuadPart < Vbn + Length) {
1049  Length = (ULONG)(Fcb->Header.AllocationSize.QuadPart - Vbn);
1050  }
1051 
1052  /* build extents for sub-range */
1054  IrpContext,
1055  Vcb,
1056  Fcb->Mcb,
1057  Vbn,
1058  Length,
1059  FALSE,
1060  &Chain);
1061 
1062  if (!NT_SUCCESS(Status)) {
1063  DbgBreak();
1064  _SEH2_LEAVE;
1065  }
1066 
1067  /* fill user buffer of RETRIEVAL_POINTERS_BUFFER */
1068  Extent = Chain;
1069  while (Extent) {
1070 
1071  DEBUG(DL_MAP, ("Ext2GetRetrievalPointers: %wZ %d Vbn = %I64xh Lbn = %I64xh\n",
1072  &Fcb->Mcb->FullName, i,
1073  ((Vbn + Extent->Offset) >> BLOCK_BITS),
1074  Extent->Lba));
1075 
1076  RPSB->Extents[i].Lcn.QuadPart = (Extent->Lba >> BLOCK_BITS);
1077  RPSB->Extents[i].NextVcn.QuadPart = ((Vbn + Extent->Offset + Extent->Length) >> BLOCK_BITS);
1078  if (i == 0) {
1079  RPSB->StartingVcn.QuadPart = ((Vbn + Extent->Offset) >> BLOCK_BITS);
1080  } else {
1081  ASSERT(RPSB->Extents[i-1].NextVcn.QuadPart == ((Vbn + Extent->Offset) >> BLOCK_BITS));
1082  }
1083  if (UsedSize + sizeof(RETRIEVAL_POINTERS_BUFFER) > OutputSize) {
1085  _SEH2_LEAVE;
1086  }
1087  UsedSize += sizeof(LARGE_INTEGER) * 2;
1088  Irp->IoStatus.Information = (ULONG_PTR)UsedSize;
1089  RPSB->ExtentCount = ++i;
1090  Extent = Extent->Next;
1091  }
1092 
1093  if (Chain) {
1094  Ext2DestroyExtentChain(Chain);
1095  Chain = NULL;
1096  }
1097 
1098  Vbn = Vbn + Length;
1099  }
1100 
1101 #if 0
1102  {
1103  NTSTATUS _s;
1104  ULONG _i = 0;
1105  LARGE_INTEGER RequestVbn = Fcb->Header.AllocationSize;
1106  PLARGE_INTEGER MappedRuns = NULL;
1107 
1109  IrpContext,
1110  Vcb,
1111  Fcb,
1112  &RequestVbn,
1113  &MappedRuns
1114  );
1115  if (!NT_SUCCESS(_s) || NULL == MappedRuns) {
1116  DbgBreak();
1117  goto exit_to_get_rps;
1118  }
1119 
1120  while (MappedRuns[_i*2 + 0].QuadPart != 0 ||
1121  MappedRuns[_i*2 + 1].QuadPart != 0 ) {
1122  DEBUG(DL_MAP, ("Ext2QueryExtentMappings: %wZ %d Vbn = %I64xh Lbn = %I64xh\n",
1123  &Fcb->Mcb->FullName, _i,
1124  MappedRuns[_i*2 + 0].QuadPart,
1125  MappedRuns[_i*2 + 1].QuadPart));
1126  _i++;
1127  }
1128 
1129 exit_to_get_rps:
1130 
1131  if (MappedRuns) {
1132  Ext2FreePool(MappedRuns, 'RE2E');
1133  }
1134  }
1135 #endif
1136 
1137  } _SEH2_FINALLY {
1138 
1139  if (FcbResourceAcquired) {
1141  }
1142 
1143  if (Chain) {
1144  Ext2DestroyExtentChain(Chain);
1145  }
1146 
1147  if (!_SEH2_AbnormalTermination()) {
1149  Status = Ext2QueueRequest(IrpContext);
1150  } else {
1151  Ext2CompleteIrpContext(IrpContext, Status);
1152  }
1153  }
1154  } _SEH2_END;
1155 
1156  return Status;
1157 }
struct _EXT2_FCB * PEXT2_FCB
#define IsMounted(Vcb)
Definition: ext2fs.h:803
#define TRUE
Definition: types.h:120
struct STARTING_VCN_INPUT_BUFFER * PSTARTING_VCN_INPUT_BUFFER
FSRTL_ADVANCED_FCB_HEADER Header
Definition: cdstruc.h:931
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
uint64 Length
Definition: DriveVolume.h:48
struct RETRIEVAL_POINTERS_BUFFER::@3209 Extents[1]
LARGE_INTEGER StartingVcn
Definition: winioctl.h:545
NTSTATUS Ext2BuildExtents(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONGLONG Offset, IN ULONG Size, IN BOOLEAN bAlloc, OUT PEXT2_EXTENT *Chain)
Definition: memory.c:1207
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
_SEH2_TRY
Definition: create.c:4250
#define STATUS_END_OF_FILE
Definition: shellext.h:62
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define MCB_FILE_DELETED
Definition: ext2fs.h:946
NTFSIDENTIFIER Identifier
Definition: ntfs.h:511
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSTATUS Ext2QueueRequest(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: dispatch.c:150
Definition: Header.h:8
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
#define STATUS_INVALID_USER_BUFFER
Definition: udferr_usr.h:166
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
LARGE_INTEGER StartingVcn
Definition: winioctl.h:527
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
#define _SEH2_AbnormalTermination()
Definition: pseh2_64.h:13
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define STATUS_FILE_DELETED
Definition: udferr_usr.h:172
int64_t LONGLONG
Definition: typedefs.h:66
#define DL_MAP
Definition: ext2fs.h:1407
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
* PFILE_OBJECT
Definition: iotypes.h:1955
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CD_MCB Mcb
Definition: cdstruc.h:1022
unsigned char UCHAR
Definition: xmlstorage.h:181
union _LARGE_INTEGER LARGE_INTEGER
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
ULONG Type
Definition: ntfs.h:95
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
ERESOURCE MainResource
Definition: ntfs.h:524
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
_SEH2_END
Definition: create.c:4424
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
#define Ext2CanIWait()
Definition: ext2fs.h:1091
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
_SEH2_FINALLY
Definition: create.c:4395
_In_ LONGLONG Vbn
Definition: fsrtlfuncs.h:470
NTSTATUS Ext2QueryExtentMappings(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Fcb, IN PLARGE_INTEGER RequestVbn, OUT PLARGE_INTEGER *pMappedRuns)
Definition: fsctl.c:670
#define IsExt2FsDevice(DO)
Definition: ext2fs.h:607
ret QuadPart
Definition: rtlfuncs.h:3091
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
#define DL_DBG
Definition: ext2fs.h:1398
#define DbgBreak()
Definition: ext2fs.h:46
VOID Ext2FreePool(IN PVOID P, IN ULONG Tag)
Definition: debug.c:2697
struct _EXT2_VCB * PEXT2_VCB
#define DEBUG(args)
Definition: rdesktop.h:129
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
VOID Ext2DestroyExtentChain(IN PEXT2_EXTENT Chain)
Definition: memory.c:546
IO_STACK_LOCATION * PEXTENDED_IO_STACK_LOCATION
Definition: ext2fs.h:174
#define _SEH2_LEAVE
Definition: filesup.c:20
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
_In_ PFCB Fcb
Definition: cdprocs.h:151
return STATUS_SUCCESS
Definition: btrfs.c:2966
struct _EXT2_CCB * PEXT2_CCB
ULONG Size
Definition: ntfs.h:96
PVOID Ext2GetUserBuffer(IN PIRP Irp)
Definition: block.c:134
LONGLONG QuadPart
Definition: typedefs.h:112
#define STATUS_CANT_WAIT
Definition: ntstatus.h:438

Referenced by Ext2UserFsRequest().

◆ Ext2InitializeReparseData()

VOID Ext2InitializeReparseData ( IN PREPARSE_DATA_BUFFER  RDB,
USHORT  PathBufferLength 
)

Definition at line 1346 of file fsctl.c.

1347 {
1348  ASSERT(FIELD_OFFSET(REPARSE_DATA_BUFFER, SymbolicLinkReparseBuffer.SubstituteNameOffset) ==
1350  RDB->ReparseTag = IO_REPARSE_TAG_SYMLINK;
1351  RDB->ReparseDataLength = FIELD_OFFSET(REPARSE_DATA_BUFFER, SymbolicLinkReparseBuffer.PathBuffer) -
1352  FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer.DataBuffer) +
1353  PathBufferLength * sizeof(WCHAR);
1354  RDB->Reserved = 0;
1355  RDB->SymbolicLinkReparseBuffer.SubstituteNameOffset = PathBufferLength;
1356  RDB->SymbolicLinkReparseBuffer.SubstituteNameLength = PathBufferLength;
1357  RDB->SymbolicLinkReparseBuffer.PrintNameOffset = 0;
1358  RDB->SymbolicLinkReparseBuffer.PrintNameLength = PathBufferLength;
1359  RDB->SymbolicLinkReparseBuffer.Flags = SYMLINK_FLAG_RELATIVE;
1360  RtlZeroMemory(&RDB->SymbolicLinkReparseBuffer.PathBuffer, PathBufferLength * 2);
1361 }
WCHAR PathBuffer[1]
Definition: shellext.h:152
UCHAR DataBuffer[1]
Definition: shellext.h:164
__wchar_t WCHAR
Definition: xmlstorage.h:180
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define SYMLINK_FLAG_RELATIVE
Definition: shellext.h:169
#define REPARSE_DATA_BUFFER_HEADER_SIZE
Definition: iotypes.h:6843
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
USHORT SubstituteNameOffset
Definition: shellext.h:147
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define IO_REPARSE_TAG_SYMLINK
Definition: iotypes.h:6884

Referenced by Ext2GetReparsePoint().

◆ Ext2InspectReparseData()

NTSTATUS Ext2InspectReparseData ( IN PREPARSE_DATA_BUFFER  RDB,
IN ULONG  InputBufferLength 
)

Definition at line 1293 of file fsctl.c.

1297 {
1299 
1300  if (!RDB) {
1302  goto out;
1303  }
1304 
1305  if (InputBufferLength < sizeof(REPARSE_DATA_BUFFER)) {
1307  goto out;
1308  }
1309 
1310  if (InputBufferLength < RDB->ReparseDataLength) {
1312  goto out;
1313  }
1314 
1315  if (RDB->ReparseTag != IO_REPARSE_TAG_SYMLINK) {
1317  goto out;
1318  }
1319 
1320  if ((PUCHAR)RDB->SymbolicLinkReparseBuffer.PathBuffer
1321  + RDB->SymbolicLinkReparseBuffer.SubstituteNameOffset
1322  + RDB->SymbolicLinkReparseBuffer.SubstituteNameLength
1323  > (PUCHAR)RDB + InputBufferLength ) {
1325  goto out;
1326  }
1327 
1328  if ((PUCHAR)RDB->SymbolicLinkReparseBuffer.PathBuffer
1329  + RDB->SymbolicLinkReparseBuffer.PrintNameOffset
1330  + RDB->SymbolicLinkReparseBuffer.PrintNameLength
1331  > (PUCHAR)RDB + InputBufferLength) {
1333  goto out;
1334  }
1335 
1336  if (RDB->SymbolicLinkReparseBuffer.Flags != SYMLINK_FLAG_RELATIVE) {
1338  goto out;
1339  }
1340 
1341 out:
1342  return Status;
1343 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
static FILE * out
Definition: regtests2xml.c:44
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG InputBufferLength
Definition: fltkernel.h:1372
#define SYMLINK_FLAG_RELATIVE
Definition: shellext.h:169
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define IO_REPARSE_TAG_SYMLINK
Definition: iotypes.h:6884

Referenced by Ext2SetReparsePoint().

◆ Ext2InvalidateVolumes()

NTSTATUS Ext2InvalidateVolumes ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 296 of file fsctl.c.

297 {
299  PIRP Irp;
301 
302 #ifndef __REACTOS__
303  PVPB NewVpb = NULL;
304 #endif
305  HANDLE Handle;
306  PLIST_ENTRY ListEntry;
307 
308  ULONG InputLength = 0;
311  BOOLEAN GlobalResourceAcquired = FALSE;
312 
314 
315  _SEH2_TRY {
316 
317  Irp = IrpContext->Irp;
319 
322  _SEH2_LEAVE;
323  }
324 
325  if (!SeSinglePrivilegeCheck(Privilege, Irp->RequestorMode)) {
327  _SEH2_LEAVE;
328  }
329 
330 
331 #ifndef _GNU_NTIFS_
332  InputLength = IrpSp->Parameters.FileSystemControl.InputBufferLength;
333 #else
334  InputLength = ((PEXTENDED_IO_STACK_LOCATION)(IrpSp))->
335  Parameters.FileSystemControl.InputBufferLength;
336 #endif
337 
338 #if defined(_WIN64)
339  if (IoIs32bitProcess(Irp)) {
340  if (InputLength != sizeof(UINT32)) {
342  _SEH2_LEAVE;
343  }
344  Handle = (HANDLE) LongToHandle( (*(PUINT32)Irp->AssociatedIrp.SystemBuffer) );
345  } else
346 #endif
347  {
348  if (InputLength != sizeof(HANDLE)) {
350  _SEH2_LEAVE;
351  }
352  Handle = *(PHANDLE)Irp->AssociatedIrp.SystemBuffer;
353  }
354 
356  0,
358  KernelMode,
359  (void **)&FileObject,
360  NULL );
361 
362  if (!NT_SUCCESS(Status)) {
363  _SEH2_LEAVE;
364  } else {
365  DeviceObject = FileObject->DeviceObject;
367  }
368 
370  GlobalResourceAcquired = TRUE;
371 
372  ListEntry = Ext2Global->VcbList.Flink;
373  while (ListEntry != &Ext2Global->VcbList) {
374 
375  PEXT2_VCB Vcb = CONTAINING_RECORD(ListEntry, EXT2_VCB, Next);
376  ListEntry = ListEntry->Flink;
377 
378  DEBUG(DL_DBG, ( "Ext2InvalidateVolumes: Vcb=%xh Vcb->Vpb=%xh "
379  "Blink = %p &Vcb->Next = %p\n",
380  Vcb, Vcb->Vpb, ListEntry->Blink, &Vcb->Next));
381 
382  if (Vcb->Vpb && (Vcb->Vpb->RealDevice == DeviceObject)) {
383 
384  DEBUG(DL_DBG, ( "Ext2InvalidateVolumes: Got Vcb=%xh Vcb->Vpb=%xh "
385  "Blink = %p &Vcb->Next = %p\n",
386  Vcb, Vcb->Vpb, ListEntry->Blink, &Vcb->Next));
387  /* dismount the volume */
388  Ext2CheckDismount(IrpContext, Vcb, FALSE);
389  }
390  }
391 
392  } _SEH2_FINALLY {
393 
394  if (GlobalResourceAcquired) {
396  }
397 
398  if (!IrpContext->ExceptionInProgress) {
399  Ext2CompleteIrpContext(IrpContext, Status);
400  }
401  } _SEH2_END;
402 
403  return Status;
404 }
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
#define TRUE
Definition: types.h:120
_In_ PIRP Irp
Definition: csq.h:116
unsigned int * PUINT32
Definition: basetsd.h:127
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _LIST_ENTRY * Blink
Definition: typedefs.h:120
ERESOURCE Resource
Definition: ext2fs.h:510
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
BOOLEAN NTAPI SeSinglePrivilegeCheck(IN LUID PrivilegeValue, IN KPROCESSOR_MODE PreviousMode)
Definition: priv.c:524
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
LIST_ENTRY VcbList
Definition: ext2fs.h:536
_SEH2_TRY
Definition: create.c:4250
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:496
#define SE_TCB_PRIVILEGE
Definition: security.c:661
unsigned int UINT32
BOOLEAN Ext2CheckDismount(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bForce)
Definition: fsctl.c:2592
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
_In_ HANDLE Handle
Definition: extypes.h:390
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
PVOID HANDLE
Definition: typedefs.h:71
PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2867
BOOL Privilege(LPTSTR pszPrivilege, BOOL bEnable)
Definition: user_lib.cpp:531
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
* PFILE_OBJECT
Definition: iotypes.h:1955
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:872
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
#define LongToHandle(h)
Definition: basetsd.h:82
Definition: typedefs.h:117
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
_SEH2_END
Definition: create.c:4424
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
_SEH2_FINALLY
Definition: create.c:4395
Definition: iotypes.h:166
#define IsExt2FsDevice(DO)
Definition: ext2fs.h:607
unsigned int ULONG
Definition: retypes.h:1
#define DL_DBG
Definition: ext2fs.h:1398
#define DEBUG(args)
Definition: rdesktop.h:129
IO_STACK_LOCATION * PEXTENDED_IO_STACK_LOCATION
Definition: ext2fs.h:174
#define _SEH2_LEAVE
Definition: filesup.c:20
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772

Referenced by Ext2UserFsRequest().

◆ Ext2IsHandleCountZero()

BOOLEAN Ext2IsHandleCountZero ( IN PEXT2_VCB  Vcb)

Definition at line 68 of file fsctl.c.

69 {
70  PEXT2_FCB Fcb;
72 
73  for ( List = Vcb->FcbList.Flink;
74  List != &Vcb->FcbList;
75  List = List->Flink ) {
76 
78 
80  (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
81 
82  DEBUG(DL_INF, ( "Ext2IsHandleCountZero: Inode:%xh File:%S OpenHandleCount=%xh\n",
83  Fcb->Inode->i_ino, Fcb->Mcb->ShortName.Buffer, Fcb->OpenHandleCount));
84 
85  if (Fcb->OpenHandleCount) {
86  return FALSE;
87  }
88  }
89 
90  return TRUE;
91 }
#define TRUE
Definition: types.h:120
NTFSIDENTIFIER Identifier
Definition: ntfs.h:511
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
ULONG OpenHandleCount
Definition: ntfs.h:533
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
LIST_ENTRY List
Definition: psmgr.c:57
#define DL_INF
Definition: ext2fs.h:1399
#define Vcb
Definition: cdprocs.h:1425
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CD_MCB Mcb
Definition: cdstruc.h:1022
ULONG Type
Definition: ntfs.h:95
Definition: typedefs.h:117
#define DEBUG(args)
Definition: rdesktop.h:129
_In_ PFCB Fcb
Definition: cdprocs.h:151
ULONG Size
Definition: ntfs.h:96

Referenced by Ext2LockVcb().

◆ Ext2IsMediaWriteProtected()

BOOLEAN Ext2IsMediaWriteProtected ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PDEVICE_OBJECT  TargetDevice 
)

Definition at line 2005 of file fsctl.c.

2009 {
2010  PIRP Irp;
2011  KEVENT Event;
2012  NTSTATUS Status;
2014 
2016 
2018  TargetDevice,
2019  NULL,
2020  0,
2021  NULL,
2022  0,
2023  FALSE,
2024  &Event,
2025  &IoStatus );
2026 
2027  if (Irp == NULL) {
2028  return FALSE;
2029  }
2030 
2032 
2034 
2035  if (Status == STATUS_PENDING) {
2036 
2038  Executive,
2039  KernelMode,
2040  FALSE,
2041  (PLARGE_INTEGER)NULL );
2042 
2043  Status = IoStatus.Status;
2044  }
2045 
2047 }
_Must_inspect_result_ __drv_aliasesMem PDEVICE_OBJECT _In_ PDEVICE_OBJECT TargetDevice
Definition: iofuncs.h:688
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define IOCTL_DISK_IS_WRITABLE
Definition: cdrw_usr.h:172
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1780
#define STATUS_MEDIA_WRITE_PROTECTED
Definition: udferr_usr.h:161
#define STATUS_PENDING
Definition: ntstatus.h:82
#define VOID
Definition: acefi.h:82
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881

Referenced by Ext2InitializeVcb(), and Ext2VerifyVolume().

◆ Ext2IsVolumeDirty()

NTSTATUS Ext2IsVolumeDirty ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 618 of file fsctl.c.

621 {
623  PIRP Irp;
626 
627  _SEH2_TRY {
628 
629  Irp = IrpContext->Irp;
631 
632  //
633  // Get a pointer to the output buffer. Look at the system buffer field in th
634  // irp first. Then the Irp Mdl.
635  //
636 
637  if (Irp->AssociatedIrp.SystemBuffer != NULL) {
638 
639  VolumeState = Irp->AssociatedIrp.SystemBuffer;
640 
641  } else if (Irp->MdlAddress != NULL) {
642 
643  VolumeState = MmGetSystemAddressForMdl( Irp->MdlAddress );
644 
645  } else {
646 
648  _SEH2_LEAVE;
649  }
650 
651  if (IrpSp->Parameters.FileSystemControl.OutputBufferLength < sizeof(ULONG)) {
653  _SEH2_LEAVE;
654  }
655 
656  *VolumeState = 0;
657 
658  } _SEH2_FINALLY {
659 
660  if (!IrpContext->ExceptionInProgress) {
661  Ext2CompleteIrpContext(IrpContext, status);
662  }
663  } _SEH2_END;
664 
665  return status;
666 }
IN PVCB IN FAT_VOLUME_STATE VolumeState
Definition: fatprocs.h:1987
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
_SEH2_TRY
Definition: create.c:4250
#define STATUS_INVALID_USER_BUFFER
Definition: udferr_usr.h:166
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
_SEH2_END
Definition: create.c:4424
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
_SEH2_FINALLY
Definition: create.c:4395
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1
#define MmGetSystemAddressForMdl(Mdl)
IO_STACK_LOCATION * PEXTENDED_IO_STACK_LOCATION
Definition: ext2fs.h:174
#define _SEH2_LEAVE
Definition: filesup.c:20
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2966
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by Ext2UserFsRequest().

◆ Ext2IsVolumeMounted()

NTSTATUS Ext2IsVolumeMounted ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 2494 of file fsctl.c.

2495 {
2497  PEXT2_VCB Vcb = 0;
2499 
2500  ASSERT(IrpContext);
2501 
2502  ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
2503  (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
2504 
2505 
2506  DeviceObject = IrpContext->DeviceObject;
2507 
2509 
2510  ASSERT(IsMounted(Vcb));
2511 
2512  Ext2VerifyVcb (IrpContext, Vcb);
2513 
2514  Ext2CompleteIrpContext(IrpContext, Status);
2515 
2516  return Status;
2517 }
#define IsMounted(Vcb)
Definition: ext2fs.h:803
LONG NTSTATUS
Definition: precomp.h:26
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define Vcb
Definition: cdprocs.h:1425
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
struct _EXT2_VCB * PEXT2_VCB
return STATUS_SUCCESS
Definition: btrfs.c:2966
VOID Ext2VerifyVcb(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: fsctl.c:2277

Referenced by Ext2UserFsRequest().

◆ Ext2LockVcb()

NTSTATUS Ext2LockVcb ( IN PEXT2_VCB  Vcb,
IN PFILE_OBJECT  FileObject 
)

Definition at line 94 of file fsctl.c.

96 {
98 
99  _SEH2_TRY {
100 
101  if (FlagOn(Vcb->Flags, VCB_VOLUME_LOCKED)) {
102  DEBUG(DL_INF, ( "Ext2LockVolume: Volume is already locked.\n"));
104  _SEH2_LEAVE;
105  }
106 
107  if (Vcb->OpenHandleCount > (ULONG)(FileObject ? 1 : 0)) {
108  DEBUG(DL_INF, ( "Ext2LockVcb: There are still opened files.\n"));
109 
111  _SEH2_LEAVE;
112  }
113 
114  if (!Ext2IsHandleCountZero(Vcb)) {
115  DEBUG(DL_INF, ( "Ext2LockVcb: Thare are still opened files.\n"));
116 
118  _SEH2_LEAVE;
119  }
120 
123  Vcb->LockFile = FileObject;
124 
125  DEBUG(DL_INF, ( "Ext2LockVcb: Volume locked.\n"));
126 
127  } _SEH2_FINALLY {
128  // Nothing
129  } _SEH2_END;
130 
131  return Status;
132 }
LONG NTSTATUS
Definition: precomp.h:26
_SEH2_TRY
Definition: create.c:4250
#define VPB_LOCKED
Definition: iotypes.h:1765
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define DL_INF
Definition: ext2fs.h:1399
#define Vcb
Definition: cdprocs.h:1425
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
Status
Definition: gdiplustypes.h:24
_SEH2_END
Definition: create.c:4424
BOOLEAN Ext2IsHandleCountZero(IN PEXT2_VCB Vcb)
Definition: fsctl.c:68
#define SetLongFlag(_F, _SF)
Definition: ext2fs.h:253
_SEH2_FINALLY
Definition: create.c:4395
#define VCB_VOLUME_LOCKED
Definition: ext2fs.h:780
unsigned int ULONG
Definition: retypes.h:1
#define DEBUG(args)
Definition: rdesktop.h:129
VOID Ext2SetVpbFlag(IN PVPB Vpb, IN USHORT Flag)
Definition: fsctl.c:44
#define _SEH2_LEAVE
Definition: filesup.c:20
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by Ext2LockVolume().

◆ Ext2LockVolume()

NTSTATUS Ext2LockVolume ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 136 of file fsctl.c.

137 {
140  PEXT2_VCB Vcb = NULL;
142  BOOLEAN VcbResourceAcquired = FALSE;
143 
144  _SEH2_TRY {
145 
146  ASSERT(IrpContext != NULL);
147 
148  ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
149  (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
150 
151  DeviceObject = IrpContext->DeviceObject;
152 
154 
155  //
156  // This request is not allowed on the main device object
157  //
160  _SEH2_LEAVE;
161  }
162 
164 
165  ASSERT(Vcb != NULL);
166 
167  ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
168  (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
169 
170  ASSERT(IsMounted(Vcb));
171 
172  IrpSp = IoGetCurrentIrpStackLocation(IrpContext->Irp);
173 
174 #if (_WIN32_WINNT >= 0x0500)
176 #endif
178  &Vcb->MainResource,
179  TRUE );
180 
181  VcbResourceAcquired = TRUE;
182 
183  /* flush dirty data before locking the volume */
184  if (!IsVcbReadOnly(Vcb)) {
185  Ext2FlushFiles(IrpContext, Vcb, FALSE);
186  Ext2FlushVolume(IrpContext, Vcb, FALSE);
187  }
188 
190 
191  } _SEH2_FINALLY {
192 
193  if (VcbResourceAcquired) {
194  ExReleaseResourceLite(&Vcb->MainResource);
195  }
196 
197  if (!IrpContext->ExceptionInProgress) {
198  Ext2CompleteIrpContext(IrpContext, Status);
199  }
200  } _SEH2_END;
201 
202  return Status;
203 }
#define IsMounted(Vcb)
Definition: ext2fs.h:803
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS Ext2FlushVolume(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bShutDown)
Definition: flush.c:39
_SEH2_TRY
Definition: create.c:4250
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI CcWaitForCurrentLazyWriterActivity(VOID)
Definition: lazyrite.c:30
#define IsVcbReadOnly(Vcb)
Definition: ext2fs.h:805
#define Vcb
Definition: cdprocs.h:1425
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
_SEH2_END
Definition: create.c:4424
NTSTATUS Ext2FlushFiles(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN BOOLEAN bShutDown)
Definition: flush.c:108
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
_SEH2_FINALLY
Definition: create.c:4395
#define IsExt2FsDevice(DO)
Definition: ext2fs.h:607
struct _EXT2_VCB * PEXT2_VCB
NTSTATUS Ext2LockVcb(IN PEXT2_VCB Vcb, IN PFILE_OBJECT FileObject)
Definition: fsctl.c:94
#define _SEH2_LEAVE
Definition: filesup.c:20

Referenced by Ext2Format(), and Ext2UserFsRequest().

◆ Ext2MountVolume()

NTSTATUS Ext2MountVolume ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 2050 of file fsctl.c.

2051 {
2053  BOOLEAN GlobalDataResourceAcquired = FALSE;
2054  PIRP Irp;
2055  PIO_STACK_LOCATION IoStackLocation;
2058  PDEVICE_OBJECT VolumeDeviceObject = NULL;
2059  PEXT2_VCB Vcb = NULL, OldVcb = NULL;
2060  PVPB OldVpb = NULL, Vpb = NULL;
2061  PEXT2_SUPER_BLOCK Ext2Sb = NULL;
2062  ULONG dwBytes;
2063  DISK_GEOMETRY DiskGeometry;
2064 
2065  _SEH2_TRY {
2066 
2067  ASSERT(IrpContext != NULL);
2068  ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
2069  (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
2070 
2071  MainDeviceObject = IrpContext->DeviceObject;
2072 
2073  //
2074  // Make sure we can wait.
2075  //
2076 
2077  SetFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT);
2078 
2079  //
2080  // This request is only allowed on the main device object
2081  //
2084  _SEH2_LEAVE;
2085  }
2086 
2089  _SEH2_LEAVE;
2090  }
2091 
2092 #if 0
2093  if (IrpContext->RealDevice->Size >= sizeof(ULONG) + sizeof(DEVICE_OBJECT) &&
2094  *((PULONG)IrpContext->RealDevice->DeviceExtension) == 'DSSA') {
2095  } else {
2097  _SEH2_LEAVE;
2098  }
2099 #endif
2100 
2101  Irp = IrpContext->Irp;
2102  IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
2104  IoStackLocation->Parameters.MountVolume.DeviceObject;
2105 
2106  dwBytes = sizeof(DISK_GEOMETRY);
2110  NULL,
2111  0,
2112  &DiskGeometry,
2113  &dwBytes );
2114 
2115  if (!NT_SUCCESS(Status)) {
2116  _SEH2_LEAVE;
2117  }
2118 
2120  MainDeviceObject->DriverObject,
2121  sizeof(EXT2_VCB),
2122  NULL,
2124  0,
2125  FALSE,
2126  &VolumeDeviceObject );
2127 
2128  if (!NT_SUCCESS(Status)) {
2129  _SEH2_LEAVE;
2130  }
2131  INC_MEM_COUNT(PS_VCB, VolumeDeviceObject, sizeof(EXT2_VCB));
2132 
2133 #ifdef _PNP_POWER_
2134  /* don't care about power management requests */
2135  VolumeDeviceObject->DeviceObjectExtension->PowerControlNeeded = FALSE;
2136 #endif
2137 
2138  VolumeDeviceObject->StackSize = (CCHAR)(TargetDeviceObject->StackSize + 1);
2139  ClearFlag(VolumeDeviceObject->Flags, DO_DEVICE_INITIALIZING);
2140 
2141 /*
2142  These are for buffer-address alignment requirements.
2143  Never do this check, unless you want fail user requests :)
2144 
2145  if (TargetDeviceObject->AlignmentRequirement >
2146  VolumeDeviceObject->AlignmentRequirement) {
2147 
2148  VolumeDeviceObject->AlignmentRequirement =
2149  TargetDeviceObject->AlignmentRequirement;
2150  }
2151 
2152  if (DiskGeometry.BytesPerSector - 1 >
2153  VolumeDeviceObject->AlignmentRequirement) {
2154  VolumeDeviceObject->AlignmentRequirement =
2155  DiskGeometry.BytesPerSector - 1;
2156  TargetDeviceObject->AlignmentRequirement =
2157  DiskGeometry.BytesPerSector - 1;
2158  }
2159 */
2160  (IoStackLocation->Parameters.MountVolume.Vpb)->DeviceObject =
2161  VolumeDeviceObject;
2162  Vpb = IoStackLocation->Parameters.MountVolume.Vpb;
2163 
2164  Vcb = (PEXT2_VCB) VolumeDeviceObject->DeviceExtension;
2165 
2166  RtlZeroMemory(Vcb, sizeof(EXT2_VCB));
2167  Vcb->Identifier.Type = EXT2VCB;
2168  Vcb->Identifier.Size = sizeof(EXT2_VCB);
2169  Vcb->TargetDeviceObject = TargetDeviceObject;
2170  Vcb->DiskGeometry = DiskGeometry;
2171  InitializeListHead(&Vcb->Next);
2172 
2173  Status = Ext2LoadSuper(Vcb, FALSE, &Ext2Sb);
2174  if (!NT_SUCCESS(Status)) {
2175  Vcb = NULL;
2177  _SEH2_LEAVE;
2178  }
2179  ASSERT (NULL != Ext2Sb);
2180 
2181  /* check Linux Ext2/Ext3 volume magic */
2182  if (Ext2Sb->s_magic == EXT2_SUPER_MAGIC) {
2183  DEBUG(DL_INF, ( "Volume of ext2 file system is found.\n"));
2184  } else {
2186  Vcb = NULL;
2187  _SEH2_LEAVE;
2188  }
2189 
2190  DEBUG(DL_DBG, ("Ext2MountVolume: DevObject=%p Vcb=%p\n", VolumeDeviceObject, Vcb));
2191 
2192  /* initialize Vcb structure */
2193  Status = Ext2InitializeVcb( IrpContext, Vcb, Ext2Sb,
2195  VolumeDeviceObject, Vpb);
2196 
2197  if (NT_SUCCESS(Status)) {
2198 
2199  PLIST_ENTRY List;
2200 
2202  GlobalDataResourceAcquired = TRUE;
2203 
2204  for (List = Ext2Global->VcbList.Flink;
2205  List != &Ext2Global->VcbList;
2206  List = List->Flink) {
2207 
2208  OldVcb = CONTAINING_RECORD(List, EXT2_VCB, Next);
2209  OldVpb = OldVcb->Vpb;
2210 
2211  /* in case we are already in the queue, should not happen */
2212  if (OldVpb == Vpb) {
2213  continue;
2214  }
2215 
2216  if ( (OldVpb->SerialNumber == Vpb->SerialNumber) &&
2217  (!IsMounted(OldVcb)) && (IsFlagOn(OldVcb->Flags, VCB_NEW_VPB)) &&
2218  (OldVpb->RealDevice == TargetDeviceObject) &&
2219  (OldVpb->VolumeLabelLength == Vpb->VolumeLabelLength) &&
2220  (RtlEqualMemory(&OldVpb->VolumeLabel[0],
2221  &Vpb->VolumeLabel[0],
2222  Vpb->VolumeLabelLength)) &&
2223  (RtlEqualMemory(&OldVcb->SuperBlock->s_uuid[0],
2224  &Vcb->SuperBlock->s_uuid[0], 16)) ) {
2225  ClearFlag(OldVcb->Flags, VCB_MOUNTED);
2226  }
2227  }
2228 
2229  SetLongFlag(Vcb->Flags, VCB_MOUNTED);
2230  SetFlag(Vcb->Vpb->Flags, VPB_MOUNTED);
2231  Ext2InsertVcb(Vcb);
2232  Vcb = NULL;
2233  Vpb = NULL;
2235 
2236  } else {
2237 
2238  Vcb = NULL;
2239  }
2240 
2241  } _SEH2_FINALLY {
2242 
2243  if (GlobalDataResourceAcquired) {
2245  }
2246 
2247  if (!NT_SUCCESS(Status)) {
2248 
2249  if (!NT_SUCCESS(Status)) {
2250  if ( Vpb != NULL ) {
2251  Vpb->DeviceObject = NULL;
2252  }
2253  }
2254 
2255  if (Vcb) {
2257  } else {
2258  if (Ext2Sb) {
2259  Ext2FreePool(Ext2Sb, EXT2_SB_MAGIC);
2260  }
2261  if (VolumeDeviceObject) {
2262  IoDeleteDevice(VolumeDeviceObject);
2263  DEC_MEM_COUNT(PS_VCB, VolumeDeviceObject, sizeof(EXT2_VCB));
2264  }
2265  }
2266  }
2267 
2268  if (!IrpContext->ExceptionInProgress) {
2269  Ext2CompleteIrpContext(IrpContext, Status);
2270  }
2271  } _SEH2_END;
2272 
2273  return Status;
2274 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
NTSTATUS Ext2LoadSuper(IN PEXT2_VCB Vcb, IN BOOLEAN bVerify, OUT PEXT2_SUPER_BLOCK *Sb)
Definition: generic.c:25
#define IsMounted(Vcb)
Definition: ext2fs.h:803
#define TRUE
Definition: types.h:120
#define IRP_CONTEXT_FLAG_WAIT
Definition: cdstruc.h:1221
WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH/sizeof(WCHAR)]
Definition: iotypes.h:175
NTSTATUS Ext2DiskIoControl(IN PDEVICE_OBJECT DeviceOjbect, IN ULONG IoctlCode, IN PVOID InputBuffer, IN ULONG InputBufferSize, IN OUT PVOID OutputBuffer, IN OUT PULONG OutputBufferSize)
Definition: block.c:589
#define DEC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:599
_In_ PIRP Irp
Definition: csq.h:116
#define VCB_MOUNTED
Definition: ext2fs.h:781
ERESOURCE Resource
Definition: ext2fs.h:510
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
VOID Ext2DestroyVcb(IN PEXT2_VCB Vcb)
Definition: memory.c:2813
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
LIST_ENTRY VcbList
Definition: ext2fs.h:536
_SEH2_TRY
Definition: create.c:4250
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define EXT2_SUPER_MAGIC
Definition: ext2fs.h:344
#define STATUS_UNRECOGNIZED_VOLUME
Definition: udferr_usr.h:173
#define VCB_NEW_VPB
Definition: ext2fs.h:783
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define INC_MEM_COUNT(_i, _p, _s)
Definition: ext2fs.h:598
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define FILE_DEVICE_DISK_FILE_SYSTEM
Definition: winioctl.h:113
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
NTSYSAPI ULONG NTAPI RtlEqualMemory(CONST VOID *Source1, CONST VOID *Source2, ULONG Length)
LIST_ENTRY List
Definition: psmgr.c:57
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DL_INF
Definition: ext2fs.h:1399
char CCHAR
Definition: typedefs.h:50
struct _DEVICE_OBJECT * RealDevice
Definition: iotypes.h:172
#define Vcb
Definition: cdprocs.h:1425
struct _EXT2_VCB EXT2_VCB
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
VOID Ext2InsertVcb(PEXT2_VCB Vcb)
Definition: memory.c:1931
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
Definition: typedefs.h:117
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
#define PS_VCB
Definition: common.h:17
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
struct _DISK_GEOMETRY DISK_GEOMETRY
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_SEH2_END
Definition: create.c:4424
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
static PDEVICE_OBJECT MainDeviceObject
#define SetLongFlag(_F, _SF)
Definition: ext2fs.h:253
_SEH2_FINALLY
Definition: create.c:4395
unsigned int * PULONG
Definition: retypes.h:1
#define EXT2_UNLOAD_PENDING
Definition: ext2fs.h:581
Definition: iotypes.h:166
USHORT VolumeLabelLength
Definition: iotypes.h:170
#define IsExt2FsDevice(DO)
Definition: ext2fs.h:607
NTSTATUS Ext2InitializeVcb(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_SUPER_BLOCK Ext2Sb, PDEVICE_OBJECT TargetDevice, PDEVICE_OBJECT VolumeDevice, PVPB Vpb)
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
#define EXT2_SB_MAGIC
Definition: ext2fs.h:297
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define DL_DBG
Definition: ext2fs.h:1398
VOID Ext2FreePool(IN PVOID P, IN ULONG Tag)
Definition: debug.c:2697
struct _EXT2_VCB * PEXT2_VCB
#define DEBUG(args)
Definition: rdesktop.h:129
ULONG SerialNumber
Definition: iotypes.h:173
#define _SEH2_LEAVE
Definition: filesup.c:20
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
IN OUT PVCB IN PDEVICE_OBJECT TargetDeviceObject
Definition: fatprocs.h:1664
#define VPB_MOUNTED
Definition: iotypes.h:1764
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1664
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
Definition: cdrw_usr.h:169
ULONG Flags
Definition: ext2fs.h:514

Referenced by Ext2FileSystemControl().

◆ Ext2OplockRequest()

NTSTATUS Ext2OplockRequest ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 451 of file fsctl.c.

454 {
456 
457  ULONG FsCtrlCode;
460 
461  PIRP Irp = NULL;
464 
465  PEXT2_VCB Vcb = NULL;
466  PEXT2_FCB Fcb = NULL;
467  PEXT2_CCB Ccb = NULL;
468 
469  ULONG OplockCount = 0;
470 
471  BOOLEAN VcbResourceAcquired = FALSE;
472  BOOLEAN FcbResourceAcquired = FALSE;
473 
474  ASSERT(IrpContext);
475 
476  _SEH2_TRY {
477 
478  Irp = IrpContext->Irp;
479  ASSERT(Irp);
480 
482  ASSERT(IrpSp);
484 
485  ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
486  (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
487 
488  DeviceObject = IrpContext->DeviceObject;
489 
490  //
491  // This request is not allowed on the main device object
492  //
495  _SEH2_LEAVE;
496  }
497 
499 
500  ASSERT(Vcb != NULL);
501 
502  ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
503  (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
504 
505  ASSERT(IsMounted(Vcb));
506 
507  FileObject = IrpContext->FileObject;
508 
509  Fcb = (PEXT2_FCB) FileObject->FsContext;
510 
511  //
512  // This request is not allowed on volumes
513  //
514 
515  if (Fcb == NULL || Fcb->Identifier.Type == EXT2VCB) {
517  _SEH2_LEAVE;
518  }
519 
520  ASSERT((Fcb->Identifier.Type == EXT2FCB) &&
521  (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
522 
523  if (IsFlagOn(Fcb->Mcb->Flags, MCB_FILE_DELETED)) {
525  _SEH2_LEAVE;
526  }
527 
528  Ccb = (PEXT2_CCB) FileObject->FsContext2;
529  if (Ccb == NULL) {
531  _SEH2_LEAVE;
532  }
533 
534 
535  ASSERT((Ccb->Identifier.Type == EXT2CCB) &&
536  (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
537 
538  FsCtrlCode = EIrpSp->Parameters.FileSystemControl.FsControlCode;
539 
540  switch (FsCtrlCode) {
541 
545 
546  VcbResourceAcquired =
548  &Vcb->MainResource,
549  IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT) );
550 
551  ClearFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT);
552 
553  FcbResourceAcquired =
555  &Fcb->MainResource,
556  IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT));
557 
558  if (FsCtrlCode == FSCTL_REQUEST_OPLOCK_LEVEL_2) {
559  OplockCount = (ULONG) FsRtlAreThereCurrentFileLocks(&Fcb->FileLockAnchor);
560  } else {
561  OplockCount = Fcb->OpenHandleCount;
562  }
563 
564  break;
565 
570 
571  FcbResourceAcquired =
573  &Fcb->MainResource,
574  IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT));
575 
576  break;
577 
578  default:
579 
580  Ext2BugCheck(EXT2_BUGCHK_FSCTL, FsCtrlCode, 0, 0);
581  }
582 
583 
584  //
585  // Call the FsRtl routine to grant/acknowledge oplock.
586  //
587 
588  Status = FsRtlOplockFsctrl( &Fcb->Oplock,
589  Irp,
590  OplockCount );
591 
592  //
593  // Set the flag indicating if Fast I/O is possible
594  //
595 
596  Fcb->Header.IsFastIoPossible = Ext2IsFastIoPossible(Fcb);
597  IrpContext->Irp = NULL;
598 
599  } _SEH2_FINALLY {
600 
601  if (FcbResourceAcquired) {
603  }
604 
605  if (VcbResourceAcquired) {
606  ExReleaseResourceLite(&Vcb->MainResource);
607  }
608 
609  if (!_SEH2_AbnormalTermination()) {
610  Ext2CompleteIrpContext(IrpContext, Status);
611  }
612  } _SEH2_END;
613 
614  return Status;
615 }
struct _EXT2_FCB * PEXT2_FCB
#define IsMounted(Vcb)
Definition: ext2fs.h:803
#define IRP_CONTEXT_FLAG_WAIT
Definition: cdstruc.h:1221
FSRTL_ADVANCED_FCB_HEADER Header
Definition: cdstruc.h:931
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define FSCTL_OPLOCK_BREAK_ACK_NO_2
Definition: nt_native.h:846
#define FSCTL_OPBATCH_ACK_CLOSE_PENDING
Definition: nt_native.h:830
#define FSCTL_REQUEST_BATCH_OPLOCK
Definition: nt_native.h:828
_SEH2_TRY
Definition: create.c:4250
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
NTSTATUS NTAPI FsRtlOplockFsctrl(IN POPLOCK Oplock, IN PIRP Irp, IN ULONG OpenCount)
Definition: oplock.c:1432
#define MCB_FILE_DELETED
Definition: ext2fs.h:946
NTFSIDENTIFIER Identifier
Definition: ntfs.h:511
#define FSCTL_OPLOCK_BREAK_NOTIFY
Definition: nt_native.h:831
#define Ext2BugCheck(A, B, C, D)
Definition: ext2fs.h:335
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define _SEH2_AbnormalTermination()
Definition: pseh2_64.h:13
FAST_IO_POSSIBLE Ext2IsFastIoPossible(IN PEXT2_FCB Fcb)
Definition: fastio.c:38
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define FsRtlAreThereCurrentFileLocks(FL)
Definition: fsrtlfuncs.h:1584
#define STATUS_FILE_DELETED
Definition: udferr_usr.h:172
#define FSCTL_OPLOCK_BREAK_ACKNOWLEDGE
Definition: nt_native.h:829
ULONG OpenHandleCount
Definition: ntfs.h:533
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define FSCTL_REQUEST_OPLOCK_LEVEL_2
Definition: nt_native.h:827
#define Vcb
Definition: cdprocs.h:1425
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
* PFILE_OBJECT
Definition: iotypes.h:1955
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CD_MCB Mcb
Definition: cdstruc.h:1022
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
ULONG Type
Definition: ntfs.h:95
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
#define EXT2_BUGCHK_FSCTL
Definition: ext2fs.h:323
#define FSCTL_REQUEST_OPLOCK_LEVEL_1
Definition: nt_native.h:826
ERESOURCE MainResource
Definition: ntfs.h:524
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
_SEH2_END
Definition: create.c:4424
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
_SEH2_FINALLY
Definition: create.c:4395
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
#define IsExt2FsDevice(DO)
Definition: ext2fs.h:607
unsigned int ULONG
Definition: retypes.h:1
struct _EXT2_VCB * PEXT2_VCB
IO_STACK_LOCATION * PEXTENDED_IO_STACK_LOCATION
Definition: ext2fs.h:174
#define _SEH2_LEAVE
Definition: filesup.c:20
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
_In_ PFCB Fcb
Definition: cdprocs.h:151
struct _EXT2_CCB * PEXT2_CCB
ULONG Size
Definition: ntfs.h:96

Referenced by Ext2UserFsRequest().

◆ Ext2PurgeFile()

NTSTATUS Ext2PurgeFile ( IN PEXT2_FCB  Fcb,
IN BOOLEAN  FlushBeforePurge 
)

Definition at line 2811 of file fsctl.c.

2813 {
2815 
2816  ASSERT(Fcb != NULL);
2817 
2818  ASSERT((Fcb->Identifier.Type == EXT2FCB) &&
2819  (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
2820 
2821 
2822  if (!IsVcbReadOnly(Fcb->Vcb) && FlushBeforePurge) {
2823  DEBUG(DL_INF, ( "Ext2PurgeFile: CcFlushCache on %wZ.\n",
2824  &Fcb->Mcb->FullName));
2827  CcFlushCache(&Fcb->SectionObject, NULL, 0, &IoStatus);
2829  }
2830 
2831  if (Fcb->SectionObject.ImageSectionObject) {
2832  DEBUG(DL_INF, ( "Ext2PurgeFile: MmFlushImageSection on %wZ.\n",
2833  &Fcb->Mcb->FullName));
2834  MmFlushImageSection(&Fcb->SectionObject, MmFlushForWrite);
2835  }
2836 
2837  if (Fcb->SectionObject.DataSectionObject) {
2838  DEBUG(DL_INF, ( "Ext2PurgeFile: CcPurgeCacheSection on %wZ.\n",
2839  &Fcb->Mcb->FullName));
2840  CcPurgeCacheSection(&Fcb->SectionObject, NULL, 0, FALSE);
2841  }
2842 
2843  return STATUS_SUCCESS;
2844 }
BOOLEAN NTAPI CcPurgeCacheSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN UninitializeCacheMaps)
Definition: fssup.c:384
#define TRUE
Definition: types.h:120
VOID NTAPI CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, OUT OPTIONAL PIO_STATUS_BLOCK IoStatus)
Definition: cachesub.c:222
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
NTFSIDENTIFIER Identifier
Definition: ntfs.h:511
smooth NULL
Definition: ftsmooth.c:416
#define DL_INF
Definition: ext2fs.h:1399
BOOLEAN NTAPI MmFlushImageSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN MMFLUSH_TYPE FlushType)
Definition: section.c:4798
#define IsVcbReadOnly(Vcb)
Definition: ext2fs.h:805
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG Flags
Definition: ntfs.h:532
CD_MCB Mcb
Definition: cdstruc.h:1022
ULONG Type
Definition: ntfs.h:95
#define FCB_FILE_MODIFIED
Definition: ext2fs.h:873
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
BOOLEAN NTAPI ExAcquireSharedStarveExclusive(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:1063
ERESOURCE PagingIoResource
Definition: ntfs.h:523
PVCB Vcb
Definition: cdstruc.h:939
#define DEBUG(args)
Definition: rdesktop.h:129
_In_ PFCB Fcb
Definition: cdprocs.h:151
return STATUS_SUCCESS
Definition: btrfs.c:2966
ULONG Size
Definition: ntfs.h:96

Referenced by Ext2PurgeVolume().

◆ Ext2PurgeVolume()

NTSTATUS Ext2PurgeVolume ( IN PEXT2_VCB  Vcb,
IN BOOLEAN  FlushBeforePurge 
)

Definition at line 2704 of file fsctl.c.

2706 {
2707  PEXT2_FCB Fcb;
2708  LIST_ENTRY List, *Next;
2709 
2710  BOOLEAN VcbResourceAcquired = FALSE;
2711  BOOLEAN FcbResourceAcquired = FALSE;
2712  BOOLEAN gdResourceAcquired = FALSE;
2713 
2714  _SEH2_TRY {
2715 
2716  ASSERT(Vcb != NULL);
2717  ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
2718  (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
2719 
2720  ExAcquireResourceExclusiveLite(&Vcb->MainResource, TRUE);
2721  VcbResourceAcquired = TRUE;
2722 
2723  if (IsVcbReadOnly(Vcb)) {
2724  FlushBeforePurge = FALSE;
2725  }
2726 
2728 
2730  FcbResourceAcquired = TRUE;
2731 
2732  while (!IsListEmpty(&Vcb->FcbList)) {
2733 
2734  Next = RemoveHeadList(&Vcb->FcbList);
2735  Fcb = CONTAINING_RECORD(Next, EXT2_FCB, Next);
2736 
2737  DEBUG(DL_INF, ( "Ext2PurgeVolume: %wZ refercount=%xh\n",
2738  &Fcb->Mcb->FullName, Fcb->ReferenceCount));
2739  InsertTailList(&List, &Fcb->Next);
2740  }
2741 
2742  while (!IsListEmpty(&List)) {
2743 
2744  Next = RemoveHeadList(&List);
2745  Fcb = CONTAINING_RECORD(Next, EXT2_FCB, Next);
2746 
2748  &Fcb->MainResource,
2749  TRUE )) {
2750 
2751  Ext2PurgeFile(Fcb, FlushBeforePurge);
2752 
2753  if (Fcb->ReferenceCount <= 1) {
2754  Fcb->TsDrop.QuadPart = 0;
2755  InsertHeadList(&Vcb->FcbList, &Fcb->Next);
2756  } else {
2757  InsertTailList(&Vcb->FcbList, &Fcb->Next);
2758  }
2760  }
2761  }
2762 
2763  if (FcbResourceAcquired) {
2764  ExReleaseResourceLite(&Vcb->FcbLock);
2765  FcbResourceAcquired = FALSE;
2766  }
2767 
2768  /* acquire bd lock to avoid bh creation */
2769  ExAcquireResourceExclusiveLite(&Vcb->sbi.s_gd_lock, TRUE);
2770  gdResourceAcquired = TRUE;
2771 
2772  /* discard buffer_headers for group_desc */
2773  Ext2DropBH(Vcb);
2774 
2775  if (FlushBeforePurge) {
2776  ExAcquireSharedStarveExclusive(&Vcb->PagingIoResource, TRUE);
2777  ExReleaseResourceLite(&Vcb->PagingIoResource);
2778 
2779  CcFlushCache(&Vcb->SectionObject, NULL, 0, NULL);
2780  }
2781 
2782  if (Vcb->SectionObject.ImageSectionObject) {
2783  MmFlushImageSection(&Vcb->SectionObject, MmFlushForWrite);
2784  }
2785 
2786  if (Vcb->SectionObject.DataSectionObject) {
2787  CcPurgeCacheSection(&Vcb->SectionObject, NULL, 0, FALSE);
2788  }
2789 
2790  DEBUG(DL_INF, ( "Ext2PurgeVolume: Volume flushed and purged.\n"));
2791 
2792  } _SEH2_FINALLY {
2793 
2794  if (gdResourceAcquired) {
2795  ExReleaseResourceLite(&Vcb->sbi.s_gd_lock);
2796  }
2797 
2798  if (FcbResourceAcquired) {
2799  ExReleaseResourceLite(&Vcb->FcbLock);
2800  }
2801 
2802  if (VcbResourceAcquired) {
2803  ExReleaseResourceLite(&Vcb->MainResource);
2804  }
2805  } _SEH2_END;
2806 
2807  return STATUS_SUCCESS;
2808 }
BOOLEAN NTAPI CcPurgeCacheSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN UninitializeCacheMaps)
Definition: fssup.c:384
#define TRUE
Definition: types.h:120
VOID NTAPI CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, OUT OPTIONAL PIO_STATUS_BLOCK IoStatus)
Definition: cachesub.c:222
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
NTSTATUS Ext2PurgeFile(IN PEXT2_FCB Fcb, IN BOOLEAN FlushBeforePurge)
Definition: fsctl.c:2811
#define InsertTailList(ListHead, Entry)
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
_SEH2_TRY
Definition: create.c:4250
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
VOID Ext2DropBH(IN PEXT2_VCB Vcb)
Definition: generic.c:262
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
LIST_ENTRY List
Definition: psmgr.c:57
#define DL_INF
Definition: ext2fs.h:1399
BOOLEAN NTAPI MmFlushImageSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN MMFLUSH_TYPE FlushType)
Definition: section.c:4798
#define IsVcbReadOnly(Vcb)
Definition: ext2fs.h:805
#define Vcb
Definition: cdprocs.h:1425
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CD_MCB Mcb
Definition: cdstruc.h:1022
Definition: typedefs.h:117
ERESOURCE MainResource
Definition: ntfs.h:524
BOOLEAN NTAPI ExAcquireSharedStarveExclusive(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:1063
_SEH2_END
Definition: create.c:4424
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
_SEH2_FINALLY
Definition: create.c:4395
#define DEBUG(args)
Definition: rdesktop.h:129
_In_ PFCB Fcb
Definition: cdprocs.h:151
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by Ext2DismountVolume(), Ext2VerifyVolume(), and Ext2WriteVolume().

◆ Ext2QueryExtentMappings()

NTSTATUS Ext2QueryExtentMappings ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_FCB  Fcb,
IN PLARGE_INTEGER  RequestVbn,
OUT PLARGE_INTEGER pMappedRuns 
)

Definition at line 670 of file fsctl.c.

677 {
678  PLARGE_INTEGER MappedRuns = NULL;
679  PLARGE_INTEGER PartialRuns = NULL;
680 
681  PEXT2_EXTENT Chain = NULL;
683 
684  LONGLONG Vbn = 0;
685  ULONG Length = 0;
686  ULONG i = 0;
687 
689 
690  _SEH2_TRY {
691 
692  /* now building all the request extents */
693  while (Vbn < RequestVbn->QuadPart) {
694 
695  Length = 0x80000000; /* 2g bytes */
696  if (RequestVbn->QuadPart < Vbn + Length) {
697  Length = (ULONG)(RequestVbn->QuadPart - Vbn);
698  }
699 
700  /* build extents for sub-range */
701  Extent = NULL;
703  IrpContext,
704  Vcb,
705  Fcb->Mcb,
706  Vbn,
707  Length,
708  FALSE,
709  &Extent);
710 
711  if (!NT_SUCCESS(Status)) {
712  _SEH2_LEAVE;
713  }
714 
715  if (Chain) {
716  Ext2JointExtents(Chain, Extent);
717  } else {
718  Chain = Extent;
719  }
720 
721  /* allocate extent array */
722  PartialRuns = Ext2AllocatePool(
723  NonPagedPool,
724  (Ext2CountExtents(Chain) + 2) *
725  (2 * sizeof(LARGE_INTEGER)),
726  'RE2E');
727 
728  if (PartialRuns == NULL) {
730  _SEH2_LEAVE;
731  }
732  RtlZeroMemory( PartialRuns,
733  (Ext2CountExtents(Chain) + 2) *
734  (2 * sizeof(LARGE_INTEGER)));
735 
736  if (MappedRuns) {
737  RtlMoveMemory(PartialRuns,
738  MappedRuns,
739  i * 2 * sizeof(LARGE_INTEGER));
740  Ext2FreePool(MappedRuns, 'RE2E');
741  }
742  MappedRuns = PartialRuns;
743 
744  /* walk all the Mcb runs in Extent */
745  for (; Extent != NULL; Extent = Extent->Next) {
746  MappedRuns[i*2 + 0].QuadPart = Vbn + Extent->Offset;
747  MappedRuns[i*2 + 1].QuadPart = Extent->Lba;
748  i = i+1;
749  }
750 
751  Vbn = Vbn + Length;
752  }
753 
754  *pMappedRuns = MappedRuns;
755 
756  } _SEH2_FINALLY {
757 
758  if (!NT_SUCCESS(Status) || Status == STATUS_PENDING) {
759  if (MappedRuns) {
760  Ext2FreePool(MappedRuns, 'RE2E');
761  }
762  *pMappedRuns = NULL;
763  }
764 
765  if (Chain) {
766  Ext2DestroyExtentChain(Chain);
767  }
768  } _SEH2_END;
769 
770  return Status;
771 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONG NTSTATUS
Definition: precomp.h:26
ULONG Ext2CountExtents(IN PEXT2_EXTENT Chain)
Definition: memory.c:513
VOID Ext2JointExtents(IN PEXT2_EXTENT Chain, IN PEXT2_EXTENT Extent)
Definition: memory.c:527
NTSTATUS Ext2BuildExtents(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONGLONG Offset, IN ULONG Size, IN BOOLEAN bAlloc, OUT PEXT2_EXTENT *Chain)
Definition: memory.c:1207
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
_SEH2_TRY
Definition: create.c:4250
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
int64_t LONGLONG
Definition: typedefs.h:66
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
CD_MCB Mcb
Definition: cdstruc.h:1022
Status
Definition: gdiplustypes.h:24
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
_In_ LONGLONG Vbn
Definition: fsrtlfuncs.h:470
ret QuadPart
Definition: rtlfuncs.h:3091
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
VOID Ext2FreePool(IN PVOID P, IN ULONG Tag)
Definition: debug.c:2697
VOID Ext2DestroyExtentChain(IN PEXT2_EXTENT Chain)
Definition: memory.c:546
#define _SEH2_LEAVE
Definition: filesup.c:20
_In_ PFCB Fcb
Definition: cdprocs.h:151
return STATUS_SUCCESS
Definition: btrfs.c:2966
PVOID Ext2AllocatePool(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
Definition: debug.c:2684
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by Ext2GetRetrievalPointers(), and Ext2QueryRetrievalPointers().

◆ Ext2QueryRetrievalPointers()

NTSTATUS Ext2QueryRetrievalPointers ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 774 of file fsctl.c.

777 {
778  PIRP Irp = NULL;
781 
784 
785  PEXT2_VCB Vcb = NULL;
786  PEXT2_FCB Fcb = NULL;
787  PEXT2_CCB Ccb = NULL;
788 
789  PLARGE_INTEGER RequestVbn;
790  PLARGE_INTEGER * pMappedRuns;
791 
792  ULONG InputSize;
793  ULONG OutputSize;
794 
796 
797  BOOLEAN FcbResourceAcquired = FALSE;
798 
799  _SEH2_TRY {
800 
801  ASSERT(IrpContext);
802  Irp = IrpContext->Irp;
803  ASSERT(Irp);
804 
807  ASSERT(IrpSp);
808 
809  InputSize = EIrpSp->Parameters.FileSystemControl.InputBufferLength;
810  OutputSize = EIrpSp->Parameters.FileSystemControl.OutputBufferLength;
811 
812  ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
813  (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
814 
815  DeviceObject = IrpContext->DeviceObject;
816 
817  DbgBreak();
818 
819  /* This request is not allowed on the main device object */
822  _SEH2_LEAVE;
823  }
824 
826  ASSERT(Vcb != NULL);
827  ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
828  (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
829  ASSERT(IsMounted(Vcb));
830 
831  FileObject = IrpContext->FileObject;
832  Fcb = (PEXT2_FCB) FileObject->FsContext;
833 
834  /* check Fcb is valid or not */
835  if (Fcb == NULL || Fcb->Identifier.Type == EXT2VCB) {
837  _SEH2_LEAVE;
838  }
839 
840  ASSERT((Fcb->Identifier.Type == EXT2FCB) &&
841  (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
842  if (IsFlagOn(Fcb->Mcb->Flags, MCB_FILE_DELETED)) {
844  _SEH2_LEAVE;
845  }
846 
847  Ccb = (PEXT2_CCB) FileObject->FsContext2;
848  if (Ccb == NULL) {
850  _SEH2_LEAVE;
851  }
852 
853  ASSERT((Ccb->Identifier.Type == EXT2CCB) &&
854  (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
855 
856  /* Is requstor in kernel and Fcb a paging file ? */
857  if (Irp->RequestorMode != KernelMode ||
859  InputSize != sizeof(LARGE_INTEGER) ||
860  OutputSize != sizeof(PVOID)) {
862  _SEH2_LEAVE;
863  }
864 
866  &Fcb->MainResource, Ext2CanIWait())) {
868  _SEH2_LEAVE;
869  }
870  FcbResourceAcquired = TRUE;
871 
872  RequestVbn = EIrpSp->Parameters.FileSystemControl.Type3InputBuffer;
873  pMappedRuns = Irp->UserBuffer;
874 
875  DbgBreak();
876 
877  /* request size beyonds whole file size */
878  if (RequestVbn->QuadPart >= Fcb->Header.AllocationSize.QuadPart) {
880  _SEH2_LEAVE;
881  }
882 
884  IrpContext,
885  Vcb,
886  Fcb,
887  RequestVbn,
888  pMappedRuns
889  );
890 
891  } _SEH2_FINALLY {
892 
893  if (FcbResourceAcquired) {
895  }
896 
897  if (!_SEH2_AbnormalTermination()) {
899  Status = Ext2QueueRequest(IrpContext);
900  } else {
901  Ext2CompleteIrpContext(IrpContext, Status);
902  }
903  }
904  } _SEH2_END;
905 
906  return Status;
907 }
struct _EXT2_FCB * PEXT2_FCB
#define IsMounted(Vcb)
Definition: ext2fs.h:803
#define TRUE
Definition: types.h:120
FSRTL_ADVANCED_FCB_HEADER Header
Definition: cdstruc.h:931
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
_SEH2_TRY
Definition: create.c:4250
#define STATUS_END_OF_FILE
Definition: shellext.h:62
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define MCB_FILE_DELETED
Definition: ext2fs.h:946
NTFSIDENTIFIER Identifier
Definition: ntfs.h:511
NTSTATUS Ext2QueueRequest(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: dispatch.c:150
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define _SEH2_AbnormalTermination()
Definition: pseh2_64.h:13
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define STATUS_FILE_DELETED
Definition: udferr_usr.h:172
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define STATUS_PENDING
Definition: ntstatus.h:82
#define Vcb
Definition: cdprocs.h:1425
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
* PFILE_OBJECT
Definition: iotypes.h:1955
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG Flags
Definition: ntfs.h:532
CD_MCB Mcb
Definition: cdstruc.h:1022
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
ULONG Type
Definition: ntfs.h:95
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
ERESOURCE MainResource
Definition: ntfs.h:524
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
_SEH2_END
Definition: create.c:4424
#define Ext2CanIWait()
Definition: ext2fs.h:1091
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
_SEH2_FINALLY
Definition: create.c:4395
#define FCB_PAGE_FILE
Definition: ext2fs.h:872
NTSTATUS Ext2QueryExtentMappings(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Fcb, IN PLARGE_INTEGER RequestVbn, OUT PLARGE_INTEGER *pMappedRuns)
Definition: fsctl.c:670
#define IsExt2FsDevice(DO)
Definition: ext2fs.h:607
unsigned int ULONG
Definition: retypes.h:1
#define DbgBreak()
Definition: ext2fs.h:46
struct _EXT2_VCB * PEXT2_VCB
IO_STACK_LOCATION * PEXTENDED_IO_STACK_LOCATION
Definition: ext2fs.h:174
#define _SEH2_LEAVE
Definition: filesup.c:20
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
_In_ PFCB Fcb
Definition: cdprocs.h:151
return STATUS_SUCCESS
Definition: btrfs.c:2966
struct _EXT2_CCB * PEXT2_CCB
ULONG Size
Definition: ntfs.h:96
LONGLONG QuadPart
Definition: typedefs.h:112
#define STATUS_CANT_WAIT
Definition: ntstatus.h:438

Referenced by Ext2UserFsRequest().

◆ Ext2ReadSymlink()

NTSTATUS Ext2ReadSymlink ( IN PEXT2_IRP_CONTEXT  IrpContext,
IN PEXT2_VCB  Vcb,
IN PEXT2_MCB  Mcb,
IN PVOID  Buffer,
IN ULONG  Size,
OUT PULONG  BytesRead 
)

Definition at line 1364 of file fsctl.c.

1372 {
1373  return Ext2ReadInode ( IrpContext,
1374  Vcb,
1375  Mcb,
1376  0,
1377  Buffer,
1378  Size,
1379  FALSE,
1380  BytesRead);
1381 }
BOOLEAN Ext2ReadInode(PEXT2_VOLUME_INFO Volume, ULONG Inode, PEXT2_INODE InodeBuffer)
Definition: ext2.c:909
Definition: bufpool.h:45
#define Vcb
Definition: cdprocs.h:1425
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255

Referenced by Ext2FollowLink(), and Ext2GetReparsePoint().

◆ Ext2SetReparsePoint()

NTSTATUS Ext2SetReparsePoint ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 1572 of file fsctl.c.

1573 {
1574  PIRP Irp = NULL;
1576 
1578 
1579  PEXT2_VCB Vcb = NULL;
1580  PEXT2_FCB Fcb = NULL;
1581  PEXT2_CCB Ccb = NULL;
1582  PEXT2_MCB Mcb = NULL;
1583 
1585 
1588  ULONG BytesWritten = 0;
1589 
1590  PEXT2_FCB ParentDcb = NULL; /* Dcb of it's current parent */
1591  PEXT2_MCB ParentMcb = NULL;
1592 
1594 
1595  UNICODE_STRING UniName;
1597 
1598  PCHAR OemNameBuffer = NULL;
1599  int OemNameLength = 0, i;
1600 
1601  BOOLEAN MainResourceAcquired = FALSE;
1602  BOOLEAN FcbLockAcquired = FALSE;
1603 
1604  _SEH2_TRY {
1605 
1606  Ccb = IrpContext->Ccb;
1607  ASSERT(Ccb != NULL);
1608  ASSERT((Ccb->Identifier.Type == EXT2CCB) &&
1609  (Ccb->Identifier.Size == sizeof(EXT2_CCB)));
1610  DeviceObject = IrpContext->DeviceObject;
1612  Fcb = IrpContext->Fcb;
1613  Mcb = Fcb->Mcb;
1614  Irp = IrpContext->Irp;
1616 
1618  FcbLockAcquired = TRUE;
1619 
1620  ParentMcb = Mcb->Parent;
1621  ParentDcb = ParentMcb->Fcb;
1622  if (ParentDcb == NULL) {
1623  ParentDcb = Ext2AllocateFcb(Vcb, ParentMcb);
1624  }
1625  if (ParentDcb) {
1626  Ext2ReferXcb(&ParentDcb->ReferenceCount);
1627  }
1628 
1629  if (!Mcb)
1630  _SEH2_LEAVE;
1631 
1632  if (FcbLockAcquired) {
1633  ExReleaseResourceLite(&Vcb->FcbLock);
1634  FcbLockAcquired = FALSE;
1635  }
1636 
1638  &Fcb->MainResource,
1639  IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT) )) {
1641  _SEH2_LEAVE;
1642  }
1643  MainResourceAcquired = TRUE;
1644 
1645  InputBuffer = Irp->AssociatedIrp.SystemBuffer;
1646  InputBufferLength = IrpSp->Parameters.FileSystemControl.InputBufferLength;
1647 
1650  if (!NT_SUCCESS(Status)) {
1651  _SEH2_LEAVE;
1652  }
1653 
1654  UniName.Length = RDB->SymbolicLinkReparseBuffer.SubstituteNameLength;
1655  UniName.MaximumLength = UniName.Length;
1656  UniName.Buffer =
1657  (PWCHAR)((PUCHAR)&RDB->SymbolicLinkReparseBuffer.PathBuffer
1658  + RDB->SymbolicLinkReparseBuffer.SubstituteNameOffset);
1659 
1660  OemNameLength = Ext2UnicodeToOEMSize(Vcb, &UniName);
1661  if (OemNameLength > USHRT_MAX) {
1663  _SEH2_LEAVE;
1664  }
1665  OemName.Length = (USHORT)OemNameLength;
1666  OemName.MaximumLength = OemNameLength + 1;
1667  OemNameBuffer = OemName.Buffer = Ext2AllocatePool(PagedPool,
1668  OemName.MaximumLength,
1669  'NL2E');
1670  if (!OemNameBuffer) {
1672  _SEH2_LEAVE;
1673  }
1674 
1675  Ext2UnicodeToOEM(Vcb, &OemName, &UniName);
1676  OemName.Buffer[OemName.Length] = '\0';
1677  for (i = 0;i < OemName.Length;i++) {
1678  if (OemName.Buffer[i] == '\\') {
1679  OemName.Buffer[i] = '/';
1680  }
1681  }
1682 
1683  /* free all data blocks of the inode (to be set as symlink) */
1684  {
1685  LARGE_INTEGER zero = {0};
1686  Status = Ext2TruncateFile(IrpContext, Vcb, Mcb, &zero);
1687  }
1688 
1689  /* decrease dir count of group desc and vcb stat */
1690  if (S_ISDIR(Mcb->Inode.i_mode)) {
1691 
1692  ULONG group = (Mcb->Inode.i_ino - 1) / INODES_PER_GROUP;
1693  Ext2UpdateGroupDirStat(IrpContext, Vcb, group);
1694 
1695  /* drop extra reference for dir inode */
1696  ext3_dec_count(&Mcb->Inode);
1697  }
1698 
1699  /* overwrite inode mode as type SYMLINK */
1700  Ext2SaveInode(IrpContext, Vcb, &Mcb->Inode);
1702 
1703  Status = Ext2WriteSymlink(IrpContext, Vcb, Mcb, OemNameBuffer,
1704  OemNameLength, &BytesWritten);
1705  if (NT_SUCCESS(Status)) {
1706  Ext2SetFileType(IrpContext, Vcb, ParentDcb, Mcb,
1707  S_IFLNK | S_IRWXUGO);
1708  }
1709 
1710  } _SEH2_FINALLY {
1711 
1712  if (FcbLockAcquired) {
1713  ExReleaseResourceLite(&Vcb->FcbLock);
1714  FcbLockAcquired = FALSE;
1715  }
1716 
1717  if (MainResourceAcquired) {
1719  }
1720 
1721  if (OemNameBuffer) {
1722  Ext2FreePool(OemNameBuffer, 'NL2E');
1723  }
1724 
1725  if (NT_SUCCESS(Status)) {
1727  IrpContext,
1728  Vcb,
1729  Mcb,
1732  }
1733 
1734  if (!_SEH2_AbnormalTermination()) {
1736  Status = Ext2QueueRequest(IrpContext);
1737  } else {
1738  Ext2CompleteIrpContext(IrpContext, Status);
1739  }
1740  }
1741 
1742  if (ParentDcb) {
1744  }
1745  } _SEH2_END;
1746 
1747  return Status;
1748 }
signed char * PCHAR
Definition: retypes.h:7
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesWritten
Definition: fltkernel.h:1293
#define TRUE
Definition: types.h:120
#define IRP_CONTEXT_FLAG_WAIT
Definition: cdstruc.h:1221
PEXT2_FCB Fcb
Definition: ext2fs.h:905
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
USHORT MaximumLength
Definition: env_spec_w32.h:370
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
uint16_t * PWCHAR
Definition: typedefs.h:54
STRING OEM_STRING
Definition: umtypes.h:203
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB ParentDcb
Definition: create.c:4157
NTSTATUS Ext2WriteSymlink(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN PVOID Buffer, IN ULONG Size, OUT PULONG BytesWritten)
Definition: fsctl.c:1519
CHAR InputBuffer[80]
Definition: conmgr.c:33
_SEH2_TRY
Definition: create.c:4250
void ext3_dec_count(struct inode *inode)
Definition: htree.c:312
NTSTATUS Ext2TruncateFile(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER AllocationSize)
Definition: fileinfo.c:1199
#define USHRT_MAX
Definition: limits.h:38
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define S_IRWXUGO
Definition: ext2fs.h:395
NTFSIDENTIFIER Identifier
Definition: ntfs.h:511
#define S_IFLNK
Definition: ext2fs.h:355
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSTATUS Ext2QueueRequest(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: dispatch.c:150
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
#define FILE_ACTION_MODIFIED
VOID Ext2NotifyReportChange(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb, IN ULONG Filter, IN ULONG Action)
Definition: dirctl.c:1209
NTSTATUS Ext2UnicodeToOEM(IN PEXT2_VCB Vcb, IN OUT POEM_STRING Oem, IN PUNICODE_STRING Unicode)
Definition: misc.c:261
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define _SEH2_AbnormalTermination()
Definition: pseh2_64.h:13
PEXT2_FCB Ext2AllocateFcb(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb)
Definition: memory.c:131
#define FILE_ATTRIBUTE_REPARSE_POINT
Definition: ntifs_ex.h:381
GLboolean GLuint group
Definition: glext.h:11120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define S_ISDIR(mode)
Definition: various.h:18
#define Vcb
Definition: cdprocs.h:1425
NTSTATUS Ext2InspectReparseData(IN PREPARSE_DATA_BUFFER RDB, IN ULONG InputBufferLength)
Definition: fsctl.c:1293
struct _REPARSE_DATA_BUFFER::@301::@303 SymbolicLinkReparseBuffer
ULONG Ext2UnicodeToOEMSize(IN PEXT2_VCB Vcb, IN PUNICODE_STRING Unicode)
Definition: misc.c:239
#define Ext2ReferXcb(_C)
Definition: ext2fs.h:967
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
CD_MCB Mcb
Definition: cdstruc.h:1022
static double zero
Definition: j0_y0.c:96
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
ULONG Type
Definition: ntfs.h:95
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
ERESOURCE MainResource
Definition: ntfs.h:524
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG InputBufferLength
Definition: fltkernel.h:1372
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_SEH2_END
Definition: create.c:4424
unsigned short USHORT
Definition: pedump.c:61
#define FILE_NOTIFY_CHANGE_ATTRIBUTES
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
struct _FCB::@693::@696 Fcb
NTSTATUS Ext2UpdateGroupDirStat(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG Group)
Definition: generic.c:1661
_SEH2_FINALLY
Definition: create.c:4395
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
VOID Ext2ReleaseFcb(IN PEXT2_FCB Fcb)
Definition: memory.c:276
unsigned int ULONG
Definition: retypes.h:1
#define INODES_PER_GROUP
Definition: ext2fs.h:99
VOID Ext2FreePool(IN PVOID P, IN ULONG Tag)
Definition: debug.c:2697
struct _EXT2_VCB * PEXT2_VCB
NTSTATUS Ext2SetFileType(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN PEXT2_FCB Dcb, IN PEXT2_MCB Mcb, IN umode_t mode)
Definition: generic.c:1884
#define _SEH2_LEAVE
Definition: filesup.c:20
IN PDCB IN POEM_STRING OemName
Definition: fatprocs.h:1294
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
_In_ PFCB Fcb
Definition: cdprocs.h:151
PVOID Ext2AllocatePool(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag)
Definition: debug.c:2684
BOOLEAN Ext2SaveInode(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN struct inode *Inode)
Definition: generic.c:548
ULONG Size
Definition: ntfs.h:96
struct _REPARSE_DATA_BUFFER * PREPARSE_DATA_BUFFER
#define STATUS_CANT_WAIT
Definition: ntstatus.h:438

Referenced by Ext2UserFsRequest().

◆ Ext2SetVpbFlag()

VOID Ext2SetVpbFlag ( IN PVPB  Vpb,
IN USHORT  Flag 
)

Definition at line 44 of file fsctl.c.

47 {
48  KIRQL OldIrql;
49 
51  Vpb->Flags |= Flag;
53 }
VOID NTAPI IoAcquireVpbSpinLock(OUT PKIRQL Irql)
Definition: volume.c:1209
UCHAR KIRQL
Definition: env_spec_w32.h:591
Definition: xml2sdb.h:79
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
VOID NTAPI IoReleaseVpbSpinLock(IN KIRQL Irql)
Definition: volume.c:1220
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1664

Referenced by Ext2LockVcb().

◆ Ext2TruncateSymlink()

NTSTATUS Ext2TruncateSymlink ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb,
PEXT2_MCB  Mcb,
ULONG  Size 
)

Definition at line 1751 of file fsctl.c.

1757 {
1759  PUCHAR data = (PUCHAR)&Mcb->Inode.i_block;
1760  ULONG len = (ULONG)Mcb->Inode.i_size;
1762 
1763  if (len < EXT2_LINKLEN_IN_INODE && !Mcb->Inode.i_blocks) {
1764 
1766  Mcb->Inode.i_size = Size;
1767  Ext2SaveInode(IrpContext, Vcb, &Mcb->Inode);
1768 
1769  } else {
1770  NewSize.QuadPart = Size;
1771  status = Ext2TruncateFile(IrpContext, Vcb, Mcb, &NewSize);
1772  if (!NT_SUCCESS(status)) {
1773  goto out;
1774  }
1775  }
1776 
1777 out:
1778  return status;
1779 }
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS Ext2TruncateFile(PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb, PEXT2_MCB Mcb, PLARGE_INTEGER AllocationSize)
Definition: fileinfo.c:1199
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
static FILE * out
Definition: regtests2xml.c:44
#define EXT2_LINKLEN_IN_INODE
Definition: ext2fs.h:76
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum GLsizei len
Definition: glext.h:6722
_Must_inspect_result_ _In_ USHORT NewSize
Definition: fltkernel.h:975
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
Definition: fatprocs.h:334
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2966
static SERVICE_STATUS status
Definition: service.c:31
BOOLEAN Ext2SaveInode(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN struct inode *Inode)
Definition: generic.c:548
Definition: ps.c:97

Referenced by Ext2DeleteReparsePoint().

◆ Ext2UnlockVcb()

NTSTATUS Ext2UnlockVcb ( IN PEXT2_VCB  Vcb,
IN PFILE_OBJECT  FileObject 
)

Definition at line 206 of file fsctl.c.

208 {
210 
211  _SEH2_TRY {
212 
213  if (FileObject && FileObject->FsContext != Vcb) {
215  _SEH2_LEAVE;
216  }
217 
218  if (!FlagOn(Vcb->Flags, VCB_VOLUME_LOCKED)) {
219  DEBUG(DL_ERR, ( ": Ext2UnlockVcb: Volume is not locked.\n"));
221  _SEH2_LEAVE;
222  }
223 
224  if (Vcb->LockFile == FileObject) {
227  DEBUG(DL_INF, ( "Ext2UnlockVcb: Volume unlocked.\n"));
229  } else {
231  }
232 
233  } _SEH2_FINALLY {
234  // Nothing
235  } _SEH2_END;
236 
237  return Status;
238 }
LONG NTSTATUS
Definition: precomp.h:26
VOID Ext2ClearVpbFlag(IN PVPB Vpb, IN USHORT Flag)
Definition: fsctl.c:56
_SEH2_TRY
Definition: create.c:4250
#define VPB_LOCKED
Definition: iotypes.h:1765
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define DL_INF
Definition: ext2fs.h:1399
#define Vcb
Definition: cdprocs.h:1425
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
Status
Definition: gdiplustypes.h:24
#define DL_ERR
Definition: ext2fs.h:1397
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
#define VCB_VOLUME_LOCKED
Definition: ext2fs.h:780
#define STATUS_NOT_LOCKED
Definition: ntstatus.h:265
#define DEBUG(args)
Definition: rdesktop.h:129
#define _SEH2_LEAVE
Definition: filesup.c:20
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by Ext2UnlockVolume().

◆ Ext2UnlockVolume()

NTSTATUS Ext2UnlockVolume ( IN PEXT2_IRP_CONTEXT  IrpContext)

Definition at line 241 of file fsctl.c.

244 {
247  PEXT2_VCB Vcb = NULL;
249  BOOLEAN VcbResourceAcquired = FALSE;
250 
251  _SEH2_TRY {
252 
253  ASSERT(IrpContext != NULL);
254  ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
255  (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
256 
257  DeviceObject = IrpContext->DeviceObject;
258  IrpSp = IoGetCurrentIrpStackLocation(IrpContext->Irp);
259 
260  //
261  // This request is not allowed on the main device object
262  //
265  _SEH2_LEAVE;
266  }
267 
269  ASSERT(Vcb != NULL);
270  ASSERT((Vcb->Identifier.Type == EXT2VCB) &&
271  (Vcb->Identifier.Size == sizeof(EXT2_VCB)));
272 
274  &Vcb->MainResource,
275  TRUE );
276  VcbResourceAcquired = TRUE;
277 
279 
280  } _SEH2_FINALLY {
281 
282  if (VcbResourceAcquired) {
283  ExReleaseResourceLite(&Vcb->MainResource);
284  }
285 
286  if (!IrpContext->ExceptionInProgress) {
287  Ext2CompleteIrpContext(IrpContext, Status);
288  }
289  } _SEH2_END;
290 
291  return Status;
292 }
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135