Merge lp:~csurbhi/ubuntu/maverick/gparted/gparted.fix-598946 into lp:ubuntu/maverick/gparted

Proposed by Surbhi Palande
Status: Merged
Merged at revision: 24
Proposed branch: lp:~csurbhi/ubuntu/maverick/gparted/gparted.fix-598946
Merge into: lp:ubuntu/maverick/gparted
Diff against target: 696 lines (+512/-27)
10 files modified
.pc/applied-patches (+1/-0)
configure.in (+18/-0)
debian/changelog (+7/-0)
debian/patches/02-btrfs.patch (+410/-0)
debian/patches/series (+1/-0)
include/Makefile.am (+6/-1)
include/Utils.h (+12/-5)
src/GParted_Core.cc (+47/-20)
src/Makefile.am (+6/-1)
src/Utils.cc (+4/-0)
To merge this branch: bzr merge lp:~csurbhi/ubuntu/maverick/gparted/gparted.fix-598946
Reviewer Review Type Date Requested Status
Colin Watson Approve
Review via email: mp+29379@code.launchpad.net

Description of the change

This patch fixes the bug 598946 on LP. It adds the following btrfs support to gparted:
1) btrfs.mkfs
2) btrfs.fsck
3) btrfs-show
using the external btrfs-tools.

The original patch was fetched from https://bugzilla.gnome.org/show_bug.cgi?id=571170
It was slightly modified so as to keep the original support of btrfs detection intact. The original patch adds all the support in #if BTRFS_SUPPORT. Kept the original btrfs detection code in gparted in the #else part so as to allow btrfs partition from being detected even when gparted is compiled without BTRFS_SUPPORT = 1.
On the other hand when gparted is compiled with BTRFS_SUPPORT, the extra functionality along with detection is added.

Do consider merging this for maverick.

Thanks!

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

Thanks for working on this bug.

The gparted package uses the newish 3.0 (quilt) source package format,
according to debian/source/format, so you need to do a bit more than
applying the patch directly to the source tree. Follow the directions
in /usr/share/doc/quilt/README.source to set up .quiltrc; you might also
want to set QUILT_REFRESH_ARGS="--no-timestamps -p ab" or similar. Then
import your patch; the least error-prone way is probably to start from a
clean checkout of lp:ubuntu/gparted, run 'quilt new 02_btrfs.patch',
then 'quilt shell', make your changes, exit, and run 'quilt refresh'
(although there are other faster ways).

(Debian is converging on 3.0 (quilt), so it's a useful one to learn,
although many packages also use older patch systems so we still have to
be pretty flexible. There's a wrapper script in
lp:~mvo/+junk/edit-patch which may be useful.)

You'll need to 'bzr add' the new file under debian/patches/ at the end.
You should end up with a 'bzr diff' that shows both the raw changes and
a new file in debian/patches/ with those same changes (this may seem a
bit odd but it's a trade-off against other useful properties that I can
describe elsewhere if you're interested).

The patch changes configure.in, but not configure. I think you'll need
to run 'autoreconf' inside 'quilt shell' in order for this change to
take effect.

It seems a bit odd to have this support be configured by a configure
option, but I see that this was in one of the upstream patches so it's
not necessary to undo that. In any case, it looks like the current
state of your branch won't build it in by default. You should add
--enable-btrfs to the configure options in debian/rules (make this
change directly rather than as a quilt patch).

Revision history for this message
Surbhi Palande (csurbhi) wrote :

Created a new bzr branch with the above comments. This is kept at code.edge.launchpad.net/~csurbhi/ubuntu/maverick/gparted/gparted-fix.598946/
Shall delete this branch soon.

Revision history for this message
Surbhi Palande (csurbhi) wrote :

1) Changed the debian/patches/02-btrfs.patch with the correct quilt commands.
2) Changed the configure.in to enable btrfs support by default. To disable btrfs support, ./configure should be invoked with --enable-btrfs=no

Revision history for this message
Surbhi Palande (csurbhi) wrote :
24. By Surbhi Palande

Added btrfs support (mkfs, fsck, show) to gparted. Original patch came
from https://bugzilla.gnome.org/attachment.cgi?id=128768 . (LP: #598946)

Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.pc/applied-patches'
2--- .pc/applied-patches 2010-03-14 12:54:22 +0000
3+++ .pc/applied-patches 2010-07-14 16:03:42 +0000
4@@ -1,1 +1,2 @@
5 01_fix-desktop.patch
6+02-btrfs.patch
7
8=== modified file 'configure.in'
9--- configure.in 2010-03-14 12:54:22 +0000
10+++ configure.in 2010-07-14 16:03:42 +0000
11@@ -170,6 +170,22 @@
12
13 AM_CONDITIONAL(DISABLE_DOC, test ${enable_doc} = no)
14
15+dnl ******************************
16+dnl Optional btrfs support
17+dnl ******************************
18+
19+with_btrfs="yes"
20+AC_ARG_ENABLE( btrfs,
21+ AS_HELP_STRING([--enable-btrfs], [enable experimental btrfs support (enabled by default)]),
22+ with_btrfs=$enableval)
23+
24+if test "x$with_btrfs" = "xyes"; then
25+ AC_DEFINE(BTRFS_SUPPORT,1,[Build in btrfs support])
26+else
27+ with_btrfs="no"
28+fi
29+AM_CONDITIONAL(BTRFS_SUPPORT, test "x$with_btrfs" = "xyes")
30+
31
32 AC_CONFIG_FILES([
33 Makefile
34@@ -194,6 +210,8 @@
35 echo "================ Final configuration ==================="
36 echo " Installing into prefix : $prefix"
37 echo ""
38+echo " Enable btrfs support? : $with_btrfs"
39+echo ""
40 echo " Build documentation? : $enable_doc"
41 echo ""
42 echo " Need pt re-read work around? : $need_pt_reread_work_around"
43
44=== modified file 'debian/changelog'
45--- debian/changelog 2010-03-22 13:10:57 +0000
46+++ debian/changelog 2010-07-14 16:03:42 +0000
47@@ -1,3 +1,10 @@
48+gparted (0.5.2-2ubuntu1) maverick; urgency=low
49+
50+ * Added btrfs support (mkfs, fsck, show) to gparted. Original patch came
51+ from https://bugzilla.gnome.org/attachment.cgi?id=128768 . (LP: #598946)
52+
53+ -- Surbhi Palande <surbhi.palande@canonical.com> Tue, 13 Jul 2010 16:57:36 +0300
54+
55 gparted (0.5.2-2) unstable; urgency=low
56
57 * Rebuild against parted 2.2
58
59=== added file 'debian/patches/02-btrfs.patch'
60--- debian/patches/02-btrfs.patch 1970-01-01 00:00:00 +0000
61+++ debian/patches/02-btrfs.patch 2010-07-14 16:03:42 +0000
62@@ -0,0 +1,410 @@
63+Index: b/configure.in
64+===================================================================
65+--- a/configure.in
66++++ b/configure.in
67+@@ -170,6 +170,22 @@
68+
69+ AM_CONDITIONAL(DISABLE_DOC, test ${enable_doc} = no)
70+
71++dnl ******************************
72++dnl Optional btrfs support
73++dnl ******************************
74++
75++with_btrfs="yes"
76++AC_ARG_ENABLE( btrfs,
77++ AS_HELP_STRING([--enable-btrfs], [enable experimental btrfs support (enabled by default)]),
78++ with_btrfs=$enableval)
79++
80++if test "x$with_btrfs" = "xyes"; then
81++ AC_DEFINE(BTRFS_SUPPORT,1,[Build in btrfs support])
82++else
83++ with_btrfs="no"
84++fi
85++AM_CONDITIONAL(BTRFS_SUPPORT, test "x$with_btrfs" = "xyes")
86++
87+
88+ AC_CONFIG_FILES([
89+ Makefile
90+@@ -194,6 +210,8 @@
91+ echo "================ Final configuration ==================="
92+ echo " Installing into prefix : $prefix"
93+ echo ""
94++echo " Enable btrfs support? : $with_btrfs"
95++echo ""
96+ echo " Build documentation? : $enable_doc"
97+ echo ""
98+ echo " Need pt re-read work around? : $need_pt_reread_work_around"
99+Index: b/include/Makefile.am
100+===================================================================
101+--- a/include/Makefile.am
102++++ b/include/Makefile.am
103+@@ -1,5 +1,9 @@
104+ gparted_includedir = $(pkgincludedir)
105+
106++if BTRFS_SUPPORT
107++btrfs_source = btrfs.h
108++endif
109++
110+ EXTRA_DIST = \
111+ Device.h \
112+ Dialog_Base_Partition.h \
113+@@ -48,4 +52,5 @@
114+ reiser4.h \
115+ reiserfs.h \
116+ ufs.h \
117+- xfs.h
118++ xfs.h \
119++ $(btrfs_source)
120+Index: b/include/Utils.h
121+===================================================================
122+--- a/include/Utils.h
123++++ b/include/Utils.h
124+@@ -66,11 +66,18 @@
125+ FS_HFS = 15,
126+ FS_HFSPLUS = 16,
127+ FS_UFS = 17,
128++#if BTRFS_SUPPORT
129++ FS_BTRFS = 18,
130+
131+- FS_USED = 18,
132+- FS_UNUSED = 19,
133++ FS_USED = 19,
134++ FS_UNUSED = 20,
135++#else
136++ FS_USED = 18,
137++ FS_UNUSED = 19,
138++
139++ FS_BTRFS = 20, /* FIXME: Move this higher up list when full support added */
140++#endif
141+
142+- FS_BTRFS = 20, /* FIXME: Move this higher up list when full support added */
143+ FS_LVM2 = 21,
144+ FS_LUKS = 22
145+ } ;
146+Index: b/include/btrfs.h
147+===================================================================
148+--- /dev/null
149++++ b/include/btrfs.h
150+@@ -0,0 +1,42 @@
151++/* Copyright (C) 2009 Luca Bruno <lucab@debian.org>
152++ *
153++ * This program is free software; you can redistribute it and/or modify
154++ * it under the terms of the GNU General Public License as published by
155++ * the Free Software Foundation; either version 2 of the License, or
156++ * (at your option) any later version.
157++ *
158++ * This program is distributed in the hope that it will be useful,
159++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
160++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
161++ * GNU Library General Public License for more details.
162++ *
163++ * You should have received a copy of the GNU General Public License
164++ * along with this program; if not, write to the Free Software
165++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
166++ */
167++
168++
169++#ifndef BTRFS_H_
170++#define BTRFS_H_
171++
172++#include "../include/FileSystem.h"
173++
174++namespace GParted
175++{
176++class btrfs : public FileSystem
177++{
178++public:
179++ FS get_filesystem_support() ;
180++ void set_used_sectors( Partition & partition ) ;
181++ void read_label( Partition & partition ) ;
182++ bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
183++ bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
184++ bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
185++ bool copy( const Glib::ustring & src_part_path,
186++ const Glib::ustring & dest_part_path,
187++ OperationDetail & operationdetail ) ;
188++ bool check_repair( const Partition & partition, OperationDetail & operationdetail ) ;
189++};
190++} //GParted
191++
192++#endif //BTRFS_H_
193+Index: b/src/GParted_Core.cc
194+===================================================================
195+--- a/src/GParted_Core.cc
196++++ b/src/GParted_Core.cc
197+@@ -27,6 +27,7 @@
198+ #include "../include/OperationFormat.h"
199+ #include "../include/OperationResizeMove.h"
200+ #include "../include/OperationLabelPartition.h"
201++#include "../config.h"
202+
203+ #include "../include/ext2.h"
204+ #include "../include/ext3.h"
205+@@ -42,7 +43,9 @@
206+ #include "../include/hfsplus.h"
207+ #include "../include/reiser4.h"
208+ #include "../include/ufs.h"
209+-
210++#ifdef BTRFS_SUPPORT
211++#include "../include/btrfs.h"
212++#endif
213+ #include <set>
214+ #include <cerrno>
215+ #include <cstring>
216+@@ -127,12 +130,17 @@
217+
218+ xfs fs_xfs;
219+ FILESYSTEMS .push_back( fs_xfs .get_filesystem_support() ) ;
220+-
221++
222+ FS *fs ;
223++#ifdef BTRFS_SUPPORT
224++ btrfs fs_btrfs;
225++ FILESYSTEMS .push_back( fs_btrfs .get_filesystem_support() ) ;
226++#else
227+ //btrfs FIXME: Add full support when on-disk-format stabilized
228+ fs = new( FS ) ;
229+ fs ->filesystem = GParted::FS_BTRFS ;
230+ FILESYSTEMS .push_back( * fs ) ;
231++#endif
232+
233+ //lvm2 physical volume -- not a file system
234+ fs = new( FS ) ;
235+@@ -972,26 +980,23 @@
236+ if ( Glib::ustring( buf ) == "ReIsEr4" )
237+ return GParted::FS_REISER4 ;
238+
239+- //lvm2
240+- //NOTE: lvm2 is not a file system but we do wish to recognize the Physical Volume
241+- char magic1[16] ;
242+- char magic2[16] ;
243++#ifdef BTRFS_SUPPORT
244++ //btrfs
245++ //extemporaneus hack - patch already sent to parted (detection only, there too)
246++ #define BTRFS_SUPER_INFO_SIZE 4096
247++ #define BTRFS_SUPER_INFO_OFFSET (64 * 1024)
248++ #define BTRFS_SIGNATURE "_BHRfS_M"
249++
250++ char buf_btrfs[BTRFS_SUPER_INFO_SIZE];
251+
252+ ped_device_open( lp_device );
253+- ped_geometry_read( & lp_partition ->geom, buf, 1, 1 ) ;
254+- strncpy(magic1, buf+0, 8) ; magic1[8] = '\0' ; //set and terminate string
255+- strncpy(magic2, buf+24, 4) ; magic2[4] = '\0' ; //set and terminate string
256++ if (ped_geometry_read( & lp_partition ->geom, buf_btrfs, \
257++ (BTRFS_SUPER_INFO_OFFSET / 512), \
258++ (BTRFS_SUPER_INFO_SIZE / 512)))
259++ if ( Glib::ustring( buf+64, strlen(BTRFS_SIGNATURE) ) == BTRFS_SIGNATURE)
260++ return GParted::FS_BTRFS;
261+ ped_device_close( lp_device );
262+-
263+- if ( Glib::ustring( magic1 ) == "LABELONE"
264+- && Glib::ustring( magic2 ) == "LVM2" )
265+- {
266+- temp = _( "Logical Volume Management is not yet supported." ) ;
267+- temp += "\n" ;
268+- partition_temp .messages .push_back( temp ) ;
269+- return GParted::FS_LVM2 ;
270+- }
271+-
272++#else
273+ //btrfs
274+ const Sector BTRFS_SUPER_INFO_SIZE = 4096 ;
275+ const Sector BTRFS_SUPER_INFO_OFFSET = (64 * 1024) ;
276+@@ -1014,6 +1019,26 @@
277+ partition_temp .messages .push_back( temp ) ;
278+ return GParted::FS_BTRFS ;
279+ }
280++#endif
281++ //lvm2
282++ //NOTE: lvm2 is not a file system but we do wish to recognize the Physical Volume
283++ char magic1[16] ;
284++ char magic2[16] ;
285++
286++ ped_device_open( lp_device );
287++ ped_geometry_read( & lp_partition ->geom, buf, 1, 1 ) ;
288++ strncpy(magic1, buf+0, 8) ; magic1[8] = '\0' ; //set and terminate string
289++ strncpy(magic2, buf+24, 4) ; magic2[4] = '\0' ; //set and terminate string
290++ ped_device_close( lp_device );
291++
292++ if ( Glib::ustring( magic1 ) == "LABELONE"
293++ && Glib::ustring( magic2 ) == "LVM2" )
294++ {
295++ temp = _( "Logical Volume Management is not yet supported." ) ;
296++ temp += "\n" ;
297++ partition_temp .messages .push_back( temp ) ;
298++ return GParted::FS_LVM2 ;
299++ }
300+
301+ //no file system found....
302+ temp = _( "Unable to detect file system! Possible reasons are:" ) ;
303+@@ -2599,7 +2624,9 @@
304+ case FS_HFS : p_filesystem = new hfs() ; break ;
305+ case FS_HFSPLUS : p_filesystem = new hfsplus() ; break ;
306+ case FS_UFS : p_filesystem = new ufs() ; break ;
307+-
308++#ifdef BTRFS_SUPPORT
309++ case FS_BTRFS : p_filesystem = new btrfs() ; break ;
310++#endif
311+ default : p_filesystem = NULL ;
312+ }
313+
314+Index: b/src/Makefile.am
315+===================================================================
316+--- a/src/Makefile.am
317++++ b/src/Makefile.am
318+@@ -7,6 +7,10 @@
319+
320+ AM_CXXFLAGS = -Wall
321+
322++if BTRFS_SUPPORT
323++btrfs_source = btrfs.cc
324++endif
325++
326+ sbin_PROGRAMS = gpartedbin
327+
328+ gpartedbin_SOURCES = \
329+@@ -57,7 +61,8 @@
330+ reiser4.cc \
331+ reiserfs.cc \
332+ ufs.cc \
333+- xfs.cc
334++ xfs.cc \
335++ $(btrfs_source)
336+
337+ gpartedbin_LDFLAGS = -lparted -lgthread-2.0
338+
339+Index: b/src/Utils.cc
340+===================================================================
341+--- a/src/Utils.cc
342++++ b/src/Utils.cc
343+@@ -17,6 +17,7 @@
344+ */
345+
346+ #include "../include/Utils.h"
347++#include "../config.h"
348+
349+ #include <sstream>
350+ #include <iomanip>
351+@@ -161,6 +162,9 @@
352+ case FS_REISER4 : return "reiser4progs" ;
353+ case FS_REISERFS : return "reiserfsprogs" ;
354+ case FS_UFS : return "" ;
355++#ifdef BTRFS_SUPPORT
356++ case FS_BTRFS : return "btrfs-tools" ;
357++#endif
358+ case FS_XFS : return "xfsprogs" ;
359+
360+ default : return "" ;
361+Index: b/src/btrfs.cc
362+===================================================================
363+--- /dev/null
364++++ b/src/btrfs.cc
365+@@ -0,0 +1,107 @@
366++/* Copyright (C) 2009 Luca Bruno <lucab@debian.org>
367++ *
368++ * This program is free software; you can redistribute it and/or modify
369++ * it under the terms of the GNU General Public License as published by
370++ * the Free Software Foundation; either version 2 of the License, or
371++ * (at your option) any later version.
372++ *
373++ * This program is distributed in the hope that it will be useful,
374++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
375++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376++ * GNU Library General Public License for more details.
377++ *
378++ * You should have received a copy of the GNU General Public License
379++ * along with this program; if not, write to the Free Software
380++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
381++ */
382++
383++
384++#include "../include/btrfs.h"
385++
386++namespace GParted
387++{
388++
389++FS btrfs::get_filesystem_support()
390++{
391++ FS fs ;
392++ fs .filesystem = GParted::FS_BTRFS ;
393++
394++ if ( ! Glib::find_program_in_path( "btrfs-show" ) .empty() )
395++ {
396++ fs .read = GParted::FS::EXTERNAL ;
397++ fs .read_label = FS::EXTERNAL ;
398++ }
399++
400++ if ( ! Glib::find_program_in_path( "mkfs.btrfs" ) .empty() )
401++ fs .create = GParted::FS::EXTERNAL ;
402++
403++ if ( ! Glib::find_program_in_path( "btrfsck" ) .empty() )
404++ fs .check = GParted::FS::EXTERNAL ;
405++
406++ if ( fs .check )
407++ {
408++ fs .copy = GParted::FS::GPARTED ;
409++ fs .move = GParted::FS::GPARTED ;
410++ }
411++
412++ fs .MIN = 256 * MEBIBYTE ;
413++
414++ return fs ;
415++}
416++
417++bool btrfs::create( const Partition & new_partition, OperationDetail & operationdetail )
418++{
419++ return (! execute_command( "mkfs.btrfs -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) );
420++}
421++
422++bool btrfs::check_repair( const Partition & partition, OperationDetail & operationdetail )
423++{
424++ return (! execute_command( "btrfsck " + partition .get_path(), operationdetail )) ;
425++}
426++
427++void btrfs::set_used_sectors( Partition & partition )
428++{
429++// TODO
430++ return;
431++}
432++
433++bool btrfs::write_label( const Partition & partition, OperationDetail & operationdetail )
434++{
435++// TODO
436++ return true ;
437++}
438++
439++bool btrfs::copy( const Glib::ustring & src_part_path,
440++ const Glib::ustring & dest_part_path,
441++ OperationDetail & operationdetail )
442++{
443++// TODO
444++ return true ;
445++}
446++
447++bool btrfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
448++{
449++// TODO
450++ return true ;
451++}
452++
453++void btrfs::read_label( Partition & partition )
454++{
455++ if ( ! Utils::execute_command( "btrfs-show " + partition .get_path(), output, error, true ) )
456++ {
457++ partition .label = Utils::regexp_label( output, "^Label ([^\n\t]*)" ) ;
458++ }
459++ else
460++ {
461++ if ( ! output .empty() )
462++ partition .messages .push_back( output ) ;
463++
464++ if ( ! error .empty() )
465++ partition .messages .push_back( error ) ;
466++ }
467++
468++}
469++
470++} //GParted
471++
472++
473
474=== modified file 'debian/patches/series'
475--- debian/patches/series 2009-11-07 20:00:00 +0000
476+++ debian/patches/series 2010-07-14 16:03:42 +0000
477@@ -1,1 +1,2 @@
478 01_fix-desktop.patch
479+02-btrfs.patch
480
481=== modified file 'include/Makefile.am'
482--- include/Makefile.am 2009-12-15 12:06:03 +0000
483+++ include/Makefile.am 2010-07-14 16:03:42 +0000
484@@ -1,5 +1,9 @@
485 gparted_includedir = $(pkgincludedir)
486
487+if BTRFS_SUPPORT
488+btrfs_source = btrfs.h
489+endif
490+
491 EXTRA_DIST = \
492 Device.h \
493 Dialog_Base_Partition.h \
494@@ -48,4 +52,5 @@
495 reiser4.h \
496 reiserfs.h \
497 ufs.h \
498- xfs.h
499+ xfs.h \
500+ $(btrfs_source)
501
502=== modified file 'include/Utils.h'
503--- include/Utils.h 2010-01-27 12:50:10 +0000
504+++ include/Utils.h 2010-07-14 16:03:42 +0000
505@@ -66,11 +66,18 @@
506 FS_HFS = 15,
507 FS_HFSPLUS = 16,
508 FS_UFS = 17,
509-
510- FS_USED = 18,
511- FS_UNUSED = 19,
512-
513- FS_BTRFS = 20, /* FIXME: Move this higher up list when full support added */
514+#if BTRFS_SUPPORT
515+ FS_BTRFS = 18,
516+
517+ FS_USED = 19,
518+ FS_UNUSED = 20,
519+#else
520+ FS_USED = 18,
521+ FS_UNUSED = 19,
522+
523+ FS_BTRFS = 20, /* FIXME: Move this higher up list when full support added */
524+#endif
525+
526 FS_LVM2 = 21,
527 FS_LUKS = 22
528 } ;
529
530=== modified file 'src/GParted_Core.cc'
531--- src/GParted_Core.cc 2010-03-14 12:54:22 +0000
532+++ src/GParted_Core.cc 2010-07-14 16:03:42 +0000
533@@ -27,6 +27,7 @@
534 #include "../include/OperationFormat.h"
535 #include "../include/OperationResizeMove.h"
536 #include "../include/OperationLabelPartition.h"
537+#include "../config.h"
538
539 #include "../include/ext2.h"
540 #include "../include/ext3.h"
541@@ -42,7 +43,9 @@
542 #include "../include/hfsplus.h"
543 #include "../include/reiser4.h"
544 #include "../include/ufs.h"
545-
546+#ifdef BTRFS_SUPPORT
547+#include "../include/btrfs.h"
548+#endif
549 #include <set>
550 #include <cerrno>
551 #include <cstring>
552@@ -127,12 +130,17 @@
553
554 xfs fs_xfs;
555 FILESYSTEMS .push_back( fs_xfs .get_filesystem_support() ) ;
556-
557+
558 FS *fs ;
559+#ifdef BTRFS_SUPPORT
560+ btrfs fs_btrfs;
561+ FILESYSTEMS .push_back( fs_btrfs .get_filesystem_support() ) ;
562+#else
563 //btrfs FIXME: Add full support when on-disk-format stabilized
564 fs = new( FS ) ;
565 fs ->filesystem = GParted::FS_BTRFS ;
566 FILESYSTEMS .push_back( * fs ) ;
567+#endif
568
569 //lvm2 physical volume -- not a file system
570 fs = new( FS ) ;
571@@ -972,26 +980,23 @@
572 if ( Glib::ustring( buf ) == "ReIsEr4" )
573 return GParted::FS_REISER4 ;
574
575- //lvm2
576- //NOTE: lvm2 is not a file system but we do wish to recognize the Physical Volume
577- char magic1[16] ;
578- char magic2[16] ;
579+#ifdef BTRFS_SUPPORT
580+ //btrfs
581+ //extemporaneus hack - patch already sent to parted (detection only, there too)
582+ #define BTRFS_SUPER_INFO_SIZE 4096
583+ #define BTRFS_SUPER_INFO_OFFSET (64 * 1024)
584+ #define BTRFS_SIGNATURE "_BHRfS_M"
585+
586+ char buf_btrfs[BTRFS_SUPER_INFO_SIZE];
587
588 ped_device_open( lp_device );
589- ped_geometry_read( & lp_partition ->geom, buf, 1, 1 ) ;
590- strncpy(magic1, buf+0, 8) ; magic1[8] = '\0' ; //set and terminate string
591- strncpy(magic2, buf+24, 4) ; magic2[4] = '\0' ; //set and terminate string
592+ if (ped_geometry_read( & lp_partition ->geom, buf_btrfs, \
593+ (BTRFS_SUPER_INFO_OFFSET / 512), \
594+ (BTRFS_SUPER_INFO_SIZE / 512)))
595+ if ( Glib::ustring( buf+64, strlen(BTRFS_SIGNATURE) ) == BTRFS_SIGNATURE)
596+ return GParted::FS_BTRFS;
597 ped_device_close( lp_device );
598-
599- if ( Glib::ustring( magic1 ) == "LABELONE"
600- && Glib::ustring( magic2 ) == "LVM2" )
601- {
602- temp = _( "Logical Volume Management is not yet supported." ) ;
603- temp += "\n" ;
604- partition_temp .messages .push_back( temp ) ;
605- return GParted::FS_LVM2 ;
606- }
607-
608+#else
609 //btrfs
610 const Sector BTRFS_SUPER_INFO_SIZE = 4096 ;
611 const Sector BTRFS_SUPER_INFO_OFFSET = (64 * 1024) ;
612@@ -1014,6 +1019,26 @@
613 partition_temp .messages .push_back( temp ) ;
614 return GParted::FS_BTRFS ;
615 }
616+#endif
617+ //lvm2
618+ //NOTE: lvm2 is not a file system but we do wish to recognize the Physical Volume
619+ char magic1[16] ;
620+ char magic2[16] ;
621+
622+ ped_device_open( lp_device );
623+ ped_geometry_read( & lp_partition ->geom, buf, 1, 1 ) ;
624+ strncpy(magic1, buf+0, 8) ; magic1[8] = '\0' ; //set and terminate string
625+ strncpy(magic2, buf+24, 4) ; magic2[4] = '\0' ; //set and terminate string
626+ ped_device_close( lp_device );
627+
628+ if ( Glib::ustring( magic1 ) == "LABELONE"
629+ && Glib::ustring( magic2 ) == "LVM2" )
630+ {
631+ temp = _( "Logical Volume Management is not yet supported." ) ;
632+ temp += "\n" ;
633+ partition_temp .messages .push_back( temp ) ;
634+ return GParted::FS_LVM2 ;
635+ }
636
637 //no file system found....
638 temp = _( "Unable to detect file system! Possible reasons are:" ) ;
639@@ -2599,7 +2624,9 @@
640 case FS_HFS : p_filesystem = new hfs() ; break ;
641 case FS_HFSPLUS : p_filesystem = new hfsplus() ; break ;
642 case FS_UFS : p_filesystem = new ufs() ; break ;
643-
644+#ifdef BTRFS_SUPPORT
645+ case FS_BTRFS : p_filesystem = new btrfs() ; break ;
646+#endif
647 default : p_filesystem = NULL ;
648 }
649
650
651=== modified file 'src/Makefile.am'
652--- src/Makefile.am 2009-12-15 12:06:03 +0000
653+++ src/Makefile.am 2010-07-14 16:03:42 +0000
654@@ -7,6 +7,10 @@
655
656 AM_CXXFLAGS = -Wall
657
658+if BTRFS_SUPPORT
659+btrfs_source = btrfs.cc
660+endif
661+
662 sbin_PROGRAMS = gpartedbin
663
664 gpartedbin_SOURCES = \
665@@ -57,7 +61,8 @@
666 reiser4.cc \
667 reiserfs.cc \
668 ufs.cc \
669- xfs.cc
670+ xfs.cc \
671+ $(btrfs_source)
672
673 gpartedbin_LDFLAGS = -lparted -lgthread-2.0
674
675
676=== modified file 'src/Utils.cc'
677--- src/Utils.cc 2010-03-14 12:54:22 +0000
678+++ src/Utils.cc 2010-07-14 16:03:42 +0000
679@@ -17,6 +17,7 @@
680 */
681
682 #include "../include/Utils.h"
683+#include "../config.h"
684
685 #include <sstream>
686 #include <iomanip>
687@@ -161,6 +162,9 @@
688 case FS_REISER4 : return "reiser4progs" ;
689 case FS_REISERFS : return "reiserfsprogs" ;
690 case FS_UFS : return "" ;
691+#ifdef BTRFS_SUPPORT
692+ case FS_BTRFS : return "btrfs-tools" ;
693+#endif
694 case FS_XFS : return "xfsprogs" ;
695
696 default : return "" ;

Subscribers

People subscribed via source and target branches

to all changes: