pacemaker  3.0.0-d8340737c4
Scalable High-Availability cluster resource manager
io_internal.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022-2024 the Pacemaker project contributors
3  *
4  * The version control history for this file may have further details.
5  *
6  * This source code is licensed under the GNU Lesser General Public License
7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8  */
9 
10 #ifndef PCMK__CRM_COMMON_IO_INTERNAL__H
11 #define PCMK__CRM_COMMON_IO_INTERNAL__H
12 
13 #include <fcntl.h> // open()
14 #include <stdbool.h> // bool
15 #include <unistd.h> // uid_t, gid_t
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 int pcmk__real_path(const char *path, char **resolved_path);
22 
23 char *pcmk__series_filename(const char *directory, const char *series,
24  unsigned int sequence, bool bzip);
25 int pcmk__read_series_sequence(const char *directory, const char *series,
26  unsigned int *seq);
27 void pcmk__write_series_sequence(const char *directory, const char *series,
28  unsigned int sequence, int max);
29 int pcmk__chown_series_sequence(const char *directory, const char *series,
30  uid_t uid, gid_t gid);
31 
32 int pcmk__build_path(const char *path_c, mode_t mode);
33 char *pcmk__full_path(const char *filename, const char *dirname);
34 bool pcmk__daemon_can_write(const char *dir, const char *file);
35 void pcmk__sync_directory(const char *name);
36 
37 int pcmk__file_contents(const char *filename, char **contents);
38 int pcmk__write_sync(int fd, const char *contents);
39 int pcmk__set_nonblocking(int fd);
40 const char *pcmk__get_tmpdir(void);
41 
42 void pcmk__close_fds_in_child(bool);
43 
53 static inline void
54 pcmk__open_devnull(int flags)
55 {
56  // Static analysis clutter
57  // cppcheck-suppress leakReturnValNotUsed
58  (void) open("/dev/null", flags);
59 }
60 
61 #ifdef __cplusplus
62 }
63 #endif
64 
65 #endif // PCMK__CRM_COMMON_IO_INTERNAL__H
int pcmk__set_nonblocking(int fd)
Definition: io.c:520
const char * name
Definition: cib.c:26
void pcmk__write_series_sequence(const char *directory, const char *series, unsigned int sequence, int max)
Definition: io.c:183
int pcmk__chown_series_sequence(const char *directory, const char *series, uid_t uid, gid_t gid)
Definition: io.c:234
int pcmk__read_series_sequence(const char *directory, const char *series, unsigned int *seq)
Definition: io.c:136
int pcmk__write_sync(int fd, const char *contents)
Definition: io.c:490
int pcmk__build_path(const char *path_c, mode_t mode)
Definition: io.c:41
void pcmk__sync_directory(const char *name)
Definition: io.c:392
char * pcmk__series_filename(const char *directory, const char *series, unsigned int sequence, bool bzip)
Definition: io.c:117
char * pcmk__full_path(const char *filename, const char *dirname)
Duplicate a file path, inserting a prefix if not absolute.
Definition: io.c:630
const char * pcmk__get_tmpdir(void)
Definition: io.c:543
int pcmk__file_contents(const char *filename, char **contents)
Definition: io.c:428
const char * path
Definition: cib.c:28
bool pcmk__daemon_can_write(const char *dir, const char *file)
Definition: io.c:324
void pcmk__close_fds_in_child(bool)
Definition: io.c:561
int pcmk__real_path(const char *path, char **resolved_path)
Definition: io.c:81
uint64_t flags
Definition: remote.c:211