]> git.proxmox.com Git - pve-cluster.git/blame - data/src/cfs-utils.h
remove cman, and use corosync.conf instead of cluster.conf
[pve-cluster.git] / data / src / cfs-utils.h
CommitLineData
fe000966
DM
1/*
2 Copyright (C) 2010 Proxmox Server Solutions GmbH
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"
35
36#define CFS_MAX(a, b) (((a) > (b)) ? (a) : (b))
37#define CFS_MIN(a, b) (((a) < (b)) ? (a) : (b))
38
39typedef struct {
40 char *nodename;
41 char *ip;
42 gid_t gid;
43 int debug;
fe000966
DM
44} cfs_t;
45
46extern cfs_t cfs;
47
48void
49utf8_to_ascii(
50 char *buf,
51 int bufsize,
52 const char *msg,
53 gboolean quotequote);
54
55void
56cfs_log(
57 const gchar *log_domain,
58 GLogLevelFlags log_level,
59 const char *file,
60 int line,
61 const char *func,
62 const gchar *format,
63 ...) G_GNUC_PRINTF (6, 7);
64
65void ipc_log_fn(
66 const char *file,
67 int32_t line,
68 int32_t severity,
69 const char *msg);
70
71
72#define cfs_debug(...) G_STMT_START { \
73 if (cfs.debug) \
74 cfs_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__); \
75 } G_STMT_END
76
77#define cfs_dom_debug(domain, ...) G_STMT_START { \
78 if (cfs.debug) \
79 cfs_log(domain, G_LOG_LEVEL_DEBUG, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__); \
80 } G_STMT_END
81
82#define cfs_critical(...) cfs_log(G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
83#define cfs_dom_critical(domain, ...) cfs_log(domain, G_LOG_LEVEL_CRITICAL, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
84#define cfs_message(...) cfs_log(G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
85#define cfs_dom_message(domain, ...) cfs_log(domain, G_LOG_LEVEL_MESSAGE, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
86
87guint64
88cluster_config_version(
89 const gpointer config_data,
90 gsize config_length);
91
92ssize_t
93safe_read(
94 int fd,
95 char *buf,
96 size_t count);
97
98gboolean
99full_write(
100 int fd,
101 const char *buf,
102 size_t len);
103
104gboolean
105atomic_write_file(
106 const char *filename,
107 gconstpointer data,
108 size_t len,
109 mode_t mode,
110 gid_t gid);
111
112gboolean
113path_is_private(const char *path);
114
115gboolean
116path_is_lockdir(const char *path);
117
118#endif /* _PVE_CFS_UTILS_H_ */