Windows: disable short names on Windows 8
authorJeffrey Altman <jaltman@your-file-system.com>
Wed, 8 Aug 2012 17:54:48 +0000 (13:54 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Fri, 10 Aug 2012 22:42:27 +0000 (15:42 -0700)
Add "ShortNames" option to control whether 8.3 compatible short
names are generated for objects stored in AFS.   Set the default
to on for all operating systems prior to Windows 8 and Server 2012.

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

doc/xml/ReleaseNotesWindows/relnotes.xml
src/WINNT/afsd/afsd.h
src/WINNT/afsd/afsd_init.c
src/WINNT/afsd/cm_btree.c
src/WINNT/afsd/cm_vnodeops.c
src/WINNT/afsd/smb.c
src/WINNT/afsd/smb3.c
src/WINNT/afsrdr/user/RDRFunction.c

index 894d4c5..e409260 100644 (file)
             <para>Microsoft Windows 2008 Server R2 (64-bit Intel)</para>
           </listitem>
           <listitem>
-            <para>Microsoft Windows 8 Release Preview (32-bit and 64-bit Intel)</para>
-            <para><emphasis role="italic">(not guaranteed to work with the final
-              release)</emphasis></para>
+            <para>Microsoft Windows 8 (32-bit and 64-bit Intel)</para>
           </listitem>
           <listitem>
-            <para>Microsoft Windows Server 2012 Release Preview (64-bit Intel)</para>
-            <para><emphasis role="italic">(not guaranteed to work with the final
-              release)</emphasis></para>
+            <para>Microsoft Windows Server 2012 (64-bit Intel)</para>
           </listitem>
         </itemizedlist>
       </para>
       </itemizedlist>
       </para>
     </section>
+    <section>
+      <title id="windows8_changes">3.56. Changes for Windows 8 and Server 2012</title>
+      <indexterm significance="normal">
+        <primary>Windows 8</primary>
+      </indexterm>
+      <indexterm significance="normal">
+        <primary>Server 2012</primary>
+      </indexterm>
+      <para>
+      In Windows 8 and Server 2012 Microsoft has introduced a new file system, ReFS, and has begun the process of transitioning away from several legacy file system properties including 8.3 compatible short names for all file system objects.
+      The OpenAFS file system has followed suit and is disabling automatic generation of 8.3 compatible names on Windows 8 and Server 2012.
+      </para>
+    </section>
 
   </chapter>
   <chapter id="chap_4">
@@ -4213,6 +4222,20 @@ Default: 0</para>
           <para>The "fs getverify" and "fs setverify {on, off}" commands can be used to query and
             set this value at runtime.</para>
         </section>
+        <section>
+          <title id="Regkey_TransarcAFSDaemon_Parameters_ShortNames">Value: ShortNames</title>
+          <indexterm significance="normal">
+            <primary>ShortNames</primary>
+          </indexterm>
+          <para>Regkey: [HKLM\SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters]</para>
+          <para>Type: DWORD {0, 1}
+          </para>
+          <para>
+            Default: 0 on Windows 8 and Server 2012, 1 otherwise</para>
+          <para>Determines whether or not the AFS Cache Manager will generate 8.3 compatible shortnames for all objects stored in AFS.  Short names are disabled by default on Windows 8 and Server 2012.  All prior operating systems enable short names by default.</para>
+          <para>0: do not generate 8.3 compatible short names.</para>
+          <para>1: generate 8.3 compatible short names.</para>
+        </section>
       </section>
       <section>
         <title id="Regkey_TransarcAFSDaemon_Parameters_GlobalAutoMapper">Regkey:
index feabae2..695973a 100644 (file)
@@ -114,6 +114,7 @@ extern int cm_fakeGettingCallback;                  // 1 if currently updating the fake root.af
 
 extern int cm_dnsEnabled;
 extern int cm_readonlyVolumeVersioning;
+extern int cm_shortNames;
 
 extern long rx_mtu;
 
index 5bfac71..44763cf 100644 (file)
@@ -77,6 +77,7 @@ int cm_logChunkSize;
 int cm_chunkSize;
 int cm_virtualCache = 0;
 afs_int32 cm_verifyData = 0;
+int cm_shortNames = 1;
 
 int smb_UseV3 = 1;
 afs_uint32 smb_Enabled = 1;
@@ -534,6 +535,12 @@ afsd_InitCM(char **reasonP)
     int cm_NetMtu[CM_MAXINTERFACE_ADDR];    /* client's MTU sizes */
     int cm_NetFlags[CM_MAXINTERFACE_ADDR];  /* network flags */
     DWORD dwPriority;
+    OSVERSIONINFO osVersion;
+
+    /* Get the version of Windows */
+    memset(&osVersion, 0x00, sizeof(osVersion));
+    osVersion.dwOSVersionInfoSize = sizeof(osVersion);
+    GetVersionEx(&osVersion);
 
     WSAStartup(0x0101, &WSAjunk);
 
@@ -1356,6 +1363,22 @@ afsd_InitCM(char **reasonP)
     }
     afsi_log("CM ReadOnlyVolumeVersioning is %u", cm_readonlyVolumeVersioning);
 
+    dummyLen = sizeof(DWORD);
+    code = RegQueryValueEx(parmKey, "ShortNames", NULL, NULL,
+                           (BYTE *) &dwValue, &dummyLen);
+    if (code == ERROR_SUCCESS) {
+        cm_shortNames = (unsigned short) dwValue;
+    } else {
+        /* disable by default on Win8 and Server 2008 R2 */
+        if (osVersion.dwMajorVersion > 6 ||
+            osVersion.dwMajorVersion == 6 &&
+            osVersion.dwMinorVersion >= 2)
+            cm_shortNames = 0;
+        else
+            cm_shortNames = 1;
+    }
+    afsi_log("CM ShortNames is %u", cm_shortNames);
+
     RegCloseKey (parmKey);
 
     cacheBlocks = ((afs_uint64)cacheSize * 1024) / blockSize;
@@ -1373,7 +1396,7 @@ afsd_InitCM(char **reasonP)
                   cm_IPAddr[0], cm_SubnetMask[0]);
 
     /*
-     * Save client configuration for GetCacheConfig requests
+     * Save client configuration for GetCacheConf\eig requests
      */
     cm_initParams.nChunkFiles = 0;
     cm_initParams.nStatCaches = stats;
index 4f7048d..fc1b9d4 100644 (file)
@@ -1797,7 +1797,7 @@ long cm_BPlusDirCreateEntry(cm_dirOp_t * op, clientchar_t * entry, cm_fid_t * cf
 
     insert(op->scp->dirBplus, key, data);
 
-    if (!cm_Is8Dot3(entry)) {
+    if (cm_shortNames && !cm_Is8Dot3(entry)) {
         cm_dirFid_t dfid;
         clientchar_t wshortName[13];
 
@@ -1908,14 +1908,17 @@ int  cm_BPlusDirDeleteEntry(cm_dirOp_t * op, clientchar_t *centry)
                 }
 
                 if (rc != CM_ERROR_AMBIGUOUS_FILENAME) {
-                    dfid.vnode = htonl(fid.vnode);
-                    dfid.unique = htonl(fid.unique);
-                    cm_Gen8Dot3NameIntW(centry, &dfid, shortName, NULL);
-
                     /* delete first the long name and then the short name */
                     delete(op->scp->dirBplus, key);
-                    key.name = shortName;
-                    delete(op->scp->dirBplus, key);
+
+                    if (cm_shortNames) {
+                        dfid.vnode = htonl(fid.vnode);
+                        dfid.unique = htonl(fid.unique);
+                        cm_Gen8Dot3NameIntW(centry, &dfid, shortName, NULL);
+
+                        key.name = shortName;
+                        delete(op->scp->dirBplus, key);
+                    }
                 }
             } /* !NONODE */
         } else {
@@ -2031,7 +2034,7 @@ int cm_BPlusDirFoo(struct cm_scache *scp, struct cm_dirEntry *dep,
     /* the Write lock is held in cm_BPlusDirBuildTree() */
     insert(scp->dirBplus, key, data);
 
-    if (!cm_Is8Dot3(data.cname)) {
+    if (cm_shortNames && !cm_Is8Dot3(data.cname)) {
         cm_dirFid_t dfid;
         wchar_t wshortName[13];
 
@@ -2276,17 +2279,19 @@ cm_BPlusDirEnumerate(cm_scache_t *dscp, cm_user_t *userp, cm_req_t *reqp,
                     enump->entry[count].name = name;
                     enump->entry[count].fid  = getdatavalue(dataNode).fid;
 
-                    if (!cm_Is8Dot3(name)) {
-                        cm_dirFid_t dfid;
+                    if (cm_shortNames) {
+                        if (!cm_Is8Dot3(name)) {
+                            cm_dirFid_t dfid;
 
-                        dfid.vnode = htonl(getdatavalue(dataNode).fid.vnode);
-                        dfid.unique = htonl(getdatavalue(dataNode).fid.unique);
+                            dfid.vnode = htonl(getdatavalue(dataNode).fid.vnode);
+                            dfid.unique = htonl(getdatavalue(dataNode).fid.unique);
 
-                        cm_Gen8Dot3NameIntW(name, &dfid, enump->entry[count].shortName, NULL);
-                    } else {
-                        StringCbCopyW(enump->entry[count].shortName,
-                                      sizeof(enump->entry[count].shortName),
-                                      name);
+                            cm_Gen8Dot3NameIntW(name, &dfid, enump->entry[count].shortName, NULL);
+                        } else {
+                            StringCbCopyW(enump->entry[count].shortName,
+                                          sizeof(enump->entry[count].shortName),
+                                          name);
+                        }
                     }
 
                     count++;
index 5ee30c7..2432edb 100644 (file)
@@ -767,6 +767,7 @@ long cm_LookupSearchProc(cm_scache_t *scp, cm_dirEntry_t *dep, void *rockp,
 
     if (match != 0
         && sp->hasTilde
+        && cm_shortNames
         && !cm_Is8Dot3(matchName)) {
 
         cm_Gen8Dot3NameInt(dep->name, &dep->fid, matchName, NULL);
index 8d699a4..d9d5332 100644 (file)
@@ -5189,7 +5189,7 @@ long smb_ReceiveCoreSearchDir(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *ou
 
         /* Compute 8.3 name if necessary */
         actualName = cm_FsStringToClientStringAlloc(dep->name, -1, NULL);
-        if (dep->fid.vnode != 0 && !cm_Is8Dot3(actualName)) {
+        if (dep->fid.vnode != 0 && cm_shortNames && !cm_Is8Dot3(actualName)) {
             if (actualName)
                 free(actualName);
             cm_Gen8Dot3NameInt(dep->name, &dep->fid, shortName, &shortNameEnd);
@@ -5947,6 +5947,7 @@ int smb_UnlinkProc(cm_scache_t *dscp, cm_dirEntry_t *dep, void *vrockp, osi_hype
     match = cm_MatchMask(matchName, rockp->maskp, caseFold);
     if (!match &&
         (rockp->flags & SMB_MASKFLAG_TILDE) &&
+        cm_shortNames &&
         !cm_Is8Dot3(matchName)) {
         cm_Gen8Dot3Name(dep, matchName, NULL);
         /* 8.3 matches are always case insensitive */
@@ -6153,6 +6154,7 @@ int smb_RenameProc(cm_scache_t *dscp, cm_dirEntry_t *dep, void *vrockp, osi_hype
     match = cm_MatchMask(matchName, rockp->maskp, caseFold);
     if (!match &&
         (rockp->flags & SMB_MASKFLAG_TILDE) &&
+        cm_shortNames &&
         !cm_Is8Dot3(matchName)) {
         cm_Gen8Dot3Name(dep, matchName, NULL);
         match = cm_MatchMask(matchName, rockp->maskp, caseFold);
@@ -6613,6 +6615,7 @@ int smb_RmdirProc(cm_scache_t *dscp, cm_dirEntry_t *dep, void *vrockp, osi_hyper
         match = (cm_ClientStrCmp(matchName, rockp->maskp) == 0);
     if (!match &&
          (rockp->flags & SMB_MASKFLAG_TILDE) &&
+         cm_shortNames &&
          !cm_Is8Dot3(matchName)) {
         cm_Gen8Dot3Name(dep, matchName, NULL);
         match = (cm_ClientStrCmpI(matchName, rockp->maskp) == 0);
@@ -6830,7 +6833,7 @@ int smb_FullNameProc(cm_scache_t *scp, cm_dirEntry_t *dep, void *rockp,
         return 0;
     }
 
-    if (!cm_Is8Dot3(matchName)) {
+    if (cm_shortNames && !cm_Is8Dot3(matchName)) {
         clientchar_t shortName[13];
 
         cm_Gen8Dot3Name(dep, shortName, NULL);
index b154bcc..9507920 100644 (file)
@@ -5232,8 +5232,8 @@ long smb_T2SearchDirSingle(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op
 
     fp = (smb_tran2Find_t *) op;
 
-    if (infoLevel == SMB_FIND_FILE_BOTH_DIRECTORY_INFO
-        && !cm_Is8Dot3(maskp)) {
+    if (infoLevel == SMB_FIND_FILE_BOTH_DIRECTORY_INFO &&
+        cm_shortNames && !cm_Is8Dot3(maskp)) {
 
         /*
          * Since the _._AFS_IOCTL_._ file does not actually exist
@@ -5960,6 +5960,7 @@ long smb_ReceiveTran2SearchDir(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t
         /* Need 8.3 name? */
         NeedShortName = 0;
         if (infoLevel == SMB_FIND_FILE_BOTH_DIRECTORY_INFO &&
+            cm_shortNames &&
             !cm_Is8Dot3(cfileName)) {
             cm_Gen8Dot3Name(dep, shortName, &shortNameEnd);
             NeedShortName = 1;
index a1174ba..e8b89ab 100644 (file)
@@ -140,6 +140,7 @@ RDR_SetInitParams( OUT AFSRedirectorInitInfo **ppRedirInitInfo, OUT DWORD * pRed
     *pRedirInitInfoLen = (DWORD) (sizeof(AFSRedirectorInitInfo) + (cm_CachePathLen + TempPathLen) * sizeof(WCHAR));
     *ppRedirInitInfo = (AFSRedirectorInitInfo *)malloc(*pRedirInitInfoLen);
     (*ppRedirInitInfo)->Flags = smb_hideDotFiles ? AFS_REDIR_INIT_FLAG_HIDE_DOT_FILES : 0;
+    (*ppRedirInitInfo)->Flags |= cm_shortNames ? 0 : AFS_REDIR_INIT_FLAG_DISABLE_SHORTNAMES;
     (*ppRedirInitInfo)->MaximumChunkLength = cm_data.chunkSize;
     (*ppRedirInitInfo)->GlobalFileId.Cell   = cm_data.rootFid.cell;
     (*ppRedirInitInfo)->GlobalFileId.Volume = cm_data.rootFid.volume;
@@ -896,7 +897,7 @@ RDR_EnumerateDirectory( IN cm_user_t *userp,
                     code = RDR_PopulateCurrentEntry( pCurrentEntry, dwMaxEntryLength,
                                                      dscp, scp, userp, &req,
                                                      entryp->name,
-                                                     cm_Is8Dot3(entryp->name) ? NULL : entryp->shortName,
+                                                     cm_shortNames && cm_Is8Dot3(entryp->name) ? NULL : entryp->shortName,
                                                      (bWow64 ? RDR_POP_WOW64 : 0) |
                                                      (bSkipStatus ? RDR_POP_NO_GETSTATUS : 0),
                                                      code,
@@ -906,7 +907,7 @@ RDR_EnumerateDirectory( IN cm_user_t *userp,
                     code = RDR_PopulateCurrentEntryNoScp( pCurrentEntry, dwMaxEntryLength,
                                                           dscp, &entryp->fid, userp, &req,
                                                           entryp->name,
-                                                          cm_Is8Dot3(entryp->name) ? NULL : entryp->shortName,
+                                                          cm_shortNames && cm_Is8Dot3(entryp->name) ? NULL : entryp->shortName,
                                                           (bWow64 ? RDR_POP_WOW64 : 0),
                                                           code,
                                                           &pCurrentEntry, &dwMaxEntryLength);
@@ -1077,7 +1078,9 @@ RDR_EvaluateNodeByName( IN cm_user_t *userp,
     if (code == 0 && scp) {
         wchar_t shortName[13]=L"";
 
-        if (bVol) {
+        if (!cm_shortNames) {
+            shortName[0] = L'\0';
+        } else if (bVol) {
             cm_Gen8Dot3VolNameW(scp->fid.cell, scp->fid.volume, shortName, NULL);
         } else if (!cm_Is8Dot3(wszName)) {
             cm_dirFid_t dfid;
@@ -1087,7 +1090,7 @@ RDR_EvaluateNodeByName( IN cm_user_t *userp,
 
             cm_Gen8Dot3NameIntW(FileName, &dfid, shortName, NULL);
         } else {
-            shortName[0] = '\0';
+            shortName[0] = L'\0';
         }
 
         code = RDR_PopulateCurrentEntry(pCurrentEntry, dwRemaining,
@@ -1418,13 +1421,15 @@ RDR_CreateFileEntry( IN cm_user_t *userp,
         cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
         lock_ReleaseWrite(&dscp->rw);
 
-        dfid.vnode = htonl(scp->fid.vnode);
-        dfid.unique = htonl(scp->fid.unique);
+        if (cm_shortNames) {
+            dfid.vnode = htonl(scp->fid.vnode);
+            dfid.unique = htonl(scp->fid.unique);
 
-        if (!cm_Is8Dot3(FileName))
-            cm_Gen8Dot3NameIntW(FileName, &dfid, shortName, NULL);
-        else
-            shortName[0] = '\0';
+            if (!cm_Is8Dot3(FileName))
+                cm_Gen8Dot3NameIntW(FileName, &dfid, shortName, NULL);
+            else
+                shortName[0] = '\0';
+        }
 
         code = RDR_PopulateCurrentEntry(&pResultCB->DirEnum, dwRemaining,
                                         dscp, scp, userp, &req, FileName, shortName,
@@ -2421,13 +2426,15 @@ RDR_RenameFileEntry( IN cm_user_t *userp,
         cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
         lock_ReleaseWrite(&scp->rw);
 
-        dfid.vnode = htonl(scp->fid.vnode);
-        dfid.unique = htonl(scp->fid.unique);
+        if (cm_shortNames) {
+            dfid.vnode = htonl(scp->fid.vnode);
+            dfid.unique = htonl(scp->fid.unique);
 
-        if (!cm_Is8Dot3(TargetFileName))
-            cm_Gen8Dot3NameIntW(TargetFileName, &dfid, shortName, NULL);
-        else
-            shortName[0] = '\0';
+            if (!cm_Is8Dot3(TargetFileName))
+                cm_Gen8Dot3NameIntW(TargetFileName, &dfid, shortName, NULL);
+            else
+                shortName[0] = '\0';
+        }
 
         RDR_PopulateCurrentEntry(&pResultCB->DirEnum, dwRemaining,
                                  newDscp, scp, userp, &req, TargetFileName, shortName,