]>
Commit | Line | Data |
---|---|---|
f4f15635 LP |
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 | ||
f4f15635 | 22 | #include <fcntl.h> |
71d35b6b | 23 | #include <limits.h> |
11c3a366 TA |
24 | #include <stdbool.h> |
25 | #include <stdint.h> | |
77601719 LP |
26 | #include <sys/inotify.h> |
27 | #include <sys/types.h> | |
f4f15635 LP |
28 | #include <unistd.h> |
29 | ||
30 | #include "time-util.h" | |
31 | ||
32 | int unlink_noerrno(const char *path); | |
33 | ||
34 | int rmdir_parents(const char *path, const char *stop); | |
35 | ||
36 | int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char *newpath); | |
37 | ||
38 | int readlinkat_malloc(int fd, const char *p, char **ret); | |
39 | int readlink_malloc(const char *p, char **r); | |
40 | int readlink_value(const char *p, char **ret); | |
41 | int readlink_and_make_absolute(const char *p, char **r); | |
42 | int readlink_and_canonicalize(const char *p, char **r); | |
0ec0deaa | 43 | int readlink_and_make_absolute_root(const char *root, const char *path, char **ret); |
f4f15635 LP |
44 | |
45 | int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid); | |
f4f15635 LP |
46 | |
47 | int fchmod_umask(int fd, mode_t mode); | |
48 | ||
49 | int fd_warn_permissions(const char *path, int fd); | |
50 | ||
51 | #define laccess(path, mode) faccessat(AT_FDCWD, (path), (mode), AT_SYMLINK_NOFOLLOW) | |
52 | ||
53 | int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gid, mode_t mode); | |
54 | int touch(const char *path); | |
55 | ||
56 | int symlink_idempotent(const char *from, const char *to); | |
57 | ||
58 | int symlink_atomic(const char *from, const char *to); | |
59 | int mknod_atomic(const char *path, mode_t mode, dev_t dev); | |
60 | int mkfifo_atomic(const char *path, mode_t mode); | |
61 | ||
62 | int get_files_in_directory(const char *path, char ***list); | |
77601719 | 63 | |
992e8f22 LP |
64 | int tmp_dir(const char **ret); |
65 | int var_tmp_dir(const char **ret); | |
34a8f081 | 66 | |
77601719 LP |
67 | #define INOTIFY_EVENT_MAX (sizeof(struct inotify_event) + NAME_MAX + 1) |
68 | ||
69 | #define FOREACH_INOTIFY_EVENT(e, buffer, sz) \ | |
70 | for ((e) = &buffer.ev; \ | |
71 | (uint8_t*) (e) < (uint8_t*) (buffer.raw) + (sz); \ | |
72 | (e) = (struct inotify_event*) ((uint8_t*) (e) + sizeof(struct inotify_event) + (e)->len)) | |
73 | ||
74 | union inotify_event_buffer { | |
75 | struct inotify_event ev; | |
76 | uint8_t raw[INOTIFY_EVENT_MAX]; | |
77 | }; | |
430fbf8e LP |
78 | |
79 | int inotify_add_watch_fd(int fd, int what, uint32_t mask); |