Pino Toscano
2016-May-16 12:25 UTC
[Libguestfs] [PATCH] btrfs_filesystem_show: work with btrfs < 4.3.1
Versions older than 4.3.1 output also the version string after the output. Ignore such line, since it isn't relevant to what btrfs_filesystem_show needs. --- daemon/btrfs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/daemon/btrfs.c b/daemon/btrfs.c index 62bdac7..9b52aa8 100644 --- a/daemon/btrfs.c +++ b/daemon/btrfs.c @@ -2270,6 +2270,12 @@ do_btrfs_filesystem_show (const char *device) } else if (STRPREFIX (lines[i], "\t*** Some devices missing")) { reply_with_error_errno (ENODEV, "%s: missing devices", device); return NULL; + } else if (STRPREFIX (lines[i], "btrfs-progs v")) { + /* Older versions of btrfs-progs output also the version string + * (the same as `btrfs --version`. This has been fixed upstream + * since v4.3.1, commit e29ec82e4e66042ca55bf8cd9ef609e3b21a7eb7. + * To support these older versions, ignore the version line. */ + continue; } else { reply_with_error ("unrecognized line in output from 'btrfs filesystem show': %s", lines[i]); return NULL; -- 2.5.5
Richard W.M. Jones
2016-May-16 12:26 UTC
Re: [Libguestfs] [PATCH] btrfs_filesystem_show: work with btrfs < 4.3.1
On Mon, May 16, 2016 at 02:25:03PM +0200, Pino Toscano wrote:> Versions older than 4.3.1 output also the version string after the > output. Ignore such line, since it isn't relevant to what > btrfs_filesystem_show needs. > --- > daemon/btrfs.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/daemon/btrfs.c b/daemon/btrfs.c > index 62bdac7..9b52aa8 100644 > --- a/daemon/btrfs.c > +++ b/daemon/btrfs.c > @@ -2270,6 +2270,12 @@ do_btrfs_filesystem_show (const char *device) > } else if (STRPREFIX (lines[i], "\t*** Some devices missing")) { > reply_with_error_errno (ENODEV, "%s: missing devices", device); > return NULL; > + } else if (STRPREFIX (lines[i], "btrfs-progs v")) { > + /* Older versions of btrfs-progs output also the version string > + * (the same as `btrfs --version`. This has been fixed upstream > + * since v4.3.1, commit e29ec82e4e66042ca55bf8cd9ef609e3b21a7eb7. > + * To support these older versions, ignore the version line. */ > + continue; > } else { > reply_with_error ("unrecognized line in output from 'btrfs filesystem show': %s", lines[i]); > return NULL; > -- > 2.5.5Looks reasonable, 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/