DEVEL15-linux-nfstrans-updates-20080630
[openafs.git] / src / afs / afs_util.c
index 5fe5327..602b822 100644 (file)
@@ -136,6 +136,19 @@ afs_strchr(char *s, int c)
     return NULL;
 }
 #endif
+#ifndef afs_strrchr
+char *
+afs_strrchr(char *s, int c)
+{
+    char *p = NULL;
+    
+    do {
+       if (*s == c)
+           p = (char*) s;
+    } while (*s++);
+    return p;
+}
+#endif
 
 char *
 afs_strdup(char *s)
@@ -184,79 +197,6 @@ print_internet_address(char *preamble, struct srvAddr *sa, char *postamble,
 
 
 
-/* * * * * * *
- * this code badly needs to be cleaned up...  too many ugly ifdefs.
- * XXX
- */
-#if 0
-void
-afs_warn(char *a, long b, long c, long d, long e, long f, long g, long h,
-        long i, long j)
-#else
-void
-afs_warn(a, b, c, d, e, f, g, h, i, j)
-     char *a;
-#if defined( AFS_USE_VOID_PTR)
-     void *b, *c, *d, *e, *f, *g, *h, *i, *j;
-#else
-     long b, c, d, e, f, g, h, i, j;
-#endif
-#endif
-{
-    AFS_STATCNT(afs_warn);
-
-    if (afs_showflags & GAGCONSOLE) {
-#if defined(AFS_AIX_ENV)
-       struct file *fd;
-
-       /* cf. console_printf() in oncplus/kernext/nfs/serv/shared.c */
-       if (fp_open
-           ("/dev/console", O_WRONLY | O_NOCTTY | O_NDELAY, 0666, 0, FP_SYS,
-            &fd) == 0) {
-           char buf[1024];
-           ssize_t len;
-           ssize_t count;
-
-           sprintf(buf, a, b, c, d, e, f, g, h, i, j);
-           len = strlen(buf);
-           fp_write(fd, buf, len, 0, UIO_SYSSPACE, &count);
-           fp_close(fd);
-       }
-#else
-       printf(a, b, c, d, e, f, g, h, i, j);
-#endif
-    }
-}
-
-#if 0
-void
-afs_warnuser(char *a, long b, long c, long d, long e, long f, long g, long h,
-            long i, long j)
-#else
-void
-afs_warnuser(a, b, c, d, e, f, g, h, i, j)
-     char *a;
-     long b, c, d, e, f, g, h, i, j;
-#endif
-{
-    AFS_STATCNT(afs_warnuser);
-    if (afs_showflags & GAGUSER) {
-#ifdef AFS_GLOBAL_SUNLOCK
-       int haveGlock = ISAFS_GLOCK();
-       if (haveGlock)
-           AFS_GUNLOCK();
-#endif /* AFS_GLOBAL_SUNLOCK */
-
-       uprintf(a, b, c, d, e, f, g, h, i, j);
-
-#ifdef AFS_GLOBAL_SUNLOCK
-       if (haveGlock)
-           AFS_GLOCK();
-#endif /* AFS_GLOBAL_SUNLOCK */
-    }
-}
-
-
 /* run everywhere, checking locks */
 void
 afs_CheckLocks(void)
@@ -649,7 +589,7 @@ AFS_MD5_Final (void *res, struct afs_md5 *m)
 
 afs_int32 afs_calc_inum (afs_int32 volume, afs_int32 vnode)
 { 
-    afs_int32 ino;
+    afs_int32 ino, vno = vnode;
     char digest[16];
     struct afs_md5 ct;
     
@@ -659,10 +599,11 @@ afs_int32 afs_calc_inum (afs_int32 volume, afs_int32 vnode)
        AFS_MD5_Update(&ct, &vnode, 4);
        AFS_MD5_Final(digest, &ct);
        memcpy(&ino, digest, sizeof(ino_t));
+       ino ^= (ino ^ vno) & 1;
     } else {
        ino = (volume << 16) + vnode;
-       ino &= 0x7fffffff;      /* Assumes 32 bit ino_t ..... */
     }
+    ino &= 0x7fffffff;      /* Assumes 32 bit ino_t ..... */
     return ino;
 }