windows-misc-20050722
[openafs.git] / src / WINNT / afsd / cm_vnodeops.c
index 20872df..7162e77 100644 (file)
@@ -128,7 +128,6 @@ char cm_LegalChars[256] = {
 int cm_Is8Dot3(char *namep)
 {
     int sawDot = 0;
-    int sawUpper = 0, sawLower = 0;
     unsigned char tc;
     int charCount = 0;
         
@@ -153,10 +152,6 @@ int cm_Is8Dot3(char *namep)
         }
         if (cm_LegalChars[tc] == 0)
             return 0;
-        if (tc >= 'A' && tc <= 'Z')
-            sawUpper = 1;
-        else if (tc >= 'a' && tc <= 'z')
-            sawLower = 1;
         charCount++;
         if (!sawDot && charCount > 8)
             /* more than 8 chars in name */
@@ -165,14 +160,6 @@ int cm_Is8Dot3(char *namep)
             /* more than 3 chars in extension */
             return 0;
     }
-    /*
-     * Used to check that all characters were the same case.
-     * This doesn't help 16-bit apps, and meanwhile it causes the
-     * MS-DOS Command Prompt to misbehave; see Sybase defect 10709.
-     *
-     if (sawUpper && sawLower)
-         return 0;
-     */
     return 1;
 }
 
@@ -558,6 +545,20 @@ long cm_ApplyDir(cm_scache_t *scp, cm_DirFuncp_t funcp, void *parmp,
                 break;
             }
 
+#ifdef AFSIFS
+            /* Why was this added for IFS? - jaltman 06/18/2006 */
+            lock_ObtainMutex(&scp->mx);
+            if ((scp->flags & CM_SCACHEFLAG_BULKSTATTING) == 0
+                 && (scp->bulkStatProgress.QuadPart <= thyper.QuadPart))
+            {
+                scp->flags |= CM_SCACHEFLAG_BULKSTATTING;
+                cm_TryBulkStat(scp, &thyper, userp, reqp);
+                scp->flags &= ~CM_SCACHEFLAG_BULKSTATTING;
+                scp->bulkStatProgress = thyper;
+            }
+            lock_ReleaseMutex(&scp->mx);
+#endif
+
             lock_ObtainMutex(&bufferp->mx);
             bufferOffset = thyper;
 
@@ -1635,8 +1636,8 @@ long cm_EvaluateSymLink(cm_scache_t *dscp, cm_scache_t *linkScp,
                      CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW | CM_FLAG_DIRSEARCH,
                      userp, NULL, reqp, outScpp);
 
-       if (code == CM_ERROR_NOSUCHFILE)
-               code = CM_ERROR_NOSUCHPATH;
+    if (code == CM_ERROR_NOSUCHFILE)
+        code = CM_ERROR_NOSUCHPATH;
 
     /* this stuff is allocated no matter what happened on the namei call,
      * so free it */
@@ -2599,8 +2600,10 @@ long cm_Rename(cm_scache_t *oldDscp, char *oldNamep, cm_scache_t *newDscp,
                 lock_ReleaseMutex(&newDscp->mx);
                 if (code) {
                     /* cleanup first one */
+                    lock_ObtainMutex(&newDscp->mx);
                     cm_SyncOpDone(oldDscp, NULL,
                                    CM_SCACHESYNC_STOREDATA);
+                    lock_ReleaseMutex(&oldDscp->mx);
                 }       
             }
         }
@@ -2619,8 +2622,10 @@ long cm_Rename(cm_scache_t *oldDscp, char *oldNamep, cm_scache_t *newDscp,
                 lock_ReleaseMutex(&oldDscp->mx);
                 if (code) {
                     /* cleanup first one */
+                    lock_ObtainMutex(&newDscp->mx);
                     cm_SyncOpDone(newDscp, NULL,
                                    CM_SCACHESYNC_STOREDATA);
+                    lock_ReleaseMutex(&newDscp->mx);
                 }       
             }
         }
@@ -2701,6 +2706,10 @@ long cm_Lock(cm_scache_t *scp, unsigned char LockType,
     int found = 0;
     struct rx_connection * callp;
 
+    osi_Log1(afsd_logp, "cm_Lock scp 0x%x ...", (long) scp);
+    osi_Log4(afsd_logp, "cm_Lock type 0x%x offset %d length %d timeout %d",
+             LockType, (unsigned long)LOffset.QuadPart, (unsigned long)LLength.QuadPart, Timeout);
+
     /* Look for a conflict.  Also, if we are asking for a shared lock,
      * look for another shared lock, so we don't have to do an RPC.
      */
@@ -2716,6 +2725,8 @@ long cm_Lock(cm_scache_t *scp, unsigned char LockType,
         q = osi_QNext(q);
     }
 
+    osi_Log1(afsd_logp, "cm_Lock found = %d", found);
+
     if (found)
         code = 0;
     else {
@@ -2724,6 +2735,7 @@ long cm_Lock(cm_scache_t *scp, unsigned char LockType,
         tfid.Unique = scp->fid.unique;
         lock_ReleaseMutex(&scp->mx);
         do {
+            osi_Log1(afsd_logp, "CALL SetLock scp 0x%x", (long) scp);
             code = cm_Conn(&scp->fid, userp, reqp, &connp);
             if (code) 
                 break;
@@ -2735,6 +2747,10 @@ long cm_Lock(cm_scache_t *scp, unsigned char LockType,
 
         } while (cm_Analyze(connp, userp, reqp, &scp->fid, &volSync,
                              NULL, NULL, code));
+        if (code)
+            osi_Log1(afsd_logp, "CALL SetLock FAILURE, code 0x%x", code);
+        else
+            osi_Log0(afsd_logp, "CALL SetLock SUCCESS");
         lock_ObtainMutex(&scp->mx);
         code = cm_MapRPCError(code, reqp);
     }
@@ -2754,6 +2770,7 @@ long cm_Lock(cm_scache_t *scp, unsigned char LockType,
         lock_ReleaseWrite(&cm_scacheLock);
         if (code != 0) 
             *lockpp = fileLock;
+        osi_Log1(afsd_logp, "cm_Lock Lock added 0x%x", (long) fileLock);
     }
     return code;
 }
@@ -2774,6 +2791,9 @@ long cm_Unlock(cm_scache_t *scp, unsigned char LockType,
     int found = 0;
     struct rx_connection * callp;
 
+    osi_Log4(afsd_logp, "cm_Unlock scp 0x%x type 0x%x offset %d length %d",
+             (long) scp, LockType, (unsigned long)LOffset.QuadPart, (unsigned long)LLength.QuadPart);
+
     if (LargeIntegerLessThan(LLength, scp->length))
         smallLock = 1;
 
@@ -2798,12 +2818,16 @@ long cm_Unlock(cm_scache_t *scp, unsigned char LockType,
     }
 
     /* ignore byte ranges */
-    if (smallLock && !found)
+    if (smallLock && !found) {
+        osi_Log0(afsd_logp, "cm_Unlock lock not found and ignored");
         return 0;
+    }
 
     /* don't try to unlock other people's locks */
-    if (!found)
+    if (!found) {
+        osi_Log0(afsd_logp, "cm_Unlock lock not found; failure");
         return CM_ERROR_WOULDBLOCK;
+    }
 
     /* discard lock record */
     osi_QRemove(&scp->fileLocks, qq);
@@ -2843,6 +2867,7 @@ long cm_Unlock(cm_scache_t *scp, unsigned char LockType,
         lock_ObtainMutex(&scp->mx);
     }
 
+    osi_Log1(afsd_logp, "cm_Unlock code 0x%x", code);
     return code;
 }