aboutsummaryrefslogtreecommitdiff
path: root/src/systems.h
diff options
context:
space:
mode:
authorJason Downs <downsj@downsj.com>2008-11-30 05:31:02 +0000
committerJason Downs <downsj@downsj.com>2008-11-30 05:31:02 +0000
commitda266015729fb8cf7519813c222fb83154ca0b8a (patch)
treeb30210adbb7a0d17d727d7a4bfa7ae0526120ddd /src/systems.h
parent10fe387708ddfba6449b9abd74cfbdf67d495465 (diff)
downloadgdbm-da266015729fb8cf7519813c222fb83154ca0b8a.tar.gz
gdbm-da266015729fb8cf7519813c222fb83154ca0b8a.tar.bz2
The library was not working on Solaris due to file locking. fcntl locks are
not working over NFS at all. They also need to be changed to use flock64 structs, which has been done. File locking needs to be refactored within the library. We likely need to add lockf support, and use a better method for determining which locking type to use (our current method is to just make assumptions). testgdbm now builds on Solaris. From ChangeLog: * configure.ac: Add test for sys/termios.h * src/systems.h: Add macros for Solaris-style 64bit fcntl locks. * src/testgdbm.c: Add support for opening files without locking. Add sys/termios.h include and add check for TIOCWINSZ. * export/export.c: Add support for opening files without locking.
Diffstat (limited to 'src/systems.h')
-rw-r--r--src/systems.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/systems.h b/src/systems.h
index dd8cfa7..6725471 100644
--- a/src/systems.h
+++ b/src/systems.h
@@ -77,6 +77,32 @@
/* Assume it is done like System V. */
+#if defined(F_SETLK64) && (defined(_LARGE_FILES) || _FILE_OFFSET_BITS == 64)
+#define UNLOCK_FILE(dbf) \
+ { \
+ struct flock64 flock; \
+ flock.l_type = F_UNLCK; \
+ flock.l_whence = SEEK_SET; \
+ flock.l_start = flock.l_len = 0L; \
+ fcntl (dbf->desc, F_SETLK64, &flock); \
+ }
+#define READLOCK_FILE(dbf) \
+ { \
+ struct flock64 flock; \
+ flock.l_type = F_RDLCK; \
+ flock.l_whence = SEEK_SET; \
+ flock.l_start = flock.l_len = 0L; \
+ lock_val = fcntl (dbf->desc, F_SETLK64, &flock); \
+ }
+#define WRITELOCK_FILE(dbf) \
+ { \
+ struct flock64 flock; \
+ flock.l_type = F_WRLCK; \
+ flock.l_whence = SEEK_SET; \
+ flock.l_start = flock.l_len = 0L; \
+ lock_val = fcntl (dbf->desc, F_SETLK64, &flock); \
+ }
+#else
#define UNLOCK_FILE(dbf) \
{ \
struct flock flock; \
@@ -103,6 +129,8 @@
}
#endif
+#endif
+
/* Default block size. Some systems do not have blocksize in their
stat record. This code uses the BSD blocksize from stat. */

Return to:

Send suggestions and report system problems to the System administrator.