chiark / gitweb /
basic: remove rm_rf_and_free, add rm_rf_physical_and_free, use rm_rf_physical_and_fre...
authorEvgeny Vereshchagin <evvers@ya.ru>
Fri, 20 May 2016 13:08:24 +0000 (16:08 +0300)
committerSven Eden <yamakuzure@gmx.net>
Fri, 16 Jun 2017 08:12:58 +0000 (10:12 +0200)
Some distros don't mount /tmp as tmpfs.
For example:
https://lists.ubuntu.com/archives/ubuntu-cloud/2016-January/001009.html

Some tests:
* print 'Attempted to remove disk file system, and we can't allow that.'
* don't really cleanup /tmp

src/basic/rm-rf.h

index 40b5b527d57265e98f7994dbdbea8eae82ab5f78..f693a5bb7c52bbadbf8424f9edde4d8f65952b02 100644 (file)
@@ -32,10 +32,10 @@ int rm_rf_children(int fd, RemoveFlags flags, struct stat *root_dev);
 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_and_free(char *p) {
+static inline void rm_rf_physical_and_free(char *p) {
         if (!p)
                 return;
-        (void) rm_rf(p, REMOVE_ROOT);
+        (void) rm_rf(p, REMOVE_ROOT|REMOVE_PHYSICAL);
         free(p);
 }
-DEFINE_TRIVIAL_CLEANUP_FUNC(char*, rm_rf_and_free);
+DEFINE_TRIVIAL_CLEANUP_FUNC(char*, rm_rf_physical_and_free);