[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
how to determine that UNIX Advisory lock availability
From: |
Richard Bos |
Subject: |
how to determine that UNIX Advisory lock availability |
Date: |
Thu, 31 Jul 2003 15:52:14 +0200 |
User-agent: |
KMail/1.5 |
Hello,
My next question, is about how to determine that UNIX Advisory lock can
be used on a system. This is used in the database application that I'm trying
to port to the autoconf. The description is as follows:
ADVLOCK: "Define to use UNIX Advisory lock with L<relation> lock files."
This is all I have.
At the moment we think that the definition depends on F_GETLK and/or F_SETLK,
may this be a valid assumption (e.g. F_GETLK and F_SETLK are not present
present on each system)?
The define name that is used at the moment is ADVLOCK and if set
includes the following in the sourced file:
#ifdef ADVLOCK
#include <sys/utsname.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
struct LOCKREC {
char fn[MAXPATH+4]; /* Full path name to lock file allowing for "/./"
or "././" prefix */
int fd; /* File descriptor of lock file */
struct stat buf; /* output from fstat(2) on lock file */
};
static struct LOCKREC *Lockrec; /* Pointer to array structs */
static int Numlockrec; /* Number of locked files */
#define NUMLOCKREC 2 /* Allocate room for this many lock
* file entries per allocation call.
*/
static struct utsname uts_name; /* unix system/node name for lock file */
#endif
Further down in the file F_GETLK is used which comes from the header
file fcntl.h:
if ( ( fcntl( lockfd, F_GETLK, &flockbuf ) == 0 )
F_GETLK is present on my system via /usr/include/fcntl.h which includes
/usr/include/bits/fcntl.h (Same can be said about F_SETLK which is used
as well:
if ( fcntl( lockfd, F_SETLK, &flockbuf ) == 0 )
> cgrep -E "F_GETLK|F_SETLK" /usr/include/bits/fcntl.h
# define F_GETLK 5 /* Get record locking info. */
# define F_SETLK 6 /* Set record locking info (non-blocking). */
configure already checks for fcntl.h, but how to check for the presence of
F_GETLK and or F_SETLK
Should there be a new macro written, that does something with:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
...do something with F_SETLK
But what should be done?
--
Richard Bos
Without a home the journey is endless
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- how to determine that UNIX Advisory lock availability,
Richard Bos <=