mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
daemon: Don't need to prefix error messages with the command name.
The RPC stubs already prefix the command name to error messages.
The daemon doesn't have to do this. As a (small) benefit this also
makes the daemon slightly smaller.
Code in the daemon such as:
if (argv[0] == NULL) {
reply_with_error ("passed an empty list");
return NULL;
}
now results in error messages like this:
><fs> command ""
libguestfs: error: command: passed an empty list
(whereas previously you would have seen ..command: command:..)
This commit is contained in:
@@ -36,7 +36,7 @@ do_vfs_type (const char *device)
|
||||
r = command (&out, &err,
|
||||
"/sbin/blkid", "-o", "value", "-s", "TYPE", device, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("vfs_type: %s: %s", device, err);
|
||||
reply_with_error ("%s: %s", device, err);
|
||||
free (out);
|
||||
free (err);
|
||||
return NULL;
|
||||
|
||||
@@ -111,7 +111,7 @@ int
|
||||
do_blockdev_setbsz (const char *device, int blocksize)
|
||||
{
|
||||
if (blocksize <= 0 /* || blocksize >= what? */) {
|
||||
reply_with_error ("blockdev_setbsz: blocksize must be > 0");
|
||||
reply_with_error ("blocksize must be > 0");
|
||||
return -1;
|
||||
}
|
||||
return (int) call_blockdev (device, "--setbsz", blocksize, 0);
|
||||
|
||||
@@ -53,7 +53,7 @@ do_equal (const char *file1, const char *file2)
|
||||
free (file2buf);
|
||||
|
||||
if (r == -1 || r > 1) {
|
||||
reply_with_error ("cmp: %s", err);
|
||||
reply_with_error ("%s", err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ do_command (char *const *argv)
|
||||
* commandv. We just have to check the list is non-empty.
|
||||
*/
|
||||
if (argv[0] == NULL) {
|
||||
reply_with_error ("command: passed an empty list");
|
||||
reply_with_error ("passed an empty list");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ cpmv_cmd (const char *cmd, const char *flags, const char *src, const char *dest)
|
||||
free (destbuf);
|
||||
|
||||
if (r == -1) {
|
||||
reply_with_error ("%s: %s", cmd, err);
|
||||
reply_with_error ("%s", err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,10 @@ extern int sync_disks (void);
|
||||
/*-- in proto.c --*/
|
||||
extern void main_loop (int sock) __attribute__((noreturn));
|
||||
|
||||
/* ordinary daemon functions use these to indicate errors */
|
||||
/* ordinary daemon functions use these to indicate errors
|
||||
* 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_perror_errno (int err, const char *fs, ...)
|
||||
|
||||
@@ -62,7 +62,7 @@ do_dd (const char *src, const char *dest)
|
||||
free (of_arg);
|
||||
|
||||
if (r == -1) {
|
||||
reply_with_error ("dd: %s: %s: %s", src, dest, err);
|
||||
reply_with_error ("%s: %s: %s", src, dest, err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ debug_sh (const char *subcmd, int argc, char *const *const argv)
|
||||
char *out;
|
||||
|
||||
if (argc < 1) {
|
||||
reply_with_error ("debug: sh: expecting a command to run");
|
||||
reply_with_error ("sh: expecting a command to run");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ do_df (void)
|
||||
|
||||
r = command (&out, &err, "df", NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("df: %s", err);
|
||||
reply_with_error ("%s", err);
|
||||
free (out);
|
||||
free (err);
|
||||
return NULL;
|
||||
@@ -58,7 +58,7 @@ do_df_h (void)
|
||||
|
||||
r = command (&out, &err, "df", "-h", NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("df -h: %s", err);
|
||||
reply_with_error ("%s", err);
|
||||
free (out);
|
||||
free (err);
|
||||
return NULL;
|
||||
|
||||
16
daemon/dir.c
16
daemon/dir.c
@@ -39,7 +39,7 @@ do_rmdir (const char *path)
|
||||
CHROOT_OUT;
|
||||
|
||||
if (r == -1) {
|
||||
reply_with_perror ("rmdir: %s", path);
|
||||
reply_with_perror ("%s", path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ do_rm_rf (const char *path)
|
||||
char *buf, *err;
|
||||
|
||||
if (STREQ (path, "/")) {
|
||||
reply_with_error ("rm -rf: cannot remove root directory");
|
||||
reply_with_error ("cannot remove root directory");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ do_rm_rf (const char *path)
|
||||
|
||||
/* rm -rf is never supposed to fail. I/O errors perhaps? */
|
||||
if (r == -1) {
|
||||
reply_with_error ("rm -rf: %s: %s", path, err);
|
||||
reply_with_error ("%s: %s", path, err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ do_mkdir (const char *path)
|
||||
CHROOT_OUT;
|
||||
|
||||
if (r == -1) {
|
||||
reply_with_perror ("mkdir: %s", path);
|
||||
reply_with_perror ("%s", path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ do_mkdir_mode (const char *path, int mode)
|
||||
CHROOT_OUT;
|
||||
|
||||
if (r == -1) {
|
||||
reply_with_perror ("mkdir_mode: %s", path);
|
||||
reply_with_perror ("%s", path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -174,11 +174,11 @@ do_mkdir_p (const char *path)
|
||||
CHROOT_OUT;
|
||||
|
||||
if (r == -1) {
|
||||
reply_with_perror ("mkdir -p: %s", path);
|
||||
reply_with_perror ("%s", path);
|
||||
return -1;
|
||||
}
|
||||
if (r == -2) {
|
||||
reply_with_error ("mkdir -p: %s: a path element was not a directory", path);
|
||||
reply_with_error ("%s: a path element was not a directory", path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ do_mkdtemp (const char *template)
|
||||
CHROOT_OUT;
|
||||
|
||||
if (r == NULL) {
|
||||
reply_with_perror ("mkdtemp: %s", template);
|
||||
reply_with_perror ("%s", template);
|
||||
free (writable);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ do_dmesg (void)
|
||||
|
||||
r = command (&out, &err, "dmesg", NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("dmesg: %s", err);
|
||||
reply_with_error ("%s", err);
|
||||
free (out);
|
||||
free (err);
|
||||
return NULL;
|
||||
|
||||
@@ -46,7 +46,7 @@ do_du (const char *path)
|
||||
r = command (&out, &err, "du", "-s", buf, NULL);
|
||||
free (buf);
|
||||
if (r == -1) {
|
||||
reply_with_error ("du: %s: %s", path, err);
|
||||
reply_with_error ("%s: %s", path, err);
|
||||
free (out);
|
||||
free (err);
|
||||
return -1;
|
||||
@@ -55,7 +55,7 @@ do_du (const char *path)
|
||||
free (err);
|
||||
|
||||
if (sscanf (out, "%"SCNi64, &rv) != 1) {
|
||||
reply_with_error ("du: %s: could not read output: %s", path, out);
|
||||
reply_with_error ("%s: could not read output: %s", path, out);
|
||||
free (out);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ do_tune2fs_l (const char *device)
|
||||
|
||||
r = command (&out, &err, "/sbin/tune2fs", "-l", device, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("tune2fs: %s", err);
|
||||
reply_with_error ("%s", err);
|
||||
free (err);
|
||||
free (out);
|
||||
return NULL;
|
||||
@@ -53,7 +53,7 @@ do_tune2fs_l (const char *device)
|
||||
p = strchr (p, '\n');
|
||||
if (p) p++;
|
||||
else {
|
||||
reply_with_error ("tune2fs: truncated output");
|
||||
reply_with_error ("truncated output");
|
||||
free (out);
|
||||
return NULL;
|
||||
}
|
||||
@@ -123,7 +123,7 @@ do_set_e2label (const char *device, const char *label)
|
||||
|
||||
r = command (NULL, &err, "/sbin/e2label", device, label, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("e2label: %s", err);
|
||||
reply_with_error ("%s", err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
@@ -140,7 +140,7 @@ do_get_e2label (const char *device)
|
||||
|
||||
r = command (&out, &err, "/sbin/e2label", device, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("e2label: %s", err);
|
||||
reply_with_error ("%s", err);
|
||||
free (out);
|
||||
free (err);
|
||||
return NULL;
|
||||
@@ -164,7 +164,7 @@ do_set_e2uuid (const char *device, const char *uuid)
|
||||
|
||||
r = command (NULL, &err, "/sbin/tune2fs", "-U", uuid, device, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("tune2fs -U: %s", err);
|
||||
reply_with_error ("%s", err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
@@ -186,7 +186,7 @@ do_get_e2uuid (const char *device)
|
||||
|
||||
r = command (&out, &err, "/sbin/tune2fs", "-l", device, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("tune2fs -l: %s", err);
|
||||
reply_with_error ("%s", err);
|
||||
free (out);
|
||||
free (err);
|
||||
return NULL;
|
||||
@@ -242,7 +242,7 @@ do_resize2fs (const char *device)
|
||||
|
||||
r = command (NULL, &err, "/sbin/resize2fs", device, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("resize2fs: %s", err);
|
||||
reply_with_error ("%s", err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
@@ -259,7 +259,7 @@ do_e2fsck_f (const char *device)
|
||||
|
||||
r = command (NULL, &err, "/sbin/e2fsck", "-p", "-f", device, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("e2fsck: %s", err);
|
||||
reply_with_error ("%s", err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
@@ -281,7 +281,7 @@ do_mke2journal (int blocksize, const char *device)
|
||||
"/sbin/mke2fs", "-O", "journal_dev", "-b", blocksize_s,
|
||||
device, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("mke2journal: %s", err);
|
||||
reply_with_error ("%s", err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
@@ -304,7 +304,7 @@ do_mke2journal_L (int blocksize, const char *label, const char *device)
|
||||
"-L", label,
|
||||
device, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("mke2journal_L: %s", err);
|
||||
reply_with_error ("%s", err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
@@ -327,7 +327,7 @@ do_mke2journal_U (int blocksize, const char *uuid, const char *device)
|
||||
"-U", uuid,
|
||||
device, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("mke2journal_U: %s", err);
|
||||
reply_with_error ("%s", err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
@@ -366,7 +366,7 @@ get_mke2fs (void)
|
||||
if (access (progs[i], F_OK) == 0)
|
||||
return progs[i];
|
||||
|
||||
reply_with_error ("mke2fs: no mke2fs binary found in appliance");
|
||||
reply_with_error ("no mke2fs binary found in appliance");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ do_mke2fs_J (const char *fstype, int blocksize, const char *device,
|
||||
prog, "-t", fstype, "-J", jdev, "-b", blocksize_s,
|
||||
device, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("mke2fs_J: %s", err);
|
||||
reply_with_error ("%s", err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
@@ -421,7 +421,7 @@ do_mke2fs_JL (const char *fstype, int blocksize, const char *device,
|
||||
prog, "-t", fstype, "-J", jdev, "-b", blocksize_s,
|
||||
device, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("mke2fs_JL: %s", err);
|
||||
reply_with_error ("%s", err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
@@ -451,7 +451,7 @@ do_mke2fs_JU (const char *fstype, int blocksize, const char *device,
|
||||
prog, "-t", fstype, "-J", jdev, "-b", blocksize_s,
|
||||
device, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("mke2fs_JU: %s", err);
|
||||
reply_with_error ("%s", err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ do_fallocate (const char *path, int len)
|
||||
fd = open (path, O_WRONLY | O_CREAT | O_TRUNC | O_NOCTTY, 0666);
|
||||
CHROOT_OUT;
|
||||
if (fd == -1) {
|
||||
reply_with_perror ("failed to open %s", path);
|
||||
reply_with_perror ("open: %s", path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ do_fallocate (const char *path, int len)
|
||||
|
||||
r = posix_fallocate (fd, 0, len);
|
||||
if (r == -1) {
|
||||
reply_with_perror ("posix_fallocate: %s", path);
|
||||
reply_with_perror ("%s", path);
|
||||
close (fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ do_cat (const char *path)
|
||||
if (size >= alloc) {
|
||||
alloc += 8192;
|
||||
if (alloc > max) {
|
||||
reply_with_error ("cat: %s: file is too large for message buffer",
|
||||
reply_with_error ("%s: file is too large for message buffer",
|
||||
path);
|
||||
free (buf);
|
||||
close (fd);
|
||||
@@ -186,7 +186,7 @@ do_rm (const char *path)
|
||||
CHROOT_OUT;
|
||||
|
||||
if (r == -1) {
|
||||
reply_with_perror ("unlink: %s", path);
|
||||
reply_with_perror ("%s", path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ do_chmod (int mode, const char *path)
|
||||
CHROOT_OUT;
|
||||
|
||||
if (r == -1) {
|
||||
reply_with_perror ("chmod: %s: 0%o", path, mode);
|
||||
reply_with_perror ("%s: 0%o", path, mode);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ do_chown (int owner, int group, const char *path)
|
||||
CHROOT_OUT;
|
||||
|
||||
if (r == -1) {
|
||||
reply_with_perror ("chown: %s: %d.%d", path, owner, group);
|
||||
reply_with_perror ("%s: %d.%d", path, owner, group);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ do_lchown (int owner, int group, const char *path)
|
||||
CHROOT_OUT;
|
||||
|
||||
if (r == -1) {
|
||||
reply_with_perror ("lchown: %s: %d.%d", path, owner, group);
|
||||
reply_with_perror ("%s: %d.%d", path, owner, group);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ do_read_file (const char *path, size_t *size_r)
|
||||
* be caught later when we try to serialize the message.
|
||||
*/
|
||||
if (*size_r >= GUESTFS_MESSAGE_MAX) {
|
||||
reply_with_error ("read_file: %s: file is too large for the protocol, use guestfs_download instead", path);
|
||||
reply_with_error ("%s: file is too large for the protocol, use guestfs_download instead", path);
|
||||
close (fd);
|
||||
return NULL;
|
||||
}
|
||||
@@ -378,7 +378,7 @@ do_pread (const char *path, int count, int64_t offset, size_t *size_r)
|
||||
* will be caught later when we try to serialize the message.
|
||||
*/
|
||||
if (count >= GUESTFS_MESSAGE_MAX) {
|
||||
reply_with_error ("pread: %s: count is too large for the protocol, use smaller reads", path);
|
||||
reply_with_error ("%s: count is too large for the protocol, use smaller reads", path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -453,7 +453,7 @@ do_file (const char *path)
|
||||
|
||||
if (r == -1) {
|
||||
free (out);
|
||||
reply_with_error ("file: %s: %s", path, err);
|
||||
reply_with_error ("%s: %s", path, err);
|
||||
free (err);
|
||||
return NULL;
|
||||
}
|
||||
@@ -482,7 +482,7 @@ do_zfile (const char *method, const char *path)
|
||||
else if (STREQ (method, "bzip2"))
|
||||
zcat = "bzcat";
|
||||
else {
|
||||
reply_with_error ("zfile: unknown method");
|
||||
reply_with_error ("unknown method");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -504,13 +504,13 @@ do_zfile (const char *method, const char *path)
|
||||
free (cmd);
|
||||
|
||||
if (fgets (line, sizeof line, fp) == NULL) {
|
||||
reply_with_perror ("zfile: fgets");
|
||||
reply_with_perror ("fgets");
|
||||
fclose (fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fclose (fp) == -1) {
|
||||
reply_with_perror ("zfile: fclose");
|
||||
reply_with_perror ("fclose");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -532,7 +532,7 @@ do_filesize (const char *path)
|
||||
CHROOT_OUT;
|
||||
|
||||
if (r == -1) {
|
||||
reply_with_perror ("filesize: %s", path);
|
||||
reply_with_perror ("%s", path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,12 +38,12 @@ do_fill (int c, int len, const char *path)
|
||||
char buf[BUFSIZ];
|
||||
|
||||
if (c < 0 || c > 255) {
|
||||
reply_with_error ("fill: %d: byte number must be in range 0..255", c);
|
||||
reply_with_error ("%d: byte number must be in range 0..255", c);
|
||||
return -1;
|
||||
}
|
||||
memset (buf, c, BUFSIZ);
|
||||
if (len < 0) {
|
||||
reply_with_error ("fill: %d: length is < 0", len);
|
||||
reply_with_error ("%d: length is < 0", len);
|
||||
return -1;
|
||||
}
|
||||
len_sz = (size_t) len;
|
||||
|
||||
@@ -114,7 +114,7 @@ do_find (const char *dir)
|
||||
}
|
||||
}
|
||||
if (pclose (fp) != 0) {
|
||||
reply_with_perror ("pclose: find");
|
||||
reply_with_perror ("pclose");
|
||||
free_stringslen (res, size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ do_fsck (const char *fstype, const char *device)
|
||||
|
||||
r = commandr (NULL, &err, "/sbin/fsck", "-a", "-t", fstype, device, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("fsck: %s: %s", device, err);
|
||||
reply_with_error ("%s: %s", device, err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ do_glob_expand (const char *pattern)
|
||||
|
||||
if (r != 0) {
|
||||
if (errno != 0)
|
||||
reply_with_perror ("glob: %s", pattern);
|
||||
reply_with_perror ("%s", pattern);
|
||||
else
|
||||
reply_with_error ("glob failed: %s", pattern);
|
||||
return NULL;
|
||||
|
||||
@@ -41,7 +41,7 @@ do_grub_install (const char *root, const char *device)
|
||||
free (buf);
|
||||
|
||||
if (r == -1) {
|
||||
reply_with_error ("grub-install: %s", err);
|
||||
reply_with_error ("%s", err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ do_hexdump (const char *path)
|
||||
r = command (&out, &err, "hexdump", "-C", buf, NULL);
|
||||
free (buf);
|
||||
if (r == -1) {
|
||||
reply_with_error ("hexdump: %s: %s", path, err);
|
||||
reply_with_error ("%s: %s", path, err);
|
||||
free (err);
|
||||
free (out);
|
||||
return NULL;
|
||||
|
||||
@@ -149,7 +149,7 @@ do_initrd_cat (const char *path, const char *filename, size_t *size_r)
|
||||
* be caught later when we try to serialize the message.
|
||||
*/
|
||||
if (*size_r >= GUESTFS_MESSAGE_MAX) {
|
||||
reply_with_error ("initrd_cat: %s:%s: file is too large for the protocol",
|
||||
reply_with_error ("%s:%s: file is too large for the protocol",
|
||||
path, filename);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ do_inotify_init (int max_events)
|
||||
NEED_ROOT (return -1);
|
||||
|
||||
if (max_events < 0) {
|
||||
reply_with_error ("inotify_init: max_events < 0");
|
||||
reply_with_error ("max_events < 0");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ do_inotify_init (int max_events)
|
||||
#ifdef HAVE_INOTIFY_INIT1
|
||||
inotify_fd = inotify_init1 (IN_NONBLOCK | IN_CLOEXEC);
|
||||
if (inotify_fd == -1) {
|
||||
reply_with_perror ("inotify_init");
|
||||
reply_with_perror ("inotify_init1");
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
@@ -130,7 +130,7 @@ do_inotify_close (void)
|
||||
NEED_INOTIFY (-1);
|
||||
|
||||
if (inotify_fd == -1) {
|
||||
reply_with_error ("inotify_close: handle is not open");
|
||||
reply_with_error ("handle is not open");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ do_inotify_add_watch (const char *path, int mask)
|
||||
r = inotify_add_watch (inotify_fd, buf, mask);
|
||||
free (buf);
|
||||
if (r == -1) {
|
||||
reply_with_perror ("inotify_add_watch: %s", path);
|
||||
reply_with_perror ("%s", path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ do_inotify_rm_watch (int wd)
|
||||
NEED_INOTIFY (-1);
|
||||
|
||||
if (inotify_rm_watch (inotify_fd, wd) == -1) {
|
||||
reply_with_perror ("inotify_rm_watch: %d", wd);
|
||||
reply_with_perror ("%d", wd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ do_inotify_read (void)
|
||||
goto error;
|
||||
}
|
||||
if (r == 0) { /* End of file - we're not expecting it. */
|
||||
reply_with_error ("inotify_read: unexpected end of file");
|
||||
reply_with_error ("unexpected end of file");
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ do_readlinklist (const char *path, char *const *names)
|
||||
CHROOT_OUT;
|
||||
|
||||
if (fd_cwd == -1) {
|
||||
reply_with_perror ("readlinklist: %s", path);
|
||||
reply_with_perror ("open: %s", path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ do_lvresize (const char *logvol, int mbytes)
|
||||
"/sbin/lvm", "lvresize",
|
||||
"-L", size, logvol, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("lvresize: %s", err);
|
||||
reply_with_error ("%s", err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
@@ -418,7 +418,7 @@ do_pvresize (const char *device)
|
||||
r = command (NULL, &err,
|
||||
"/sbin/lvm", "pvresize", device, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("pvresize: %s: %s", device, err);
|
||||
reply_with_error ("%s: %s", device, err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
@@ -479,7 +479,7 @@ do_lvrename (const char *logvol, const char *newlogvol)
|
||||
"/sbin/lvm", "lvrename",
|
||||
logvol, newlogvol, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("lvrename: %s -> %s: %s", logvol, newlogvol, err);
|
||||
reply_with_error ("%s -> %s: %s", logvol, newlogvol, err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
@@ -501,7 +501,7 @@ do_vgrename (const char *volgroup, const char *newvolgroup)
|
||||
"/sbin/lvm", "vgrename",
|
||||
volgroup, newvolgroup, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("vgrename: %s -> %s: %s", volgroup, newvolgroup, err);
|
||||
reply_with_error ("%s -> %s: %s", volgroup, newvolgroup, err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ mkfs (const char *fstype, const char *device,
|
||||
|
||||
r = commandv (NULL, &err, argv);
|
||||
if (r == -1) {
|
||||
reply_with_error ("mkfs: %s: %s: %s", fstype, device, err);
|
||||
reply_with_error ("%s: %s: %s", fstype, device, err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ do_mknod (int mode, int devmajor, int devminor, const char *path)
|
||||
CHROOT_OUT;
|
||||
|
||||
if (r == -1) {
|
||||
reply_with_perror ("mknod: %s", path);
|
||||
reply_with_perror ("%s", path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ do_mount_vfs (const char *options, const char *vfstype,
|
||||
is_root = STREQ (mountpoint, "/");
|
||||
|
||||
if (!root_mounted && !is_root) {
|
||||
reply_with_error ("mount: you must mount something on / first");
|
||||
reply_with_error ("you must mount something on / first");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ do_mount_vfs (const char *options, const char *vfstype,
|
||||
"mount", "-o", options, device, mp, NULL);
|
||||
free (mp);
|
||||
if (r == -1) {
|
||||
reply_with_error ("mount: %s on %s: %s", device, mountpoint, error);
|
||||
reply_with_error ("%s on %s: %s", device, mountpoint, error);
|
||||
free (error);
|
||||
return -1;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ do_umount (const char *pathordevice)
|
||||
free (buf);
|
||||
|
||||
if (r == -1) {
|
||||
reply_with_error ("umount: %s: %s", pathordevice, err);
|
||||
reply_with_error ("%s: %s", pathordevice, err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
@@ -338,7 +338,7 @@ do_mount_loop (const char *file, const char *mountpoint)
|
||||
free (mp);
|
||||
free (buf);
|
||||
if (r == -1) {
|
||||
reply_with_error ("mount: %s on %s: %s", file, mountpoint, error);
|
||||
reply_with_error ("%s on %s: %s", file, mountpoint, error);
|
||||
free (error);
|
||||
return -1;
|
||||
}
|
||||
@@ -363,7 +363,7 @@ do_mkmountpoint (const char *path)
|
||||
CHROOT_OUT;
|
||||
|
||||
if (r == -1) {
|
||||
reply_with_perror ("mkmountpoint: %s", path);
|
||||
reply_with_perror ("%s", path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -388,7 +388,7 @@ do_rmmountpoint (const char *path)
|
||||
CHROOT_OUT;
|
||||
|
||||
if (r == -1) {
|
||||
reply_with_perror ("rmmountpoint: %s", path);
|
||||
reply_with_perror ("%s", path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ do_ntfs_3g_probe (int rw, const char *device)
|
||||
|
||||
r = commandr (NULL, &err, "ntfs-3g.probe", rw_flag, device, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("ntfs-3g.probe: %s: %s", device, err);
|
||||
reply_with_error ("%s: %s", device, err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ do_part_init (const char *device, const char *parttype)
|
||||
{
|
||||
parttype = check_parttype (parttype);
|
||||
if (!parttype) {
|
||||
reply_with_error ("part-init: unknown partition type: common choices are \"gpt\" and \"msdos\"");
|
||||
reply_with_error ("unknown partition type: common choices are \"gpt\" and \"msdos\"");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -133,12 +133,12 @@ do_part_add (const char *device, const char *prlogex,
|
||||
else if (STREQ (prlogex, "e"))
|
||||
prlogex = "extended";
|
||||
else {
|
||||
reply_with_error ("part-add: unknown partition type: %s: this should be \"primary\", \"logical\" or \"extended\"", prlogex);
|
||||
reply_with_error ("unknown partition type: %s: this should be \"primary\", \"logical\" or \"extended\"", prlogex);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (startsect < 0) {
|
||||
reply_with_error ("part-add: startsect cannot be negative");
|
||||
reply_with_error ("startsect cannot be negative");
|
||||
return -1;
|
||||
}
|
||||
/* but endsect can be negative */
|
||||
@@ -166,7 +166,7 @@ do_part_disk (const char *device, const char *parttype)
|
||||
|
||||
parttype = check_parttype (parttype);
|
||||
if (!parttype) {
|
||||
reply_with_error ("part-disk: unknown partition type: common choices are \"gpt\" and \"msdos\"");
|
||||
reply_with_error ("unknown partition type: common choices are \"gpt\" and \"msdos\"");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -249,14 +249,14 @@ print_partition_table (const char *device)
|
||||
return NULL;
|
||||
|
||||
if (lines[0] == NULL || STRNEQ (lines[0], "BYT;")) {
|
||||
reply_with_error ("parted print: unknown signature, expected \"BYT;\" as first line of the output: %s",
|
||||
reply_with_error ("unknown signature, expected \"BYT;\" as first line of the output: %s",
|
||||
lines[0] ? lines[0] : "(signature was null)");
|
||||
free_strings (lines);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (lines[1] == NULL) {
|
||||
reply_with_error ("parted print: parted didn't return a line describing the device");
|
||||
reply_with_error ("parted didn't return a line describing the device");
|
||||
free_strings (lines);
|
||||
return NULL;
|
||||
}
|
||||
@@ -284,7 +284,7 @@ do_part_get_parttype (const char *device)
|
||||
|| strtok (NULL, ":") == NULL /* physical sector size */
|
||||
|| (r = strtok (NULL, ":")) == NULL /* return value */
|
||||
) {
|
||||
reply_with_error ("part_get_parttype: too few fields in output from parted print command: %s", lines[1]);
|
||||
reply_with_error ("too few fields in output from parted print command: %s", lines[1]);
|
||||
free_strings (lines);
|
||||
return NULL;
|
||||
}
|
||||
@@ -339,7 +339,7 @@ do_part_list (const char *device)
|
||||
&r->guestfs_int_partition_list_val[i].part_start,
|
||||
&r->guestfs_int_partition_list_val[i].part_end,
|
||||
&r->guestfs_int_partition_list_val[i].part_size) != 4) {
|
||||
reply_with_error ("part_list: could not parse row from output of parted print command: %s", lines[row]);
|
||||
reply_with_error ("could not parse row from output of parted print command: %s", lines[row]);
|
||||
goto error3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ do_realpath (const char *path)
|
||||
ret = realpath (path, NULL);
|
||||
CHROOT_OUT;
|
||||
if (ret == NULL) {
|
||||
reply_with_perror ("realpath");
|
||||
reply_with_perror ("%s", path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -98,11 +98,11 @@ do_case_sensitive_path (const char *path)
|
||||
|
||||
if ((i == 1 && path[0] == '.') ||
|
||||
(i == 2 && path[0] == '.' && path[1] == '.')) {
|
||||
reply_with_error ("case_sensitive_path: path contained . or .. elements");
|
||||
reply_with_error ("path contained . or .. elements");
|
||||
goto error;
|
||||
}
|
||||
if (i > NAME_MAX) {
|
||||
reply_with_error ("case_sensitive_path: path element too long");
|
||||
reply_with_error ("path element too long");
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ do_scrub_device (const char *device)
|
||||
|
||||
r = command (NULL, &err, "scrub", device, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("scrub_device: %s: %s", device, err);
|
||||
reply_with_error ("%s: %s", device, err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
@@ -70,7 +70,7 @@ do_scrub_file (const char *file)
|
||||
r = command (NULL, &err, "scrub", "-r", buf, NULL);
|
||||
free (buf);
|
||||
if (r == -1) {
|
||||
reply_with_error ("scrub_file: %s: %s", file, err);
|
||||
reply_with_error ("%s: %s", file, err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ do_scrub_freespace (const char *dir)
|
||||
r = command (NULL, &err, "scrub", "-X", buf, NULL);
|
||||
free (buf);
|
||||
if (r == -1) {
|
||||
reply_with_error ("scrub_freespace: %s: %s", dir, err);
|
||||
reply_with_error ("%s: %s", dir, err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ sfdisk_flag (const char *device, const char *flag)
|
||||
|
||||
r = command (&out, &err, "/sbin/sfdisk", flag, device, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("sfdisk: %s: %s", device, err);
|
||||
reply_with_error ("%s: %s", device, err);
|
||||
free (out);
|
||||
free (err);
|
||||
return NULL;
|
||||
|
||||
@@ -151,7 +151,7 @@ do_lstatlist (const char *path, char *const *names)
|
||||
CHROOT_OUT;
|
||||
|
||||
if (path_fd == -1) {
|
||||
reply_with_perror ("lstatlist: %s", path);
|
||||
reply_with_perror ("%s", path);
|
||||
free (ret->guestfs_int_stat_list_val);
|
||||
free (ret);
|
||||
return NULL;
|
||||
|
||||
@@ -42,7 +42,7 @@ do_strings_e (const char *encoding, const char *path)
|
||||
r = command (&out, &err, "strings", "-e", encoding, buf, NULL);
|
||||
free (buf);
|
||||
if (r == -1) {
|
||||
reply_with_error ("strings: %s: %s", path, err);
|
||||
reply_with_error ("%s: %s", path, err);
|
||||
free (err);
|
||||
free (out);
|
||||
return NULL;
|
||||
|
||||
@@ -58,7 +58,7 @@ mkswap (const char *device, const char *flag, const char *value)
|
||||
r = command (NULL, &err, "/sbin/mkswap", "-f", flag, value, device, NULL);
|
||||
|
||||
if (r == -1) {
|
||||
reply_with_error ("mkswap: %s", err);
|
||||
reply_with_error ("%s", err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ swaponoff (const char *cmd, const char *flag, const char *value)
|
||||
r = command (NULL, &err, cmd, flag, value, NULL);
|
||||
|
||||
if (r == -1) {
|
||||
reply_with_error ("%s: %s: %s", cmd, value, err);
|
||||
reply_with_error ("%s: %s", value, err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ do_tar_in (const char *dir)
|
||||
|
||||
if (!root_mounted || dir[0] != '/') {
|
||||
cancel_receive ();
|
||||
reply_with_error ("tar-in: root must be mounted and path must be absolute");
|
||||
reply_with_error ("root must be mounted and path must be absolute");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ do_tgz_in (const char *dir)
|
||||
|
||||
if (!root_mounted || dir[0] != '/') {
|
||||
cancel_receive ();
|
||||
reply_with_error ("tar-in: root must be mounted and path must be absolute");
|
||||
reply_with_error ("root must be mounted and path must be absolute");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ do_upload (const char *filename)
|
||||
if (!is_dev) {
|
||||
if (!root_mounted || filename[0] != '/') {
|
||||
cancel_receive ();
|
||||
reply_with_error ("upload: root must be mounted and path must be absolute");
|
||||
reply_with_error ("root must be mounted and path must be absolute");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ wc (const char *flag, const char *path)
|
||||
|
||||
/* Parse the number. */
|
||||
if (sscanf (out, "%d", &r) != 1) {
|
||||
reply_with_error ("wc: cannot parse number: %s", out);
|
||||
reply_with_error ("cannot parse number: %s", out);
|
||||
free (out);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ do_getxattrs (const char *path)
|
||||
#if defined(HAVE_LISTXATTR) && defined(HAVE_GETXATTR)
|
||||
return getxattrs (path, listxattr, getxattr);
|
||||
#else
|
||||
reply_with_error ("getxattrs: no support for listxattr and getxattr");
|
||||
reply_with_error ("no support for listxattr and getxattr");
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
@@ -63,7 +63,7 @@ do_lgetxattrs (const char *path)
|
||||
#if defined(HAVE_LLISTXATTR) && defined(HAVE_LGETXATTR)
|
||||
return getxattrs (path, llistxattr, lgetxattr);
|
||||
#else
|
||||
reply_with_error ("lgetxattrs: no support for llistxattr and lgetxattr");
|
||||
reply_with_error ("no support for llistxattr and lgetxattr");
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
@@ -74,7 +74,7 @@ do_setxattr (const char *xattr, const char *val, int vallen, const char *path)
|
||||
#if defined(HAVE_SETXATTR)
|
||||
return _setxattr (xattr, val, vallen, path, setxattr);
|
||||
#else
|
||||
reply_with_error ("setxattr: no support for setxattr");
|
||||
reply_with_error ("no support for setxattr");
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
@@ -85,7 +85,7 @@ do_lsetxattr (const char *xattr, const char *val, int vallen, const char *path)
|
||||
#if defined(HAVE_LSETXATTR)
|
||||
return _setxattr (xattr, val, vallen, path, lsetxattr);
|
||||
#else
|
||||
reply_with_error ("lsetxattr: no support for lsetxattr");
|
||||
reply_with_error ("no support for lsetxattr");
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
@@ -96,7 +96,7 @@ do_removexattr (const char *xattr, const char *path)
|
||||
#if defined(HAVE_REMOVEXATTR)
|
||||
return _removexattr (xattr, path, removexattr);
|
||||
#else
|
||||
reply_with_error ("removexattr: no support for removexattr");
|
||||
reply_with_error ("no support for removexattr");
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
@@ -107,7 +107,7 @@ do_lremovexattr (const char *xattr, const char *path)
|
||||
#if defined(HAVE_LREMOVEXATTR)
|
||||
return _removexattr (xattr, path, lremovexattr);
|
||||
#else
|
||||
reply_with_error ("lremovexattr: no support for lremovexattr");
|
||||
reply_with_error ("no support for lremovexattr");
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
@@ -127,7 +127,7 @@ getxattrs (const char *path,
|
||||
len = listxattr (path, NULL, 0);
|
||||
CHROOT_OUT;
|
||||
if (len == -1) {
|
||||
reply_with_perror ("listxattr");
|
||||
reply_with_perror ("listxattr: %s", path);
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ getxattrs (const char *path,
|
||||
len = listxattr (path, buf, len);
|
||||
CHROOT_OUT;
|
||||
if (len == -1) {
|
||||
reply_with_perror ("listxattr");
|
||||
reply_with_perror ("listxattr: %s", path);
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ do_lxattrlist (const char *path, char *const *names)
|
||||
char *buf = NULL;
|
||||
|
||||
if (path_len >= PATH_MAX) {
|
||||
reply_with_perror ("lxattrlist: path longer than PATH_MAX");
|
||||
reply_with_perror ("path longer than PATH_MAX");
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ do_lxattrlist (const char *path, char *const *names)
|
||||
* outgoing struct list.
|
||||
*/
|
||||
if (path_len + strlen (names[k]) + 2 > PATH_MAX) {
|
||||
reply_with_perror ("lxattrlist: path and name longer than PATH_MAX");
|
||||
reply_with_perror ("path and name longer than PATH_MAX");
|
||||
goto error;
|
||||
}
|
||||
pathname[path_len] = '/';
|
||||
@@ -443,7 +443,7 @@ do_lxattrlist (const char *path, char *const *names)
|
||||
}
|
||||
return NULL;
|
||||
#else
|
||||
reply_with_error ("lxattrlist: no support for llistxattr and lgetxattr");
|
||||
reply_with_error ("no support for llistxattr and lgetxattr");
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ do_zerofree (const char *device)
|
||||
|
||||
r = command (NULL, &err, "/usr/sbin/zerofree", device, NULL);
|
||||
if (r == -1) {
|
||||
reply_with_error ("zerofree: %s: %s", device, err);
|
||||
reply_with_error ("%s: %s", device, err);
|
||||
free (err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -5810,7 +5810,7 @@ and generate_daemon_actions () =
|
||||
pr " memset (&args, 0, sizeof args);\n";
|
||||
pr "\n";
|
||||
pr " if (!xdr_guestfs_%s_args (xdr_in, &args)) {\n" name;
|
||||
pr " reply_with_error (\"%%s: daemon failed to decode procedure arguments\", \"%s\");\n" name;
|
||||
pr " reply_with_error (\"daemon failed to decode procedure arguments\");\n";
|
||||
pr " return;\n";
|
||||
pr " }\n";
|
||||
let pr_args n =
|
||||
|
||||
Reference in New Issue
Block a user