/* Register a @watch on the given path, using the given xenbus_watch structure for storage, and the given @callback function as the callback. Return 0 on success, or -errno on error. On success, the given @path will be saved as @watch->node, and remains the caller's to free. On error, @watch->node will be NULL, the device will switch to XenbusStateClosing, and the error will be saved in the store.  */
int xenbus_watch_path(struct xenbus_device *dev, const char *path, struct xenbus_watch *watch, void(*callback)(struct xenbus_watch *, const char **, unsigned int))
/* Register a @watch on the given path, using the given xenbus_watch structure for storage, and the given @callback function as the callback. Return 0 on success, or -errno on error. On success, the given @path will be saved as @watch->node, and remains the caller's to free. On error, @watch->node will be NULL, the device will switch to XenbusStateClosing, and the error will be saved in the store.  */
int xenbus_watch_path(struct xenbus_device *dev, const char *path, struct xenbus_watch *watch, void(*callback)(struct xenbus_watch *, const char **, unsigned int))
{
	int err;
	watch->node = path;
	watch->callback = callback;
	err = register_xenbus_watch(watch);
	if (err) {
		watch->node = NULL;
		watch->callback = NULL;
		xenbus_dev_fatal(dev, err, "adding watch on %s", path);
	}
	return err;
}