Windows: Media Protected if create on RO volume
authorJeffrey Altman <jaltman@your-file-system.com>
Sun, 24 Jun 2012 14:16:42 +0000 (10:16 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Tue, 3 Jul 2012 16:31:45 +0000 (09:31 -0700)
If there is an attempt to create a file/directory on a readonly
volume as indicated by the Volume Characteristics, return
STATUS_MEDIA_WRITE_PROTECTED immediately.  Do not bother contacting
the afsd_service.

Change-Id: I809adacbbc429166d9a0e308752e484400799cb8
Reviewed-on: http://gerrit.openafs.org/7647
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

src/WINNT/afsrdr/kernel/lib/AFSCreate.cpp

index ec41544..df0555e 100644 (file)
@@ -688,6 +688,28 @@ AFSCommonCreate( IN PDEVICE_OBJECT DeviceObject,
               pDirectoryCB == NULL))
         {
 
+            if ( pVolumeCB &&
+                 BooleanFlagOn( pVolumeCB->VolumeInformation.Characteristics, FILE_READ_ONLY_DEVICE))
+            {
+
+                AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+                              AFS_TRACE_LEVEL_VERBOSE,
+                              "AFSCommonCreate ReadOnly Device on create Status %08lX\n",
+                              ntStatus);
+
+                InterlockedDecrement( &pParentDirectoryCB->OpenReferenceCount);
+
+                AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+                              AFS_TRACE_LEVEL_VERBOSE,
+                              "AFSCommonCreate Decrement13 count on %wZ DE %p Ccb %p Cnt %d\n",
+                              &pParentDirectoryCB->NameInformation.FileName,
+                              pParentDirectoryCB,
+                              NULL,
+                              pParentDirectoryCB->OpenReferenceCount);
+
+                try_return( ntStatus = STATUS_MEDIA_WRITE_PROTECTED);
+            }
+
             if( uniComponentName.Length == 0 ||
                 pDirectoryCB != NULL)
             {