1 /* SPDX-License-Identifier: GPL-2.0+ */
21 __attribute__ ((warn_unused_result))
22 void *xrealloc(void *p, size_t size);
24 __attribute__ ((warn_unused_result))
25 void *xmalloc(size_t size);
27 __attribute__ ((warn_unused_result))
28 void *xzmalloc(size_t size);
30 void *xstrdup(const char *s);
32 __attribute__ ((format (printf, 1, 2))) __attribute__ ((warn_unused_result))
33 char *msg(const char *fmt, ...);
35 __attribute__ ((noreturn))
36 void die_empty_arg(const char *opt);
38 __attribute__ ((noreturn))
39 void die_range(const char *opt);
41 void check_range(uint32_t val, uint32_t min, uint32_t max, const char *opt);
42 bool xexec(char * const argv[], char **buf);
45 LS_GLOBAL, LS_VG, LS_POOL, LS_ORIGIN
49 char *vg, *pool, *tlv;
51 void parse_lvmspec(const char *arg, const char *context,
52 struct lvmspec *result);
53 void free_lvmspec(struct lvmspec *spec);
54 struct percentage_pair {
57 struct threshold_arg {
58 struct lvmspec lvmspec;
59 struct percentage_pair threshold;
61 void parse_threshold_arg(const char *arg, const char *context,
62 struct threshold_arg *result);
64 struct lvmspec lvmspec;
67 unsigned parse_timespec(const char *spec, const char *context);
68 void parse_time_arg(const char *arg, const char *context,
69 struct time_arg *result);
71 void valid_fd012(void);
72 int daemonize(const char *logfile);
73 bool misma_lock(const char *string);
74 pid_t get_misma_pid(const char *string);
79 void line_iter_init(struct line_iter *liter, char *text);
80 char *line_iter_get(struct line_iter *liter);
81 bool fd2buf(int fd, char **buf);
83 enum loglevels {LOGLEVELS, NUM_LOGLEVELS};
85 __attribute__ ((format (printf, 2, 3)))
86 void misma_log(int ll, const char* fmt,...);
88 #define DEBUG_LOG(f,...) misma_log(LL_DEBUG, "%s: " f, __FUNCTION__, ## __VA_ARGS__)
89 #define INFO_LOG(f,...) misma_log(LL_INFO, "%s: " f, __FUNCTION__, ## __VA_ARGS__)
90 #define NOTICE_LOG(f,...) misma_log(LL_NOTICE, "%s: " f, __FUNCTION__, ## __VA_ARGS__)
91 #define WARNING_LOG(f,...) misma_log(LL_WARNING, "%s: " f, __FUNCTION__, ## __VA_ARGS__)
92 #define ERROR_LOG(f,...) misma_log(LL_ERROR, "%s: " f, __FUNCTION__, ## __VA_ARGS__)
93 #define CRIT_LOG(f,...) misma_log(LL_CRIT, "%s: " f, __FUNCTION__, ## __VA_ARGS__)
94 #define EMERG_LOG(f,...) misma_log(LL_EMERG, "%s: " f, __FUNCTION__, ## __VA_ARGS__)
96 __attribute__ ((noreturn))
97 __attribute__ ((format (printf, 1, 2)))
98 void die(const char *fmt, ...);
100 __attribute__ ((noreturn))
101 __attribute__ ((format (printf, 1, 2)))
102 void die_errno(const char *fmt, ...);
105 struct heap *heap_init(void *array, unsigned num_elements,
106 int (*compare)(const void *data1, const void *data2));
107 unsigned heap_num_elements(const struct heap *h);
108 void heap_insert(void *new_element, struct heap *h);
109 void *heap_min(const struct heap *h);
110 void *heap_extract_min(struct heap *h);
111 void heap_dump(const struct heap *h, void (*dumper)(const void *));