]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/basic/rm-rf.c
switch-root: modernize rm_rf_children() invocation a bit
[thirdparty/systemd.git] / src / basic / rm-rf.c
index 0c957c9b3a8c22588ddab818f90ecf8f92f5f344..3843fc36fcb86b6bf7b8bfca79a3780fc96bc530 100644 (file)
@@ -33,8 +33,8 @@ int rm_rf_children(int fd, RemoveFlags flags, struct stat *root_dev) {
 
         assert(fd >= 0);
 
-        /* This returns the first error we run into, but nevertheless
-         * tries to go on. This closes the passed fd. */
+        /* This returns the first error we run into, but nevertheless tries to go on. This closes the passed
+         * fd, in all cases, including on failure.. */
 
         if (!(flags & REMOVE_PHYSICAL)) {
 
@@ -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. */