From 41f7661609070aca157acaea46878f0d0a764fdd Mon Sep 17 00:00:00 2001 From: Adam Moody Date: Thu, 22 Jun 2023 18:24:59 -0700 Subject: [PATCH 1/3] avoid missing function prototype from newer C compilers --- client/src/unifyfs-stdio.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/src/unifyfs-stdio.c b/client/src/unifyfs-stdio.c index ffa5b29e..8b5db6c5 100644 --- a/client/src/unifyfs-stdio.c +++ b/client/src/unifyfs-stdio.c @@ -3043,9 +3043,10 @@ __svfscanf(unifyfs_stream_t* fp, const char* fmt0, va_list ap) * considered part of the scanset. */ static const u_char* -__sccl(tab, fmt) -char* tab; -const u_char* fmt; +__sccl(char* tab, const u_char* fmt) +//__sccl(tab, fmt) +//char* tab; +//const u_char* fmt; { int c, n, v; From a5711f1db5c78ef07a910ed8969fd16885cdc4a3 Mon Sep 17 00:00:00 2001 From: Adam Moody Date: Thu, 22 Jun 2023 18:26:22 -0700 Subject: [PATCH 2/3] make stat wrappers conditional on symbol existence --- client/src/unifyfs-sysio.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/client/src/unifyfs-sysio.c b/client/src/unifyfs-sysio.c index 33a56eb5..cd1d3b97 100644 --- a/client/src/unifyfs-sysio.c +++ b/client/src/unifyfs-sysio.c @@ -835,7 +835,6 @@ static int __stat64(const char* path, struct stat64* buf) return 0; } - int UNIFYFS_WRAP(stat)(const char* path, struct stat* buf) { LOGDBG("stat was called for %s", path); @@ -851,6 +850,7 @@ int UNIFYFS_WRAP(stat)(const char* path, struct stat* buf) } } +#ifdef HAVE_STAT64 int UNIFYFS_WRAP(stat64)(const char* path, struct stat64* buf) { LOGDBG("stat64 was called for %s", path); @@ -864,8 +864,8 @@ int UNIFYFS_WRAP(stat64)(const char* path, struct stat64* buf) int ret = UNIFYFS_REAL(stat64)(path, buf); return ret; } - return 0; } +#endif int UNIFYFS_WRAP(fstat)(int fd, struct stat* buf) { @@ -873,12 +873,13 @@ int UNIFYFS_WRAP(fstat)(int fd, struct stat* buf) /* check whether we should intercept this file descriptor */ if (unifyfs_intercept_fd(&fd)) { - int fid = unifyfs_get_fid_from_fd(fd); /* check if the file is still active (e.g., not closed) */ + int fid = unifyfs_get_fid_from_fd(fd); if (fid == -1) { errno = EBADF; return -1; } + const char* path = unifyfs_path_from_fid(posix_client, fid); int ret = __stat(path, buf); return ret; @@ -889,13 +890,20 @@ int UNIFYFS_WRAP(fstat)(int fd, struct stat* buf) } } +#ifdef HAVE_FSTAT64 int UNIFYFS_WRAP(fstat64)(int fd, struct stat64* buf) { LOGDBG("fstat64 was called for fd: %d", fd); /* check whether we should intercept this file descriptor */ if (unifyfs_intercept_fd(&fd)) { + /* check if the file is still active (e.g., not closed) */ int fid = unifyfs_get_fid_from_fd(fd); + if (fid == -1) { + errno = EBADF; + return -1; + } + const char* path = unifyfs_path_from_fid(posix_client, fid); int ret = __stat64(path, buf); return ret; @@ -905,6 +913,7 @@ int UNIFYFS_WRAP(fstat64)(int fd, struct stat64* buf) return ret; } } +#endif /* * NOTE on __xstat(2), __lxstat(2), and __fxstat(2) From f19fac5ad5e4519e3d11e06eb00ec2e14241bbfd Mon Sep 17 00:00:00 2001 From: Adam Moody Date: Wed, 5 Jul 2023 17:20:52 -0700 Subject: [PATCH 3/3] avoid unused function error when no stat64 variant detected --- client/src/unifyfs-sysio.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/src/unifyfs-sysio.c b/client/src/unifyfs-sysio.c index cd1d3b97..77158b60 100644 --- a/client/src/unifyfs-sysio.c +++ b/client/src/unifyfs-sysio.c @@ -788,6 +788,11 @@ static int __stat(const char* path, struct stat* buf) return 0; } +#if defined(HAVE_STAT64) || \ + defined(HAVE_FSTAT64) || \ + defined(HAVE___XSTAT64) || \ + defined(HAVE___LXSTAT64) || \ + defined(HAVE___FXSTAT64) static int __stat64(const char* path, struct stat64* buf) { /* check that caller gave us a buffer to write to */ @@ -834,6 +839,7 @@ static int __stat64(const char* path, struct stat64* buf) errno = 0; return 0; } +#endif int UNIFYFS_WRAP(stat)(const char* path, struct stat* buf) {