From: "Richard W.M. Jones" <rjones(a)redhat.com>
Callers are supposed to use the availability API to check for
functions that may not be available in particular builds of
libguestfs. If they don't do this, currently they tend to get obscure
error messages, eg:
libguestfs: error: zerofree: /dev/vda1: zerofree: No such file or directory
This commit changes the error message to explain what callers ought to
be doing instead:
libguestfs: error: zerofree: feature 'zerofree' is not available in this
build of libguestfs. Read 'AVAILABILITY' in the guestfs(3) man page for
how to check for the availability of features.
---
daemon/augeas.c | 30 ++++++++++++------------
daemon/btrfs.c | 4 ++-
daemon/daemon.h | 29 +++++++++++++++++------
daemon/grub.c | 2 +
daemon/inotify.c | 12 +++++-----
daemon/luks.c | 16 ++++++++++++-
daemon/lvm.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++-
daemon/md.c | 10 +++++++-
daemon/mknod.c | 4 +-
daemon/modprobe.c | 8 +++++-
daemon/ntfs.c | 8 ++++++
daemon/realpath.c | 2 +-
daemon/scrub.c | 8 +++++-
daemon/selinux.c | 6 ++--
daemon/swap.c | 8 +++++-
daemon/tar.c | 2 +
daemon/xattr.c | 18 +++++++-------
daemon/zerofree.c | 4 ++-
18 files changed, 181 insertions(+), 54 deletions(-)
diff --git a/daemon/augeas.c b/daemon/augeas.c
index f52c091..135212e 100644
--- a/daemon/augeas.c
+++ b/daemon/augeas.c
@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
- * Copyright (C) 2009 Red Hat Inc.
+ * Copyright (C) 2009-2012 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -99,7 +99,7 @@ do_aug_init (const char *root, int flags)
return 0;
#else
- NOT_AVAILABLE (-1);
+ NOT_AVAILABLE (augeas, -1);
#endif
}
@@ -114,7 +114,7 @@ do_aug_close (void)
return 0;
#else
- NOT_AVAILABLE (-1);
+ NOT_AVAILABLE (augeas, -1);
#endif
}
@@ -133,7 +133,7 @@ do_aug_defvar (const char *name, const char *expr)
}
return r;
#else
- NOT_AVAILABLE (-1);
+ NOT_AVAILABLE (augeas, -1);
#endif
}
@@ -163,7 +163,7 @@ do_aug_defnode (const char *name, const char *expr, const char *val)
return r;
#else
- NOT_AVAILABLE (NULL);
+ NOT_AVAILABLE (augeas, NULL);
#endif
}
@@ -205,7 +205,7 @@ do_aug_get (const char *path)
return v; /* Caller frees. */
#else
- NOT_AVAILABLE (NULL);
+ NOT_AVAILABLE (augeas, NULL);
#endif
}
@@ -225,7 +225,7 @@ do_aug_set (const char *path, const char *val)
return 0;
#else
- NOT_AVAILABLE (-1);
+ NOT_AVAILABLE (augeas, -1);
#endif
}
@@ -245,7 +245,7 @@ do_aug_clear (const char *path)
return 0;
#else
- NOT_AVAILABLE (-1);
+ NOT_AVAILABLE (augeas, -1);
#endif
}
@@ -265,7 +265,7 @@ do_aug_insert (const char *path, const char *label, int before)
return 0;
#else
- NOT_AVAILABLE (-1);
+ NOT_AVAILABLE (augeas, -1);
#endif
}
@@ -285,7 +285,7 @@ do_aug_rm (const char *path)
return r;
#else
- NOT_AVAILABLE (-1);
+ NOT_AVAILABLE (augeas, -1);
#endif
}
@@ -305,7 +305,7 @@ do_aug_mv (const char *src, const char *dest)
return 0;
#else
- NOT_AVAILABLE (-1);
+ NOT_AVAILABLE (augeas, -1);
#endif
}
@@ -339,7 +339,7 @@ do_aug_match (const char *path)
return matches; /* Caller frees. */
#else
- NOT_AVAILABLE (NULL);
+ NOT_AVAILABLE (augeas, NULL);
#endif
}
@@ -356,7 +356,7 @@ do_aug_save (void)
return 0;
#else
- NOT_AVAILABLE (-1);
+ NOT_AVAILABLE (augeas, -1);
#endif
}
@@ -373,7 +373,7 @@ do_aug_load (void)
return 0;
#else
- NOT_AVAILABLE (-1);
+ NOT_AVAILABLE (augeas, -1);
#endif
}
@@ -421,6 +421,6 @@ do_aug_ls (const char *path)
sort_strings (matches, count_strings ((void *) matches));
return matches; /* Caller frees. */
#else
- NOT_AVAILABLE (NULL);
+ NOT_AVAILABLE (augeas, NULL);
#endif
}
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index a20ee08..88a7386 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
- * Copyright (C) 2011 Red Hat Inc.
+ * Copyright (C) 2011-2012 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -47,6 +47,8 @@ do_btrfs_filesystem_resize (const char *filesystem, int64_t size)
size_t i = 0;
char size_str[32];
+ IF_NOT_AVAILABLE_ERROR (btrfs, -1);
+
ADD_ARG (argv, i, "btrfs");
ADD_ARG (argv, i, "filesystem");
ADD_ARG (argv, i, "resize");
diff --git a/daemon/daemon.h b/daemon/daemon.h
index babe5bc..051317f 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -331,15 +331,28 @@ is_zero (const char *buffer, size_t size)
} \
while (0)
-/* Marks functions which are not available.
- * NB. Cannot be used for FileIn functions.
+/* Better error messages for functions which may not be available
+ * (RHBZ#679737). Use NOT_AVAILABLE if the function is definitely not
+ * available at this point, or IF_NOT_AVAILABLE_ERROR to first check
+ * if the optgroup is available before printing the error.
+ *
+ * NB: (1) 'feature' parameter is a bareword, not in double quotes.
+ * (2) Cannot be used for FileIn functions.
*/
-#define NOT_AVAILABLE(errcode) \
- do { \
- reply_with_error ("%s: function not available", __func__); \
- return (errcode); \
- } \
- while (0)
+#define NOT_AVAILABLE(feature,errcode) \
+ do { \
+ reply_with_error ("feature '%s' is not available in this\n"
\
+ "build of libguestfs. Read 'AVAILABILITY' in the
guestfs(3) man page for\n" \
+ "how to check for the availability of features.", \
+ #feature); \
+ return (errcode); \
+ } while (0)
+
+#define IF_NOT_AVAILABLE_ERROR(feature,errcode) \
+ do { \
+ if (! optgroup_##feature##_available ()) \
+ NOT_AVAILABLE(feature,errcode); \
+ } while (0)
#ifndef __attribute__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
diff --git a/daemon/grub.c b/daemon/grub.c
index 9cd4f6e..bf3e07f 100644
--- a/daemon/grub.c
+++ b/daemon/grub.c
@@ -39,6 +39,8 @@ do_grub_install (const char *root, const char *device)
char *err;
char *buf;
+ IF_NOT_AVAILABLE_ERROR (grub, -1);
+
if (asprintf_nowarn (&buf, "--root-directory=%R", root) == -1) {
reply_with_perror ("asprintf");
return -1;
diff --git a/daemon/inotify.c b/daemon/inotify.c
index add1f14..bafc336 100644
--- a/daemon/inotify.c
+++ b/daemon/inotify.c
@@ -130,7 +130,7 @@ do_inotify_init (int max_events)
return 0;
#else
- NOT_AVAILABLE (-1);
+ NOT_AVAILABLE (inotify, -1);
#endif
}
@@ -155,7 +155,7 @@ do_inotify_close (void)
return 0;
#else
- NOT_AVAILABLE (-1);
+ NOT_AVAILABLE (inotify, -1);
#endif
}
@@ -183,7 +183,7 @@ do_inotify_add_watch (const char *path, int mask)
return r;
#else
- NOT_AVAILABLE (-1);
+ NOT_AVAILABLE (inotify, -1);
#endif
}
@@ -200,7 +200,7 @@ do_inotify_rm_watch (int wd)
return 0;
#else
- NOT_AVAILABLE (-1);
+ NOT_AVAILABLE (inotify, -1);
#endif
}
@@ -314,7 +314,7 @@ do_inotify_read (void)
free (ret);
return NULL;
#else
- NOT_AVAILABLE (NULL);
+ NOT_AVAILABLE (inotify, NULL);
#endif
}
@@ -405,6 +405,6 @@ do_inotify_files (void)
unlink (tempfile);
return NULL;
#else
- NOT_AVAILABLE (NULL);
+ NOT_AVAILABLE (inotify, NULL);
#endif
}
diff --git a/daemon/luks.c b/daemon/luks.c
index 02620ef..148a0ab 100644
--- a/daemon/luks.c
+++ b/daemon/luks.c
@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
- * Copyright (C) 2010 Red Hat Inc.
+ * Copyright (C) 2010-2012 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -129,18 +129,24 @@ luks_open (const char *device, const char *key, const char
*mapname,
int
do_luks_open (const char *device, const char *key, const char *mapname)
{
+ IF_NOT_AVAILABLE_ERROR (luks, -1);
+
return luks_open (device, key, mapname, 0);
}
int
do_luks_open_ro (const char *device, const char *key, const char *mapname)
{
+ IF_NOT_AVAILABLE_ERROR (luks, -1);
+
return luks_open (device, key, mapname, 1);
}
int
do_luks_close (const char *device)
{
+ IF_NOT_AVAILABLE_ERROR (luks, -1);
+
/* Must be /dev/mapper/... */
if (! STRPREFIX (device, "/dev/mapper/")) {
reply_with_error ("luks_close: you must call this on the /dev/mapper device
created by luks_open");
@@ -210,6 +216,8 @@ luks_format (const char *device, const char *key, int keyslot,
int
do_luks_format (const char *device, const char *key, int keyslot)
{
+ IF_NOT_AVAILABLE_ERROR (luks, -1);
+
return luks_format (device, key, keyslot, NULL);
}
@@ -217,6 +225,8 @@ int
do_luks_format_cipher (const char *device, const char *key, int keyslot,
const char *cipher)
{
+ IF_NOT_AVAILABLE_ERROR (luks, -1);
+
return luks_format (device, key, keyslot, cipher);
}
@@ -224,6 +234,8 @@ int
do_luks_add_key (const char *device, const char *key, const char *newkey,
int keyslot)
{
+ IF_NOT_AVAILABLE_ERROR (luks, -1);
+
char *keyfile = write_key_to_temp (key);
if (!keyfile)
return -1;
@@ -269,6 +281,8 @@ do_luks_add_key (const char *device, const char *key, const char
*newkey,
int
do_luks_kill_slot (const char *device, const char *key, int keyslot)
{
+ IF_NOT_AVAILABLE_ERROR (luks, -1);
+
char *tempfile = write_key_to_temp (key);
if (!tempfile)
return -1;
diff --git a/daemon/lvm.c b/daemon/lvm.c
index 9a71c65..d16cd15 100644
--- a/daemon/lvm.c
+++ b/daemon/lvm.c
@@ -102,6 +102,8 @@ do_pvs (void)
char *out, *err;
int r;
+ IF_NOT_AVAILABLE_ERROR (lvm2, NULL);
+
r = command (&out, &err,
"lvm", "pvs", "-o", "pv_name",
"--noheadings", NULL);
if (r == -1) {
@@ -122,6 +124,8 @@ do_vgs (void)
char *out, *err;
int r;
+ IF_NOT_AVAILABLE_ERROR (lvm2, NULL);
+
r = command (&out, &err,
"lvm", "vgs", "-o", "vg_name",
"--noheadings", NULL);
if (r == -1) {
@@ -142,6 +146,8 @@ do_lvs (void)
char *out, *err;
int r;
+ IF_NOT_AVAILABLE_ERROR (lvm2, NULL);
+
r = command (&out, &err,
"lvm", "lvs",
"-o", "vg_name,lv_name", "--noheadings",
@@ -165,18 +171,24 @@ do_lvs (void)
guestfs_int_lvm_pv_list *
do_pvs_full (void)
{
+ IF_NOT_AVAILABLE_ERROR (lvm2, NULL);
+
return parse_command_line_pvs ();
}
guestfs_int_lvm_vg_list *
do_vgs_full (void)
{
+ IF_NOT_AVAILABLE_ERROR (lvm2, NULL);
+
return parse_command_line_vgs ();
}
guestfs_int_lvm_lv_list *
do_lvs_full (void)
{
+ IF_NOT_AVAILABLE_ERROR (lvm2, NULL);
+
return parse_command_line_lvs ();
}
@@ -186,6 +198,8 @@ do_pvcreate (const char *device)
char *err;
int r;
+ IF_NOT_AVAILABLE_ERROR (lvm2, -1);
+
r = command (NULL, &err,
"lvm", "pvcreate", device, NULL);
if (r == -1) {
@@ -208,6 +222,8 @@ do_vgcreate (const char *volgroup, char *const *physvols)
int r, argc, i;
const char **argv;
+ IF_NOT_AVAILABLE_ERROR (lvm2, -1);
+
argc = count_strings (physvols) + 3;
argv = malloc (sizeof (char *) * (argc + 1));
if (argv == NULL) {
@@ -243,6 +259,8 @@ do_lvcreate (const char *logvol, const char *volgroup, int mbytes)
int r;
char size[64];
+ IF_NOT_AVAILABLE_ERROR (lvm2, -1);
+
snprintf (size, sizeof size, "%d", mbytes);
r = command (NULL, &err,
@@ -268,6 +286,8 @@ do_lvresize (const char *logvol, int mbytes)
int r;
char size[64];
+ IF_NOT_AVAILABLE_ERROR (lvm2, -1);
+
snprintf (size, sizeof size, "%d", mbytes);
r = command (NULL, &err,
@@ -289,6 +309,8 @@ do_lvresize_free (const char *logvol, int percent)
char *err;
int r;
+ IF_NOT_AVAILABLE_ERROR (lvm2, -1);
+
if (percent < 0 || percent > 100) {
reply_with_error ("percentage must be [0..100] (was %d)", percent);
return -1;
@@ -319,6 +341,8 @@ do_lvm_remove_all (void)
int i, r;
char *err;
+ IF_NOT_AVAILABLE_ERROR (lvm2, -1);
+
/* Remove LVs. */
xs = do_lvs ();
if (xs == NULL)
@@ -392,6 +416,8 @@ do_lvremove (const char *device)
char *err;
int r;
+ IF_NOT_AVAILABLE_ERROR (lvm2, -1);
+
r = command (NULL, &err,
"lvm", "lvremove", "-f", device, NULL);
if (r == -1) {
@@ -413,6 +439,8 @@ do_vgremove (const char *device)
char *err;
int r;
+ IF_NOT_AVAILABLE_ERROR (lvm2, -1);
+
r = command (NULL, &err,
"lvm", "vgremove", "-f", device, NULL);
if (r == -1) {
@@ -434,6 +462,8 @@ do_pvremove (const char *device)
char *err;
int r;
+ IF_NOT_AVAILABLE_ERROR (lvm2, -1);
+
r = command (NULL, &err,
"lvm", "pvremove", "-ff", device, NULL);
if (r == -1) {
@@ -455,6 +485,8 @@ do_pvresize (const char *device)
char *err;
int r;
+ IF_NOT_AVAILABLE_ERROR (lvm2, -1);
+
r = command (NULL, &err,
"lvm", "pvresize", device, NULL);
if (r == -1) {
@@ -472,8 +504,10 @@ do_pvresize_size (const char *device, int64_t size)
{
char *err;
int r;
-
char buf[32];
+
+ IF_NOT_AVAILABLE_ERROR (lvm2, -1);
+
snprintf (buf, sizeof buf, "%" PRIi64 "b", size);
r = command (NULL, &err,
@@ -497,6 +531,8 @@ do_vg_activate (int activate, char *const *volgroups)
int r, i, argc;
const char **argv;
+ IF_NOT_AVAILABLE_ERROR (lvm2, -1);
+
argc = count_strings (volgroups) + 4;
argv = malloc (sizeof (char *) * (argc+1));
if (argv == NULL) {
@@ -540,6 +576,8 @@ do_lvrename (const char *logvol, const char *newlogvol)
char *err;
int r;
+ IF_NOT_AVAILABLE_ERROR (lvm2, -1);
+
r = command (NULL, &err,
"lvm", "lvrename",
logvol, newlogvol, NULL);
@@ -562,6 +600,8 @@ do_vgrename (const char *volgroup, const char *newvolgroup)
char *err;
int r;
+ IF_NOT_AVAILABLE_ERROR (lvm2, -1);
+
r = command (NULL, &err,
"lvm", "vgrename",
volgroup, newvolgroup, NULL);
@@ -603,18 +643,24 @@ get_lvm_field (const char *cmd, const char *field, const char
*device)
char *
do_pvuuid (const char *device)
{
+ IF_NOT_AVAILABLE_ERROR (lvm2, NULL);
+
return get_lvm_field ("pvs", "pv_uuid", device);
}
char *
do_vguuid (const char *vgname)
{
+ IF_NOT_AVAILABLE_ERROR (lvm2, NULL);
+
return get_lvm_field ("vgs", "vg_uuid", vgname);
}
char *
do_lvuuid (const char *device)
{
+ IF_NOT_AVAILABLE_ERROR (lvm2, NULL);
+
return get_lvm_field ("lvs", "lv_uuid", device);
}
@@ -652,12 +698,16 @@ get_lvm_fields (const char *cmd, const char *field, const char
*device)
char **
do_vgpvuuids (const char *vgname)
{
+ IF_NOT_AVAILABLE_ERROR (lvm2, NULL);
+
return get_lvm_fields ("vgs", "pv_uuid", vgname);
}
char **
do_vglvuuids (const char *vgname)
{
+ IF_NOT_AVAILABLE_ERROR (lvm2, NULL);
+
return get_lvm_fields ("vgs", "lv_uuid", vgname);
}
@@ -667,6 +717,8 @@ do_vgscan (void)
char *err;
int r;
+ IF_NOT_AVAILABLE_ERROR (lvm2, -1);
+
r = command (NULL, &err,
"lvm", "vgscan", NULL);
if (r == -1) {
@@ -745,6 +797,8 @@ lv_canonical (const char *device, char **ret)
int
do_is_lv (const char *device)
{
+ IF_NOT_AVAILABLE_ERROR (lvm2, -1);
+
return lv_canonical (device, NULL);
}
@@ -753,7 +807,11 @@ char *
do_lvm_canonical_lv_name (const char *device)
{
char *canonical;
- int r = lv_canonical (device, &canonical);
+ int r;
+
+ IF_NOT_AVAILABLE_ERROR (lvm2, NULL);
+
+ r = lv_canonical (device, &canonical);
if (r == -1)
return NULL;
@@ -775,6 +833,8 @@ do_list_dm_devices (void)
DIR *dir;
int r;
+ IF_NOT_AVAILABLE_ERROR (lvm2, NULL);
+
dir = opendir ("/dev/mapper");
if (!dir) {
reply_with_perror ("opendir: /dev/mapper");
diff --git a/daemon/md.c b/daemon/md.c
index 41e2c75..fb3a4a7 100644
--- a/daemon/md.c
+++ b/daemon/md.c
@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
- * Copyright (C) 2011 Red Hat Inc.
+ * Copyright (C) 2011-2012 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -62,6 +62,8 @@ do_md_create (const char *name, char *const *devices,
char *err;
uint64_t umissingbitmap = (uint64_t) missingbitmap;
+ IF_NOT_AVAILABLE_ERROR (mdadm, -1);
+
/* Check the optional parameters and set defaults where appropriate. */
if (!(optargs_bitmask & GUESTFS_MD_CREATE_MISSINGBITMAP_BITMASK))
umissingbitmap = 0;
@@ -184,6 +186,8 @@ do_list_md_devices (void)
int size = 0, alloc = 0;
glob_t mds;
+ IF_NOT_AVAILABLE_ERROR (mdadm, NULL);
+
memset(&mds, 0, sizeof(mds));
#define PREFIX "/sys/block/md"
@@ -244,6 +248,8 @@ do_md_detail(const char *md)
char **ret = NULL;
int size = 0, alloc = 0;
+ IF_NOT_AVAILABLE_ERROR (mdadm, NULL);
+
const char *mdadm[] = { "mdadm", "-D", "--export", md,
NULL };
r = commandv (&out, &err, mdadm);
if (r == -1) {
@@ -320,6 +326,8 @@ do_md_stop(const char *md)
int r;
char *err = NULL;
+ IF_NOT_AVAILABLE_ERROR (mdadm, -1);
+
const char *mdadm[] = { "mdadm", "--stop", md, NULL};
r = commandv(NULL, &err, mdadm);
if (r == -1) {
diff --git a/daemon/mknod.c b/daemon/mknod.c
index d5b8467..d13414b 100644
--- a/daemon/mknod.c
+++ b/daemon/mknod.c
@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
- * Copyright (C) 2009 Red Hat Inc.
+ * Copyright (C) 2009-2012 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -67,7 +67,7 @@ do_mknod (int mode, int devmajor, int devminor, const char *path)
return 0;
#else
- NOT_AVAILABLE (-1);
+ NOT_AVAILABLE (mknod, -1);
#endif
}
diff --git a/daemon/modprobe.c b/daemon/modprobe.c
index 1063043..d7c5656 100644
--- a/daemon/modprobe.c
+++ b/daemon/modprobe.c
@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
- * Copyright (C) 2009 Red Hat Inc.
+ * Copyright (C) 2009-2012 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,7 +35,11 @@ int
do_modprobe (const char *module)
{
char *err;
- int r = command (NULL, &err, "modprobe", module, NULL);
+ int r;
+
+ IF_NOT_AVAILABLE_ERROR (linuxmodules, -1);
+
+ r = command (NULL, &err, "modprobe", module, NULL);
if (r == -1) {
reply_with_error ("%s", err);
diff --git a/daemon/ntfs.c b/daemon/ntfs.c
index e8be344..b6dec83 100644
--- a/daemon/ntfs.c
+++ b/daemon/ntfs.c
@@ -49,6 +49,8 @@ do_ntfs_3g_probe (int rw, const char *device)
int r;
const char *rw_flag;
+ IF_NOT_AVAILABLE_ERROR (ntfs3g, -1);
+
rw_flag = rw ? "-w" : "-r";
r = commandr (NULL, &err, "ntfs-3g.probe", rw_flag, device, NULL);
@@ -72,6 +74,8 @@ do_ntfsresize_opts (const char *device, int64_t size, int force)
size_t i = 0;
char size_str[32];
+ IF_NOT_AVAILABLE_ERROR (ntfsprogs, -1);
+
ADD_ARG (argv, i, "ntfsresize");
ADD_ARG (argv, i, "-P");
@@ -106,12 +110,16 @@ do_ntfsresize_opts (const char *device, int64_t size, int force)
int
do_ntfsresize (const char *device)
{
+ IF_NOT_AVAILABLE_ERROR (ntfsprogs, -1);
+
return do_ntfsresize_opts (device, 0, 0);
}
int
do_ntfsresize_size (const char *device, int64_t size)
{
+ IF_NOT_AVAILABLE_ERROR (ntfsprogs, -1);
+
optargs_bitmask = GUESTFS_NTFSRESIZE_OPTS_SIZE_BITMASK;
return do_ntfsresize_opts (device, size, 0);
}
diff --git a/daemon/realpath.c b/daemon/realpath.c
index 8ec9674..a42aec3 100644
--- a/daemon/realpath.c
+++ b/daemon/realpath.c
@@ -62,7 +62,7 @@ do_realpath (const char *path)
return ret; /* caller frees */
#else
- NOT_AVAILABLE (NULL);
+ NOT_AVAILABLE (realpath, NULL);
#endif
}
diff --git a/daemon/scrub.c b/daemon/scrub.c
index 2cef69d..48ddd35 100644
--- a/daemon/scrub.c
+++ b/daemon/scrub.c
@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
- * Copyright (C) 2009 Red Hat Inc.
+ * Copyright (C) 2009-2012 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -40,6 +40,8 @@ do_scrub_device (const char *device)
char *err;
int r;
+ IF_NOT_AVAILABLE_ERROR (scrub, -1);
+
r = command (NULL, &err, "scrub", device, NULL);
if (r == -1) {
reply_with_error ("%s: %s", device, err);
@@ -59,6 +61,8 @@ do_scrub_file (const char *file)
char *err;
int r;
+ IF_NOT_AVAILABLE_ERROR (scrub, -1);
+
/* Make the path relative to /sysroot. */
buf = sysroot_path (file);
if (!buf) {
@@ -86,6 +90,8 @@ do_scrub_freespace (const char *dir)
char *err;
int r;
+ IF_NOT_AVAILABLE_ERROR (scrub, -1);
+
/* Make the path relative to /sysroot. */
buf = sysroot_path (dir);
if (!buf) {
diff --git a/daemon/selinux.c b/daemon/selinux.c
index 2db05ee..9c52781 100644
--- a/daemon/selinux.c
+++ b/daemon/selinux.c
@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
- * Copyright (C) 2009 Red Hat Inc.
+ * Copyright (C) 2009-2012 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -60,7 +60,7 @@ do_setcon (const char *context)
return 0;
#else
- NOT_AVAILABLE (-1);
+ NOT_AVAILABLE (selinux, -1);
#endif
}
@@ -85,6 +85,6 @@ do_getcon (void)
return r; /* caller frees */
#else
- NOT_AVAILABLE (NULL);
+ NOT_AVAILABLE (selinux, NULL);
#endif
}
diff --git a/daemon/swap.c b/daemon/swap.c
index 51dbbe4..4891470 100644
--- a/daemon/swap.c
+++ b/daemon/swap.c
@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
- * Copyright (C) 2009 Red Hat Inc.
+ * Copyright (C) 2009-2012 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -99,6 +99,8 @@ do_mkswap_L (const char *label, const char *device)
int
do_mkswap_U (const char *uuid, const char *device)
{
+ IF_NOT_AVAILABLE_ERROR (linuxfsuuid, -1);
+
return mkswap (device, "-U", uuid);
}
@@ -219,11 +221,15 @@ do_swapoff_label (const char *label)
int
do_swapon_uuid (const char *uuid)
{
+ IF_NOT_AVAILABLE_ERROR (linuxfsuuid, -1);
+
return swaponoff ("swapon", "-U", uuid);
}
int
do_swapoff_uuid (const char *uuid)
{
+ IF_NOT_AVAILABLE_ERROR (linuxfsuuid, -1);
+
return swaponoff ("swapoff", "-U", uuid);
}
diff --git a/daemon/tar.c b/daemon/tar.c
index 9295f0d..79c9ac4 100644
--- a/daemon/tar.c
+++ b/daemon/tar.c
@@ -247,5 +247,7 @@ do_tgz_out (const char *dir)
int
do_txz_out (const char *dir)
{
+ IF_NOT_AVAILABLE_ERROR (xz, -1);
+
return do_tXz_out (dir, "J");
}
diff --git a/daemon/xattr.c b/daemon/xattr.c
index 2445748..1b98555 100644
--- a/daemon/xattr.c
+++ b/daemon/xattr.c
@@ -520,55 +520,55 @@ optgroup_linuxxattrs_available (void)
guestfs_int_xattr_list *
do_getxattrs (const char *path)
{
- NOT_AVAILABLE (NULL);
+ NOT_AVAILABLE (linuxxattrs, NULL);
}
guestfs_int_xattr_list *
do_lgetxattrs (const char *path)
{
- NOT_AVAILABLE (NULL);
+ NOT_AVAILABLE (linuxxattrs, NULL);
}
int
do_setxattr (const char *xattr, const char *val, int vallen, const char *path)
{
- NOT_AVAILABLE (-1);
+ NOT_AVAILABLE (linuxxattrs, -1);
}
int
do_lsetxattr (const char *xattr, const char *val, int vallen, const char *path)
{
- NOT_AVAILABLE (-1);
+ NOT_AVAILABLE (linuxxattrs, -1);
}
int
do_removexattr (const char *xattr, const char *path)
{
- NOT_AVAILABLE (-1);
+ NOT_AVAILABLE (linuxxattrs, -1);
}
int
do_lremovexattr (const char *xattr, const char *path)
{
- NOT_AVAILABLE (-1);
+ NOT_AVAILABLE (linuxxattrs, -1);
}
guestfs_int_xattr_list *
do_lxattrlist (const char *path, char *const *names)
{
- NOT_AVAILABLE (NULL);
+ NOT_AVAILABLE (linuxxattrs, NULL);
}
char *
do_getxattr (const char *path, const char *name, size_t *size_r)
{
- NOT_AVAILABLE (NULL);
+ NOT_AVAILABLE (linuxxattrs, NULL);
}
char *
do_lgetxattr (const char *path, const char *name, size_t *size_r)
{
- NOT_AVAILABLE (NULL);
+ NOT_AVAILABLE (linuxxattrs, NULL);
}
#endif /* no xattr.h */
diff --git a/daemon/zerofree.c b/daemon/zerofree.c
index e9be8fc..bc1b7ff 100644
--- a/daemon/zerofree.c
+++ b/daemon/zerofree.c
@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
- * Copyright (C) 2009 Red Hat Inc.
+ * Copyright (C) 2009-2012 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -40,6 +40,8 @@ do_zerofree (const char *device)
char *err;
int r;
+ IF_NOT_AVAILABLE_ERROR (zerofree, -1);
+
r = command (NULL, &err, "zerofree", device, NULL);
if (r == -1) {
reply_with_error ("%s: %s", device, err);
--
1.7.6