From 150cbf3db8c4c2c5bd95297f60da0eac84ba14c4 Mon Sep 17 00:00:00 2001 From: Nickolai Zeldovich Date: Tue, 27 Mar 2001 08:58:49 +0000 Subject: [PATCH] make-namei-fileserver-compile-on-solaris8-20010327 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 | 4 ++-- src/util/flipbase64.c | 2 +- src/vol/namei_ops.c | 35 ++++++++++++++++++++++++++++++++++- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/util/afsutil.h b/src/util/afsutil.h index e3fecc6..4430693 100644 --- a/src/util/afsutil.h +++ b/src/util/afsutil.h @@ -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 diff --git a/src/util/flipbase64.c b/src/util/flipbase64.c index 27af4f8..ba6ef91 100644 --- a/src/util/flipbase64.c +++ b/src/util/flipbase64.c @@ -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; diff --git a/src/vol/namei_ops.c b/src/vol/namei_ops.c index 3432719..d4fa192 100644 --- a/src/vol/namei_ops.c +++ b/src/vol/namei_ops.c @@ -22,6 +22,12 @@ #include #include #include +#ifdef AFS_AIX_ENV +#include +#endif +#ifdef AFS_SUN5_ENV +#include +#endif #include #include #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; } -- 1.9.4