summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2003-07-27 19:54:27 +0000
committerLennart Poettering <lennart@poettering.net>2003-07-27 19:54:27 +0000
commitce358c24ef7426e8e3013185f60b724fe86faa61 (patch)
tree91127eee0daffe17ee1f45da6628e39014ae9982
parent14db0c158e42c2f723fef9105551769b6e8436ec (diff)
locking
git-svn-id: file:///home/lennart/svn/public/ivcall/trunk@4 e0b13411-74c3-0310-b366-a0654dd0340f
-rw-r--r--configure.ac5
-rw-r--r--src/Makefile.am2
-rw-r--r--src/ivcall.c4
-rw-r--r--src/lock.c8
4 files changed, 12 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac
index b6740bc..d2235f5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,6 +34,9 @@ if test "x$GCC" = "xyes" ; then
CFLAGS="$CFLAGS -pipe -Wall"
fi
+AC_ARG_WITH(lockdir, AC_HELP_STRING([--with-lockdir=LOCKDIR], [Specify a lock dir]), LOCKDIR="$withval", LOCK_DIR="/var/lock")
+AC_SUBST(LOCK_DIR)
+
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
@@ -93,5 +96,7 @@ fi
AM_CONDITIONAL([USE_XMLTOMAN], [test "x$xmltoman" = xyes])
+AC_MSG_NOTICE([*** Using $LOCK_DIR as lock directory ***])
+
AC_CONFIG_FILES([src/Makefile Makefile man/Makefile doc/Makefile doc/README.html])
AC_OUTPUT
diff --git a/src/Makefile.am b/src/Makefile.am
index 1fa04d5..ad3f137 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,6 +16,8 @@
# along with ifplugd; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+AM_CFLAGS=-DLOCK_DIR=\"$(LOCK_DIR)\"
+
bin_PROGRAMS = ivcall
ivcall_SOURCES = ivcall.c lock.c lock.h util.c util.h
diff --git a/src/ivcall.c b/src/ivcall.c
index 54c840d..bccd290 100644
--- a/src/ivcall.c
+++ b/src/ivcall.c
@@ -42,10 +42,6 @@
#include "config.h"
#endif
-// Where do lockfiles reside?
-#ifndef LOCK_PATH
-#define LOCK_PATH "/var/lock"
-#endif
// Those nifty DLE-sequences
#define DLE 0x10
diff --git a/src/lock.c b/src/lock.c
index 465736c..eb8a3cb 100644
--- a/src/lock.c
+++ b/src/lock.c
@@ -34,7 +34,9 @@
#include "util.h"
// Where do lockfiles reside?
-#define LOCK_PATH "/var/lock"
+#ifndef LOCK_DIR
+#define LOCK_DIR "/var/lock"
+#endif
static char* lockfile = NULL;
@@ -48,10 +50,10 @@ int device_lock(char *dev, char *appname) {
assert(dev && !lockfile);
- if (access(LOCK_PATH, W_OK) < 0)
+ if (access(LOCK_DIR, W_OK) < 0)
return -1;
- snprintf(path, sizeof(path), "%s/LCK..%s", LOCK_PATH, basename(dev));
+ snprintf(path, sizeof(path), "%s/LCK..%s", LOCK_DIR, basename(dev));
if ((fd = open(path, O_RDONLY)) >= 0) {
int n = loop_read(fd, buf, sizeof(buf) - 1);