Files
Juergen Gross 5c293058b1 tools/xenstore: move xenstored sources into dedicated directory
In tools/xenstore there are living xenstored and xenstore clients.
They are no longer sharing anything apart from the "xenstore" in their
names.

Move the xenstored sources into a new directory tools/xenstored while
dropping the "xenstored_" prefix from their names. This will make it
clearer that xenstore clients and xenstored are independent from each
other.

In order to avoid two very similar named directories below tools,
rename tools/xenstore to tools/xs-clients.

Drop the make targets [un]install-clients as those are not used in
the Xen tree.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
2023-08-23 19:10:37 +01:00

82 lines
1.3 KiB
C

#define _GNU_SOURCE
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <signal.h>
#include "utils.h"
static void default_xprintf(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fflush(stderr);
}
void (*xprintf)(const char *fmt, ...) = default_xprintf;
void barf(const char *fmt, ...)
{
char *str;
int bytes;
va_list arglist;
xprintf("FATAL: ");
va_start(arglist, fmt);
bytes = vasprintf(&str, fmt, arglist);
va_end(arglist);
if (bytes >= 0) {
syslog(LOG_CRIT, "%s\n", str);
xprintf("%s\n", str);
free(str);
}
exit(1);
}
void barf_perror(const char *fmt, ...)
{
char *str;
int bytes, err = errno;
va_list arglist;
xprintf("FATAL: ");
va_start(arglist, fmt);
bytes = vasprintf(&str, fmt, arglist);
va_end(arglist);
if (bytes >= 0) {
syslog(LOG_CRIT, "%s: %s\n", str, strerror(err));
xprintf("%s: %s\n", str, strerror(err));
free(str);
}
exit(1);
}
const char *dump_state_align(FILE *fp)
{
long len;
static char nul[8] = {};
len = ftell(fp);
if (len < 0)
return "Dump state align error";
len &= 7;
if (!len)
return NULL;
if (fwrite(nul, 8 - len, 1, fp) != 1)
return "Dump state align error";
return NULL;
}