const char *path, struct xs_permissions *perms,
unsigned int num_perms);
+/* On success, *result_out came from the gc.
+ * On error, *result_out is undefined.
+ * ENOENT is regarded as error.
+ */
+int libxl__xs_read_mandatory(libxl__gc *gc, xs_transaction_t t,
+ const char *path, const char **result_out);
+
/* On success, *result_out came from the gc.
* On error, *result_out is undefined.
* ENOENT counts as success but sets *result_out=0
usbctrlinfo->devid = usbctrl->devid;
#define READ_SUBPATH(path, subpath) ({ \
- rc = libxl__xs_read_checked(gc, XBT_NULL, \
- GCSPRINTF("%s/" subpath, path), \
- &tmp); \
+ rc = libxl__xs_read_mandatory(gc, XBT_NULL, \
+ GCSPRINTF("%s/" subpath, path), \
+ &tmp); \
if (rc) goto out; \
(char *)tmp; \
})
return s;
}
+int libxl__xs_read_mandatory(libxl__gc *gc, xs_transaction_t t,
+ const char *path, const char **result_out)
+{
+ char *result = libxl__xs_read(gc, t, path);
+ if (!result) {
+ LOGE(ERROR, "xenstore read failed: `%s'", path);
+ return ERROR_FAIL;
+ }
+ *result_out = result;
+ return 0;
+}
+
int libxl__xs_read_checked(libxl__gc *gc, xs_transaction_t t,
const char *path, const char **result_out)
{