]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/basic/rm-rf.h
util-lib: save/restore errno in cleanup calls
[thirdparty/systemd.git] / src / basic / rm-rf.h
index 1127e326b2ba810c88836e62f8418d930a30b0a6..ad63e9be4070615a99efdf89657229497a11df16 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <sys/stat.h>
 
+#include "util.h"
+
 typedef enum RemoveFlags {
         REMOVE_ONLY_DIRECTORIES = 1,
         REMOVE_ROOT = 2,
@@ -34,6 +36,7 @@ int rm_rf(const char *path, RemoveFlags flags);
 
 /* Useful for usage with _cleanup_(), destroys a directory and frees the pointer */
 static inline void rm_rf_physical_and_free(char *p) {
+        PROTECT_ERRNO;
         (void) rm_rf(p, REMOVE_ROOT|REMOVE_PHYSICAL);
         free(p);
 }