]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart,homed: split out disk cleanup macros into generic header
authorLennart Poettering <lennart@poettering.net>
Tue, 28 Sep 2021 21:24:57 +0000 (23:24 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 25 Nov 2021 11:10:34 +0000 (12:10 +0100)
src/home/homework-luks.c
src/partition/repart.c
src/shared/fdisk-util.h [new file with mode: 0644]
src/shared/meson.build

index 29a18b48d961286be1047c3bb9fb0c3875ae20b5..774d5d4e30bc27ae8b280a5504fc206787c7a87d 100644 (file)
@@ -1,6 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <libfdisk.h>
 #include <linux/loop.h>
 #include <poll.h>
 #include <sys/file.h>
@@ -24,6 +23,7 @@
 #include "env-util.h"
 #include "errno-util.h"
 #include "fd-util.h"
+#include "fdisk-util.h"
 #include "fileio.h"
 #include "filesystems.h"
 #include "fs-util.h"
@@ -1833,11 +1833,6 @@ static int luks_format(
         return 0;
 }
 
-DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_context*, fdisk_unref_context, NULL);
-DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_partition*, fdisk_unref_partition, NULL);
-DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_parttype*, fdisk_unref_parttype, NULL);
-DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_table*, fdisk_unref_table, NULL);
-
 static int make_partition_table(
                 int fd,
                 const char *label,
index 5e6e88df94e198b63184ddda0d7dfde49b57285c..50b1f453151c22a4a300308c9c988301e9ee873d 100644 (file)
@@ -6,7 +6,6 @@
 
 #include <fcntl.h>
 #include <getopt.h>
-#include <libfdisk.h>
 #include <linux/fs.h>
 #include <linux/loop.h>
 #include <sys/file.h>
@@ -31,6 +30,7 @@
 #include "efivars.h"
 #include "errno-util.h"
 #include "fd-util.h"
+#include "fdisk-util.h"
 #include "fileio.h"
 #include "format-table.h"
 #include "format-util.h"
@@ -1420,11 +1420,6 @@ static int context_read_definitions(
         return 0;
 }
 
-DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_context*, fdisk_unref_context, NULL);
-DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_partition*, fdisk_unref_partition, NULL);
-DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_parttype*, fdisk_unref_parttype, NULL);
-DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_table*, fdisk_unref_table, NULL);
-
 static int determine_current_padding(
                 struct fdisk_context *c,
                 struct fdisk_table *t,
diff --git a/src/shared/fdisk-util.h b/src/shared/fdisk-util.h
new file mode 100644 (file)
index 0000000..64c0c2f
--- /dev/null
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#if HAVE_LIBFDISK
+
+#include <libfdisk.h>
+
+#include "macro.h"
+
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_context*, fdisk_unref_context, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_partition*, fdisk_unref_partition, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_parttype*, fdisk_unref_parttype, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_table*, fdisk_unref_table, NULL);
+
+#endif
index 00485e654342e0add414a9b5ee87352656606341..130c03ec99a65a3fb034241acb3e47a6b7c4eeb1 100644 (file)
@@ -118,6 +118,7 @@ shared_sources = files('''
         exit-status.h
         extension-release.c
         extension-release.h
+        fdisk-util.h
         fdset.c
         fdset.h
         fileio-label.c