]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
util-lib: export cryptsetup logging glue function
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 1 Nov 2017 14:56:25 +0000 (15:56 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 30 Nov 2017 19:43:25 +0000 (20:43 +0100)
src/basic/crypt-util.c [new file with mode: 0644]
src/basic/crypt-util.h
src/basic/meson.build
src/cryptsetup/cryptsetup.c
src/veritysetup/veritysetup.c

diff --git a/src/basic/crypt-util.c b/src/basic/crypt-util.c
new file mode 100644 (file)
index 0000000..193cf65
--- /dev/null
@@ -0,0 +1,27 @@
+/***
+  This file is part of systemd.
+
+  Copyright 2017 Zbigniew Jędrzejewski-Szmek
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#if HAVE_LIBCRYPTSETUP
+#include "crypt-util.h"
+#include "log.h"
+
+void cryptsetup_log_glue(int level, const char *msg, void *usrptr) {
+        log_debug("%s", msg);
+}
+#endif
index b95eb9a4e7085f7d74f8253910ff70104f87f12a..e8e753275a3c870ba1673abb177d1de03e9dbe4e 100644 (file)
@@ -24,4 +24,6 @@
 #include "macro.h"
 
 DEFINE_TRIVIAL_CLEANUP_FUNC(struct crypt_device *, crypt_free);
+
+void cryptsetup_log_glue(int level, const char *msg, void *usrptr);
 #endif
index 68064ab693699688e326221d7b6b38d835457f3e..a37e279e570dee93aafc3eee61e4b8a211fe3fd5 100644 (file)
@@ -61,6 +61,7 @@ basic_sources_plain = files('''
         copy.h
         cpu-set-util.c
         cpu-set-util.h
+        crypt-util.c
         crypt-util.h
         def.h
         device-nodes.c
index 38468023cb39c5df61f72755d03e9ab478350996..84bcdb467da99e7f79ef344ab6b85992d2ae0ab0 100644 (file)
@@ -255,10 +255,6 @@ static int parse_options(const char *options) {
         return 0;
 }
 
-static void log_glue(int level, const char *msg, void *usrptr) {
-        log_debug("%s", msg);
-}
-
 static int disk_major_minor(const char *path, char **ret) {
         struct stat st;
 
@@ -667,7 +663,7 @@ int main(int argc, char *argv[]) {
                         goto finish;
                 }
 
-                crypt_set_log_callback(cd, log_glue, NULL);
+                crypt_set_log_callback(cd, cryptsetup_log_glue, NULL);
 
                 status = crypt_status(cd, argv[2]);
                 if (IN_SET(status, CRYPT_ACTIVE, CRYPT_BUSY)) {
@@ -751,7 +747,7 @@ int main(int argc, char *argv[]) {
                         goto finish;
                 }
 
-                crypt_set_log_callback(cd, log_glue, NULL);
+                crypt_set_log_callback(cd, cryptsetup_log_glue, NULL);
 
                 r = crypt_deactivate(cd, argv[2]);
                 if (r < 0) {
index 2376f1dc2c8bc24761d641ade7e8763ce21a72c3..d3066ca429daf94248780820ba2caa0612bf8466 100644 (file)
@@ -41,10 +41,6 @@ static int help(void) {
         return 0;
 }
 
-static void log_glue(int level, const char *msg, void *usrptr) {
-        log_debug("%s", msg);
-}
-
 int main(int argc, char *argv[]) {
         _cleanup_(crypt_freep) struct crypt_device *cd = NULL;
         int r;
@@ -89,7 +85,7 @@ int main(int argc, char *argv[]) {
                         goto finish;
                 }
 
-                crypt_set_log_callback(cd, log_glue, NULL);
+                crypt_set_log_callback(cd, cryptsetup_log_glue, NULL);
 
                 status = crypt_status(cd, argv[2]);
                 if (IN_SET(status, CRYPT_ACTIVE, CRYPT_BUSY)) {
@@ -127,7 +123,7 @@ int main(int argc, char *argv[]) {
                         goto finish;
                 }
 
-                crypt_set_log_callback(cd, log_glue, NULL);
+                crypt_set_log_callback(cd, cryptsetup_log_glue, NULL);
 
                 r = crypt_deactivate(cd, argv[2]);
                 if (r < 0) {