return rm_rf_at(AT_FDCWD, path, flags);
}
-/* Useful for usage with _cleanup_(), destroys a directory and frees the pointer */
-static inline char *rm_rf_physical_and_free(char *p) {
+/* 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;
+}
+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)
}
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) {
+/* Similar as above, but also has magic btrfs subvolume powers. */
+static inline char* rm_rf_subvolume_and_free(char *p) {
PROTECT_ERRNO;
if (!p)