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
=== modified file '.pc/applied-patches'
--- .pc/applied-patches 2010-03-14 12:54:22 +0000
+++ .pc/applied-patches 2010-07-14 16:03:42 +0000
@@ -1,1 +1,2 @@
101_fix-desktop.patch101_fix-desktop.patch
202-btrfs.patch
23
=== modified file 'configure.in'
--- configure.in 2010-03-14 12:54:22 +0000
+++ configure.in 2010-07-14 16:03:42 +0000
@@ -170,6 +170,22 @@
170170
171AM_CONDITIONAL(DISABLE_DOC, test ${enable_doc} = no)171AM_CONDITIONAL(DISABLE_DOC, test ${enable_doc} = no)
172172
173dnl ******************************
174dnl Optional btrfs support
175dnl ******************************
176
177with_btrfs="yes"
178AC_ARG_ENABLE( btrfs,
179 AS_HELP_STRING([--enable-btrfs], [enable experimental btrfs support (enabled by default)]),
180 with_btrfs=$enableval)
181
182if test "x$with_btrfs" = "xyes"; then
183 AC_DEFINE(BTRFS_SUPPORT,1,[Build in btrfs support])
184else
185 with_btrfs="no"
186fi
187AM_CONDITIONAL(BTRFS_SUPPORT, test "x$with_btrfs" = "xyes")
188
173189
174AC_CONFIG_FILES([190AC_CONFIG_FILES([
175Makefile191Makefile
@@ -194,6 +210,8 @@
194echo "================ Final configuration ==================="210echo "================ Final configuration ==================="
195echo " Installing into prefix : $prefix"211echo " Installing into prefix : $prefix"
196echo ""212echo ""
213echo " Enable btrfs support? : $with_btrfs"
214echo ""
197echo " Build documentation? : $enable_doc"215echo " Build documentation? : $enable_doc"
198echo ""216echo ""
199echo " Need pt re-read work around? : $need_pt_reread_work_around"217echo " Need pt re-read work around? : $need_pt_reread_work_around"
200218
=== modified file 'debian/changelog'
--- debian/changelog 2010-03-22 13:10:57 +0000
+++ debian/changelog 2010-07-14 16:03:42 +0000
@@ -1,3 +1,10 @@
1gparted (0.5.2-2ubuntu1) maverick; urgency=low
2
3 * Added btrfs support (mkfs, fsck, show) to gparted. Original patch came
4 from https://bugzilla.gnome.org/attachment.cgi?id=128768 . (LP: #598946)
5
6 -- Surbhi Palande <surbhi.palande@canonical.com> Tue, 13 Jul 2010 16:57:36 +0300
7
1gparted (0.5.2-2) unstable; urgency=low8gparted (0.5.2-2) unstable; urgency=low
29
3 * Rebuild against parted 2.210 * Rebuild against parted 2.2
411
=== added file 'debian/patches/02-btrfs.patch'
--- debian/patches/02-btrfs.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/02-btrfs.patch 2010-07-14 16:03:42 +0000
@@ -0,0 +1,410 @@
1Index: b/configure.in
2===================================================================
3--- a/configure.in
4+++ b/configure.in
5@@ -170,6 +170,22 @@
6
7 AM_CONDITIONAL(DISABLE_DOC, test ${enable_doc} = no)
8
9+dnl ******************************
10+dnl Optional btrfs support
11+dnl ******************************
12+
13+with_btrfs="yes"
14+AC_ARG_ENABLE( btrfs,
15+ AS_HELP_STRING([--enable-btrfs], [enable experimental btrfs support (enabled by default)]),
16+ with_btrfs=$enableval)
17+
18+if test "x$with_btrfs" = "xyes"; then
19+ AC_DEFINE(BTRFS_SUPPORT,1,[Build in btrfs support])
20+else
21+ with_btrfs="no"
22+fi
23+AM_CONDITIONAL(BTRFS_SUPPORT, test "x$with_btrfs" = "xyes")
24+
25
26 AC_CONFIG_FILES([
27 Makefile
28@@ -194,6 +210,8 @@
29 echo "================ Final configuration ==================="
30 echo " Installing into prefix : $prefix"
31 echo ""
32+echo " Enable btrfs support? : $with_btrfs"
33+echo ""
34 echo " Build documentation? : $enable_doc"
35 echo ""
36 echo " Need pt re-read work around? : $need_pt_reread_work_around"
37Index: b/include/Makefile.am
38===================================================================
39--- a/include/Makefile.am
40+++ b/include/Makefile.am
41@@ -1,5 +1,9 @@
42 gparted_includedir = $(pkgincludedir)
43
44+if BTRFS_SUPPORT
45+btrfs_source = btrfs.h
46+endif
47+
48 EXTRA_DIST = \
49 Device.h \
50 Dialog_Base_Partition.h \
51@@ -48,4 +52,5 @@
52 reiser4.h \
53 reiserfs.h \
54 ufs.h \
55- xfs.h
56+ xfs.h \
57+ $(btrfs_source)
58Index: b/include/Utils.h
59===================================================================
60--- a/include/Utils.h
61+++ b/include/Utils.h
62@@ -66,11 +66,18 @@
63 FS_HFS = 15,
64 FS_HFSPLUS = 16,
65 FS_UFS = 17,
66+#if BTRFS_SUPPORT
67+ FS_BTRFS = 18,
68
69- FS_USED = 18,
70- FS_UNUSED = 19,
71+ FS_USED = 19,
72+ FS_UNUSED = 20,
73+#else
74+ FS_USED = 18,
75+ FS_UNUSED = 19,
76+
77+ FS_BTRFS = 20, /* FIXME: Move this higher up list when full support added */
78+#endif
79
80- FS_BTRFS = 20, /* FIXME: Move this higher up list when full support added */
81 FS_LVM2 = 21,
82 FS_LUKS = 22
83 } ;
84Index: b/include/btrfs.h
85===================================================================
86--- /dev/null
87+++ b/include/btrfs.h
88@@ -0,0 +1,42 @@
89+/* Copyright (C) 2009 Luca Bruno <lucab@debian.org>
90+ *
91+ * This program is free software; you can redistribute it and/or modify
92+ * it under the terms of the GNU General Public License as published by
93+ * the Free Software Foundation; either version 2 of the License, or
94+ * (at your option) any later version.
95+ *
96+ * This program is distributed in the hope that it will be useful,
97+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
98+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
99+ * GNU Library General Public License for more details.
100+ *
101+ * You should have received a copy of the GNU General Public License
102+ * along with this program; if not, write to the Free Software
103+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
104+ */
105+
106+
107+#ifndef BTRFS_H_
108+#define BTRFS_H_
109+
110+#include "../include/FileSystem.h"
111+
112+namespace GParted
113+{
114+class btrfs : public FileSystem
115+{
116+public:
117+ FS get_filesystem_support() ;
118+ void set_used_sectors( Partition & partition ) ;
119+ void read_label( Partition & partition ) ;
120+ bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
121+ bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
122+ bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
123+ bool copy( const Glib::ustring & src_part_path,
124+ const Glib::ustring & dest_part_path,
125+ OperationDetail & operationdetail ) ;
126+ bool check_repair( const Partition & partition, OperationDetail & operationdetail ) ;
127+};
128+} //GParted
129+
130+#endif //BTRFS_H_
131Index: b/src/GParted_Core.cc
132===================================================================
133--- a/src/GParted_Core.cc
134+++ b/src/GParted_Core.cc
135@@ -27,6 +27,7 @@
136 #include "../include/OperationFormat.h"
137 #include "../include/OperationResizeMove.h"
138 #include "../include/OperationLabelPartition.h"
139+#include "../config.h"
140
141 #include "../include/ext2.h"
142 #include "../include/ext3.h"
143@@ -42,7 +43,9 @@
144 #include "../include/hfsplus.h"
145 #include "../include/reiser4.h"
146 #include "../include/ufs.h"
147-
148+#ifdef BTRFS_SUPPORT
149+#include "../include/btrfs.h"
150+#endif
151 #include <set>
152 #include <cerrno>
153 #include <cstring>
154@@ -127,12 +130,17 @@
155
156 xfs fs_xfs;
157 FILESYSTEMS .push_back( fs_xfs .get_filesystem_support() ) ;
158-
159+
160 FS *fs ;
161+#ifdef BTRFS_SUPPORT
162+ btrfs fs_btrfs;
163+ FILESYSTEMS .push_back( fs_btrfs .get_filesystem_support() ) ;
164+#else
165 //btrfs FIXME: Add full support when on-disk-format stabilized
166 fs = new( FS ) ;
167 fs ->filesystem = GParted::FS_BTRFS ;
168 FILESYSTEMS .push_back( * fs ) ;
169+#endif
170
171 //lvm2 physical volume -- not a file system
172 fs = new( FS ) ;
173@@ -972,26 +980,23 @@
174 if ( Glib::ustring( buf ) == "ReIsEr4" )
175 return GParted::FS_REISER4 ;
176
177- //lvm2
178- //NOTE: lvm2 is not a file system but we do wish to recognize the Physical Volume
179- char magic1[16] ;
180- char magic2[16] ;
181+#ifdef BTRFS_SUPPORT
182+ //btrfs
183+ //extemporaneus hack - patch already sent to parted (detection only, there too)
184+ #define BTRFS_SUPER_INFO_SIZE 4096
185+ #define BTRFS_SUPER_INFO_OFFSET (64 * 1024)
186+ #define BTRFS_SIGNATURE "_BHRfS_M"
187+
188+ char buf_btrfs[BTRFS_SUPER_INFO_SIZE];
189
190 ped_device_open( lp_device );
191- ped_geometry_read( & lp_partition ->geom, buf, 1, 1 ) ;
192- strncpy(magic1, buf+0, 8) ; magic1[8] = '\0' ; //set and terminate string
193- strncpy(magic2, buf+24, 4) ; magic2[4] = '\0' ; //set and terminate string
194+ if (ped_geometry_read( & lp_partition ->geom, buf_btrfs, \
195+ (BTRFS_SUPER_INFO_OFFSET / 512), \
196+ (BTRFS_SUPER_INFO_SIZE / 512)))
197+ if ( Glib::ustring( buf+64, strlen(BTRFS_SIGNATURE) ) == BTRFS_SIGNATURE)
198+ return GParted::FS_BTRFS;
199 ped_device_close( lp_device );
200-
201- if ( Glib::ustring( magic1 ) == "LABELONE"
202- && Glib::ustring( magic2 ) == "LVM2" )
203- {
204- temp = _( "Logical Volume Management is not yet supported." ) ;
205- temp += "\n" ;
206- partition_temp .messages .push_back( temp ) ;
207- return GParted::FS_LVM2 ;
208- }
209-
210+#else
211 //btrfs
212 const Sector BTRFS_SUPER_INFO_SIZE = 4096 ;
213 const Sector BTRFS_SUPER_INFO_OFFSET = (64 * 1024) ;
214@@ -1014,6 +1019,26 @@
215 partition_temp .messages .push_back( temp ) ;
216 return GParted::FS_BTRFS ;
217 }
218+#endif
219+ //lvm2
220+ //NOTE: lvm2 is not a file system but we do wish to recognize the Physical Volume
221+ char magic1[16] ;
222+ char magic2[16] ;
223+
224+ ped_device_open( lp_device );
225+ ped_geometry_read( & lp_partition ->geom, buf, 1, 1 ) ;
226+ strncpy(magic1, buf+0, 8) ; magic1[8] = '\0' ; //set and terminate string
227+ strncpy(magic2, buf+24, 4) ; magic2[4] = '\0' ; //set and terminate string
228+ ped_device_close( lp_device );
229+
230+ if ( Glib::ustring( magic1 ) == "LABELONE"
231+ && Glib::ustring( magic2 ) == "LVM2" )
232+ {
233+ temp = _( "Logical Volume Management is not yet supported." ) ;
234+ temp += "\n" ;
235+ partition_temp .messages .push_back( temp ) ;
236+ return GParted::FS_LVM2 ;
237+ }
238
239 //no file system found....
240 temp = _( "Unable to detect file system! Possible reasons are:" ) ;
241@@ -2599,7 +2624,9 @@
242 case FS_HFS : p_filesystem = new hfs() ; break ;
243 case FS_HFSPLUS : p_filesystem = new hfsplus() ; break ;
244 case FS_UFS : p_filesystem = new ufs() ; break ;
245-
246+#ifdef BTRFS_SUPPORT
247+ case FS_BTRFS : p_filesystem = new btrfs() ; break ;
248+#endif
249 default : p_filesystem = NULL ;
250 }
251
252Index: b/src/Makefile.am
253===================================================================
254--- a/src/Makefile.am
255+++ b/src/Makefile.am
256@@ -7,6 +7,10 @@
257
258 AM_CXXFLAGS = -Wall
259
260+if BTRFS_SUPPORT
261+btrfs_source = btrfs.cc
262+endif
263+
264 sbin_PROGRAMS = gpartedbin
265
266 gpartedbin_SOURCES = \
267@@ -57,7 +61,8 @@
268 reiser4.cc \
269 reiserfs.cc \
270 ufs.cc \
271- xfs.cc
272+ xfs.cc \
273+ $(btrfs_source)
274
275 gpartedbin_LDFLAGS = -lparted -lgthread-2.0
276
277Index: b/src/Utils.cc
278===================================================================
279--- a/src/Utils.cc
280+++ b/src/Utils.cc
281@@ -17,6 +17,7 @@
282 */
283
284 #include "../include/Utils.h"
285+#include "../config.h"
286
287 #include <sstream>
288 #include <iomanip>
289@@ -161,6 +162,9 @@
290 case FS_REISER4 : return "reiser4progs" ;
291 case FS_REISERFS : return "reiserfsprogs" ;
292 case FS_UFS : return "" ;
293+#ifdef BTRFS_SUPPORT
294+ case FS_BTRFS : return "btrfs-tools" ;
295+#endif
296 case FS_XFS : return "xfsprogs" ;
297
298 default : return "" ;
299Index: b/src/btrfs.cc
300===================================================================
301--- /dev/null
302+++ b/src/btrfs.cc
303@@ -0,0 +1,107 @@
304+/* Copyright (C) 2009 Luca Bruno <lucab@debian.org>
305+ *
306+ * This program is free software; you can redistribute it and/or modify
307+ * it under the terms of the GNU General Public License as published by
308+ * the Free Software Foundation; either version 2 of the License, or
309+ * (at your option) any later version.
310+ *
311+ * This program is distributed in the hope that it will be useful,
312+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
313+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
314+ * GNU Library General Public License for more details.
315+ *
316+ * You should have received a copy of the GNU General Public License
317+ * along with this program; if not, write to the Free Software
318+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
319+ */
320+
321+
322+#include "../include/btrfs.h"
323+
324+namespace GParted
325+{
326+
327+FS btrfs::get_filesystem_support()
328+{
329+ FS fs ;
330+ fs .filesystem = GParted::FS_BTRFS ;
331+
332+ if ( ! Glib::find_program_in_path( "btrfs-show" ) .empty() )
333+ {
334+ fs .read = GParted::FS::EXTERNAL ;
335+ fs .read_label = FS::EXTERNAL ;
336+ }
337+
338+ if ( ! Glib::find_program_in_path( "mkfs.btrfs" ) .empty() )
339+ fs .create = GParted::FS::EXTERNAL ;
340+
341+ if ( ! Glib::find_program_in_path( "btrfsck" ) .empty() )
342+ fs .check = GParted::FS::EXTERNAL ;
343+
344+ if ( fs .check )
345+ {
346+ fs .copy = GParted::FS::GPARTED ;
347+ fs .move = GParted::FS::GPARTED ;
348+ }
349+
350+ fs .MIN = 256 * MEBIBYTE ;
351+
352+ return fs ;
353+}
354+
355+bool btrfs::create( const Partition & new_partition, OperationDetail & operationdetail )
356+{
357+ return (! execute_command( "mkfs.btrfs -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) );
358+}
359+
360+bool btrfs::check_repair( const Partition & partition, OperationDetail & operationdetail )
361+{
362+ return (! execute_command( "btrfsck " + partition .get_path(), operationdetail )) ;
363+}
364+
365+void btrfs::set_used_sectors( Partition & partition )
366+{
367+// TODO
368+ return;
369+}
370+
371+bool btrfs::write_label( const Partition & partition, OperationDetail & operationdetail )
372+{
373+// TODO
374+ return true ;
375+}
376+
377+bool btrfs::copy( const Glib::ustring & src_part_path,
378+ const Glib::ustring & dest_part_path,
379+ OperationDetail & operationdetail )
380+{
381+// TODO
382+ return true ;
383+}
384+
385+bool btrfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
386+{
387+// TODO
388+ return true ;
389+}
390+
391+void btrfs::read_label( Partition & partition )
392+{
393+ if ( ! Utils::execute_command( "btrfs-show " + partition .get_path(), output, error, true ) )
394+ {
395+ partition .label = Utils::regexp_label( output, "^Label ([^\n\t]*)" ) ;
396+ }
397+ else
398+ {
399+ if ( ! output .empty() )
400+ partition .messages .push_back( output ) ;
401+
402+ if ( ! error .empty() )
403+ partition .messages .push_back( error ) ;
404+ }
405+
406+}
407+
408+} //GParted
409+
410+
0411
=== modified file 'debian/patches/series'
--- debian/patches/series 2009-11-07 20:00:00 +0000
+++ debian/patches/series 2010-07-14 16:03:42 +0000
@@ -1,1 +1,2 @@
101_fix-desktop.patch101_fix-desktop.patch
202-btrfs.patch
23
=== modified file 'include/Makefile.am'
--- include/Makefile.am 2009-12-15 12:06:03 +0000
+++ include/Makefile.am 2010-07-14 16:03:42 +0000
@@ -1,5 +1,9 @@
1gparted_includedir = $(pkgincludedir)1gparted_includedir = $(pkgincludedir)
22
3if BTRFS_SUPPORT
4btrfs_source = btrfs.h
5endif
6
3EXTRA_DIST = \7EXTRA_DIST = \
4 Device.h \8 Device.h \
5 Dialog_Base_Partition.h \9 Dialog_Base_Partition.h \
@@ -48,4 +52,5 @@
48 reiser4.h \52 reiser4.h \
49 reiserfs.h \53 reiserfs.h \
50 ufs.h \54 ufs.h \
51 xfs.h55 xfs.h \
56 $(btrfs_source)
5257
=== modified file 'include/Utils.h'
--- include/Utils.h 2010-01-27 12:50:10 +0000
+++ include/Utils.h 2010-07-14 16:03:42 +0000
@@ -66,11 +66,18 @@
66 FS_HFS = 15,66 FS_HFS = 15,
67 FS_HFSPLUS = 16,67 FS_HFSPLUS = 16,
68 FS_UFS = 17,68 FS_UFS = 17,
6969#if BTRFS_SUPPORT
70 FS_USED = 18,70 FS_BTRFS = 18,
71 FS_UNUSED = 19,71
7272 FS_USED = 19,
73 FS_BTRFS = 20, /* FIXME: Move this higher up list when full support added */73 FS_UNUSED = 20,
74#else
75 FS_USED = 18,
76 FS_UNUSED = 19,
77
78 FS_BTRFS = 20, /* FIXME: Move this higher up list when full support added */
79#endif
80
74 FS_LVM2 = 21,81 FS_LVM2 = 21,
75 FS_LUKS = 2282 FS_LUKS = 22
76} ;83} ;
7784
=== modified file 'src/GParted_Core.cc'
--- src/GParted_Core.cc 2010-03-14 12:54:22 +0000
+++ src/GParted_Core.cc 2010-07-14 16:03:42 +0000
@@ -27,6 +27,7 @@
27#include "../include/OperationFormat.h"27#include "../include/OperationFormat.h"
28#include "../include/OperationResizeMove.h"28#include "../include/OperationResizeMove.h"
29#include "../include/OperationLabelPartition.h"29#include "../include/OperationLabelPartition.h"
30#include "../config.h"
3031
31#include "../include/ext2.h"32#include "../include/ext2.h"
32#include "../include/ext3.h"33#include "../include/ext3.h"
@@ -42,7 +43,9 @@
42#include "../include/hfsplus.h"43#include "../include/hfsplus.h"
43#include "../include/reiser4.h"44#include "../include/reiser4.h"
44#include "../include/ufs.h"45#include "../include/ufs.h"
4546#ifdef BTRFS_SUPPORT
47#include "../include/btrfs.h"
48#endif
46#include <set>49#include <set>
47#include <cerrno>50#include <cerrno>
48#include <cstring>51#include <cstring>
@@ -127,12 +130,17 @@
127130
128 xfs fs_xfs;131 xfs fs_xfs;
129 FILESYSTEMS .push_back( fs_xfs .get_filesystem_support() ) ;132 FILESYSTEMS .push_back( fs_xfs .get_filesystem_support() ) ;
130133
131 FS *fs ;134 FS *fs ;
135#ifdef BTRFS_SUPPORT
136 btrfs fs_btrfs;
137 FILESYSTEMS .push_back( fs_btrfs .get_filesystem_support() ) ;
138#else
132 //btrfs FIXME: Add full support when on-disk-format stabilized139 //btrfs FIXME: Add full support when on-disk-format stabilized
133 fs = new( FS ) ;140 fs = new( FS ) ;
134 fs ->filesystem = GParted::FS_BTRFS ;141 fs ->filesystem = GParted::FS_BTRFS ;
135 FILESYSTEMS .push_back( * fs ) ;142 FILESYSTEMS .push_back( * fs ) ;
143#endif
136144
137 //lvm2 physical volume -- not a file system145 //lvm2 physical volume -- not a file system
138 fs = new( FS ) ;146 fs = new( FS ) ;
@@ -972,26 +980,23 @@
972 if ( Glib::ustring( buf ) == "ReIsEr4" )980 if ( Glib::ustring( buf ) == "ReIsEr4" )
973 return GParted::FS_REISER4 ;981 return GParted::FS_REISER4 ;
974982
975 //lvm2983#ifdef BTRFS_SUPPORT
976 //NOTE: lvm2 is not a file system but we do wish to recognize the Physical Volume984 //btrfs
977 char magic1[16] ;985 //extemporaneus hack - patch already sent to parted (detection only, there too)
978 char magic2[16] ;986 #define BTRFS_SUPER_INFO_SIZE 4096
987 #define BTRFS_SUPER_INFO_OFFSET (64 * 1024)
988 #define BTRFS_SIGNATURE "_BHRfS_M"
989
990 char buf_btrfs[BTRFS_SUPER_INFO_SIZE];
979991
980 ped_device_open( lp_device );992 ped_device_open( lp_device );
981 ped_geometry_read( & lp_partition ->geom, buf, 1, 1 ) ;993 if (ped_geometry_read( & lp_partition ->geom, buf_btrfs, \
982 strncpy(magic1, buf+0, 8) ; magic1[8] = '\0' ; //set and terminate string994 (BTRFS_SUPER_INFO_OFFSET / 512), \
983 strncpy(magic2, buf+24, 4) ; magic2[4] = '\0' ; //set and terminate string995 (BTRFS_SUPER_INFO_SIZE / 512)))
996 if ( Glib::ustring( buf+64, strlen(BTRFS_SIGNATURE) ) == BTRFS_SIGNATURE)
997 return GParted::FS_BTRFS;
984 ped_device_close( lp_device );998 ped_device_close( lp_device );
985999#else
986 if ( Glib::ustring( magic1 ) == "LABELONE"
987 && Glib::ustring( magic2 ) == "LVM2" )
988 {
989 temp = _( "Logical Volume Management is not yet supported." ) ;
990 temp += "\n" ;
991 partition_temp .messages .push_back( temp ) ;
992 return GParted::FS_LVM2 ;
993 }
994
995 //btrfs1000 //btrfs
996 const Sector BTRFS_SUPER_INFO_SIZE = 4096 ;1001 const Sector BTRFS_SUPER_INFO_SIZE = 4096 ;
997 const Sector BTRFS_SUPER_INFO_OFFSET = (64 * 1024) ;1002 const Sector BTRFS_SUPER_INFO_OFFSET = (64 * 1024) ;
@@ -1014,6 +1019,26 @@
1014 partition_temp .messages .push_back( temp ) ;1019 partition_temp .messages .push_back( temp ) ;
1015 return GParted::FS_BTRFS ;1020 return GParted::FS_BTRFS ;
1016 }1021 }
1022#endif
1023 //lvm2
1024 //NOTE: lvm2 is not a file system but we do wish to recognize the Physical Volume
1025 char magic1[16] ;
1026 char magic2[16] ;
1027
1028 ped_device_open( lp_device );
1029 ped_geometry_read( & lp_partition ->geom, buf, 1, 1 ) ;
1030 strncpy(magic1, buf+0, 8) ; magic1[8] = '\0' ; //set and terminate string
1031 strncpy(magic2, buf+24, 4) ; magic2[4] = '\0' ; //set and terminate string
1032 ped_device_close( lp_device );
1033
1034 if ( Glib::ustring( magic1 ) == "LABELONE"
1035 && Glib::ustring( magic2 ) == "LVM2" )
1036 {
1037 temp = _( "Logical Volume Management is not yet supported." ) ;
1038 temp += "\n" ;
1039 partition_temp .messages .push_back( temp ) ;
1040 return GParted::FS_LVM2 ;
1041 }
10171042
1018 //no file system found....1043 //no file system found....
1019 temp = _( "Unable to detect file system! Possible reasons are:" ) ;1044 temp = _( "Unable to detect file system! Possible reasons are:" ) ;
@@ -2599,7 +2624,9 @@
2599 case FS_HFS : p_filesystem = new hfs() ; break ;2624 case FS_HFS : p_filesystem = new hfs() ; break ;
2600 case FS_HFSPLUS : p_filesystem = new hfsplus() ; break ;2625 case FS_HFSPLUS : p_filesystem = new hfsplus() ; break ;
2601 case FS_UFS : p_filesystem = new ufs() ; break ;2626 case FS_UFS : p_filesystem = new ufs() ; break ;
26022627#ifdef BTRFS_SUPPORT
2628 case FS_BTRFS : p_filesystem = new btrfs() ; break ;
2629#endif
2603 default : p_filesystem = NULL ;2630 default : p_filesystem = NULL ;
2604 }2631 }
26052632
26062633
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2009-12-15 12:06:03 +0000
+++ src/Makefile.am 2010-07-14 16:03:42 +0000
@@ -7,6 +7,10 @@
77
8AM_CXXFLAGS = -Wall 8AM_CXXFLAGS = -Wall
99
10if BTRFS_SUPPORT
11btrfs_source = btrfs.cc
12endif
13
10sbin_PROGRAMS = gpartedbin14sbin_PROGRAMS = gpartedbin
1115
12gpartedbin_SOURCES = \16gpartedbin_SOURCES = \
@@ -57,7 +61,8 @@
57 reiser4.cc \61 reiser4.cc \
58 reiserfs.cc \62 reiserfs.cc \
59 ufs.cc \63 ufs.cc \
60 xfs.cc64 xfs.cc \
65 $(btrfs_source)
61 66
62gpartedbin_LDFLAGS = -lparted -lgthread-2.0 67gpartedbin_LDFLAGS = -lparted -lgthread-2.0
6368
6469
=== modified file 'src/Utils.cc'
--- src/Utils.cc 2010-03-14 12:54:22 +0000
+++ src/Utils.cc 2010-07-14 16:03:42 +0000
@@ -17,6 +17,7 @@
17 */17 */
1818
19#include "../include/Utils.h"19#include "../include/Utils.h"
20#include "../config.h"
2021
21#include <sstream>22#include <sstream>
22#include <iomanip>23#include <iomanip>
@@ -161,6 +162,9 @@
161 case FS_REISER4 : return "reiser4progs" ;162 case FS_REISER4 : return "reiser4progs" ;
162 case FS_REISERFS : return "reiserfsprogs" ;163 case FS_REISERFS : return "reiserfsprogs" ;
163 case FS_UFS : return "" ;164 case FS_UFS : return "" ;
165#ifdef BTRFS_SUPPORT
166 case FS_BTRFS : return "btrfs-tools" ;
167#endif
164 case FS_XFS : return "xfsprogs" ;168 case FS_XFS : return "xfsprogs" ;
165169
166 default : return "" ;170 default : return "" ;

Subscribers

People subscribed via source and target branches

to all changes: