mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
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.
(cherry picked from commit 7526df547c)
This commit is contained in:
@@ -145,10 +145,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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user