Skip to content

Commit 11d7349

Browse files
committed
Kernel - Add doc for DeletePending and format few files
1 parent 5657c4b commit 11d7349

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

sys/cleanup.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,23 @@ Return Value:
113113
DokanNotifyReportChange(RequestContext, fcb, FILE_NOTIFY_CHANGE_LAST_WRITE,
114114
FILE_ACTION_MODIFIED);
115115
}
116+
// DeleteOnClose is set during CreateFile but is only executed by the last
117+
// handle on the object is closed. We transfer the marker to the Fcb and will
118+
// see below if there is any outstanding open handle that will delay the
119+
// deletion execution.
116120
if (DokanCCBFlagsIsSet(ccb, DOKAN_DELETE_ON_CLOSE)) {
121+
// `DOKAN_FCB_STATE_DELETE_PENDING` will prevent the Fcb to be open. Note:
122+
// Since `UncleanCount` is set on `DokanCompleteCreate` but this flag is
123+
// checked during `DokanDispatchCreate`, there is still a possible race
124+
// condition where an inflight create will succeed.
117125
DokanFCBFlagsSetBit(fcb, DOKAN_FCB_STATE_DELETE_PENDING);
118126
DokanCCBFlagsClearBit(ccb, DOKAN_DELETE_ON_CLOSE);
119127
DOKAN_LOG_FINE_IRP(RequestContext,
120128
"Transfer DeleteOnClose from Ccb=%p to Fcb=%p", ccb,
121129
fcb);
122130
}
123-
// Only notify when the last handle on Fcb marked for deletion.
131+
// The Fcb is marked for deletion due to DeleteOnClose or through
132+
// FileDisposition, the last handle will execute the deletion.
124133
BOOLEAN deletePending =
125134
fcb->UncleanCount == 1 && DokanFCBIsPendingDeletion(fcb);
126135
BOOLEAN isDirectory = DokanFCBFlagsIsSet(fcb, DOKAN_FILE_DIRECTORY);

sys/dokan.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ typedef struct _DokanDiskControlBlock {
275275
ULONG IrpTimeout;
276276
ULONG SessionId;
277277
IO_REMOVE_LOCK RemoveLock;
278-
278+
279279
// If true, we know the requested mount point is occupied by a dokan drive we
280280
// can't remove, so force the mount manager to auto-assign a different drive
281281
// letter.

sys/fileinfo.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ DokanDispatchQueryInformation(__in PREQUEST_CONTEXT RequestContext) {
9696
if (!PrepareOutputHelper(
9797
RequestContext->Irp, &allInfo,
9898
FIELD_OFFSET(FILE_ALL_INFORMATION, NameInformation.FileName),
99-
/*SetInformationOnFailure=*/FALSE)) {
99+
/*SetInformationOnFailure=*/FALSE)) {
100100
status = STATUS_BUFFER_TOO_SMALL;
101101
__leave;
102102
}
@@ -106,7 +106,7 @@ DokanDispatchQueryInformation(__in PREQUEST_CONTEXT RequestContext) {
106106
PFILE_NAME_INFORMATION nameInfo;
107107
if (!PrepareOutputHelper(RequestContext->Irp, &nameInfo,
108108
FIELD_OFFSET(FILE_NAME_INFORMATION, FileName),
109-
/*SetInformationOnFailure=*/FALSE)) {
109+
/*SetInformationOnFailure=*/FALSE)) {
110110
status = STATUS_BUFFER_TOO_SMALL;
111111
__leave;
112112
}
@@ -599,7 +599,6 @@ DokanDispatchSetInformation(__in PREQUEST_CONTEXT RequestContext) {
599599
}
600600

601601
if (!isPagingIo) {
602-
603602
CcFlushCache(&fcb->SectionObjectPointers, NULL, 0, NULL);
604603

605604
DokanPagingIoLockRW(fcb);
@@ -620,7 +619,7 @@ DokanDispatchSetInformation(__in PREQUEST_CONTEXT RequestContext) {
620619
ASSERT(posInfo != NULL);
621620

622621
DOKAN_LOG_FINE_IRP(RequestContext, "FilePositionInformation %lld",
623-
posInfo->CurrentByteOffset.QuadPart);
622+
posInfo->CurrentByteOffset.QuadPart);
624623
fileObject->CurrentByteOffset = posInfo->CurrentByteOffset;
625624

626625
status = STATUS_SUCCESS;
@@ -635,9 +634,9 @@ DokanDispatchSetInformation(__in PREQUEST_CONTEXT RequestContext) {
635634
*/
636635
targetFileObject = RequestContext->IrpSp->Parameters.SetFile.FileObject;
637636
if (targetFileObject != NULL) {
638-
DOKAN_LOG_FINE_IRP(RequestContext,
639-
"FileObject Specified so perform flush %p \"%wZ\"",
640-
targetFileObject, &(targetFileObject->FileName));
637+
DOKAN_LOG_FINE_IRP(RequestContext,
638+
"FileObject Specified so perform flush %p \"%wZ\"",
639+
targetFileObject, &(targetFileObject->FileName));
641640
PDokanCCB targetCcb = (PDokanCCB)targetFileObject->FsContext2;
642641
ASSERT(targetCcb != NULL);
643642
PDokanFCB targetFcb = (PDokanFCB)targetCcb->Fcb;

0 commit comments

Comments
 (0)