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