]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/umask-util.h
tree-wide: remove Lennart's copyright lines
[thirdparty/systemd.git] / src / basic / umask-util.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include <stdbool.h>
5 #include <sys/stat.h>
6 #include <sys/types.h>
7
8 #include "macro.h"
9
10 static inline void umaskp(mode_t *u) {
11 umask(*u);
12 }
13
14 #define _cleanup_umask_ _cleanup_(umaskp)
15
16 struct _umask_struct_ {
17 mode_t mask;
18 bool quit;
19 };
20
21 static inline void _reset_umask_(struct _umask_struct_ *s) {
22 umask(s->mask);
23 };
24
25 #define RUN_WITH_UMASK(mask) \
26 for (_cleanup_(_reset_umask_) struct _umask_struct_ _saved_umask_ = { umask(mask), false }; \
27 !_saved_umask_.quit ; \
28 _saved_umask_.quit = true)