Windows: disable short names in redirector option
authorPeter Scott <pscott@kerneldrivers.com>
Mon, 6 Aug 2012 19:12:12 +0000 (15:12 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Fri, 10 Aug 2012 22:41:23 +0000 (15:41 -0700)
If requested during redirector initialization, disable short
name processing.   Future versions of Windows (8, Server 2012,
and beyond) will no longer require short names.

Change-Id: I14b20afd919ed9dd8dc48dd7997089b5748a8896
Reviewed-on: http://gerrit.openafs.org/7946
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/common/AFSRedirCommonDefines.h
src/WINNT/afsrdr/common/AFSUserStructs.h
src/WINNT/afsrdr/kernel/fs/AFSRDRSupport.cpp
src/WINNT/afsrdr/kernel/lib/AFSCommSupport.cpp
src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp
src/WINNT/afsrdr/kernel/lib/AFSGeneric.cpp
src/WINNT/afsrdr/kernel/lib/AFSNameSupport.cpp

index 5d7753e..d98c015 100644 (file)
@@ -243,6 +243,7 @@ static inline void AFSBreakPoint() {
 
 #define AFS_DEVICE_FLAG_HIDE_DOT_NAMES          0x00000001
 #define AFS_DEVICE_FLAG_REDIRECTOR_SHUTDOWN     0x00000002
+#define AFS_DEVICE_FLAG_DISABLE_SHORTNAMES      0x00000004
 
 #endif
 
index c759cec..8911a63 100644 (file)
@@ -108,8 +108,8 @@ typedef struct _AFS_COMM_RESULT_BLOCK
 //
 
 #define AFS_REDIR_INIT_FLAG_HIDE_DOT_FILES          0x00000001
-
 #define AFS_REDIR_INIT_NO_PAGING_FILE               0x00000002
+#define AFS_REDIR_INIT_FLAG_DISABLE_SHORTNAMES     0x00000004
 
 typedef struct _AFS_REDIR_INIT_INFO_CB
 {
index 4b28bb9..12b899d 100644 (file)
@@ -503,6 +503,16 @@ AFSInitializeRedirector( IN AFSRedirectorInitInfo *RedirInitInfo)
             SetFlag( pDevExt->DeviceFlags, AFS_DEVICE_FLAG_HIDE_DOT_NAMES);
         }
 
+        if( BooleanFlagOn( RedirInitInfo->Flags, AFS_REDIR_INIT_FLAG_DISABLE_SHORTNAMES))
+        {
+
+            //
+            // Hide files which begin with .
+            //
+
+            SetFlag( pDevExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES);
+        }
+
         if( RedirInitInfo->MemoryCacheOffset.QuadPart != 0 &&
             RedirInitInfo->MemoryCacheLength.QuadPart != 0)
         {
index 5bf6053..80e427d 100644 (file)
@@ -56,6 +56,7 @@ AFSEnumerateDirectory( IN GUID *AuthGroup,
     ULONG   ulRequestFlags = AFS_REQUEST_FLAG_SYNCHRONOUS;
     ULONG ulCRC = 0;
     UNICODE_STRING uniGUID;
+    AFSDeviceExt *pDevExt = (AFSDeviceExt *) AFSRDRDeviceObject->DeviceExtension;
 
     __Enter
     {
@@ -429,7 +430,8 @@ AFSEnumerateDirectory( IN GUID *AuthGroup,
                 // Init the short name if we have one
                 //
 
-                if( pCurrentDirEntry->ShortNameLength > 0)
+                if( !BooleanFlagOn( pDevExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
+                    pCurrentDirEntry->ShortNameLength > 0)
                 {
 
                     UNICODE_STRING uniShortName;
@@ -475,6 +477,15 @@ AFSEnumerateDirectory( IN GUID *AuthGroup,
                                        (12 * sizeof( WCHAR)));
                     }
                 }
+                else
+                {
+
+                    //
+                    // No short name or short names are disabled
+                    //
+
+                    pDirNode->Type.Data.ShortNameTreeEntry.HashIndex = 0;
+                }
 
                 //
                 // Insert the node into the name tree
@@ -758,6 +769,7 @@ AFSVerifyDirectoryContent( IN AFSObjectInfoCB *ObjectInfoCB,
     ULONGLONG ullIndex = 0;
     UNICODE_STRING uniGUID;
     LONG lCount;
+    AFSDeviceExt *pDevExt = (AFSDeviceExt *) AFSRDRDeviceObject->DeviceExtension;
 
     __Enter
     {
@@ -1232,7 +1244,8 @@ AFSVerifyDirectoryContent( IN AFSObjectInfoCB *ObjectInfoCB,
                 // Init the short name if we have one
                 //
 
-                if( pCurrentDirEntry->ShortNameLength > 0)
+                if( !BooleanFlagOn( pDevExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
+                    pCurrentDirEntry->ShortNameLength > 0)
                 {
 
                     UNICODE_STRING uniShortName;
@@ -1281,15 +1294,11 @@ AFSVerifyDirectoryContent( IN AFSObjectInfoCB *ObjectInfoCB,
                 else
                 {
 
-                    AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
-                                  AFS_TRACE_LEVEL_VERBOSE,
-                                  "AFSVerifyDirectoryContent NO short name for DE %p for %wZ FID %08lX-%08lX-%08lX-%08lX\n",
-                                  pDirNode,
-                                  &pDirNode->NameInformation.FileName,
-                                  pCurrentDirEntry->FileId.Cell,
-                                  pCurrentDirEntry->FileId.Volume,
-                                  pCurrentDirEntry->FileId.Vnode,
-                                  pCurrentDirEntry->FileId.Unique);
+                    //
+                    // No short name or short names have been disabled
+                    //
+
+                    pDirNode->Type.Data.ShortNameTreeEntry.HashIndex = 0;
                 }
 
                 //
@@ -1515,6 +1524,7 @@ AFSNotifyFileCreate( IN GUID            *AuthGroup,
     AFSDirectoryCB *pDirNode = NULL;
     ULONG     ulCRC = 0;
     LARGE_INTEGER liOldDataVersion;
+    AFSDeviceExt *pDevExt = (AFSDeviceExt *) AFSRDRDeviceObject->DeviceExtension;
 
     __Enter
     {
@@ -1760,7 +1770,8 @@ AFSNotifyFileCreate( IN GUID            *AuthGroup,
         // Init the short name if we have one
         //
 
-        if( pResultCB->DirEnum.ShortNameLength > 0)
+        if( !BooleanFlagOn( pDevExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
+            pResultCB->DirEnum.ShortNameLength > 0)
         {
 
             UNICODE_STRING uniShortName;
@@ -1788,6 +1799,14 @@ AFSNotifyFileCreate( IN GUID            *AuthGroup,
                           pDirNode,
                           &pDirNode->NameInformation.FileName);
         }
+        else
+        {
+            //
+            // No short name or short names are disabled
+            //
+
+            pDirNode->Type.Data.ShortNameTreeEntry.HashIndex = 0;
+        }
 
         if ( !BooleanFlagOn( ParentObjectInfo->Flags, AFS_OBJECT_FLAGS_VERIFY))
         {
@@ -2059,6 +2078,7 @@ AFSNotifyRename( IN AFSObjectInfoCB *ObjectInfo,
     AFSFileRenameCB *pRenameCB = NULL;
     AFSFileRenameResultCB *pRenameResultCB = NULL;
     ULONG ulResultLen = 0;
+    AFSDeviceExt *pDevExt = (AFSDeviceExt *) AFSRDRDeviceObject->DeviceExtension;
 
     __Enter
     {
@@ -2166,7 +2186,8 @@ AFSNotifyRename( IN AFSObjectInfoCB *ObjectInfo,
 
         DirectoryCB->NameInformation.ShortNameLength = pRenameResultCB->DirEnum.ShortNameLength;
 
-        if( DirectoryCB->NameInformation.ShortNameLength > 0)
+        if( !BooleanFlagOn( pDevExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
+            DirectoryCB->NameInformation.ShortNameLength > 0)
         {
 
             UNICODE_STRING uniShortName;
index 5e6aa7d..653142a 100644 (file)
@@ -2089,6 +2089,7 @@ AFSSetRenameInfo( IN PIRP Irp)
 {
 
     NTSTATUS ntStatus = STATUS_SUCCESS;
+    AFSDeviceExt *pDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
     PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp);
     IO_STATUS_BLOCK stIoSb = {0,0};
     AFSFcb *pSrcFcb = NULL, *pTargetDcb = NULL, *pTargetFcb = NULL;
@@ -2289,7 +2290,8 @@ AFSSetRenameInfo( IN PIRP Irp)
                                               &pTargetDirEntry);
         }
 
-        if( pTargetDirEntry == NULL && RtlIsNameLegalDOS8Dot3( &uniTargetName,
+        if ( !BooleanFlagOn( pDeviceExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
+             pTargetDirEntry == NULL && RtlIsNameLegalDOS8Dot3( &uniTargetName,
                                                                NULL,
                                                                NULL))
         {
@@ -2514,7 +2516,8 @@ AFSSetRenameInfo( IN PIRP Irp)
         pSrcCcb->DirectoryCB->CaseInsensitiveTreeEntry.HashIndex = AFSGenerateCRC( &pSrcCcb->DirectoryCB->NameInformation.FileName,
                                                                                    TRUE);
 
-        if( pSrcCcb->DirectoryCB->NameInformation.ShortNameLength > 0 &&
+        if( !BooleanFlagOn( pDeviceExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
+            pSrcCcb->DirectoryCB->NameInformation.ShortNameLength > 0 &&
             !RtlIsNameLegalDOS8Dot3( &pSrcCcb->DirectoryCB->NameInformation.FileName,
                                      NULL,
                                      NULL))
index 5dc0510..547ed7c 100644 (file)
@@ -3366,6 +3366,7 @@ AFSValidateDirectoryCache( IN AFSObjectInfoCB *ObjectInfo,
 {
 
     NTSTATUS ntStatus = STATUS_SUCCESS;
+    AFSDeviceExt *pDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
     BOOLEAN  bAcquiredLock = FALSE;
     AFSDirectoryCB *pCurrentDirEntry = NULL, *pNextDirEntry = NULL;
     AFSFcb *pFcb = NULL;
@@ -3507,7 +3508,8 @@ AFSValidateDirectoryCache( IN AFSObjectInfoCB *ObjectInfo,
             if( BooleanFlagOn( pCurrentDirEntry->Flags, AFS_DIR_ENTRY_VALID))
             {
 
-                if( !BooleanFlagOn( pCurrentDirEntry->Flags, AFS_DIR_ENTRY_INSERTED_SHORT_NAME) &&
+                if( !BooleanFlagOn( pDeviceExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
+                    !BooleanFlagOn( pCurrentDirEntry->Flags, AFS_DIR_ENTRY_INSERTED_SHORT_NAME) &&
                     pCurrentDirEntry->Type.Data.ShortNameTreeEntry.HashIndex > 0)
                 {
 
@@ -8329,6 +8331,7 @@ AFSCheckSymlinkAccess( IN AFSDirectoryCB *ParentDirectoryCB,
 {
 
     NTSTATUS ntStatus = STATUS_SUCCESS;
+    AFSDeviceExt *pDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
     AFSDirectoryCB *pDirEntry = NULL;
     ULONG ulCRC = 0;
     LONG lCount;
@@ -8382,7 +8385,8 @@ AFSCheckSymlinkAccess( IN AFSDirectoryCB *ParentDirectoryCB,
                 // a lookup in the short name tree
                 //
 
-                if( RtlIsNameLegalDOS8Dot3( ComponentName,
+                if( !BooleanFlagOn( pDeviceExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
+                    RtlIsNameLegalDOS8Dot3( ComponentName,
                                             NULL,
                                             NULL))
                 {
index 5727b81..028e15f 100644 (file)
@@ -1429,7 +1429,8 @@ AFSLocateNameEntry( IN GUID *AuthGroup,
                         // a lookup in the short name tree
                         //
 
-                        if( RtlIsNameLegalDOS8Dot3( &uniSearchName,
+                        if( !BooleanFlagOn( pDevExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
+                            RtlIsNameLegalDOS8Dot3( &uniSearchName,
                                                     NULL,
                                                     NULL))
                         {
@@ -3498,7 +3499,8 @@ AFSParseName( IN PIRP Irp,
                 // a lookup in the short name tree
                 //
 
-                if( RtlIsNameLegalDOS8Dot3( &uniComponentName,
+                if( !BooleanFlagOn( pDeviceExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
+                    RtlIsNameLegalDOS8Dot3( &uniComponentName,
                                             NULL,
                                             NULL))
                 {