From: Lennart Poettering Date: Fri, 29 Mar 2019 15:09:49 +0000 (+0100) Subject: rm-rf: refuse combining REMOVE_ONLY_DIRECTORIES and REMOVE_SUBVOLUME for now X-Git-Tag: v242-rc1~23 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c2f64c07c1dd317e5698b672a91bf8ba5726c948;p=thirdparty%2Fsystemd.git rm-rf: refuse combining REMOVE_ONLY_DIRECTORIES and REMOVE_SUBVOLUME for now It's not easy to implement such a combined operation race-freely since dropping a subvolume will drop all its contents, including any non-directories. Hence, let's just not support this combination for now. Which isn't much of a loss, since we never combine these flags anyway. --- diff --git a/src/basic/rm-rf.c b/src/basic/rm-rf.c index 0c957c9b3a8..acc0f88cd24 100644 --- a/src/basic/rm-rf.c +++ b/src/basic/rm-rf.c @@ -165,6 +165,11 @@ int rm_rf(const char *path, RemoveFlags flags) { assert(path); + /* For now, don't support dropping subvols when also only dropping directories, since we can't do + * this race-freely. */ + if (FLAGS_SET(flags, REMOVE_ONLY_DIRECTORIES|REMOVE_SUBVOLUME)) + return -EINVAL; + /* We refuse to clean the root file system with this * call. This is extra paranoia to never cause a really * seriously broken system. */