summaryrefslogtreecommitdiffstats
path: root/daemon
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-03-20 12:25:40 +0000
committerRichard W.M. Jones <rjones@redhat.com>2012-03-20 12:25:40 +0000
commit7526df547c5bea9a0cb4370ca022e413388dce2e (patch)
tree03db3bcb9bae7ca91364234ca84d11f8705e8feb /daemon
parentc7dff02ccbb6bbe505c73df5d83bea8afdc188c3 (diff)
downloadlibguestfs-7526df547c5bea9a0cb4370ca022e413388dce2e.tar.gz
libguestfs-7526df547c5bea9a0cb4370ca022e413388dce2e.tar.xz
libguestfs-7526df547c5bea9a0cb4370ca022e413388dce2e.zip
daemon: Add reply_with_error_errno function.
This function allows you to pass an explicit errno back to the library. reply_with_error is redefined as a macro that calls reply_with_error_errno with errno == 0.
Diffstat (limited to 'daemon')
-rw-r--r--daemon/daemon.h5
-rw-r--r--daemon/proto.c8
2 files changed, 7 insertions, 6 deletions
diff --git a/daemon/daemon.h b/daemon/daemon.h
index b7c1fd8e..9dfaa4f3 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -174,10 +174,11 @@ extern void main_loop (int sock) __attribute__((noreturn));
* NB: you don't need to prefix the string with the current command,
* it is added automatically by the client-side RPC stubs.
*/
-extern void reply_with_error (const char *fs, ...)
- __attribute__((format (printf,1,2)));
+extern void reply_with_error_errno (int err, const char *fs, ...)
+ __attribute__((format (printf,2,3)));
extern void reply_with_perror_errno (int err, const char *fs, ...)
__attribute__((format (printf,2,3)));
+#define reply_with_error(...) reply_with_error_errno(0, __VA_ARGS__)
#define reply_with_perror(...) reply_with_perror_errno(errno, __VA_ARGS__)
/* daemon functions that receive files (FileIn) should call
diff --git a/daemon/proto.c b/daemon/proto.c
index 4bbe8f87..4c3a39eb 100644
--- a/daemon/proto.c
+++ b/daemon/proto.c
@@ -221,16 +221,16 @@ main_loop (int _sock)
static void send_error (int errnum, const char *msg);
void
-reply_with_error (const char *fs, ...)
+reply_with_error_errno (int err, const char *fs, ...)
{
- char err[GUESTFS_ERROR_LEN];
+ char buf[GUESTFS_ERROR_LEN];
va_list args;
va_start (args, fs);
- vsnprintf (err, sizeof err, fs, args);
+ vsnprintf (buf, sizeof buf, fs, args);
va_end (args);
- send_error (0, err);
+ send_error (err, buf);
}
void