From 703ab2a890d3b7ae3122c0fd04ef4777237f7bbd Mon Sep 17 00:00:00 2001
From: Joerg Schirottke <master@kanotix.com>
Date: Wed, 25 Jun 2014 00:44:28 +0200
Subject: btrfs fixes and lzo support

---
 backend/modules/hdmap        | 12 ++++++++++--
 backend/modules/install_main | 11 ++++++++---
 backend/modules/partitions   |  4 ++--
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/backend/modules/hdmap b/backend/modules/hdmap
index ee447b4..ed872bf 100644
--- a/backend/modules/hdmap
+++ b/backend/modules/hdmap
@@ -246,15 +246,23 @@ function prepare_partitions_for_install()
 	emit_progress 0
         local progress_steps=$(( $(wc -l <<<"$cfg_hdmap") ))
 	local progress=0
+    local mountoptions=""
 	while IFS=: read device mountpoint filesystem automount
 	do	
                 [ -z "$mountpoint" ] && continue
 
 		[ "$1" != "--nomount" ] && umount_all_affected $device
-		
+	    
+        mountoptions=""
+        if [ "$filesystem" = "btrfs-lzo" ]; then
+            filesystem="btrfs"
+            mountoptions="-o compress=lzo"
+        fi
+
 		# format device with filesystem (if specified)
 		if [ "$filesystem" ]; then
 			
+            wipefs -a $device # clean all old signatures
 			dd if=/dev/zero of=$device bs=1k count=16 >/dev/null 2>/dev/null # shutup! :-)
 			
 			TMP=/tmp/mkfs.$$
@@ -296,7 +304,7 @@ function prepare_partitions_for_install()
 		#                          (or 4. the mountpoint is a special one that always should be mounted [/boot/efi])
 		if [ "$automount" = "auto" -a "$1" != "--nomount" ] && [ -d "/live/filesystem$mountpoint" -o "$mountpoint" = "/boot/efi" ]; then
 			# mount device to mountpoint
-			EC="$(LC_ALL=C mount $device ${TARGET}${mountpoint} 2>&1)"
+			EC="$(LC_ALL=C mount $mountoptions $device ${TARGET}${mountpoint} 2>&1)"
 			if (($?)); then
 				case "$EC" in
 				"*already mounted*") # then let's try "mount --bind"
diff --git a/backend/modules/install_main b/backend/modules/install_main
index e7629a0..275415c 100644
--- a/backend/modules/install_main
+++ b/backend/modules/install_main
@@ -66,10 +66,15 @@ EOF
 		if [ "$mountpoint" = "/" ]; then
 			fstab_pass=1
 			case $fstab_type in
-                        btrfs)
+            btrfs)
 				fstab_options="defaults"
-                                fstab_pass=0
-                                ;;
+                fstab_pass=0
+                ;;
+            btrfs-lzo)
+                fstab_options="defaults,compress=lzo"
+                fstab_pass=0
+                fstab_type="btrfs"
+                ;;
 			reiser*|xfs|jfs)
 				fstab_options="defaults"
 				;;
diff --git a/backend/modules/partitions b/backend/modules/partitions
index eac5e6f..4ea9b55 100644
--- a/backend/modules/partitions
+++ b/backend/modules/partitions
@@ -299,7 +299,7 @@ function send_possible_root_partitions()
 function send_possible_root_filesystems()
 {
 	send data possible_root_filesystems
-	for fs in ext4 ext3 reiserfs btrfs xfs jfs; do echo $fs; done
+	for fs in ext4 ext3 reiserfs btrfs btrfs-lzo xfs jfs; do echo $fs; done
 }
 
 # Synopsis: get_filesystem <device>
@@ -332,7 +332,7 @@ function get_filesystem_type()
                 filesystem="$(get_filesystem "$1")"
         fi
         case $filesystem in
-        ext4|ext3|ext2|reiserfs|xfs|minix|hfs|efs|reiser4|jfs|btrfs) echo Linux;;
+        ext4|ext3|ext2|reiserfs|xfs|minix|hfs|efs|reiser4|jfs|btrfs*) echo Linux;;
         iso9660) echo CD-ROM;;
         vfat) echo DOS;;
         ntfs) echo Windows;;
-- 
cgit v1.0