X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fbasic%2Frm-rf.h;h=f693a5bb7c52bbadbf8424f9edde4d8f65952b02;hp=769bbc853dd35089690bd189efefa95d524ba338;hb=906f94da76802b2aae4dd052018766f5378ae4b8;hpb=1cfc78c91965df340cdde100ad6cb3ed50b28927 diff --git a/src/basic/rm-rf.h b/src/basic/rm-rf.h index 769bbc853..f693a5bb7 100644 --- a/src/basic/rm-rf.h +++ b/src/basic/rm-rf.h @@ -1,5 +1,3 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - #pragma once /*** @@ -27,7 +25,17 @@ typedef enum RemoveFlags { REMOVE_ONLY_DIRECTORIES = 1, REMOVE_ROOT = 2, REMOVE_PHYSICAL = 4, /* if not set, only removes files on tmpfs, never physical file systems */ + REMOVE_SUBVOLUME = 8, } RemoveFlags; 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_physical_and_free(char *p) { + if (!p) + return; + (void) rm_rf(p, REMOVE_ROOT|REMOVE_PHYSICAL); + free(p); +} +DEFINE_TRIVIAL_CLEANUP_FUNC(char*, rm_rf_physical_and_free);