]> git.proxmox.com Git - pve-cluster.git/blame - data/src/cfs-utils.h
pmxcfs: update copyright in license header
[pve-cluster.git] / data / src / cfs-utils.h
CommitLineData
fe000966 1/*
84c98315 2 Copyright (C) 2010 - 2020 Proxmox Server Solutions GmbH
fe000966
DM
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Affero General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Affero General Public License for more details.
13
14 You should have received a copy of the GNU Affero General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 Author: Dietmar Maurer <dietmar@proxmox.com>
18
19*/
20
21#ifndef _PVE_CFS_UTILS_H_
22#define _PVE_CFS_UTILS_H_
23
24#ifdef HAVE_CONFIG_H
25#include <config.h>
26#endif /* HAVE_CONFIG_H */
27
28#include <stdint.h>
29#include <glib.h>
30#include <fcntl.h>
31
2113d031 32#define HOST_CLUSTER_CONF_FN "/etc/corosync/corosync.conf"
fe000966
DM
33#define CFS_PID_FN "/var/run/pve-cluster.pid"
34#define VARLIBDIR "/var/lib/pve-cluster"
68da7070 35#define RUNDIR "/run/pve-cluster"
fe000966
DM
36
37#define CFS_MAX(a, b) (((a) > (b)) ? (a) : (b))
38#define CFS_MIN(a, b) (((a) < (b)) ? (a) : (b))
39
40typedef struct {
41 char *nodename;
42 char *ip;
43 gid_t gid;
44 int debug;
fe000966
DM
45} cfs_t;
46
47extern cfs_t cfs;
48
49void
50utf8_to_ascii(
51 char *buf,
52 int bufsize,
53 const char *msg,
54 gboolean quotequote);
55
56void
57cfs_log(
58 const gchar *log_domain,
59 GLogLevelFlags log_level,
60 const char *file,
61 int line,
62 const char *func,
63 const gchar *format,
64 ...) G_GNUC_PRINTF (6, 7);
65
66void ipc_log_fn(
67 const char *file,
68 int32_t line,
69 int32_t severity,
70 const char *msg);
71
72
73#define cfs_debug(...) G_STMT_START { \
74 if (cfs.debug) \
75 cfs_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__); \
76 } G_STMT_END
77
78#define cfs_dom_debug(domain, ...) G_STMT_START { \
79 if (cfs.debug) \
80 cfs_log(domain, G_LOG_LEVEL_DEBUG, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__); \
81 } G_STMT_END
82
83#define cfs_critical(...) cfs_log(G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
84#define cfs_dom_critical(domain, ...) cfs_log(domain, G_LOG_LEVEL_CRITICAL, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
85#define cfs_message(...) cfs_log(G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
86#define cfs_dom_message(domain, ...) cfs_log(domain, G_LOG_LEVEL_MESSAGE, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
87
88guint64
89cluster_config_version(
90 const gpointer config_data,
91 gsize config_length);
92
93ssize_t
94safe_read(
95 int fd,
96 char *buf,
97 size_t count);
98
99gboolean
100full_write(
101 int fd,
102 const char *buf,
103 size_t len);
104
105gboolean
106atomic_write_file(
107 const char *filename,
108 gconstpointer data,
109 size_t len,
110 mode_t mode,
111 gid_t gid);
112
113gboolean
114path_is_private(const char *path);
115
42789cda
DM
116gboolean
117path_is_lxc_conf(const char *path);
118
fe000966
DM
119gboolean
120path_is_lockdir(const char *path);
121
122#endif /* _PVE_CFS_UTILS_H_ */