[syslinux] [PATCH] Fix booting off a btrfs subvolume

Alexander E. Patrakov patrakov at gmail.com
Mon Jun 4 11:10:10 PDT 2012


The attached patch fixes booting off a btrfs subvolume for me.

I have only tested the situation when the boot subvolume is made the
default subvolume with "btrfs subvolume set-default boot ."

Since I am going to remove all traces of btrfs from my computer for
reasons unrelated to syslinux, I will not be able to answer any
requests for testing modified versions of this patch if they are sent
later than tomorrow.

-- 
Alexander E. Patrakov
-------------- next part --------------
From d0d00ee4e0413aa209cf3703ebf44e7a4a73b75c Mon Sep 17 00:00:00 2001
From: "Alexander E. Patrakov" <patrakov at gmail.com>
Date: Mon, 4 Jun 2012 23:59:55 +0600
Subject: [PATCH] Fix booting off a btrfs subvolume.

The subvolume name in path.data is not NUL-terminated, so don't use
strcmp on it.

Before this patch, it would accumulate the following (given
subvolumes with names "ext2_saved", "home", "gentoo" and "boot"):

ext2_saved
home_saved
gentooaved
bootooaved

Signed-off-by: Alexander E. Patrakov <patrakov at gmail.com>
---
 core/fs/btrfs/btrfs.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/core/fs/btrfs/btrfs.c b/core/fs/btrfs/btrfs.c
index b6a14e3..aeb7614 100644
--- a/core/fs/btrfs/btrfs.c
+++ b/core/fs/btrfs/btrfs.c
@@ -602,12 +602,15 @@ static void btrfs_get_fs_tree(struct fs_info *fs)
 		do {
 			do {
 				struct btrfs_root_ref *ref;
+				int pathlen;
 
 				if (btrfs_comp_keys_type(&search_key,
 							&path.item.key))
 					break;
 				ref = (struct btrfs_root_ref *)path.data;
-				if (!strcmp((char*)(ref + 1), SubvolName)) {
+				pathlen = path.item.size - sizeof(struct btrfs_root_ref);
+
+				if (!strncmp((char*)(ref + 1), SubvolName, pathlen)) {
 					subvol_ok = true;
 					break;
 				}
-- 
1.7.8.6



More information about the Syslinux mailing list