summaryrefslogtreecommitdiffstats
path: root/daemon
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2010-11-03 12:53:00 +0000
committerRichard W.M. Jones <rjones@redhat.com>2010-11-03 17:44:30 +0000
commitd859c283c469b9d9124d90d0ac32024671372ed5 (patch)
tree8d8cfd99b88d86b618d1877829ad2c0ae3610d5a /daemon
parent2be1648632e5e8dca06d84349314ab5e84f29e5c (diff)
downloadlibguestfs-d859c283c469b9d9124d90d0ac32024671372ed5.tar.gz
libguestfs-d859c283c469b9d9124d90d0ac32024671372ed5.tar.xz
libguestfs-d859c283c469b9d9124d90d0ac32024671372ed5.zip
daemon: Send back the errno as a string.
This changes the protocol again so that if the errno is available, it is converted to a string (like "EIO") and sent back over the protocol to the library. In this commit the library just discards the string.
Diffstat (limited to 'daemon')
-rw-r--r--daemon/Makefile.am13
-rw-r--r--daemon/proto.c7
2 files changed, 18 insertions, 2 deletions
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 0e2ac6ef..2b585c27 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -36,7 +36,9 @@ $(generatorsrcdir)/stamp-generator: force
BUILT_SOURCES = \
$(generator_built) \
guestfs_protocol.c \
- guestfs_protocol.h
+ guestfs_protocol.h \
+ errnostring.c \
+ errnostring.h
EXTRA_DIST = $(BUILT_SOURCES) \
.gitignore
@@ -60,6 +62,13 @@ $(libsrcdir)/guestfs_protocol.c: force
$(libsrcdir)/guestfs_protocol.h: force
$(MAKE) -C $(libsrcdir) guestfs_protocol.h
+errnostring.c: $(libsrcdir)/errnostring.c
+ rm -f $@
+ ln $< $@
+errnostring.h: $(libsrcdir)/errnostring.h
+ rm -f $@
+ ln $< $@
+
noinst_PROGRAMS = guestfsd
guestfsd_SOURCES = \
actions.h \
@@ -82,6 +91,8 @@ guestfsd_SOURCES = \
dropcaches.c \
du.c \
echo_daemon.c \
+ errnostring.h \
+ errnostring.c \
ext2.c \
fallocate.c \
file.c \
diff --git a/daemon/proto.c b/daemon/proto.c
index f3b1fc0e..63d1cc99 100644
--- a/daemon/proto.c
+++ b/daemon/proto.c
@@ -39,6 +39,7 @@
#include "daemon.h"
#include "guestfs_protocol.h"
+#include "errnostring.h"
/* The message currently being processed. */
int proc_nr;
@@ -247,7 +248,11 @@ send_error (int errnum, const char *msg)
exit (EXIT_FAILURE);
}
- err.linux_errno = errnum;
+ /* These strings are not going to be freed. We just cast them
+ * to (char *) because they are defined that way in the XDR structs.
+ */
+ err.errno_string =
+ (char *) (errnum > 0 ? guestfs___errno_to_string (errnum) : "");
err.error_message = (char *) msg;
if (!xdr_guestfs_message_error (&xdr, &err)) {