]>
Commit | Line | Data |
---|---|---|
f4f15635 LP |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
3 | #pragma once | |
4 | ||
5 | /*** | |
6 | This file is part of systemd. | |
7 | ||
8 | Copyright 2010 Lennart Poettering | |
9 | ||
10 | systemd is free software; you can redistribute it and/or modify it | |
11 | under the terms of the GNU Lesser General Public License as published by | |
12 | the Free Software Foundation; either version 2.1 of the License, or | |
13 | (at your option) any later version. | |
14 | ||
15 | systemd is distributed in the hope that it will be useful, but | |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 | Lesser General Public License for more details. | |
19 | ||
20 | You should have received a copy of the GNU Lesser General Public License | |
21 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
22 | ***/ | |
23 | ||
f4f15635 | 24 | #include <fcntl.h> |
71d35b6b | 25 | #include <limits.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); | |
46 | int fchmod_and_fchown(int fd, mode_t mode, uid_t uid, gid_t gid); | |
47 | ||
48 | int fchmod_umask(int fd, mode_t mode); | |
49 | ||
50 | int fd_warn_permissions(const char *path, int fd); | |
51 | ||
52 | #define laccess(path, mode) faccessat(AT_FDCWD, (path), (mode), AT_SYMLINK_NOFOLLOW) | |
53 | ||
54 | int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gid, mode_t mode); | |
55 | int touch(const char *path); | |
56 | ||
57 | int symlink_idempotent(const char *from, const char *to); | |
58 | ||
59 | int symlink_atomic(const char *from, const char *to); | |
60 | int mknod_atomic(const char *path, mode_t mode, dev_t dev); | |
61 | int mkfifo_atomic(const char *path, mode_t mode); | |
62 | ||
63 | int get_files_in_directory(const char *path, char ***list); | |
77601719 LP |
64 | |
65 | #define INOTIFY_EVENT_MAX (sizeof(struct inotify_event) + NAME_MAX + 1) | |
66 | ||
67 | #define FOREACH_INOTIFY_EVENT(e, buffer, sz) \ | |
68 | for ((e) = &buffer.ev; \ | |
69 | (uint8_t*) (e) < (uint8_t*) (buffer.raw) + (sz); \ | |
70 | (e) = (struct inotify_event*) ((uint8_t*) (e) + sizeof(struct inotify_event) + (e)->len)) | |
71 | ||
72 | union inotify_event_buffer { | |
73 | struct inotify_event ev; | |
74 | uint8_t raw[INOTIFY_EVENT_MAX]; | |
75 | }; |