]>
Commit | Line | Data |
---|---|---|
1d81c6a6 CB |
1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
2 | ||
3 | #ifndef __LXCFS_UTILS_H | |
4 | #define __LXCFS_UTILS_H | |
5 | ||
1f5596dd CB |
6 | #ifndef _GNU_SOURCE |
7 | #define _GNU_SOURCE | |
8 | #endif | |
9 | ||
10 | #ifndef FUSE_USE_VERSION | |
580fe4df | 11 | #define FUSE_USE_VERSION 26 |
1f5596dd CB |
12 | #endif |
13 | ||
14 | #define _FILE_OFFSET_BITS 64 | |
580fe4df CB |
15 | |
16 | #include <fuse.h> | |
4ec5c9da | 17 | #include <signal.h> |
1f5596dd CB |
18 | #include <stdbool.h> |
19 | #include <sys/socket.h> | |
20 | #include <sys/types.h> | |
21 | #include <sys/un.h> | |
4ec5c9da | 22 | #include <sys/syscall.h> |
1f5596dd CB |
23 | #include <unistd.h> |
24 | ||
25 | #include "config.h" | |
26 | #include "macro.h" | |
580fe4df | 27 | |
1d81c6a6 CB |
28 | /* Reserve buffer size to account for file size changes. */ |
29 | #define BUF_RESERVE_SIZE 512 | |
30 | ||
1f5596dd CB |
31 | #define SEND_CREDS_OK 0 |
32 | #define SEND_CREDS_NOTSK 1 | |
33 | #define SEND_CREDS_FAIL 2 | |
34 | ||
35 | struct file_info; | |
36 | ||
87f7558b CB |
37 | __attribute__((format_arg(4))) extern char *must_strcat(char **src, size_t *sz, |
38 | size_t *asz, | |
39 | const char *format, ...); | |
1d81c6a6 CB |
40 | extern bool is_shared_pidns(pid_t pid); |
41 | extern int preserve_ns(const int pid, const char *ns); | |
580fe4df | 42 | extern void do_release_file_info(struct fuse_file_info *fi); |
1f5596dd CB |
43 | extern bool recv_creds(int sock, struct ucred *cred, char *v); |
44 | extern int send_creds(int sock, struct ucred *cred, char v, bool pingfirst); | |
45 | extern bool wait_for_sock(int sock, int timeout); | |
46 | extern int read_file_fuse(const char *path, char *buf, size_t size, | |
47 | struct file_info *d); | |
4ec5c9da CB |
48 | extern void prune_init_slice(char *cg); |
49 | extern int wait_for_pid(pid_t pid); | |
1d81c6a6 | 50 | |
2aa59b2e CB |
51 | #ifndef HAVE_PIDFD_OPEN |
52 | static inline int pidfd_open(pid_t pid, unsigned int flags) | |
53 | { | |
54 | #ifdef __NR_pidfd_open | |
55 | return syscall(__NR_pidfd_open, pid, flags); | |
56 | #else | |
57 | return ret_errno(ENOSYS); | |
58 | #endif | |
59 | } | |
60 | #endif | |
61 | ||
62 | #ifndef HAVE_PIDFD_SEND_SIGNAL | |
63 | static inline int pidfd_send_signal(int pidfd, int sig, siginfo_t *info, | |
64 | unsigned int flags) | |
65 | { | |
66 | #ifdef __NR_pidfd_send_signal | |
67 | return syscall(__NR_pidfd_send_signal, pidfd, sig, info, flags); | |
68 | #else | |
69 | return ret_errno(ENOSYS); | |
70 | #endif | |
71 | } | |
72 | #endif | |
73 | ||
757a63e7 CB |
74 | extern FILE *fopen_cached(const char *path, const char *mode, |
75 | void **caller_freed_buffer); | |
76 | ||
1d81c6a6 | 77 | #endif /* __LXCFS_UTILS_H */ |