From a4bcc4b1dccf6ab2745be83288c380f5454a2db9 Mon Sep 17 00:00:00 2001 From: Rod Widdowson Date: Mon, 14 Apr 2014 16:50:36 -0400 Subject: [PATCH] Windows: Pin write position prior to defer If we extend the file prior to defrring the write *and* the write is set up FILE_WRITE_TO_END_OF_FILE then we have to convert the FILE_WRITE_TO_END_OF_FILE to an absolute position since we have already moved the FCB->Header.FileSize. Change-Id: Ibe1a5d616490a3db152818cbd6bb24d5af251c5f Reviewed-on: http://gerrit.openafs.org/11069 Tested-by: BuildBot Reviewed-by: Rod Widdowson Reviewed-by: Jeffrey Altman --- src/WINNT/afsrdr/kernel/lib/AFSWrite.cpp | 27 ++++++++++++++---------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/WINNT/afsrdr/kernel/lib/AFSWrite.cpp b/src/WINNT/afsrdr/kernel/lib/AFSWrite.cpp index 3fcdbbd6d..eb3adaf27 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSWrite.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSWrite.cpp @@ -591,18 +591,23 @@ AFSCommonWrite( IN PDEVICE_OBJECT DeviceObject, bReleaseSectionObject = TRUE; if ( bWriteToEndOfFile) - { - if (pFcb->Header.ValidDataLength.QuadPart > pFcb->Header.FileSize.QuadPart) - { - liStartingByte = pFcb->Header.ValidDataLength; - } - else - { - liStartingByte = pFcb->Header.FileSize; - } - } + { - // + if (pFcb->Header.ValidDataLength.QuadPart > pFcb->Header.FileSize.QuadPart) + { + + liStartingByte = pFcb->Header.ValidDataLength; + } + else + { + + liStartingByte = pFcb->Header.FileSize; + } + + pIrpSp->Parameters.Write.ByteOffset = liStartingByte; + } + + // // We have the correct lock - even if we don't end up truncating // bLockOK = TRUE; -- 2.39.5