diff --git a/README.md b/README.md index b02b36ba..56efdb69 100644 --- a/README.md +++ b/README.md @@ -319,7 +319,6 @@ build options: | | | pvattest | | libxml2 | `HAVE_LIBXML2` | libkmipclient | | systemd | `HAVE_SYSTEMD` | hsavmcore | -| liblockfile | `HAVE_LOCKFILE` | ap-check | | libudev | `HAVE_LIBUDEV` | cpacfstatsd | This table lists additional build or install options: @@ -513,8 +512,7 @@ the different tools are provided: GNU awk for the build process. * ap-check: - For building the ap-check mdevctl callout utility you need liblockfile - version 1.14 or newer installed (liblockfile-devel.rpm). Also required is - json-c version 0.13 or newer (json-c-devel.rpm). - Tip: you may skip ap-check build by adding `HAVE_LOCKFILE=0` or `HAVE_JSONC=0` - to the make invocation. + For building the ap-check mdevctl callout utility you need json-c version + 0.13 or newer (json-c-devel.rpm). + Tip: you may skip ap-check build by adding `HAVE_JSONC=0` to the make + invocation. diff --git a/ap_tools/Makefile b/ap_tools/Makefile index 47f59178..77fe4c3b 100644 --- a/ap_tools/Makefile +++ b/ap_tools/Makefile @@ -7,21 +7,14 @@ MDEVCTL_CALLOUTS = /etc/mdevctl.d/scripts.d/callouts/ libs = $(rootdir)/libap/libap.a \ $(rootdir)/libutil/libutil.a -ifeq (${HAVE_LOCKFILE},0) -all: - $(SKIP) HAVE_LOCKFILE=0 - -install: - $(SKIP) HAVE_LOCKFILE=0 - -else ifeq (${HAVE_JSONC},0) +ifeq (${HAVE_JSONC},0) all: $(SKIP) HAVE_JSONC=0 install: $(SKIP) HAVE_JSONC=0 else -LDLIBS += -llockfile -ljson-c +LDLIBS += -ljson-c all: ap-check diff --git a/ap_tools/ap-check.c b/ap_tools/ap-check.c index eddccd0e..621567df 100644 --- a/ap_tools/ap-check.c +++ b/ap_tools/ap-check.c @@ -133,7 +133,7 @@ static void ap_check_cleanup(struct ap_check_anchor *anc) if (anc->dev) vfio_ap_device_free(anc->dev); if (anc->cleanup_lock) - ap_release_lock(); + ap_release_lock_callout(); } /* @@ -775,7 +775,7 @@ out: */ static int ap_check_handle_post(void) { - return ap_release_lock(); + return ap_release_lock_callout(); } /* For the specified device, print the attributes to stdout in JSON format */ diff --git a/include/lib/ap.h b/include/lib/ap.h index 911b585a..2646ad58 100644 --- a/include/lib/ap.h +++ b/include/lib/ap.h @@ -90,5 +90,6 @@ void ap_list_remove_all(struct util_list *list); int ap_get_lock(void); int ap_get_lock_callout(void); int ap_release_lock(void); +int ap_release_lock_callout(void); #endif /* LIB_AP_H */ diff --git a/libap/Makefile b/libap/Makefile index a4324def..52cc84dd 100644 --- a/libap/Makefile +++ b/libap/Makefile @@ -2,17 +2,6 @@ include ../common.mak lib = libap.a -check-dep-lock: - touch check-dep-lock -ifneq (${HAVE_LOCKFILE},0) - $(call check_dep, \ - "libap", \ - "lockfile.h", \ - "liblockfile-devel", \ - "HAVE_LOCKFILE=0") -ALL_CPPFLAGS += -DHAVE_LOCKFILE -endif - check-dep-json: touch check-dep-json ifneq (${HAVE_JSONC},0) @@ -29,7 +18,7 @@ objects = ap.o $(lib): $(objects) -$(objects): check-dep-lock check-dep-json +$(objects): check-dep-json install: all diff --git a/libap/ap.c b/libap/ap.c index b3a77c26..5e7798c7 100644 --- a/libap/ap.c +++ b/libap/ap.c @@ -22,13 +22,10 @@ #include #endif /* HAVE_JSONC */ -#ifdef HAVE_LOCKFILE -#include -#endif /* HAVE_LOCKFILE */ - #include "lib/ap.h" #include "lib/util_file.h" #include "lib/util_libc.h" +#include "lib/util_lockfile.h" #include "lib/util_panic.h" #include "lib/util_path.h" #include "lib/util_udev.h" @@ -701,33 +698,28 @@ void ap_list_remove_all(struct util_list *list) } } -#ifdef HAVE_LOCKFILE -static int ap_lockfile_create(int flags) -{ - return lockfile_create(AP_LOCKFILE, AP_LOCK_RETRIES, flags); -} - /** - * Acquire the ap config lock using this process PID (L_PID) + * Acquire the ap config lock using this Process ID + * + * @retval 0 Lock acquired on behalf of this process * - * @retval 0 Lock successfully acquired on behalf of L_PID * @retval != 0 Error, lock was not obtained */ int ap_get_lock(void) { - return ap_lockfile_create(L_PID); + return util_lockfile_lock(AP_LOCKFILE, AP_LOCK_RETRIES); } /** - * Acquire the ap config lock using the parent process PID (L_PPID) -- intended - * for use by the mdevctl callout ap-check utility + * Acquire the ap config lock using the Parent Process ID -- intended for use + * by the mdevctl callout ap-check utility * - * @retval 0 Lock successfully acquired on behalf of L_PPID + * @retval 0 Lock acquired on behalf of parent process * @retval != 0 Error, lock was not obtained */ int ap_get_lock_callout(void) { - return ap_lockfile_create(L_PPID); + return util_lockfile_parent_lock(AP_LOCKFILE, AP_LOCK_RETRIES); } /** @@ -738,23 +730,10 @@ int ap_get_lock_callout(void) */ int ap_release_lock(void) { - return lockfile_remove(AP_LOCKFILE); -} -#else -/* If no liblockfile, actions are performed without acquiring the file lock */ -int ap_get_lock(void) -{ - return 0; + return util_lockfile_release(AP_LOCKFILE); } -int ap_get_lock_callout(void) +int ap_release_lock_callout(void) { - return 0; + return util_lockfile_parent_release(AP_LOCKFILE); } - -int ap_release_lock(void) -{ - return 0; -} - -#endif /* HAVE_LOCKFILE */ diff --git a/zdev/src/Makefile b/zdev/src/Makefile index 79b702f3..281201e6 100644 --- a/zdev/src/Makefile +++ b/zdev/src/Makefile @@ -81,9 +81,6 @@ lszdev_objects += generic_ccw.o all: chzdev lszdev zdev_id -ifneq (${HAVE_LOCKFILE}, 0) -LDLIBS += -llockfile -endif ifneq (${HAVE_JSONC}, 0) LDLIBS += -ljson-c endif