#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"
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);
+}
#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 */
}
/* 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);