]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
rm-rf: Reduce transitive includes
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 5 May 2025 12:13:11 +0000 (14:13 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 7 May 2025 13:04:46 +0000 (22:04 +0900)
src/analyze/analyze-verify.c
src/core/generator-setup.c
src/import/import-tar.c
src/import/pull-tar.c
src/nsresourced/test-userns-restrict.c
src/nsresourced/userns-registry.c
src/shared/btrfs-util.c
src/shared/copy.c
src/shared/rm-rf.c
src/shared/rm-rf.h

index 3b463f2ac7731d711c90c25a00bbecd58acaeac6..02a9dbc646256dcc7151660de0048c417650aacd 100644 (file)
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include "alloc-util.h"
 #include "analyze.h"
 #include "analyze-verify.h"
 #include "analyze-verify-util.h"
index b16211e8f46ae79478d931a7b1134a8829fbecb5..7510fc3c610ab2e84fd344afad371f198aea1cf9 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <unistd.h>
 
+#include "errno-util.h"
 #include "generator-setup.h"
 #include "macro.h"
 #include "mkdir-label.h"
index a2e7eda51b7061ebcaa1820faa1a7fbf7cdda083..ac6925f30bddcb9e01015d730a0f40fe4d468894 100644 (file)
@@ -6,6 +6,7 @@
 #include "alloc-util.h"
 #include "btrfs-util.h"
 #include "copy.h"
+#include "errno-util.h"
 #include "fd-util.h"
 #include "fileio.h"
 #include "fs-util.h"
index 8c9e4f33954cc1f02e4ee157886af648ed214afb..10f3ea0497a18d8c6c306a91a8116a195994b499 100644 (file)
@@ -9,6 +9,7 @@
 #include "btrfs-util.h"
 #include "copy.h"
 #include "curl-util.h"
+#include "errno-util.h"
 #include "fd-util.h"
 #include "fs-util.h"
 #include "hostname-util.h"
index 1dcf0bd91b559ad58f6a49ff8c4ce86d4c880081..0aff1c87fbd628204a1343c37000b193a8fa1808 100644 (file)
@@ -3,6 +3,7 @@
 #include <sys/eventfd.h>
 #include <sys/mount.h>
 
+#include "errno-util.h"
 #include "fd-util.h"
 #include "log.h"
 #include "main-func.h"
index 5e39c3844e52d98a0fbe3ebdc80df54279c4958b..be314231aec802fb2d43b0ad698e2e25001992e4 100644 (file)
@@ -3,7 +3,9 @@
 #include "sd-json.h"
 #include "sd-netlink.h"
 
+#include "alloc-util.h"
 #include "chase.h"
+#include "errno-util.h"
 #include "fd-util.h"
 #include "fileio.h"
 #include "format-util.h"
index d296ac682caa0d8f4ac70b113df7e35e3cf26ebc..0615b27a02ab1db68d542ec0e257219a59e2ec20 100644 (file)
@@ -21,6 +21,7 @@
 #include "chase.h"
 #include "chattr-util.h"
 #include "copy.h"
+#include "errno-util.h"
 #include "fd-util.h"
 #include "fileio.h"
 #include "fs-util.h"
index 4288bae1ceaa8a9ba37a8087f58a5ca7a76752cd..fb006e38ed2654468c648b94e349797aef2a7700 100644 (file)
@@ -17,6 +17,7 @@
 #include "chattr-util.h"
 #include "copy.h"
 #include "dirent-util.h"
+#include "errno-util.h"
 #include "fd-util.h"
 #include "fileio.h"
 #include "fs-util.h"
index 39866e2258cd4ba3eb93a51d758051ad44f36197..08c76a384ea40445508201f3a6c680199e01b176 100644 (file)
@@ -9,6 +9,7 @@
 #include "alloc-util.h"
 #include "btrfs-util.h"
 #include "dirent-util.h"
+#include "errno-util.h"
 #include "fd-util.h"
 #include "fs-util.h"
 #include "log.h"
@@ -517,3 +518,33 @@ int rm_rf_child(int fd, const char *name, RemoveFlags flags) {
 
         return rm_rf_inner_child(fd, name, -1, flags, NULL, true);
 }
+
+const char* rm_rf_safe(const char *p) {
+        PROTECT_ERRNO;
+
+        if (!p)
+                return NULL;
+
+        (void) rm_rf(p, REMOVE_ROOT|REMOVE_MISSING_OK|REMOVE_CHMOD);
+        return NULL;
+}
+
+char* rm_rf_physical_and_free(char *p) {
+        PROTECT_ERRNO;
+
+        if (!p)
+                return NULL;
+
+        (void) rm_rf(p, REMOVE_ROOT|REMOVE_PHYSICAL|REMOVE_MISSING_OK|REMOVE_CHMOD);
+        return mfree(p);
+}
+
+char* rm_rf_subvolume_and_free(char *p) {
+        PROTECT_ERRNO;
+
+        if (!p)
+                return NULL;
+
+        (void) rm_rf(p, REMOVE_ROOT|REMOVE_PHYSICAL|REMOVE_SUBVOLUME|REMOVE_MISSING_OK|REMOVE_CHMOD);
+        return mfree(p);
+}
index 2e107da0e1a47031a92ed55eb288f3ca225ffe9d..a965df5f8e3e2254afc82a9b31f5c61ddfb0da78 100644 (file)
@@ -4,8 +4,7 @@
 #include <fcntl.h>
 #include <sys/stat.h>
 
-#include "alloc-util.h"
-#include "errno-util.h"
+#include "memory-util.h"
 
 typedef enum RemoveFlags {
         REMOVE_ONLY_DIRECTORIES = 1 << 0, /* Only remove empty directories, no files */
@@ -35,37 +34,13 @@ static inline int rm_rf(const char *path, RemoveFlags flags) {
 }
 
 /* Useful for using with _cleanup_(), destroys a directory on a temporary file system. */
-static inline const char* rm_rf_safe(const char *p) {
-        PROTECT_ERRNO;
-
-        if (!p)
-                return NULL;
-
-        (void) rm_rf(p, REMOVE_ROOT|REMOVE_MISSING_OK|REMOVE_CHMOD);
-        return NULL;
-}
+const char* rm_rf_safe(const char *p);
 DEFINE_TRIVIAL_CLEANUP_FUNC(const char*, rm_rf_safe);
 
 /* Similar as above, but allow to destroy a directory on a physical file system, and also frees the pointer. */
-static inline char* rm_rf_physical_and_free(char *p) {
-        PROTECT_ERRNO;
-
-        if (!p)
-                return NULL;
-
-        (void) rm_rf(p, REMOVE_ROOT|REMOVE_PHYSICAL|REMOVE_MISSING_OK|REMOVE_CHMOD);
-        return mfree(p);
-}
+char* rm_rf_physical_and_free(char *p);
 DEFINE_TRIVIAL_CLEANUP_FUNC(char*, rm_rf_physical_and_free);
 
 /* Similar as above, but also has magic btrfs subvolume powers. */
-static inline char* rm_rf_subvolume_and_free(char *p) {
-        PROTECT_ERRNO;
-
-        if (!p)
-                return NULL;
-
-        (void) rm_rf(p, REMOVE_ROOT|REMOVE_PHYSICAL|REMOVE_SUBVOLUME|REMOVE_MISSING_OK|REMOVE_CHMOD);
-        return mfree(p);
-}
+char* rm_rf_subvolume_and_free(char *p);
 DEFINE_TRIVIAL_CLEANUP_FUNC(char*, rm_rf_subvolume_and_free);