Windows: Deny writes/truncation to files w RO attr
[openafs.git] / src / WINNT / afsrdr / kernel / lib / AFSWrite.cpp
index 3fcdbbd..1376d06 100644 (file)
@@ -260,7 +260,7 @@ AFSCommonWrite( IN PDEVICE_OBJECT DeviceObject,
                           "AFSCommonWrite (%p) Request failed due to read only volume\n",
                           Irp));
 
-            try_return( ntStatus = STATUS_ACCESS_DENIED);
+            try_return( ntStatus = STATUS_MEDIA_WRITE_PROTECTED);
         }
 
         //
@@ -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;