]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared: make libmount_parse() non-inline
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 7 Nov 2022 10:49:36 +0000 (11:49 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 9 Nov 2022 08:20:34 +0000 (09:20 +0100)
Back in e2857b3d87306d93f0fba526f3e79f4f6806fb02 I added this function
as static inline in order to avoid linking libmount into libshared.
Nevertheless, a dependency on libmount was added to libbasic in
9e7f941acb0d8fe7a31eec7826ff2c9c6af7044f, and later moved to libshared
in 77c772f227d866331560a8d0487fba12dd128dd4. So the shenanigan with an
inline function is not useful, let's make it a normal function.

src/shared/libmount-util.c [new file with mode: 0644]
src/shared/libmount-util.h
src/shared/meson.build

diff --git a/src/shared/libmount-util.c b/src/shared/libmount-util.c
new file mode 100644 (file)
index 0000000..bcb21b5
--- /dev/null
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+#include <stdio.h>
+
+#include "libmount-util.h"
+
+int libmount_parse(
+                const char *path,
+                FILE *source,
+                struct libmnt_table **ret_table,
+                struct libmnt_iter **ret_iter) {
+
+        _cleanup_(mnt_free_tablep) struct libmnt_table *table = NULL;
+        _cleanup_(mnt_free_iterp) struct libmnt_iter *iter = NULL;
+        int r;
+
+        /* Older libmount seems to require this. */
+        assert(!source || path);
+
+        table = mnt_new_table();
+        iter = mnt_new_iter(MNT_ITER_FORWARD);
+        if (!table || !iter)
+                return -ENOMEM;
+
+        /* If source or path are specified, we use on the functions which ignore utab.
+         * Only if both are empty, we use mnt_table_parse_mtab(). */
+
+        if (source)
+                r = mnt_table_parse_stream(table, source, path);
+        else if (path)
+                r = mnt_table_parse_file(table, path);
+        else
+                r = mnt_table_parse_mtab(table, NULL);
+        if (r < 0)
+                return r;
+
+        *ret_table = TAKE_PTR(table);
+        *ret_iter = TAKE_PTR(iter);
+        return 0;
+}
index cf19c56ed12a8a55d3dde5959eb3dfc55e8af33e..6f6f36ad527a7a95e236cdada6ff44247bf05ab4 100644 (file)
@@ -1,8 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <stdio.h>
-
 /* This needs to be after sys/mount.h */
 #include <libmount.h>
 
@@ -11,37 +9,8 @@
 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct libmnt_table*, mnt_free_table, NULL);
 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct libmnt_iter*, mnt_free_iter, NULL);
 
-static inline int libmount_parse(
+int libmount_parse(
                 const char *path,
                 FILE *source,
                 struct libmnt_table **ret_table,
-                struct libmnt_iter **ret_iter) {
-
-        _cleanup_(mnt_free_tablep) struct libmnt_table *table = NULL;
-        _cleanup_(mnt_free_iterp) struct libmnt_iter *iter = NULL;
-        int r;
-
-        /* Older libmount seems to require this. */
-        assert(!source || path);
-
-        table = mnt_new_table();
-        iter = mnt_new_iter(MNT_ITER_FORWARD);
-        if (!table || !iter)
-                return -ENOMEM;
-
-        /* If source or path are specified, we use on the functions which ignore utab.
-         * Only if both are empty, we use mnt_table_parse_mtab(). */
-
-        if (source)
-                r = mnt_table_parse_stream(table, source, path);
-        else if (path)
-                r = mnt_table_parse_file(table, path);
-        else
-                r = mnt_table_parse_mtab(table, NULL);
-        if (r < 0)
-                return r;
-
-        *ret_table = TAKE_PTR(table);
-        *ret_iter = TAKE_PTR(iter);
-        return 0;
-}
+                struct libmnt_iter **ret_iter);
index bdf1701ba93069dc001950d446ec30b4a6729808..5f66b865de3ef6072be3666f90b10c8fa64a4256 100644 (file)
@@ -193,6 +193,7 @@ shared_sources = files(
         'libcrypt-util.h',
         'libfido2-util.c',
         'libfido2-util.h',
+        'libmount-util.c',
         'libmount-util.h',
         'linux/auto_dev-ioctl.h',
         'linux/bpf.h',