chiark / gitweb /
core: rename cg_unified() to cg_all_unified()
[elogind.git] / src / basic / fs-util.h
1 #pragma once
2
3 /***
4   This file is part of systemd.
5
6   Copyright 2010 Lennart Poettering
7
8   systemd is free software; you can redistribute it and/or modify it
9   under the terms of the GNU Lesser General Public License as published by
10   the Free Software Foundation; either version 2.1 of the License, or
11   (at your option) any later version.
12
13   systemd is distributed in the hope that it will be useful, but
14   WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16   Lesser General Public License for more details.
17
18   You should have received a copy of the GNU Lesser General Public License
19   along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #include <fcntl.h>
23 #include <limits.h>
24 #include <stdbool.h>
25 #include <stdint.h>
26 #include <sys/inotify.h>
27 #include <sys/types.h>
28 #include <unistd.h>
29
30 #include "time-util.h"
31
32 int unlink_noerrno(const char *path);
33
34 #if 0 /// UNNEEDED by elogind
35 int rmdir_parents(const char *path, const char *stop);
36
37 int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char *newpath);
38 #endif // 0
39
40 int readlinkat_malloc(int fd, const char *p, char **ret);
41 int readlink_malloc(const char *p, char **r);
42 #if 0 /// UNNEEDED by elogind
43 int readlink_value(const char *p, char **ret);
44 int readlink_and_make_absolute(const char *p, char **r);
45 int readlink_and_canonicalize(const char *p, char **r);
46 int readlink_and_make_absolute_root(const char *root, const char *path, char **ret);
47 #endif // 0
48
49 int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid);
50
51 int fchmod_umask(int fd, mode_t mode);
52
53 int fd_warn_permissions(const char *path, int fd);
54
55 #ifdef __GLIBC__
56 #define laccess(path, mode) faccessat(AT_FDCWD, (path), (mode), AT_SYMLINK_NOFOLLOW)
57 #else
58 #define laccess(path, mode) faccessat(AT_FDCWD, (path), (mode), 0)
59 #endif
60
61
62 int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gid, mode_t mode);
63 int touch(const char *path);
64
65 #if 0 /// UNNEEDED by elogind
66 int symlink_idempotent(const char *from, const char *to);
67
68 int symlink_atomic(const char *from, const char *to);
69 int mknod_atomic(const char *path, mode_t mode, dev_t dev);
70 int mkfifo_atomic(const char *path, mode_t mode);
71 #endif // 0
72
73 int get_files_in_directory(const char *path, char ***list);
74
75 #if 0 /// UNNEEDED by elogind
76 int tmp_dir(const char **ret);
77 int var_tmp_dir(const char **ret);
78
79 #define INOTIFY_EVENT_MAX (sizeof(struct inotify_event) + NAME_MAX + 1)
80
81 #define FOREACH_INOTIFY_EVENT(e, buffer, sz) \
82         for ((e) = &buffer.ev;                                \
83              (uint8_t*) (e) < (uint8_t*) (buffer.raw) + (sz); \
84              (e) = (struct inotify_event*) ((uint8_t*) (e) + sizeof(struct inotify_event) + (e)->len))
85
86 union inotify_event_buffer {
87         struct inotify_event ev;
88         uint8_t raw[INOTIFY_EVENT_MAX];
89 };
90
91 int inotify_add_watch_fd(int fd, int what, uint32_t mask);
92 #endif // 0