ReactOS  0.4.14-dev-114-gc8cbd56
flush.cpp File Reference
#include "udffs.h"
Include dependency graph for flush.cpp:

Go to the source code of this file.

Macros

#define UDF_BUG_CHECK_ID   UDF_FILE_FLUSH
 

Functions

NTSTATUS NTAPI UDFFlush (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS UDFCommonFlush (PtrUDFIrpContext PtrIrpContext, PIRP Irp)
 
ULONG UDFFlushAFile (IN PtrUDFFCB Fcb, IN PtrUDFCCB Ccb, OUT PIO_STATUS_BLOCK PtrIoStatus, IN ULONG FlushFlags)
 
ULONG UDFFlushADirectory (IN PVCB Vcb, IN PUDF_FILE_INFO FI, OUT PIO_STATUS_BLOCK PtrIoStatus, IN ULONG FlushFlags)
 
ULONG UDFFlushLogicalVolume (IN PtrUDFIrpContext PtrIrpContext, IN PIRP Irp, IN PVCB Vcb, IN ULONG FlushFlags)
 
NTSTATUS NTAPI UDFFlushCompletion (PDEVICE_OBJECT PtrDeviceObject, PIRP Irp, PVOID Context)
 
BOOLEAN UDFFlushIsBreaking (IN PVCB Vcb, IN ULONG FlushFlags)
 
VOID UDFFlushTryBreak (IN PVCB Vcb)
 

Macro Definition Documentation

◆ UDF_BUG_CHECK_ID

#define UDF_BUG_CHECK_ID   UDF_FILE_FLUSH

Definition at line 20 of file flush.cpp.

Function Documentation

◆ UDFCommonFlush()

NTSTATUS UDFCommonFlush ( PtrUDFIrpContext  PtrIrpContext,
PIRP  Irp 
)

Definition at line 110 of file flush.cpp.

114 {
118  PtrUDFFCB Fcb = NULL;
119  PtrUDFCCB Ccb = NULL;
120  PVCB Vcb = NULL;
122  BOOLEAN AcquiredVCB = FALSE;
123  BOOLEAN AcquiredFCB = FALSE;
124  BOOLEAN PostRequest = FALSE;
125  BOOLEAN CanWait = TRUE;
126 
127  UDFPrint(("UDFCommonFlush: \n"));
128 
129  _SEH2_TRY {
130 
131  // Get some of the parameters supplied to us
132  CanWait = ((PtrIrpContext->IrpContextFlags & UDF_IRP_CONTEXT_CAN_BLOCK) ? TRUE : FALSE);
133  // If we cannot wait, post the request immediately since a flush is inherently blocking/synchronous.
134  if (!CanWait) {
135  PostRequest = TRUE;
136  try_return(RC);
137  }
138 
139  // First, get a pointer to the current I/O stack location
141  ASSERT(IrpSp);
142 
145 
146  // Get the FCB and CCB pointers
147  Ccb = (PtrUDFCCB)(FileObject->FsContext2);
148  ASSERT(Ccb);
149  Fcb = Ccb->Fcb;
150  ASSERT(Fcb);
151  NtReqFcb = Fcb->NTRequiredFCB;
152 
153  // Check the type of object passed-in. That will determine the course of
154  // action we take.
155  if ((Fcb->NodeIdentifier.NodeType == UDF_NODE_TYPE_VCB) || (Fcb->FCBFlags & UDF_FCB_ROOT_DIRECTORY)) {
156 
157  if (Fcb->NodeIdentifier.NodeType == UDF_NODE_TYPE_VCB) {
158  Vcb = (PVCB)(Fcb);
159  } else {
160  Vcb = Fcb->Vcb;
161  }
162  Vcb->VCBFlags |= UDF_VCB_SKIP_EJECT_CHECK;
163 
164 #ifdef UDF_DELAYED_CLOSE
166 #endif //UDF_DELAYED_CLOSE
167 
168  UDFAcquireResourceExclusive(&(Vcb->VCBResource), TRUE);
169  AcquiredVCB = TRUE;
170  // The caller wishes to flush all files for the mounted
171  // logical volume. The flush volume routine below should simply
172  // walk through all of the open file streams, acquire the
173  // VCB resource, and request the flush operation from the Cache
174  // Manager. Basically, the sequence of operations listed below
175  // for a single file should be executed on all open files.
176 
177  UDFFlushLogicalVolume(PtrIrpContext, Irp, Vcb, 0);
178 
179  UDFReleaseResource(&(Vcb->VCBResource));
180  AcquiredVCB = FALSE;
181 
182  try_return(RC);
183  } else
184  if (!(Fcb->FCBFlags & UDF_FCB_DIRECTORY)) {
185  // This is a regular file.
186  Vcb = Fcb->Vcb;
187  ASSERT(Vcb);
188  if(!ExIsResourceAcquiredExclusiveLite(&(Vcb->VCBResource)) &&
189  !ExIsResourceAcquiredSharedLite(&(Vcb->VCBResource))) {
190  UDFAcquireResourceShared(&(Vcb->VCBResource), TRUE);
191  AcquiredVCB = TRUE;
192  }
194  UDFAcquireResourceExclusive(&(NtReqFcb->MainResource), TRUE);
195  AcquiredFCB = TRUE;
196 
197  // Request the Cache Manager to perform a flush operation.
198  // Further, instruct the Cache Manager that we wish to flush the
199  // entire file stream.
200  UDFFlushAFile(Fcb, Ccb, &(Irp->IoStatus), 0);
201  RC = Irp->IoStatus.Status;
202 
203  // Some log-based FSD implementations may wish to flush their
204  // log files at this time. Finally, we should update the time-stamp
205  // values for the file stream appropriately. This would involve
206  // obtaining the current time and modifying the appropriate directory
207  // entry fields.
208  } else {
209  Vcb = Fcb->Vcb;
210  }
211 
212 try_exit: NOTHING;
213 
214  } _SEH2_FINALLY {
215 
216  if (AcquiredFCB) {
218  UDFReleaseResource(&(NtReqFcb->MainResource));
219  AcquiredFCB = FALSE;
220  }
221  if (AcquiredVCB) {
222  UDFReleaseResource(&(Vcb->VCBResource));
223  AcquiredVCB = FALSE;
224  }
225 
227  if (PostRequest) {
228  // Nothing to lock now.
229  BrutePoint();
230  RC = UDFPostRequest(PtrIrpContext, Irp);
231  } else {
232  // Some applications like this request very much
233  // (ex. WinWord). But it's not a good idea for CD-R/RW media
234  if(Vcb->FlushMedia) {
235  PIO_STACK_LOCATION PtrNextIoStackLocation = NULL;
236  NTSTATUS RC1 = STATUS_SUCCESS;
237 
238  // Send the request down at this point.
239  // To do this, we must set the next IRP stack location, and
240  // maybe set a completion routine.
241  // Be careful about marking the IRP pending if the lower level
242  // driver returned pending and we do have a completion routine!
243  PtrNextIoStackLocation = IoGetNextIrpStackLocation(Irp);
244  *PtrNextIoStackLocation = *IrpSp;
245 
246  // Set the completion routine to "eat-up" any
247  // STATUS_INVALID_DEVICE_REQUEST error code returned by the lower
248  // level driver.
250 
251  RC1 = IoCallDriver(Vcb->TargetDeviceObject, Irp);
252 
253  RC = ((RC1 == STATUS_INVALID_DEVICE_REQUEST) ? RC : RC1);
254 
255  // Release the IRP context at this time.
256  UDFReleaseIrpContext(PtrIrpContext);
257  } else {
258  Irp->IoStatus.Status = RC;
259  Irp->IoStatus.Information = 0;
260  // Free up the Irp Context
261  UDFReleaseIrpContext(PtrIrpContext);
262  // complete the IRP
264  }
265  }
266  }
267  } _SEH2_END;
268 
269  return(RC);
270 } // end UDFCommonFlush()
#define UDFAcquireResourceExclusive(Resource, CanWait)
Definition: env_spec_w32.h:656
VOID UDFReleaseIrpContext(PtrUDFIrpContext PtrIrpContext)
Definition: misc.cpp:1086
struct _FCB::@697::@700 Fcb
#define UDFPrint(Args)
Definition: udffs.h:225
#define TRUE
Definition: types.h:120
struct _UDFContextControlBlock * PtrUDFCCB
NTSTATUS NTAPI UDFFlushCompletion(PDEVICE_OBJECT PtrDeviceObject, PIRP Irp, PVOID Context)
Definition: flush.cpp:578
_In_ PIRP Irp
Definition: csq.h:116
#define UDF_NODE_TYPE_VCB
Definition: struct.h:61
#define UDFReleaseResource(Resource)
Definition: env_spec_w32.h:661
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
Definition: cdstruc.h:504
#define UDF_IRP_CONTEXT_CAN_BLOCK
Definition: struct.h:385
_SEH2_TRY
Definition: create.c:4250
ULONG UDFFlushAFile(IN PtrUDFFCB Fcb, IN PtrUDFCCB Ccb, OUT PIO_STATUS_BLOCK PtrIoStatus, IN ULONG FlushFlags)
Definition: flush.cpp:288
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
#define IO_DISK_INCREMENT
Definition: iotypes.h:568
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN NTAPI ExIsResourceAcquiredExclusiveLite(IN PERESOURCE Resource)
Definition: resource.c:1619
#define _SEH2_AbnormalTermination()
Definition: pseh2_64.h:13
#define IoCompleteRequest
Definition: irp.c:1240
uint32 IrpContextFlags
Definition: struct.h:364
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define UDF_VCB_SKIP_EJECT_CHECK
Definition: udf_common.h:470
#define try_return(S)
Definition: cdprocs.h:2189
#define Vcb
Definition: cdprocs.h:1425
#define UDF_FCB_DIRECTORY
Definition: struct.h:303
#define BrutePoint()
Definition: env_spec_w32.h:504
* PFILE_OBJECT
Definition: iotypes.h:1955
#define UDF_FCB_ROOT_DIRECTORY
Definition: struct.h:304
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define NtReqFcb
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
#define NOTHING
Definition: env_spec_w32.h:461
struct _VCB * PVCB
Definition: fatstruc.h:556
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
#define UDFAcquireResourceShared(Resource, CanWait)
Definition: env_spec_w32.h:658
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
NTSTATUS UDFPostRequest(IN PtrUDFIrpContext PtrIrpContext, IN PIRP Irp)
Definition: misc.cpp:1128
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
_SEH2_END
Definition: create.c:4424
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
#define UDF_CHECK_PAGING_IO_RESOURCE(NTReqFCB)
Definition: udffs.h:262
_SEH2_FINALLY
Definition: create.c:4395
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
ULONG UDFFlushLogicalVolume(IN PtrUDFIrpContext PtrIrpContext, IN PIRP Irp, IN PVCB Vcb, IN ULONG FlushFlags)
Definition: flush.cpp:506
VOID UDFCloseAllDelayed(IN PVCB Vcb)
Definition: close.cpp:754
ULONG NTAPI ExIsResourceAcquiredSharedLite(IN PERESOURCE Resource)
Definition: resource.c:1658
PVCB Vcb
Definition: cdstruc.h:939
_In_ PFCB Fcb
Definition: cdprocs.h:151
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by UDFFlush().

◆ UDFFlush()

NTSTATUS NTAPI UDFFlush ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 42 of file flush.cpp.

45 {
47  PtrUDFIrpContext PtrIrpContext = NULL;
48  BOOLEAN AreWeTopLevel = FALSE;
49 
50  UDFPrint(("UDFFlush: \n"));
51 
54  ASSERT(Irp);
55 
56  // set the top level context
57  AreWeTopLevel = UDFIsIrpTopLevel(Irp);
58  ASSERT(!UDFIsFSDevObj(DeviceObject));
59 
60  _SEH2_TRY {
61 
62  // get an IRP context structure and issue the request
63  PtrIrpContext = UDFAllocateIrpContext(Irp, DeviceObject);
64  if(PtrIrpContext) {
65  RC = UDFCommonFlush(PtrIrpContext, Irp);
66  } else {
68  Irp->IoStatus.Status = RC;
69  Irp->IoStatus.Information = 0;
70  // complete the IRP
72  }
73 
75 
76  RC = UDFExceptionHandler(PtrIrpContext, Irp);
77 
79  } _SEH2_END;
80 
81  if (AreWeTopLevel) {
83  }
84 
86 
87  return(RC);
88 } // end UDFFlush()
PtrUDFIrpContext UDFAllocateIrpContext(PIRP Irp, PDEVICE_OBJECT PtrTargetDeviceObject)
Definition: misc.cpp:985
#define UDFPrint(Args)
Definition: udffs.h:225
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
VOID UDFLogEvent(NTSTATUS UDFEventLogId, NTSTATUS RC)
Definition: misc.cpp:575
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS UDFCommonFlush(PtrUDFIrpContext PtrIrpContext, PIRP Irp)
Definition: flush.cpp:110
_SEH2_TRY
Definition: create.c:4250
#define IO_DISK_INCREMENT
Definition: iotypes.h:568
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:11
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
NTSTATUS UDFExceptionHandler(PtrUDFIrpContext PtrIrpContext, PIRP Irp)
Definition: misc.cpp:358
BOOLEAN __fastcall UDFIsIrpTopLevel(PIRP Irp)
Definition: misc.cpp:228
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
long UDFExceptionFilter(PtrUDFIrpContext PtrIrpContext, PEXCEPTION_POINTERS PtrExceptionPointers)
Definition: misc.cpp:265
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define UDF_ERROR_INTERNAL_ERROR
Definition: errmsg.h:71
_SEH2_END
Definition: create.c:4424
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by UDFInitializeFunctionPointers().

◆ UDFFlushADirectory()

ULONG UDFFlushADirectory ( IN PVCB  Vcb,
IN PUDF_FILE_INFO  FI,
OUT PIO_STATUS_BLOCK  PtrIoStatus,
IN ULONG  FlushFlags 
)

Definition at line 415 of file flush.cpp.

421 {
422  UDFPrint(("UDFFlushADirectory: \n"));
423 // PDIR_INDEX_HDR hDI;
424  PDIR_INDEX_ITEM DI;
425 // BOOLEAN Referenced = FALSE;
426  ULONG ret_val = 0;
427 
428  if(Vcb->VCBFlags & UDF_VCB_FLAGS_RAW_DISK)
429  return 0;
430 
431  if(!FI || !FI->Dloc || !FI->Dloc->DirIndex) goto SkipFlushDir;
432 // hDI = FI->Dloc->DirIndex;
433 
434  // Flush Security if required
435  _SEH2_TRY {
436  UDFWriteSecurity(Vcb, FI->Fcb, &(FI->Fcb->NTRequiredFCB->SecurityDesc));
438  BrutePoint();
439  } _SEH2_END;
440  // Flush SDir if any
441  _SEH2_TRY {
442  if(UDFHasAStreamDir(FI) &&
443  FI->Dloc->SDirInfo &&
444  !UDFIsSDirDeleted(FI->Dloc->SDirInfo) ) {
445  ret_val |=
446  UDFFlushADirectory(Vcb, FI->Dloc->SDirInfo, PtrIoStatus, FlushFlags);
447  }
449  BrutePoint();
450  } _SEH2_END;
451 
452  // Flush Dir Tree
453  _SEH2_TRY {
454  UDF_DIR_SCAN_CONTEXT ScanContext;
455  PUDF_FILE_INFO tempFI;
456 
457  if(UDFDirIndexInitScan(FI, &ScanContext, 2)) {
458  while((DI = UDFDirIndexScan(&ScanContext, &tempFI))) {
459  // Flush Dir entry
460  _SEH2_TRY {
461  if(!tempFI) continue;
462  if(UDFIsADirectory(tempFI)) {
463  UDFFlushADirectory(Vcb, tempFI, PtrIoStatus, FlushFlags);
464  } else {
465  UDFFlushAFile(tempFI->Fcb, NULL, PtrIoStatus, FlushFlags);
466  }
468  BrutePoint();
469  } _SEH2_END;
470  if(UDFFlushIsBreaking(Vcb, FlushFlags)) {
471  ret_val |= UDF_FLUSH_FLAGS_INTERRUPTED;
472  break;
473  }
474  }
475  }
477  BrutePoint();
478  } _SEH2_END;
479 SkipFlushDir:
480  // Flush Dir
481  _SEH2_TRY {
482  UDFFlushFile__( Vcb, FI, FlushFlags );
484  BrutePoint();
485  } _SEH2_END;
486 
487  return ret_val;
488 } // end UDFFlushADirectory()
#define UDFPrint(Args)
Definition: udffs.h:225
ULONG UDFFlushADirectory(IN PVCB Vcb, IN PUDF_FILE_INFO FI, OUT PIO_STATUS_BLOCK PtrIoStatus, IN ULONG FlushFlags)
Definition: flush.cpp:415
NTSTATUS UDFWriteSecurity(IN PVCB Vcb, IN PtrUDFFCB Fcb, IN PSECURITY_DESCRIPTOR *SecurityDesc)
Definition: secursup.cpp:796
#define UDF_FLUSH_FLAGS_INTERRUPTED
Definition: struct.h:343
_SEH2_TRY
Definition: create.c:4250
ULONG UDFFlushAFile(IN PtrUDFFCB Fcb, IN PtrUDFCCB Ccb, OUT PIO_STATUS_BLOCK PtrIoStatus, IN ULONG FlushFlags)
Definition: flush.cpp:288
#define UDF_VCB_FLAGS_RAW_DISK
Definition: udf_common.h:476
#define UDFIsADirectory(FileInfo)
Definition: udf_info.h:792
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN UDFFlushIsBreaking(IN PVCB Vcb, IN ULONG FlushFlags)
Definition: flush.cpp:605
OSSTATUS UDFFlushFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN ULONG FlushFlags)
Definition: udf_info.cpp:4119
#define Vcb
Definition: cdprocs.h:1425
#define BrutePoint()
Definition: env_spec_w32.h:504
PDIR_INDEX_ITEM UDFDirIndexScan(PUDF_DIR_SCAN_CONTEXT Context, PUDF_FILE_INFO *_FileInfo)
Definition: dirtree.cpp:378
#define UDFIsSDirDeleted(FI)
Definition: udf_info.h:1004
_SEH2_END
Definition: create.c:4424
BOOLEAN UDFDirIndexInitScan(IN PUDF_FILE_INFO DirInfo, OUT PUDF_DIR_SCAN_CONTEXT Context, IN uint_di Index)
Definition: dirtree.cpp:347
unsigned int ULONG
Definition: retypes.h:1
#define UDFHasAStreamDir(FI)
Definition: udf_info.h:1000
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
struct _UDFFileControlBlock * Fcb
Definition: udf_rel.h:362

Referenced by UDFEjectReqWaiter(), UDFFlushAFile(), and UDFFlushLogicalVolume().

◆ UDFFlushAFile()

ULONG UDFFlushAFile ( IN PtrUDFFCB  Fcb,
IN PtrUDFCCB  Ccb,
OUT PIO_STATUS_BLOCK  PtrIoStatus,
IN ULONG  FlushFlags 
)

Definition at line 288 of file flush.cpp.

294 {
295  BOOLEAN SetArchive = FALSE;
296 // BOOLEAN PurgeCache = FALSE;
297  ULONG ret_val = 0;
298 
299  UDFPrint(("UDFFlushAFile: \n"));
300  if(!Fcb)
301  return 0;
302 
303  _SEH2_TRY {
304  if(Fcb->Vcb->VCBFlags & UDF_VCB_FLAGS_RAW_DISK)
305  return 0;
307  BrutePoint();
308  } _SEH2_END;
309 #ifndef UDF_READ_ONLY_BUILD
310  // Flush Security if required
311  _SEH2_TRY {
312  UDFWriteSecurity(Fcb->Vcb, Fcb, &(Fcb->NTRequiredFCB->SecurityDesc));
314  BrutePoint();
315  } _SEH2_END;
316 #endif //UDF_READ_ONLY_BUILD
317  // Flush SDir if any
318  _SEH2_TRY {
319  if(UDFHasAStreamDir(Fcb->FileInfo) &&
320  Fcb->FileInfo->Dloc->SDirInfo &&
321  !UDFIsSDirDeleted(Fcb->FileInfo->Dloc->SDirInfo) ) {
322  ret_val |=
323  UDFFlushADirectory(Fcb->Vcb, Fcb->FileInfo->Dloc->SDirInfo, PtrIoStatus, FlushFlags);
324  }
326  BrutePoint();
327  } _SEH2_END;
328  // Flush File
329  _SEH2_TRY {
330  if((Fcb->CachedOpenHandleCount || !Fcb->OpenHandleCount) &&
331  Fcb->NTRequiredFCB->SectionObject.DataSectionObject) {
332  if(!(Fcb->NTRequiredFCB->NtReqFCBFlags & UDF_NTREQ_FCB_DELETED)
333  &&
334  ((Fcb->NTRequiredFCB->NtReqFCBFlags & UDF_NTREQ_FCB_MODIFIED) ||
335  (Ccb && !(Ccb->CCBFlags & UDF_CCB_FLUSHED)) )) {
336  MmPrint((" CcFlushCache()\n"));
337  CcFlushCache(&(Fcb->NTRequiredFCB->SectionObject), NULL, 0, PtrIoStatus);
338  }
339  // notice, that we should purge cache
340  // we can't do it now, because it may cause last Close
341  // request & thus, structure deallocation
342 // PurgeCache = TRUE;
343 
344 #ifndef UDF_READ_ONLY_BUILD
345  if(Ccb) {
346  if( (Ccb->FileObject->Flags & FO_FILE_MODIFIED) &&
347  !(Ccb->CCBFlags & UDF_CCB_WRITE_TIME_SET)) {
348  if(Fcb->Vcb->CompatFlags & UDF_VCB_IC_UPDATE_MODIFY_TIME) {
351  UDFSetFileXTime(Fcb->FileInfo, NULL, NULL, NULL, &NtTime);
352  Fcb->NTRequiredFCB->LastWriteTime.QuadPart = NtTime;
353  }
354  SetArchive = TRUE;
355  Ccb->FileObject->Flags &= ~FO_FILE_MODIFIED;
356  }
357  if(Ccb->FileObject->Flags & FO_FILE_SIZE_CHANGED) {
358  LONGLONG ASize = UDFGetFileAllocationSize(Fcb->Vcb, Fcb->FileInfo);
359  UDFSetFileSizeInDirNdx(Fcb->Vcb, Fcb->FileInfo, &ASize);
360  Ccb->FileObject->Flags &= ~FO_FILE_SIZE_CHANGED;
361  }
362  }
363 #endif //UDF_READ_ONLY_BUILD
364  }
366  BrutePoint();
367  } _SEH2_END;
368 
369  _SEH2_TRY {
370 #ifndef UDF_READ_ONLY_BUILD
371  if(SetArchive &&
372  (Fcb->Vcb->CompatFlags & UDF_VCB_IC_UPDATE_ARCH_BIT)) {
373  ULONG Attr;
374  PDIR_INDEX_ITEM DirNdx;
375  DirNdx = UDFDirIndex(UDFGetDirIndexByFileInfo(Fcb->FileInfo), Fcb->FileInfo->Index);
376  // Archive bit
377  Attr = UDFAttributesToNT(DirNdx, Fcb->FileInfo->Dloc->FileEntry);
378  if(!(Attr & FILE_ATTRIBUTE_ARCHIVE))
379  UDFAttributesToUDF(DirNdx, Fcb->FileInfo->Dloc->FileEntry, Attr | FILE_ATTRIBUTE_ARCHIVE);
380  }
381 #endif //UDF_READ_ONLY_BUILD
382  UDFFlushFile__( Fcb->Vcb, Fcb->FileInfo, FlushFlags);
384  BrutePoint();
385  } _SEH2_END;
386 
387 /* if(PurgeCache) {
388  _SEH2_TRY {
389  MmPrint((" CcPurgeCacheSection()\n"));
390  CcPurgeCacheSection( &(Fcb->NTRequiredFCB->SectionObject), NULL, 0, FALSE );
391  } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
392  BrutePoint();
393  } _SEH2_END;
394  }*/
395 
396  return ret_val;
397 } // end UDFFlushAFile()
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
LARGE_INTEGER LastWriteTime
Definition: fatstruc.h:921
#define UDFPrint(Args)
Definition: udffs.h:225
#define TRUE
Definition: types.h:120
ULONG UDFFlushADirectory(IN PVCB Vcb, IN PUDF_FILE_INFO FI, OUT PIO_STATUS_BLOCK PtrIoStatus, IN ULONG FlushFlags)
Definition: flush.cpp:415
#define UDFGetFileAllocationSize(Vcb, FileInfo)
Definition: udf_info.h:797
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
PFILE_OBJECT FileObject
Definition: ntfs.h:516
NTSTATUS UDFWriteSecurity(IN PVCB Vcb, IN PtrUDFFCB Fcb, IN PSECURITY_DESCRIPTOR *SecurityDesc)
Definition: secursup.cpp:796
__inline PDIR_INDEX_ITEM UDFDirIndex(IN PDIR_INDEX_HDR hDirNdx, IN uint_di i)
Definition: udf_info.h:1105
#define UDF_CCB_FLUSHED
Definition: struct.h:173
void UDFSetFileSizeInDirNdx(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN int64 *ASize)
Definition: udf_info.cpp:1190
_SEH2_TRY
Definition: create.c:4250
#define UDF_VCB_FLAGS_RAW_DISK
Definition: udf_common.h:476
#define FO_FILE_SIZE_CHANGED
Definition: iotypes.h:1746
#define FO_FILE_MODIFIED
Definition: iotypes.h:1745
PDIR_INDEX_HDR UDFGetDirIndexByFileInfo(IN PUDF_FILE_INFO FileInfo)
Definition: dirtree.cpp:1092
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
OSSTATUS UDFFlushFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN ULONG FlushFlags)
Definition: udf_info.cpp:4119
ULONG OpenHandleCount
Definition: ntfs.h:533
#define UDF_VCB_IC_UPDATE_MODIFY_TIME
Definition: udf_common.h:494
int64_t LONGLONG
Definition: typedefs.h:66
#define UDF_VCB_IC_UPDATE_ARCH_BIT
Definition: udf_common.h:496
#define BrutePoint()
Definition: env_spec_w32.h:504
#define MmPrint(_x_)
Definition: env_spec_w32.h:289
VOID UDFSetFileXTime(IN PUDF_FILE_INFO FileInfo, IN LONGLONG *CrtTime, IN LONGLONG *AccTime, IN LONGLONG *AttrTime, IN LONGLONG *ChgTime)
#define FILE_ATTRIBUTE_ARCHIVE
Definition: nt_native.h:706
#define UDF_NTREQ_FCB_DELETED
Definition: struct.h:235
_In_ PLARGE_INTEGER NtTime
Definition: fatprocs.h:1905
#define UDFIsSDirDeleted(FI)
Definition: udf_info.h:1004
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
VOID UDFAttributesToUDF(IN PDIR_INDEX_ITEM FileDirNdx, IN tag *FileEntry, IN ULONG NTAttr)
_SEH2_END
Definition: create.c:4424
#define UDF_CCB_WRITE_TIME_SET
Definition: struct.h:156
ULONG UDFAttributesToNT(IN PDIR_INDEX_ITEM FileDirNdx, IN tag *FileEntry)
unsigned int ULONG
Definition: retypes.h:1
PVCB Vcb
Definition: cdstruc.h:939
#define UDFHasAStreamDir(FI)
Definition: udf_info.h:1000
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
_In_ PFCB Fcb
Definition: cdprocs.h:151
LONGLONG QuadPart
Definition: typedefs.h:112
#define UDF_NTREQ_FCB_MODIFIED
Definition: struct.h:236

Referenced by UDFCommonFlush(), UDFFlushADirectory(), and UDFSetFileAllocModeFromICB().

◆ UDFFlushCompletion()

NTSTATUS NTAPI UDFFlushCompletion ( PDEVICE_OBJECT  PtrDeviceObject,
PIRP  Irp,
PVOID  Context 
)

Definition at line 578 of file flush.cpp.

583 {
584 // NTSTATUS RC = STATUS_SUCCESS;
585 
586  UDFPrint(("UDFFlushCompletion: \n"));
587 
588  if (Irp->PendingReturned) {
590  }
591 
592  if (Irp->IoStatus.Status == STATUS_INVALID_DEVICE_REQUEST) {
593  // cannot do much here, can we?
594  Irp->IoStatus.Status = STATUS_SUCCESS;
595  }
596 
597  return(STATUS_SUCCESS);
598 } // end UDFFlushCompletion()
#define UDFPrint(Args)
Definition: udffs.h:225
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
return STATUS_SUCCESS
Definition: btrfs.c:2966
IoMarkIrpPending(Irp)

Referenced by UDFCommonFlush().

◆ UDFFlushIsBreaking()

BOOLEAN UDFFlushIsBreaking ( IN PVCB  Vcb,
IN ULONG  FlushFlags 
)

Definition at line 605 of file flush.cpp.

609 {
610  BOOLEAN ret_val = FALSE;
611 // if(!(FlushFlags & UDF_FLUSH_FLAGS_BREAKABLE))
612  return FALSE;
613  UDFAcquireResourceExclusive(&(Vcb->FlushResource),TRUE);
614  ret_val = (Vcb->VCBFlags & UDF_VCB_FLAGS_FLUSH_BREAK_REQ) ? TRUE : FALSE;
615  Vcb->VCBFlags &= ~UDF_VCB_FLAGS_FLUSH_BREAK_REQ;
616  UDFReleaseResource(&(Vcb->FlushResource));
617  return ret_val;
618 } // end UDFFlushIsBreaking()
#define UDFAcquireResourceExclusive(Resource, CanWait)
Definition: env_spec_w32.h:656
#define TRUE
Definition: types.h:120
#define UDFReleaseResource(Resource)
Definition: env_spec_w32.h:661
unsigned char BOOLEAN
#define UDF_VCB_FLAGS_FLUSH_BREAK_REQ
Definition: udf_common.h:483
#define Vcb
Definition: cdprocs.h:1425

Referenced by UDFFlushADirectory().

◆ UDFFlushLogicalVolume()

ULONG UDFFlushLogicalVolume ( IN PtrUDFIrpContext  PtrIrpContext,
IN PIRP  Irp,
IN PVCB  Vcb,
IN ULONG  FlushFlags 
)

Definition at line 506 of file flush.cpp.

512 {
513  ULONG ret_val = 0;
514 #ifndef UDF_READ_ONLY_BUILD
516 
517  UDFPrint(("UDFFlushLogicalVolume: \n"));
518 
519  _SEH2_TRY {
520  if(Vcb->VCBFlags & (UDF_VCB_FLAGS_RAW_DISK/* |
521  UDF_VCB_FLAGS_MEDIA_READ_ONLY*/))
522  return 0;
523  if(Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_READ_ONLY)
524  return 0;
525  if(!(Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_MOUNTED))
526  return 0;
527 
528  // NOTE: This function may also be invoked internally as part of
529  // processing a shutdown request.
530  ASSERT(Vcb->RootDirFCB);
531  ret_val |= UDFFlushADirectory(Vcb, Vcb->RootDirFCB->FileInfo, &IoStatus, FlushFlags);
532 
533 // if(UDFFlushIsBreaking(Vcb, FlushFlags))
534 // return;
535  // flush internal cache
536  if(FlushFlags & UDF_FLUSH_FLAGS_LITE) {
537  UDFPrint((" Lite flush, keep Modified=%d.\n", Vcb->Modified));
538  } else {
539  if(Vcb->VerifyOnWrite) {
540  UDFPrint(("UDF: Flushing cache for verify\n"));
541  //WCacheFlushAll__(&(Vcb->FastCache), Vcb);
542  WCacheFlushBlocks__(&(Vcb->FastCache), Vcb, 0, Vcb->LastLBA);
543  UDFVFlush(Vcb);
544  }
545  // umount (this is internal operation, NT will "dismount" volume later)
546  UDFUmount__(Vcb);
547 
549  WCacheFlushAll__(&(Vcb->FastCache), Vcb);
551  }
552 
553  } _SEH2_FINALLY {
554  ;
555  } _SEH2_END;
556 #endif //UDF_READ_ONLY_BUILD
557 
558  return ret_val;
559 } // end UDFFlushLogicalVolume()
#define UDFPrint(Args)
Definition: udffs.h:225
ULONG UDFFlushADirectory(IN PVCB Vcb, IN PUDF_FILE_INFO FI, OUT PIO_STATUS_BLOCK PtrIoStatus, IN ULONG FlushFlags)
Definition: flush.cpp:415
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
#define UDF_FLUSH_FLAGS_LITE
Definition: struct.h:341
_SEH2_TRY
Definition: create.c:4250
#define UDF_VCB_FLAGS_RAW_DISK
Definition: udf_common.h:476
VOID WCacheFlushAll__(IN PW_CACHE Cache, IN PVOID Context)
#define UDF_VCB_FLAGS_VOLUME_READ_ONLY
Definition: udf_common.h:463
#define Vcb
Definition: cdprocs.h:1425
OSSTATUS UDFUmount__(IN PVCB Vcb)
Definition: mount.cpp:921
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define UDF_VCB_FLAGS_VOLUME_MOUNTED
Definition: udf_common.h:459
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
VOID UDFVFlush(IN PVCB Vcb)
Definition: remap.cpp:742
OSSTATUS WCacheFlushBlocks__(IN PW_CACHE Cache, IN PVOID Context, IN lba_t Lba, IN ULONG BCount)
unsigned int ULONG
Definition: retypes.h:1
VOID UDFPreClrModified(IN PVCB Vcb)
Definition: misc_common.cpp:18
VOID UDFClrModified(IN PVCB Vcb)
Definition: misc_common.cpp:26

Referenced by UDFCommonCreate(), UDFCommonDeviceControl(), UDFCommonFlush(), UDFCommonRead(), UDFCommonWrite(), UDFDoDismountSequence(), and UDFLockVolume().

◆ UDFFlushTryBreak()

VOID UDFFlushTryBreak ( IN PVCB  Vcb)

Definition at line 625 of file flush.cpp.

628 {
629  UDFAcquireResourceExclusive(&(Vcb->FlushResource),TRUE);
630  Vcb->VCBFlags |= UDF_VCB_FLAGS_FLUSH_BREAK_REQ;
631  UDFReleaseResource(&(Vcb->FlushResource));
632 } // end UDFFlushTryBreak()
#define UDFAcquireResourceExclusive(Resource, CanWait)
Definition: env_spec_w32.h:656
#define TRUE
Definition: types.h:120
#define UDFReleaseResource(Resource)
Definition: env_spec_w32.h:661
#define UDF_VCB_FLAGS_FLUSH_BREAK_REQ
Definition: udf_common.h:483
#define Vcb
Definition: cdprocs.h:1425

Referenced by UDFCommonCreate(), UDFCommonDirControl(), UDFCommonFileInfo(), and UDFCommonQueryVolInfo().