[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/4] qemu-nbd: include our own err/errx implementati
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 2/4] qemu-nbd: include our own err/errx implementation |
Date: |
Fri, 28 Oct 2011 12:17:55 +0200 |
Signed-off-by: Paolo Bonzini <address@hidden>
---
qemu-nbd.c | 30 +++++++++++++++++++++++++++++-
1 files changed, 29 insertions(+), 1 deletions(-)
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 972524d..573bf3d 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -23,7 +23,6 @@
#include <stdarg.h>
#include <stdio.h>
#include <getopt.h>
-#include <err.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -78,6 +77,35 @@ static void version(const char *name)
, name);
}
+static void err(int status, const char *format, ...)
+{
+ char *s, *msg;
+ va_list ap;
+
+ msg = strerror(errno);
+ va_start(ap, format);
+ if (vasprintf(&s, format, ap) == -1) {
+ abort();
+ }
+ fprintf(stderr, "qemu-nbd: %s: %s\n", s, msg);
+ free(s);
+ exit(status);
+}
+
+static void errx(int status, const char *format, ...)
+{
+ char *s;
+ va_list ap;
+
+ va_start(ap, format);
+ if (vasprintf(&s, format, ap) == -1) {
+ abort();
+ }
+ fprintf(stderr, "qemu-nbd: %s\n", s);
+ free(s);
+ exit(status);
+}
+
struct partition_record
{
uint8_t bootable;
--
1.7.6.4
[Qemu-devel] [PATCH 3/4] qemu-nbd: report errors to syslog when daemonized, Paolo Bonzini, 2011/10/28