diff --git a/parted-btrfs-support.patch b/parted-btrfs-support.patch new file mode 100644 index 0000000..d1b2b52 --- /dev/null +++ b/parted-btrfs-support.patch @@ -0,0 +1,215 @@ +commit 85e5fcd1bb0fe91d8908e8a638e9827979b6feff +Author: Luca Bruno +Date: Thu Feb 12 15:15:30 2009 +0100 + + Initial btrfs support, only recognize it for now + + Add initial btrfs support to libparted; just discovering + the declared magic entry at the right place to recognize + filesystem type, for the moment. + + Signed-off-by: Luca Bruno + +--- + configure.ac | 4 - + libparted/fs/Makefile.am | 3 - + libparted/fs/btrfs/Makefile.am | 8 ++ + libparted/fs/btrfs/btrfs.c | 110 +++++++++++++++++++++++++++++++++++++++++ + libparted/libparted.c | 4 + + 5 files changed, 126 insertions(+), 3 deletions(-) + +Index: parted-2.4/configure.ac +=================================================================== +@@ -626,6 +625,7 @@ libparted/Makefile + libparted/labels/Makefile + libparted/fs/Makefile + libparted/fs/amiga/Makefile ++libparted/fs/btrfs/Makefile + libparted/fs/ext2/Makefile + libparted/fs/fat/Makefile + libparted/fs/hfs/Makefile +Index: parted-2.4/libparted/fs/Makefile.am +=================================================================== +--- parted-2.4.orig/libparted/fs/Makefile.am ++++ parted-2.4/libparted/fs/Makefile.am +@@ -4,7 +4,7 @@ + # This file may be modified and/or distributed without restriction. + + SUBDIRS = amiga ext2 ufs fat ntfs hfs linux_swap xfs jfs reiserfs \ +- nilfs2 # bfs ++ nilfs2 btrfs # bfs + + partedincludedir = -I$(top_srcdir)/include + noinst_LTLIBRARIES = libfs.la +@@ -25,6 +25,7 @@ libfs_la_LIBADD = $(UUID_LIBS) \ + xfs/libxfs.la \ + jfs/libjfs.la \ + reiserfs/libreiserfs.la \ ++ btrfs/libbtrfs.la \ + nilfs2/libnilfs2.la + # bfs/libbfs.la + +Index: parted-2.4/libparted/fs/btrfs/Makefile.am +=================================================================== +--- /dev/null ++++ parted-2.4/libparted/fs/btrfs/Makefile.am +@@ -0,0 +1,8 @@ ++partedincludedir = -I$(top_srcdir)/include ++ ++noinst_LTLIBRARIES = libbtrfs.la ++libbtrfs_la_SOURCES = btrfs.c ++ ++INCLUDES = $(partedincludedir) $(INTLINCS) ++ ++MAINTAINERCLEANFILES = Makefile.in +Index: parted-2.4/libparted/fs/btrfs/btrfs.c +=================================================================== +--- /dev/null ++++ parted-2.4/libparted/fs/btrfs/btrfs.c +@@ -0,0 +1,110 @@ ++/* ++ libparted - a library for manipulating disk partitions ++ Copyright (C) 2009 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . ++*/ ++ ++#include ++ ++#include ++#include ++ ++#if ENABLE_NLS ++# include ++# define _(String) dgettext (PACKAGE, String) ++#else ++# define _(String) (String) ++#endif /* ENABLE_NLS */ ++ ++#include ++ ++#define BTRFS_BLOCK_SIZES ((int[2]){1024, 0}) ++#define BTRFS_SUPER_INFO_SIZE 4096 ++#define BTRFS_SUPER_INFO_OFFSET (64 * 1024) ++ ++//Should be definitive, as of v0.18 ++#define BTRFS_SIGNATURE 0x4D5F53665248425F ++ ++static PedGeometry* ++btrfs_probe (PedGeometry* geom) ++{ ++ char buf[BTRFS_SUPER_INFO_SIZE]; ++ ++ uint64_t magic; ++ ++ if (!ped_geometry_read (geom, buf, ++ (BTRFS_SUPER_INFO_OFFSET / 512), ++ (BTRFS_SUPER_INFO_SIZE / 512))) ++ return 0; ++ ++ memcpy(&magic, buf + 64, sizeof(uint64_t)); ++ ++ if (magic == PED_CPU_TO_LE64(BTRFS_SIGNATURE)) ++ return ped_geometry_new (geom->dev, geom->start, geom->length); ++ else ++ return NULL; ++} ++ ++#ifndef DISCOVER_ONLY ++static int ++btrfs_clobber (PedGeometry* geom) ++{ ++ char buf[BTRFS_SUPER_INFO_SIZE]; ++ ++ memset (buf, 0, BTRFS_SUPER_INFO_SIZE); ++ return ped_geometry_write (geom, buf, ++ (BTRFS_SUPER_INFO_OFFSET / 512), ++ (BTRFS_SUPER_INFO_SIZE / 512)); ++} ++#endif /* !DISCOVER_ONLY */ ++ ++static PedFileSystemOps btrfs_ops = { ++ probe: btrfs_probe, ++#ifndef DISCOVER_ONLY ++ clobber: btrfs_clobber, ++#else ++ clobber: NULL, ++#endif ++ open: NULL, ++ create: NULL, ++ close: NULL, ++ check: NULL, ++ copy: NULL, ++ resize: NULL, ++ get_create_constraint: NULL, ++ get_resize_constraint: NULL, ++ get_copy_constraint: NULL ++}; ++ ++static PedFileSystemType btrfs_type = { ++ next: NULL, ++ ops: &btrfs_ops, ++ name: "btrfs", ++ block_sizes: BTRFS_BLOCK_SIZES ++}; ++ ++void ++ped_file_system_btrfs_init () ++{ ++ ped_file_system_type_register (&btrfs_type); ++} ++ ++void ++ped_file_system_btrfs_done () ++{ ++ ped_file_system_type_unregister (&btrfs_type); ++} ++ ++ +Index: parted-2.4/libparted/libparted.c +=================================================================== +--- parted-2.4.orig/libparted/libparted.c ++++ parted-2.4/libparted/libparted.c +@@ -110,6 +110,7 @@ extern void ped_file_system_hfs_init (vo + extern void ped_file_system_fat_init (void); + extern void ped_file_system_ext2_init (void); + extern void ped_file_system_nilfs2_init (void); ++extern void ped_file_system_btrfs_init (void); + + static void + init_file_system_types () +@@ -125,6 +126,7 @@ init_file_system_types () + ped_file_system_fat_init (); + ped_file_system_ext2_init (); + ped_file_system_nilfs2_init (); ++ ped_file_system_btrfs_init (); + } + #endif /* ENABLE_FS */ + +@@ -191,6 +193,7 @@ extern void ped_file_system_ntfs_done (v + extern void ped_file_system_reiserfs_done (void); + extern void ped_file_system_ufs_done (void); + extern void ped_file_system_xfs_done (void); ++extern void ped_file_system_btrfs_done (void); + extern void ped_file_system_amiga_done (void); + + static void +@@ -206,6 +209,7 @@ done_file_system_types () + ped_file_system_reiserfs_done (); + ped_file_system_ufs_done (); + ped_file_system_xfs_done (); ++ ped_file_system_btrfs_done (); + ped_file_system_amiga_done (); + } + #endif /* ENABLE_FS */ diff --git a/parted-fix-gpt-sync-on-BE-systems.patch b/parted-fix-gpt-sync-on-BE-systems.patch new file mode 100644 index 0000000..2c1f31b --- /dev/null +++ b/parted-fix-gpt-sync-on-BE-systems.patch @@ -0,0 +1,33 @@ +--- + libparted/labels/gpt.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +Index: parted-2.4/libparted/labels/gpt.c +=================================================================== +--- parted-2.4.orig/libparted/labels/gpt.c ++++ parted-2.4/libparted/labels/gpt.c +@@ -1256,9 +1256,9 @@ _write_pmbr (const PedDisk *disk) + pmbr->PartitionRecord[pmbr_id].EndSector = 0xFF; + pmbr->PartitionRecord[pmbr_id].EndTrack = 0xFF; + pmbr->PartitionRecord[pmbr_id].StartingLBA = PED_CPU_TO_LE32(1); +- pmbr->PartitionRecord[pmbr_id].SizeInLBA = 1; ++ pmbr->PartitionRecord[pmbr_id].SizeInLBA = PED_CPU_TO_LE32 (1); + if (esp) +- pmbr->PartitionRecord[pmbr_id].SizeInLBA = esp->geom.end - 1; ++ pmbr->PartitionRecord[pmbr_id].SizeInLBA = PED_CPU_TO_LE32 (esp->geom.end - 1); + + /* sync the first 3 GPT entries to MBR primary partitions */ + for (i=first_entry; i < last_entry; i++) { +@@ -1284,10 +1284,10 @@ _write_pmbr (const PedDisk *disk) + pmbr->PartitionRecord[i].EndHead = 0xFE; + pmbr->PartitionRecord[i].EndSector = 0xFF; + pmbr->PartitionRecord[i].EndTrack = 0xFF; +- pmbr->PartitionRecord[i].StartingLBA = _part_32bitmax(part->geom.start); ++ pmbr->PartitionRecord[i].StartingLBA = PED_CPU_TO_LE32 (_part_32bitmax(part->geom.start)); + if(((GPTPartitionData*)part->disk_specific)->boot) + pmbr->PartitionRecord[i].BootIndicator = 0x80; +- pmbr->PartitionRecord[i].SizeInLBA = _part_32bitmax(part->geom.end - part->geom.start + 1); ++ pmbr->PartitionRecord[i].SizeInLBA = PED_CPU_TO_LE32 (_part_32bitmax(part->geom.end - part->geom.start + 1)); + } + } + int write_ok = ped_device_write (dev, pmbr, GPT_PMBR_LBA, diff --git a/parted.changes b/parted.changes index 64c2bf7..3085d50 100644 --- a/parted.changes +++ b/parted.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Mon Apr 22 15:06:02 UTC 2013 - puzel@suse.com + +- fix hybrid pMBR (gpt_sync_mbr) on BE systems (bnc#809205) + - parted-fix-gpt-sync-on-BE-systems.patch +- detect btrfs filesystem (bnc#810779) + - parted-btrfs-support.patch + ------------------------------------------------------------------- Mon Apr 15 12:24:12 UTC 2013 - idonmez@suse.com diff --git a/parted.spec b/parted.spec index 6b46916..70af6e5 100644 --- a/parted.spec +++ b/parted.spec @@ -50,6 +50,8 @@ Patch19: dummy-bootcode-only-for-x86.patch Patch20: parted-stdio.h.patch Patch21: parted-workaround-windows7-gpt-implementation.patch Patch22: fix-error-informing-the-kernel.patch +Patch23: parted-fix-gpt-sync-on-BE-systems.patch +Patch24: parted-btrfs-support.patch Requires: /sbin/udevadm BuildRequires: check-devel BuildRequires: device-mapper-devel >= 1.02.33 @@ -124,6 +126,8 @@ to develop applications that require these. %patch20 -p1 %patch21 -p1 %patch22 -p1 +%patch23 -p1 +%patch24 -p1 %build export CFLAGS="%{optflags} `ncursesw6-config --cflags`"