Update: btrfs patch for grub2 with annotations
Hi Chris,
I was wondering if you had a chance to look at the btrfs patch and if it could be accepted with a GPLv2+ license at least?
Thanks a lot!
Warm Regards,
Surbhi.
P/S: I have copy pasted the original message sent to [email protected] at the end of this email.
-------- Original Message --------
Subject: btrfs patch for grub2 with annotations
Date: Wed, 14 Jul 2010 22:15:51 +0300
From: Surbhi Palande <[email protected]>
Reply-To: [email protected]
Organization: Canonical
To: [email protected]
Hi Chris,
As discussed on the #btrfs, I am sending you the btrfs patches for grub2. I have also attached a btrfs-annotation.txt with a list of functions and description of whether they are different or based on some other implementation.
If the code based on syslinux (http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-4.01.tar.bz2) cannot be accepted under GPLv2+, then I will rewrite that code either entirely or base it on the patch in grub-legacy.
I however do hope that this code can at least passed off as GPLv2+.
Thanks a lot!
Warm Regards,
Surbhi.
-------- Original Message Copy Pasted here --------
Subject: btrfs support for grub2
Date: Wed, 5 Jul 2010
From: Surbhi Palande <[email protected]>
Reply-To: [email protected]
Organization: Canonical
To: [email protected]
Hi All,
I am attaching two patches along with this email for enabling btrfs support in grub2. Please note that the licensing for this patch needs to be sorted out as grub-2 is at GPL-v3 and btrfs support in the linux kernel is at GPL-v2.
I have referred to the btrfs code in the kernel, btrfs-tools, sys-linux and legacy grub. I have used some code from sys-linux's btrfs support (written by Alek Du). As agreed in #btrfs irc, I am sending this email to Chris Mason to find out whether the code in the patch can be passed under GPLv3.
The patch provides btrfs support for the following:
1) single device.
2) subvolumes.
I have tested this patch using grub-fstest (using subcommands-ls, hex and crc). *I have not yet tested it by booting through the btrfs partition*
This is the first version of the patch and I have listed a few changes that could be made:
1) change the storage identifiers to the grub compliant ones.
2) linkcount for symbolic links needs better handling
I have a decompression support for btrfs-grub2 in an almost ready state. I will send that patch after these patches are sorted out.
Please do let me know your comments. I will be glad to incorporate the changes inorder to get btrfs support into grub-2.
Thanks for your time!
Warm Regards,
Surbhi.
P/S:
Following is a brief procedure with some eg. of how one can test these patches in qemu:
1) used an image created with "dd" as a hdb for qemu:
kvm -hda ubuntu.img -hdb btrfs.img -m 512 -net nic,macaddr='DE:AD:BE:EF::' -net tap
This is detected as /dev/sdb in qemu.
2) Booted through qemu and then did: fdisk -l /dev/sdb, created a partition table in /dev/sdb
4) Used mkfs.btrfs -A <byte_num> to create a filesystem at a byte reflected by the "start" field of the output of fdisk -ul
and then mounted this btrfs img/partition using mount -o offset=<byte-num>. Populated the fs.
5) compiled grub-2 with this patch
6) tested using this command:
a) grub-fstest /dev/sdb ls '(loop0,1)/' etc.
Subvolumes can be created as follows:
1) mount -t btrfs /dev/sdb /mnt/btrfs
2) btrfsctl -S subvol1 /mnt
3) mount -t btrfs -o subvol=subvol1 /dev/sdb /mnt/btrfs_subvol
4) create some files, dir, links on /mnt/btrfs_subvol
Now you can check the contents of the subvolume by using ./grub_fstest /dev/sdb ls '(loop0,1)/subvol1/'
surbhi (2):
config support for btrfs
btrfs support for grub-2
conf/common.rmk | 40 +- conf/i386-pc.rmk | 4 +- conf/sparc64-ieee1275.rmk | 5 +- fs/btrfs.c | 1434 +++++++++++++++++++++++++++++++++++++++++++++ fs/btrfs.h | 385 ++++++++++++ 5 files changed, 1843 insertions(+), 25 deletions(-) create mode 100644 fs/btrfs.c create mode 100644 fs/btrfs.h
code from btrfs-tools/sys-linux (which happens to be same/very similar to each other)
1) btrfs_sb_offset() - same as btrfs-tools::btrfs_sb_offset()
2) bin_search() - same as generic_bin_search() in btrfs-tools (or bin_search() in btrfs patch for grub-legacy)
3) btrfs_chunk_item_size() - same as btrfs-tools::btrfs_chunk_item_size()
4) btrfs_read_sys_chunk_array() - based on btrfs-tools::btrfs_read_sys_array() - (single device support), except that insert_map() is used to keep the mappings in an array instead of inserting in tree.
5) btrfs_read_chunk_tree() - based on btrfs-tools::btrfs_read_chunk_tree() (single device support), except that insert_map() is used to keep the mappings in an array instead of inserting in tree.
code from syslinux:
1) logical_physical()
2) btrfs_comp_keys_type()
4) search_tree()
5) next_leaf()
6) insert_map()
from the linux kernel:
1) btrfs_name_hash() - same as linux-2.6::btrfs_name_hash()
2) btrfs_comp_keys() - same as linux-2.6::btrfs_comp_cpu_keys()
what is different:
1) btrfs_get_fs_tree() - name is same as in syslinux, but the implementation is different
2) cache implementation()
3) btrfs_init_fs()
4) get_component()
5) btrfs_match_dir_item_name()
6) read_extent()
7) read_file_inr()
8) change_fs_root()
9) get_ino_cache()
10) get_parent()
11) insert_new_cache_item()
12) stripped_len()
13) search_path()
14) follow_link()
15) get_resolved_inum()
16) search_comp()
17) init_file()
18) grub_btrfs_open()
19) get_item_key()
20) grub_btrfs_read()
21) get_dirent_info()
22) btrfs_print_dir_item_names()
23) read_dir()
24) grub_btrfs_dir()
25) grub_btrfs_close()
26) grub_btrfs_label()
27) grub_btrfs_uuid()
28) grub_btrfs_mtime()
* Every function that starts with grub is grub dependent. Every other function could be used by other boot loaders as well.
From b45ad1339b7a35b5e13ed1911bef1d97444f4d85 Mon Sep 17 00:00:00 2001
Message-Id: <b45ad1339b7a35b5e13ed1911bef1d97444f4d85.1278336083.git.Surbhi.Palande@canonical.com>
In-Reply-To: <[email protected]>
References: <[email protected]>
From: surbhi <[email protected]>
Date: Mon, 5 Jul 2010 15:21:58 +0300
Subject: [PATCH 1/2] config support for btrfs
--- conf/common.rmk | 40 ++++++++++++++++++++-------------------- conf/i386-pc.rmk | 4 ++-- conf/sparc64-ieee1275.rmk | 5 ++--- 3 files changed, 24 insertions(+), 25 deletions(-)
conf/common.rmk +20 -20
@@ -33,7 +33,7 @@ grub_probe_SOURCES = gnulib/progname.c util/grub-probe.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/nilfs2.c fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c \ fs/sfs.c fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c \ - fs/afs_be.c fs/befs.c fs/befs_be.c fs/tar.c \ + fs/afs_be.c fs/befs.c fs/befs_be.c fs/tar.c fs/btrfs.c \ \ partmap/msdos.c partmap/bsdlabel.c partmap/apple.c \ partmap/sun.c partmap/sunpc.c partmap/gpt.c \
@@ -57,7 +57,7 @@ grub_fstest_SOURCES = gnulib/progname.c util/grub-fstest.c kern/emu/hostfs.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/nilfs2.c fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \ fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c fs/befs.c \ - fs/befs_be.c fs/tar.c \ + fs/befs_be.c fs/tar.c fs/btrfs.c \ \ kern/partition.c partmap/msdos.c partmap/bsdlabel.c \ partmap/apple.c partmap/sun.c partmap/sunpc.c partmap/gpt.c \
@@ -69,8 +69,7 @@ grub_fstest_SOURCES = gnulib/progname.c util/grub-fstest.c kern/emu/hostfs.c \ # For grub-mkfont. ifeq ($(enable_grub_mkfont), yes) bin_UTILITIES += grub-mkfont -grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c \ - unidata.c kern/emu/misc.c +grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c kern/emu/misc.c grub_mkfont_CFLAGS = $(freetype_cflags) grub_mkfont_LDFLAGS = $(freetype_libs) endif
@@ -96,7 +95,6 @@ grub_script_check_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c kern/misc.c kern/env.c grub_script.tab.c \ grub_script.yy.c grub_script_check_CFLAGS = $(GNULIB_UTIL_CFLAGS) -grub_script_check_DEPENDENCIES = grub_script.tab.h MOSTLYCLEANFILES += symlist.c kernel_syms.lst DEFSYMFILES += kernel_syms.lst
@@ -207,9 +205,6 @@ grub-mkconfig_SCRIPTS = 00_header 30_os-prober 40_custom 41_custom ifneq (, $(host_kernel)) grub-mkconfig_SCRIPTS += 10_$(host_kernel) endif -ifeq (linux, $(host_kernel)) -grub-mkconfig_SCRIPTS += 20_linux_xen -endif CLEANFILES += $(grub-mkconfig_SCRIPTS)
@@ -233,7 +228,7 @@ CLEANFILES += grub-reboot pkglib_MODULES += fshelp.mod fat.mod ufs1.mod ufs2.mod ext2.mod ntfs.mod \ ntfscomp.mod minix.mod hfs.mod jfs.mod iso9660.mod xfs.mod \ affs.mod sfs.mod hfsplus.mod reiserfs.mod cpio.mod tar.mod \ - udf.mod afs.mod afs_be.mod befs.mod befs_be.mod + udf.mod afs.mod afs_be.mod befs.mod befs_be.mod btrfs.mod # For fshelp.mod. fshelp_mod_SOURCES = fs/fshelp.c
@@ -356,6 +351,12 @@ befs_be_mod_SOURCES = fs/befs_be.c befs_be_mod_CFLAGS = $(COMMON_CFLAGS) befs_be_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For btrfs.mod. +btrfs_mod_SOURCES = fs/btrfs.c +btrfs_mod_CFLAGS = $(COMMON_CFLAGS) +btrfs_mod_CFLAGS += -fno-strict-aliasing +btrfs_mod_LDFLAGS = $(COMMON_LDFLAGS) + # Partition maps. pkglib_MODULES += part_amiga.mod
@@ -442,7 +443,7 @@ scsi_mod_LDFLAGS = $(COMMON_LDFLAGS) pkglib_MODULES += minicmd.mod extcmd.mod hello.mod \ ls.mod cmp.mod cat.mod help.mod search.mod loopback.mod \ configfile.mod echo.mod \ - test.mod blocklist.mod hexdump.mod \ + terminfo.mod test.mod blocklist.mod hexdump.mod \ read.mod sleep.mod loadenv.mod crc.mod parttool.mod \ msdospart.mod memrw.mod normal.mod \ gptsync.mod true.mod probe.mod password.mod \
@@ -491,8 +492,7 @@ gfxmenu_mod_SOURCES = \ gfxmenu/gui_progress_bar.c \ gfxmenu/gui_util.c \ gfxmenu/gui_string_util.c \ - gfxmenu/named_colors.c \ - gfxmenu/font.c + gfxmenu/named_colors.c gfxmenu_mod_CFLAGS = $(COMMON_CFLAGS) gfxmenu_mod_LDFLAGS = $(COMMON_LDFLAGS)
@@ -568,13 +568,10 @@ configfile_mod_SOURCES = commands/configfile.c configfile_mod_CFLAGS = $(COMMON_CFLAGS) configfile_mod_LDFLAGS = $(COMMON_LDFLAGS) -ifneq ($(platform), ieee1275) # For terminfo.mod. -pkglib_MODULES += terminfo.mod terminfo_mod_SOURCES = term/terminfo.c term/tparm.c terminfo_mod_CFLAGS = $(COMMON_CFLAGS) terminfo_mod_LDFLAGS = $(COMMON_LDFLAGS) -endif # For blocklist.mod. blocklist_mod_SOURCES = commands/blocklist.c
@@ -627,15 +624,12 @@ keystatus_mod_CFLAGS = $(COMMON_CFLAGS) keystatus_mod_LDFLAGS = $(COMMON_LDFLAGS) # For normal.mod. -ifneq (, $(FONT_SOURCE)) -normal/charset.c_DEPENDENCIES = widthspec.h -endif normal_mod_SOURCES = normal/main.c normal/cmdline.c normal/dyncmd.c \ normal/auth.c normal/autofs.c \ normal/color.c normal/completion.c normal/datetime.c normal/menu.c \ - normal/menu_entry.c normal/menu_text.c normal/charset.c \ + normal/menu_entry.c normal/menu_text.c \ normal/misc.c normal/crypto.c normal/term.c normal/context.c \ - script/main.c script/script.c script/execute.c unidata.c \ + script/main.c script/script.c script/execute.c \ script/function.c script/lexer.c grub_script.tab.c grub_script.yy.c normal_mod_CFLAGS = $(COMMON_CFLAGS) $(POSIX_CFLAGS) -Wno-error normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
@@ -709,6 +703,7 @@ png_mod_SOURCES = video/readers/png.c png_mod_CFLAGS = $(COMMON_CFLAGS) png_mod_LDFLAGS = $(COMMON_LDFLAGS) + # Misc. pkglib_MODULES += gzio.mod elf.mod
@@ -762,6 +757,11 @@ setjmp_mod_SOURCES = lib/$(target_cpu)/setjmp.S setjmp_mod_ASFLAGS = $(COMMON_ASFLAGS) setjmp_mod_LDFLAGS = $(COMMON_LDFLAGS) +pkglib_MODULES += charset.mod +charset_mod_SOURCES = lib/charset.c +charset_mod_CFLAGS = $(COMMON_CFLAGS) +charset_mod_LDFLAGS = $(COMMON_LDFLAGS) + pkglib_MODULES += regexp.mod regexp_mod_SOURCES = gnulib/regex.c commands/regexp.c regexp_mod_CFLAGS = $(COMMON_CFLAGS) $(GNULIB_CFLAGS)
conf/i386-pc.rmk +2 -2
@@ -73,7 +73,7 @@ grub_setup_SOURCES = gnulib/progname.c util/i386/pc/grub-setup.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/nilfs2.c fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c \ fs/sfs.c fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c \ - fs/afs_be.c fs/befs.c fs/befs_be.c fs/tar.c \ + fs/afs_be.c fs/befs.c fs/befs_be.c fs/tar.c fs/btrfs.c \ \ partmap/msdos.c partmap/bsdlabel.c partmap/sunpc.c \ partmap/gpt.c \
@@ -147,7 +147,7 @@ linux_mod_CFLAGS = $(COMMON_CFLAGS) linux_mod_LDFLAGS = $(COMMON_LDFLAGS) pkglib_MODULES += xnu.mod -xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c \ +xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/pc/xnu.c \ loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c xnu_mod_CFLAGS = $(COMMON_CFLAGS) xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
conf/sparc64-ieee1275.rmk +2 -3
@@ -31,8 +31,7 @@ kernel_img_SOURCES = kern/sparc64/ieee1275/crt0.S kern/ieee1275/cmain.c \ kern/sparc64/ieee1275/init.c \ kern/ieee1275/mmap.c \ term/ieee1275/ofconsole.c \ - kern/ieee1275/openfw.c term/terminfo.c term/tparm.c \ - disk/ieee1275/ofdisk.c \ + kern/ieee1275/openfw.c disk/ieee1275/ofdisk.c \ kern/parser.c kern/partition.c kern/env.c kern/$(target_cpu)/dl.c \ kern/generic/millisleep.c kern/time.c \ symlist.c kern/$(target_cpu)/cache.S
@@ -57,7 +56,7 @@ grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c \ fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \ fs/nilfs2.c fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c \ fs/sfs.c fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c \ - fs/afs_be.c fs/befs.c fs/befs_be.c fs/tar.c \ + fs/afs_be.c fs/befs.c fs/befs_be.c fs/tar.c fs/btrfs.c \ \ partmap/amiga.c partmap/apple.c partmap/msdos.c \ partmap/bsdlabel.c partmap/sun.c partmap/acorn.c \
Signature · 1 line
1.7.0.4
From 39b8bbd853911fa0ea91265744b19779c24128b8 Mon Sep 17 00:00:00 2001
Message-Id: <39b8bbd853911fa0ea91265744b19779c24128b8.1278336083.git.Surbhi.Palande@canonical.com>
In-Reply-To: <[email protected]>
References: <[email protected]>
From: surbhi <[email protected]>
Date: Mon, 5 Jul 2010 15:22:28 +0300
Subject: [PATCH 2/2] btrfs support for grub-2
This patch is usable provided the license for this patch resolves to GPLv3.
--- fs/btrfs.c | 1434 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/btrfs.h | 385 ++++++++++++++++ 2 files changed, 1819 insertions(+), 0 deletions(-) create mode 100644 fs/btrfs.c create mode 100644 fs/btrfs.h
fs/btrfs.c new file +1434 -0
1,434 lines not on this page · raw message
fs/btrfs.h new file +385 -0
385 lines not on this page · raw message
Signature · 1 line
1.7.0.4