Richard W.M. Jones
2016-Aug-25 10:12 UTC
[Libguestfs] [PATCH] inspection: Fix parsing of btrfs subvolumes in /etc/fstab.
The code to parse btrfs subvol entries in /etc/fstab failed if the entry had more than one comma-separated option, for example: /dev/sda4 /home btrfs rw,user,subvol=foo 0 0 This commit fixes that code to use Augeas correctly. Fixes commit 7ba0e10501f23358c38939930d613bf2393d744d. Reported by: Zhongfu Li https://bugs.launchpad.net/ubuntu/+source/libguestfs/+bug/1615337 --- src/inspect-fs-unix.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c index cc0e6b1..0c34701 100644 --- a/src/inspect-fs-unix.c +++ b/src/inspect-fs-unix.c @@ -1347,27 +1347,28 @@ check_fstab (guestfs_h *g, struct inspect_fs *fs) if (vfstype == NULL) return -1; if (STREQ (vfstype, "btrfs")) { - char **opt; + size_t i; snprintf (augpath, sizeof augpath, "%s/opt", *entry); CLEANUP_FREE_STRING_LIST char **opts = guestfs_aug_match (g, augpath); if (opts == NULL) return -1; - for (opt = opts; *opt; opt++) { - CLEANUP_FREE char *optname = guestfs_aug_get (g, augpath); + for (i = 0; opts[i] != NULL; ++i) { + CLEANUP_FREE char *optname = NULL, *optvalue = NULL, *subvol = NULL; + char *old_mountable; + + optname = guestfs_aug_get (g, opts[i]); if (optname == NULL) return -1; if (STREQ (optname, "subvol")) { - CLEANUP_FREE char *subvol = NULL; - char *new; + optvalue = safe_asprintf (g, "%s/value", opts[i]); - snprintf (augpath, sizeof augpath, "%s/value", *opt); - subvol = guestfs_aug_get (g, augpath); + subvol = guestfs_aug_get (g, optvalue); if (subvol == NULL) return -1; - new = safe_asprintf (g, "btrfsvol:%s/%s", mountable, subvol); - free (mountable); - mountable = new; + old_mountable = mountable; + mountable = safe_asprintf (g, "btrfsvol:%s/%s", mountable, subvol); + free (old_mountable); } } } -- 2.7.4
Pino Toscano
2016-Aug-25 11:54 UTC
Re: [Libguestfs] [PATCH] inspection: Fix parsing of btrfs subvolumes in /etc/fstab.
On Thursday, 25 August 2016 11:12:32 CEST Richard W.M. Jones wrote:> The code to parse btrfs subvol entries in /etc/fstab failed if the > entry had more than one comma-separated option, for example: > > /dev/sda4 /home btrfs rw,user,subvol=foo 0 0 > > This commit fixes that code to use Augeas correctly. > > Fixes commit 7ba0e10501f23358c38939930d613bf2393d744d. > > Reported by: Zhongfu Li > https://bugs.launchpad.net/ubuntu/+source/libguestfs/+bug/1615337 > ---LGTM. Thanks, -- Pino Toscano
Possibly Parallel Threads
- [PATCH] inspection: add support for systemd .mount files
- [PATCH] NFC: Cleanup iteration over fstab entries in inspect_fs_unix.c
- [PATCH] Converter: Update xvc0 console to ttyS0
- [PATCH] Use augeas to update securetty
- [PATCH] Fix detection of an existing grub entry