[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 2/5] libxl: add libxl__xs_path_cleanup
Add a function which behaves like "xenstore-rm -t", and which will be used to clean xenstore after unplug since we will be no longer executing xen-hotplug-cleanup script, that used to do that for us. Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxx> --- tools/libxl/libxl_device.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c index c7e057d..fe4bcc6 100644 --- a/tools/libxl/libxl_device.c +++ b/tools/libxl/libxl_device.c @@ -356,6 +356,27 @@ int libxl__device_disk_dev_number(const char *virtpath, int *pdisk, return -1; } +static int libxl__xs_path_cleanup(libxl__gc *gc, char *path) +{ + libxl_ctx *ctx = libxl__gc_owner(gc); + unsigned int nb = 0; + char *last; + + if (!path) + return 0; + + xs_rm(ctx->xsh, XBT_NULL, path); + + for (last = strrchr(path, '/'); last != NULL; last = strrchr(path, '/')) { + *last = '\0'; + if (!libxl__xs_directory(gc, XBT_NULL, path, &nb)) + continue; + if (nb == 0) { + xs_rm(ctx->xsh, XBT_NULL, path); + } + } + return 0; +} typedef struct { libxl__ao *ao; -- 1.7.7.5 (Apple Git-26) _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |