]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
c6878637 LP |
2 | #pragma once |
3 | ||
4 | /*** | |
c6878637 | 5 | Copyright 2015 Lennart Poettering |
c6878637 LP |
6 | ***/ |
7 | ||
8 | #include <sys/stat.h> | |
9 | ||
dfd14786 LP |
10 | #include "util.h" |
11 | ||
c6878637 | 12 | typedef enum RemoveFlags { |
e7279ce8 LP |
13 | REMOVE_ONLY_DIRECTORIES = 1 << 0, |
14 | REMOVE_ROOT = 1 << 1, | |
15 | REMOVE_PHYSICAL = 1 << 2, /* if not set, only removes files on tmpfs, never physical file systems */ | |
16 | REMOVE_SUBVOLUME = 1 << 3, | |
c6878637 LP |
17 | } RemoveFlags; |
18 | ||
19 | int rm_rf_children(int fd, RemoveFlags flags, struct stat *root_dev); | |
20 | int rm_rf(const char *path, RemoveFlags flags); | |
d2120590 LP |
21 | |
22 | /* Useful for usage with _cleanup_(), destroys a directory and frees the pointer */ | |
f942504e | 23 | static inline void rm_rf_physical_and_free(char *p) { |
dfd14786 | 24 | PROTECT_ERRNO; |
f942504e | 25 | (void) rm_rf(p, REMOVE_ROOT|REMOVE_PHYSICAL); |
d2120590 LP |
26 | free(p); |
27 | } | |
f942504e | 28 | DEFINE_TRIVIAL_CLEANUP_FUNC(char*, rm_rf_physical_and_free); |