Windows: add cm_Gen8Dot3VolNameW()
authorJeffrey Altman <jaltman@your-file-system.com>
Sun, 4 Sep 2011 00:16:09 +0000 (20:16 -0400)
committerJeffrey Altman <jaltman@openafs.org>
Mon, 5 Sep 2011 13:44:33 +0000 (06:44 -0700)
Change-Id: Ic514719ee247d60862cc9ff07de16e5de4ffb774
Reviewed-on: http://gerrit.openafs.org/5352
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>

src/WINNT/afsd/cm_utils.c
src/WINNT/afsd/cm_utils.h

index e963d7d..f16d574 100644 (file)
@@ -593,6 +593,43 @@ void cm_Gen8Dot3NameIntW(const clientchar_t * longname, cm_dirFid_t * pfid,
         *shortNameEndp = shortName;
 }
 
+void cm_Gen8Dot3VolNameW(afs_uint32 cell, afs_uint32 volume,
+                         clientchar_t *shortName, clientchar_t **shortNameEndp)
+{
+    clientchar_t number[12];
+    int i, nsize = 0;
+    int validExtension = 0;
+
+    /* Unparse the file's cell and volume numbers */
+    do {
+        number[nsize] = cm_8Dot3Mapping[cell % cm_8Dot3MapSize];
+        nsize++;
+        cell /= cm_8Dot3MapSize;
+    } while (cell);
+    do {
+        number[nsize] = cm_8Dot3Mapping[volume % cm_8Dot3MapSize];
+        nsize++;
+        volume /= cm_8Dot3MapSize;
+    } while (volume && nsize < 8);
+
+    /* Copy uniquifier characters */
+    for (i=0; i < nsize; i++) {
+        *shortName++ = number[i];
+    }
+
+    /* Add extension characters */
+    *shortName++ = '.';        /* copy dot */
+    *shortName++ = 'v';
+    *shortName++ = 'o';
+    *shortName++ = 'l';
+
+    /* Trailing null */
+    *shortName = 0;
+
+    if (shortNameEndp)
+        *shortNameEndp = shortName;
+}
+
 /*! \brief Compare 'pattern' (containing metacharacters '*' and '?') with the file name 'name'.
 
   \note This procedure works recursively calling itself.
index 8a3440c..b7e27d1 100644 (file)
@@ -79,6 +79,9 @@ extern void cm_Gen8Dot3NameInt(const fschar_t * longname, cm_dirFid_t * pfid,
 extern void cm_Gen8Dot3NameIntW(const clientchar_t* longname, cm_dirFid_t * pfid,
                                 clientchar_t *shortName, clientchar_t **shortNameEndp);
 
+extern void cm_Gen8Dot3VolNameW(afs_uint32 cell, afs_uint32 volume,
+                                clientchar_t *shortName, clientchar_t **shortNameEndp);
+
 extern int cm_MatchMask(clientchar_t *namep, clientchar_t *maskp, int flags);
 
 extern BOOL cm_TargetPerceivedAsDirectory(const fschar_t *target);