Pino Toscano
2016-Jan-25 18:55 UTC
[Libguestfs] [PATCH] btrfs_subvolume_show: fix root/toplevel check w/ btrfs-progs >= 4.4
In trfs-progs 4.4 the error message has been changed, and our check did not work anymore. Yes, parsing user messages really sucks... --- daemon/btrfs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/daemon/btrfs.c b/daemon/btrfs.c index 85dbe00..c67af83 100644 --- a/daemon/btrfs.c +++ b/daemon/btrfs.c @@ -1029,9 +1029,12 @@ do_btrfs_subvolume_show (const char *subvolume) } /* If the path is the btrfs root, `btrfs subvolume show' reports: - * <path> is btrfs root + * <path> is btrfs root [in btrfs-progs < 4.4] + * <path> is toplevel subvolume */ - if (out && strstr (out, "is btrfs root") != NULL) { + if (out && + (strstr (out, "is btrfs root") != NULL || + strstr (out, "is toplevel subvolume") != NULL)) { reply_with_error ("%s is btrfs root", subvolume); return NULL; } -- 2.5.0
Richard W.M. Jones
2016-Jan-25 20:55 UTC
Re: [Libguestfs] [PATCH] btrfs_subvolume_show: fix root/toplevel check w/ btrfs-progs >= 4.4
On Mon, Jan 25, 2016 at 07:55:36PM +0100, Pino Toscano wrote:> In trfs-progs 4.4 the error message has been changed, and our check did > not work anymore. Yes, parsing user messages really sucks... > --- > daemon/btrfs.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/daemon/btrfs.c b/daemon/btrfs.c > index 85dbe00..c67af83 100644 > --- a/daemon/btrfs.c > +++ b/daemon/btrfs.c > @@ -1029,9 +1029,12 @@ do_btrfs_subvolume_show (const char *subvolume) > } > > /* If the path is the btrfs root, `btrfs subvolume show' reports: > - * <path> is btrfs root > + * <path> is btrfs root [in btrfs-progs < 4.4] > + * <path> is toplevel subvolume > */ > - if (out && strstr (out, "is btrfs root") != NULL) { > + if (out && > + (strstr (out, "is btrfs root") != NULL || > + strstr (out, "is toplevel subvolume") != NULL)) { > reply_with_error ("%s is btrfs root", subvolume); > return NULL; > } > --Yup - machine readable output FTW. ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/