make-namei-fileserver-compile-on-solaris8-20010327
authorNickolai Zeldovich <kolya@mit.edu>
Tue, 27 Mar 2001 08:58:49 +0000 (08:58 +0000)
committerDerrick Brashear <shadow@dementia.org>
Tue, 27 Mar 2001 08:58:49 +0000 (08:58 +0000)
use uint64_t in preference to u_int64_t as solaris has only the latter and
linux appears to have both. also, use lockf where flock was used in the
solaris case

src/util/afsutil.h
src/util/flipbase64.c
src/vol/namei_ops.c

index e3fecc6..4430693 100644 (file)
@@ -112,9 +112,9 @@ int base32_to_int(char *s);
  * early in name.
  */
 typedef char lb64_string_t[12];
-char *int64_to_flipbase64(b64_string_t s, u_int64_t a);
+char *int64_to_flipbase64(b64_string_t s, uint64_t a);
 int64_t flipbase64_to_int64(char *s);
-#define int32_to_flipbase64(S, A) int64_to_flipbase64(S, (u_int64_t)(A))
+#define int32_to_flipbase64(S, A) int64_to_flipbase64(S, (uint64_t)(A))
 #endif
 
 /* This message preserves our ability to license AFS to the U.S. Government
index 27af4f8..ba6ef91 100644 (file)
@@ -27,7 +27,7 @@ static char c_xlate[80] =
  * The supplied string 's' must be at least 12 bytes long.
  * lb64_string in stds.h provides a typedef to get the length.
  */
-char *int64_to_flipbase64(lb64_string_t s, u_int64_t a)
+char *int64_to_flipbase64(lb64_string_t s, uint64_t a)
 {
     int i, j;
     int64_t n;
index 3432719..d4fa192 100644 (file)
 #include <sys/file.h>
 #include <sys/param.h>
 #include <lock.h>
+#ifdef AFS_AIX_ENV
+#include <sys/lockf.h>
+#endif
+#ifdef AFS_SUN5_ENV
+#include <unistd.h>
+#endif
 #include <afs/afsutil.h>
 #include <lwp.h>
 #include "nfs.h"
@@ -805,7 +811,11 @@ int namei_GetLinkCount(FdHandle_t *h, Inode ino, int lockit)
     namei_GetLCOffsetAndIndexFromIno(ino, &offset, &index);
 
     if (lockit) {
+#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV)
+        if (lockf(h->fd_fd, F_LOCK, 0) < 0)
+#else
        if (flock(h->fd_fd, LOCK_EX)<0)
+#endif
            return -1;
     }
 
@@ -820,7 +830,11 @@ int namei_GetLinkCount(FdHandle_t *h, Inode ino, int lockit)
 
  bad_getLinkByte:
     if (lockit)
+#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV)
+       lockf(h->fd_fd, F_ULOCK, 0);
+#else
        flock(h->fd_fd, LOCK_UN);
+#endif
     return -1;
 }
 
@@ -840,7 +854,11 @@ static int GetFreeTag(IHandle_t *ih, int vno)
        return -1;
 
     /* Only one manipulates at a time. */
+#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV)
+    if (lockf(fdP->fd_fd, F_LOCK, 0) < 0) {
+#else
     if (flock(fdP->fd_fd, LOCK_EX)<0) {
+#endif
        FDH_REALLYCLOSE(fdP);
        return -1;
     }
@@ -877,12 +895,20 @@ static int GetFreeTag(IHandle_t *ih, int vno)
        goto badGetFreeTag;
     }
     FDH_SYNC(fdP);
+#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV)
+    lockf(fdP->fd_fd, F_ULOCK, 0);
+#else
     flock(fdP->fd_fd, LOCK_UN);
+#endif
     FDH_REALLYCLOSE(fdP);
     return col;;
 
  badGetFreeTag:
+#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV)
+    lockf(fdP->fd_fd, F_ULOCK, 0);
+#else
     flock(fdP->fd_fd, LOCK_UN);
+#endif
     FDH_REALLYCLOSE(fdP);
     return -1;
 }
@@ -902,9 +928,12 @@ int namei_SetLinkCount(FdHandle_t *fdP, Inode ino, int count, int locked)
 
     namei_GetLCOffsetAndIndexFromIno(ino, &offset, &index);
 
-
     if (!locked) {
+#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV)
+        if (lockf(fdP->fd_fd, F_LOCK, 0) < 0) {
+#else
        if (flock(fdP->fd_fd, LOCK_EX)<0) {
+#endif
            return -1;
        }
     }
@@ -943,7 +972,11 @@ int namei_SetLinkCount(FdHandle_t *fdP, Inode ino, int count, int locked)
 
     
 bad_SetLinkCount:
+#if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV)
+    lockf(fdP->fd_fd, F_ULOCK, 0);
+#else
     flock(fdP->fd_fd, LOCK_UN);
+#endif
 
     return code;
 }