summaryrefslogtreecommitdiff
path: root/src/basic/rm-rf.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-03-29 16:13:03 +0100
committerLennart Poettering <lennart@poettering.net>2019-07-11 12:18:51 +0200
commitc0228b4fa3e4e633afa5eb8417e6cd3e311cd250 (patch)
treec3d9590862e8b6ff68f3dd790f5f853a0e3ef666 /src/basic/rm-rf.h
parent6b39223cd3d5af24c0077207c633a47ae8f7d80d (diff)
downloadsystemd-c0228b4fa3e4e633afa5eb8417e6cd3e311cd250.tar.gz
rm-rf: introduce new flag REMOVE_MISSING_OK
This new flag suppresses error if the top-level path specified doesn't exist. This is useful since suppressing this on the caller side isn't easy, since ENOENT migh be propagate for some reason from further inside and we can't distuingish that. While we are at it, also be a bit more careful witht the various combinations of flags. (Note that in some cases rm_rf() was already ignoring ENOENT from unlink() or rmdir(), however that was pretty useless, since we always open() the top-level path with O_DIRECTORY and if that hit ENOENT we didn't ignore the failure).
Diffstat (limited to 'src/basic/rm-rf.h')
-rw-r--r--src/basic/rm-rf.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/basic/rm-rf.h b/src/basic/rm-rf.h
index d42ebef434..40cbff21c0 100644
--- a/src/basic/rm-rf.h
+++ b/src/basic/rm-rf.h
@@ -6,10 +6,11 @@
#include "errno-util.h"
typedef enum RemoveFlags {
- REMOVE_ONLY_DIRECTORIES = 1 << 0,
- REMOVE_ROOT = 1 << 1,
- REMOVE_PHYSICAL = 1 << 2, /* if not set, only removes files on tmpfs, never physical file systems */
- REMOVE_SUBVOLUME = 1 << 3,
+ REMOVE_ONLY_DIRECTORIES = 1 << 0, /* Only remove empty directories, no files */
+ REMOVE_ROOT = 1 << 1, /* Remove the specified directory itself too, not just the contents of it */
+ REMOVE_PHYSICAL = 1 << 2, /* If not set, only removes files on tmpfs, never physical file systems */
+ REMOVE_SUBVOLUME = 1 << 3, /* Drop btrfs subvolumes in the tree too */
+ REMOVE_MISSING_OK = 1 << 4, /* If the top-level directory is missing, ignore the ENOENT for it */
} RemoveFlags;
int rm_rf_children(int fd, RemoveFlags flags, struct stat *root_dev);