windows-pioctl-20050902
authorJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 2 Sep 2005 18:23:50 +0000 (18:23 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 2 Sep 2005 18:23:50 +0000 (18:23 +0000)
support '/' as well as '\\' in pioctl calls

src/sys/pioctl_nt.c

index 79d9d90..3bb95a7 100644 (file)
@@ -348,14 +348,16 @@ GetIoctlHandle(char *fileNamep, HANDLE * handlep)
             tbuffer[1] = ':';
             strcpy(tbuffer + 2, SMB_IOCTL_FILENAME);
         } else if (fileNamep[0] == fileNamep[1] && 
-                              fileNamep[0] == '\\')
+                  (fileNamep[0] == '\\' || fileNamep[0] == '/'))
         {
             int count = 0, i = 0;
 
             while (count < 4 && fileNamep[i]) {
                 tbuffer[i] = fileNamep[i];
-                if ( tbuffer[i++] == '\\' )
+                if ( tbuffer[i] == '\\' ||
+                    tbuffer[i] == '/')
                     count++;
+               i++;
             }
             if (fileNamep[i] == 0)
                 tbuffer[i++] = '\\';
@@ -370,14 +372,16 @@ GetIoctlHandle(char *fileNamep, HANDLE * handlep)
                 tbuffer[1] = ':';
                 strcpy(tbuffer + 2, SMB_IOCTL_FILENAME);
             } else if (curdir[0] == curdir[1] &&
-                       curdir[0] == '\\') 
+                       (curdir[0] == '\\' || curdir[0] == '/')) 
             {
                 int count = 0, i = 0;
 
                 while (count < 4 && curdir[i]) {
                     tbuffer[i] = curdir[i];
-                    if ( tbuffer[i++] == '\\' )
-                        count++;
+                   if ( tbuffer[i] == '\\' ||
+                        tbuffer[i] == '/')
+                       count++;
+                   i++;
                 }
                 if (tbuffer[i] == 0)
                     tbuffer[i++] = '\\';
@@ -741,9 +745,10 @@ fs_GetFullPath(char *pathp, char *outPathp, long outSize)
     int pathHasDrive;
     int doSwitch;
     char newPath[3];
-       HANDLE rootDir;
-       wchar_t *wpath;
-       unsigned long length;
+    HANDLE rootDir;
+    wchar_t *wpath;
+    unsigned long length;
+    char * p;
 
 #ifdef AFSIFS
     if (!pathp)
@@ -778,7 +783,8 @@ fs_GetFullPath(char *pathp, char *outPathp, long outSize)
        pathHasDrive = 0;
     }
 
-    if ( firstp[0] == '\\' && firstp[1] == '\\') {
+    if ( firstp[0] == '\\' && firstp[1] == '\\' || 
+        firstp[0] == '/' && firstp[1] == '/') {
         /* UNC path - strip off the server and sharename */
         int i, count;
         for ( i=2,count=2; count < 4 && firstp[i]; i++ ) {
@@ -791,10 +797,18 @@ fs_GetFullPath(char *pathp, char *outPathp, long outSize)
         } else {
             strcpy(outPathp,&firstp[--i]);
         }
+       for (p=outPathp ;*p; p++) {
+           if (*p == '/')
+               *p = '\\';
+       }
         return 0;
     } else if (firstp[0] == '\\' || firstp[0] == '/') {
         /* already an absolute pathname, just copy it back */
         strcpy(outPathp, firstp);
+       for (p=outPathp ;*p; p++) {
+           if (*p == '/')
+               *p = '\\';
+       }
         return 0;
     }
 
@@ -824,7 +838,8 @@ fs_GetFullPath(char *pathp, char *outPathp, long outSize)
     GetCurrentDirectory(sizeof(tpath), tpath);
     if (tpath[1] == ':')
         strcpy(outPathp, tpath + 2);   /* skip drive letter */
-    else if ( tpath[0] == '\\' && tpath[1] == '\\') {
+    else if ( tpath[0] == '\\' && tpath[1] == '\\'||
+             tpath[0] == '/' && tpath[1] == '/') {
         /* UNC path - strip off the server and sharename */
         int i, count;
         for ( i=2,count=2; count < 4 && tpath[i]; i++ ) {
@@ -855,6 +870,10 @@ fs_GetFullPath(char *pathp, char *outPathp, long outSize)
        SetCurrentDirectory(origPath);
     }
 
+    for (p=outPathp ;*p; p++) {
+       if (*p == '/')
+           *p = '\\';
+    }
     return 0;
 }