Merge lp:~psusi/ubuntu/quantal/gparted/drop-swraid into lp:ubuntu/quantal/gparted

Proposed by Phillip Susi
Status: Work in progress
Proposed branch: lp:~psusi/ubuntu/quantal/gparted/drop-swraid
Merge into: lp:ubuntu/quantal/gparted
Diff against target: 5384 lines (+5022/-181)
20 files modified
.pc/applied-patches (+1/-0)
.pc/drop-swraid.patch/README (+192/-0)
.pc/drop-swraid.patch/include/Makefile.am (+59/-0)
.pc/drop-swraid.patch/include/SWRaid.h (+55/-0)
.pc/drop-swraid.patch/src/GParted_Core.cc (+3398/-0)
.pc/drop-swraid.patch/src/Makefile.am (+78/-0)
.pc/drop-swraid.patch/src/Makefile.in (+700/-0)
.pc/drop-swraid.patch/src/Proc_Partitions_Info.cc (+134/-0)
.pc/drop-swraid.patch/src/SWRaid.cc (+104/-0)
README (+0/-4)
debian/changelog (+8/-0)
debian/patches/drop-swraid.patch (+286/-0)
debian/patches/series (+1/-0)
include/Makefile.am (+0/-1)
include/SWRaid.h (+0/-55)
src/GParted_Core.cc (+0/-12)
src/Makefile.am (+0/-1)
src/Makefile.in (+1/-3)
src/Proc_Partitions_Info.cc (+5/-1)
src/SWRaid.cc (+0/-104)
To merge this branch: bzr merge lp:~psusi/ubuntu/quantal/gparted/drop-swraid
Reviewer Review Type Date Requested Status
Ubuntu branches Pending
Review via email: mp+143168@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Michael Terry (mterry) wrote :

This has been uploaded to quantal by laney (though still in the queue), so this does not need sponsor attention. However, I can't remove it from the sponsor page because I can't mark this as a Work In Progress.

Unmerged revisions

49. By Phillip Susi

debian/patches/drop-swraid.patch: Upstream patch to remove broken and
uneeded swraid support that was causing errors with mdadm devices
(LP: #1074606).

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 2012-06-14 10:00:43 +0000
3+++ .pc/applied-patches 2013-01-14 18:58:25 +0000
4@@ -1,2 +1,3 @@
5 01_fix-desktop.patch
6 02_use-pkexec.patch
7+drop-swraid.patch
8
9=== added directory '.pc/drop-swraid.patch'
10=== added file '.pc/drop-swraid.patch/.timestamp'
11=== added file '.pc/drop-swraid.patch/README'
12--- .pc/drop-swraid.patch/README 1970-01-01 00:00:00 +0000
13+++ .pc/drop-swraid.patch/README 2013-01-14 18:58:25 +0000
14@@ -0,0 +1,192 @@
15+GPARTED
16+=======
17+Gparted is the Gnome Partition Editor for creating, reorganizing, and
18+deleting disk partitions.
19+
20+A hard disk is usually subdivided into one or more partitions. These
21+partitions are normally not re-sizable (making one smaller and the
22+adjacent one larger.) Gparted makes it possible for you to take a
23+hard disk and change the partition organization, while preserving the
24+partition contents.
25+
26+More specifically, Gparted enables you to create, destroy, resize,
27+move, check, label, and copy partitions, and the file systems
28+contained within. This is useful for creating space for new operating
29+systems, reorganizing disk usage, and mirroring one partition with
30+another (disk imaging).
31+
32+Gparted can also be used with storage devices other than hard disks,
33+such as USB flash drives, and memory cards.
34+
35+Visit http://gparted.org for more information.
36+
37+
38+NEWS
39+----
40+Information about changes to this release, and past releases can be
41+found in the file:
42+ NEWS
43+
44+
45+INSTALL
46+-------
47+a. Pre-built Binary
48+
49+ Many GNU/Linux distributions already provide a pre-built binary
50+ package for GParted. Instructions on how to install GParted on
51+ some distributions is given below:
52+
53+ (K)Ubuntu or Debian
54+ -------------------
55+ sudo apt-get install gparted
56+
57+ Fedora
58+ ------
59+ su -
60+ yum install gparted
61+
62+b. Building from Source
63+
64+ Building Gparted from source requires that several dependencies are
65+ installed. These include:
66+ g++
67+ e2fsprogs
68+ parted
69+ gtkmm24
70+ gettext
71+ gnome-doc-utils - required if help documentation is to be built
72+
73+ On (K)Ubuntu, these dependencies may be obtained by running the
74+ following command;
75+ sudo apt-get install build-essential e2fsprogs uuid uuid-dev \
76+ gnome-common libparted-dev libgtkmm-2.4-dev \
77+ libdevmapper-dev gnome-doc-utils
78+
79+ On Fedora, you will need to run (as root);
80+ yum install gtkmm24-devel parted-devel e2fsprogs-devel gettext \
81+ 'perl(XML::Parser)' desktop-file-utils libuuid-devel \
82+ gnome-doc-utils rarian-compat
83+ yum groupinstall 'Development Tools'
84+
85+ On openSUSE, these dependencies may be obtained by running the
86+ following command;
87+ sudo zypper install automake autoconf gcc-g++ make gnome-common \
88+ libuuid-devel parted-devel gtkmm2-devel \
89+ gnome-doc-utils-devel
90+
91+ Briefly, the shell commands `./configure; make; make install' should
92+ configure, build, and install this package.
93+
94+ If you wish to build this package without the help documentation use
95+ the --disable-doc flag:
96+ E.g., ./configure --disable-doc
97+
98+ If you wish to build this package for use on a desktop that does not
99+ support scrollkeeper use the --disable-scrollkeeper flag:
100+ E.g., ./configure --disable-scrollkeeper
101+
102+ If you wish to build this package to use native libparted /dev/mapper
103+ dmraid support use the --enable-libparted-dmraid flag:
104+ E.g., ./configure --enable-libparted-dmraid
105+
106+ Please note that more than one configure flags can be used:
107+ E.g., ./configure --disable-doc --enable-libparted-dmraid
108+
109+ The INSTALL file contains further GNU installation instructions.
110+
111+
112+COPYING
113+-------
114+The copying conditions can be found in the file:
115+ COPYING
116+
117+
118+DIRECTORIES
119+------------
120+compose - contains String::ucompose() function
121+
122+data - contains desktop icons
123+
124+doc - contains manual page documentation
125+
126+help - contains GParted Manual and international translations
127+
128+include - contains source header files
129+
130+m4 - contains macro files
131+
132+po - contains international language translations
133+
134+src - contains C++ source code
135+
136+
137+DISTRIBUTION NOTES
138+------------------
139+Gparted uses GNU libparted to detect and manipulate devices and partition
140+tables. Several optional packages provide additional file system support.
141+Optional packages include:
142+
143+ btrfs-tools
144+ e2fsprogs
145+ dosfstools
146+ mtools - required to read and write FAT16/32 volume labels and UUIDs
147+ hfsutils
148+ hfsprogs
149+ jfsutils
150+ nilfs-utils
151+ ntfsprogs / ntfs-3g
152+ reiser4progs
153+ reiserfsprogs
154+ xfsprogs, xfsdump
155+
156+ NOTE: * If the vol_id command is in the search PATH, it will be used
157+ to read linux-swap, reiser4, hfs, and hfs+ file system
158+ volume labels.
159+ * If the blkid command is in the search path, it will be used
160+ to read file system UUIDs and labels. It is also used for
161+ ext4 file system detection.
162+ blkid is part of the util-linux package and e2fsprogs
163+ package before that.
164+
165+
166+For Linux software RAID support, the following package is required:
167+ mdadm - tool to administer Linux MD arrays
168+
169+
170+For dmraid support, the following packages are required:
171+
172+ dmsetup - removes /dev/mapper entries
173+ dmraid - lists dmraid devices and creates /dev/mapper entries
174+
175+For GNU/Linux distribution dmraid support, the following are required:
176+ - kernel built with Device Mapping and Mirroring built. From menuconfig,
177+ it is under Device Drivers -> <something> (RAID & LVM).
178+ - dmraid drive arrays activated on boot (e.g., dmraid -ay).
179+
180+
181+For LVM2 Physical Volume support the following command is required:
182+ lvm - LVM2 administration tool
183+And device-mapper support in the kernel.
184+
185+
186+For attempt data rescue for lost partitions, the following package
187+is required:
188+ gpart - guesses PC-type hard disk partitions
189+
190+
191+Several more commands are optionally used by GParted if found on the system.
192+These commands include:
193+
194+ blkid - used to read volume labels and detect ext4 file systems
195+ vol_id - used to read volume labels
196+ udisks - used to prevent automounting of file systems
197+ devkit-disks - used to prevent automounting of file systems
198+ {filemanager} - used in attempt data rescue to display discovered
199+ file systems. (e.g., nautilus, pcmanfm)
200+ hal-lock - used to prevent automounting of file systems
201+ gksu - used to acquire root privileges in .desktop file,
202+ but only if available when gparted source is configured.
203+ udevinfo - used in dmraid to query udev name
204+ udevadm - used in dmraid to query udev name
205+ yelp - used to display help manual
206+
207
208=== added directory '.pc/drop-swraid.patch/include'
209=== added file '.pc/drop-swraid.patch/include/Makefile.am'
210--- .pc/drop-swraid.patch/include/Makefile.am 1970-01-01 00:00:00 +0000
211+++ .pc/drop-swraid.patch/include/Makefile.am 2013-01-14 18:58:25 +0000
212@@ -0,0 +1,59 @@
213+gparted_includedir = $(pkgincludedir)
214+
215+EXTRA_DIST = \
216+ Device.h \
217+ Dialog_Base_Partition.h \
218+ Dialog_Disklabel.h \
219+ Dialog_Rescue_Data.h \
220+ Dialog_Partition_Copy.h \
221+ Dialog_Partition_Info.h \
222+ Dialog_Partition_Label.h \
223+ Dialog_Partition_New.h \
224+ Dialog_Partition_Resize_Move.h \
225+ Dialog_Progress.h \
226+ DialogFeatures.h \
227+ DialogManageFlags.h \
228+ DrawingAreaVisualDisk.h \
229+ DMRaid.h \
230+ FileSystem.h \
231+ Frame_Resizer_Base.h \
232+ Frame_Resizer_Extended.h \
233+ FS_Info.h \
234+ GParted_Core.h \
235+ HBoxOperations.h \
236+ LVM2_PV_Info.h \
237+ Operation.h \
238+ OperationCopy.h \
239+ OperationCheck.h \
240+ OperationCreate.h \
241+ OperationDelete.h \
242+ OperationDetail.h \
243+ OperationFormat.h \
244+ OperationResizeMove.h \
245+ OperationChangeUUID.h \
246+ OperationLabelPartition.h \
247+ Partition.h \
248+ Proc_Partitions_Info.h \
249+ SWRaid.h \
250+ TreeView_Detail.h \
251+ Utils.h \
252+ Win_GParted.h \
253+ btrfs.h \
254+ exfat.h \
255+ ext2.h \
256+ ext3.h \
257+ ext4.h \
258+ fat16.h \
259+ fat32.h \
260+ hfs.h \
261+ hfsplus.h \
262+ i18n.h \
263+ jfs.h \
264+ linux_swap.h \
265+ lvm2_pv.h \
266+ nilfs2.h \
267+ ntfs.h \
268+ reiser4.h \
269+ reiserfs.h \
270+ ufs.h \
271+ xfs.h
272
273=== added file '.pc/drop-swraid.patch/include/SWRaid.h'
274--- .pc/drop-swraid.patch/include/SWRaid.h 1970-01-01 00:00:00 +0000
275+++ .pc/drop-swraid.patch/include/SWRaid.h 2013-01-14 18:58:25 +0000
276@@ -0,0 +1,55 @@
277+/* Copyright (C) 2009 Curtis Gedak
278+ *
279+ * This program is free software; you can redistribute it and/or modify
280+ * it under the terms of the GNU General Public License as published by
281+ * the Free Software Foundation; either version 2 of the License, or
282+ * (at your option) any later version.
283+ *
284+ * This program is distributed in the hope that it will be useful,
285+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
286+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
287+ * GNU Library General Public License for more details.
288+ *
289+ * You should have received a copy of the GNU General Public License
290+ * along with this program; if not, write to the Free Software
291+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
292+ */
293+
294+/* READ THIS!
295+ * This class was created in an effort to reduce the complexity of the
296+ * GParted_Core class.
297+ * This class provides support for Linux software RAID devices (mdadm).
298+ * Static elements are used in order to reduce the disk accesses required to
299+ * load the data structures upon each initialization of the class.
300+ */
301+
302+#ifndef SWRAID_H_
303+#define SWRAID_H_
304+
305+#include "../include/Utils.h"
306+
307+#include <vector>
308+
309+namespace GParted
310+{
311+
312+
313+class SWRaid
314+{
315+public:
316+ SWRaid() ;
317+ SWRaid( const bool & do_refresh ) ;
318+ ~SWRaid() ;
319+ bool is_swraid_supported() ;
320+ void get_devices( std::vector<Glib::ustring> & swraid_devices ) ;
321+private:
322+ void load_swraid_cache() ;
323+ void set_commands_found() ;
324+ static bool swraid_cache_initialized ;
325+ static bool mdadm_found ;
326+ static std::vector<Glib::ustring> swraid_devices ;
327+};
328+
329+}//GParted
330+
331+#endif /* SWRAID_H_ */
332
333=== added directory '.pc/drop-swraid.patch/src'
334=== added file '.pc/drop-swraid.patch/src/GParted_Core.cc'
335--- .pc/drop-swraid.patch/src/GParted_Core.cc 1970-01-01 00:00:00 +0000
336+++ .pc/drop-swraid.patch/src/GParted_Core.cc 2013-01-14 18:58:25 +0000
337@@ -0,0 +1,3398 @@
338+/* Copyright (C) 2004 Bart 'plors' Hakvoort
339+ * Copyright (C) 2008, 2009, 2010, 2011, 2012 Curtis Gedak
340+ *
341+ * This program is free software; you can redistribute it and/or modify
342+ * it under the terms of the GNU General Public License as published by
343+ * the Free Software Foundation; either version 2 of the License, or
344+ * (at your option) any later version.
345+ *
346+ * This program is distributed in the hope that it will be useful,
347+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
348+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
349+ * GNU Library General Public License for more details.
350+ *
351+ * You should have received a copy of the GNU General Public License
352+ * along with this program; if not, write to the Free Software
353+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
354+ */
355+
356+#include "../include/Win_GParted.h"
357+#include "../include/GParted_Core.h"
358+#include "../include/DMRaid.h"
359+#include "../include/SWRaid.h"
360+#include "../include/FS_Info.h"
361+#include "../include/LVM2_PV_Info.h"
362+#include "../include/OperationCopy.h"
363+#include "../include/OperationCreate.h"
364+#include "../include/OperationDelete.h"
365+#include "../include/OperationFormat.h"
366+#include "../include/OperationResizeMove.h"
367+#include "../include/OperationChangeUUID.h"
368+#include "../include/OperationLabelPartition.h"
369+#include "../include/Proc_Partitions_Info.h"
370+
371+#include "../include/btrfs.h"
372+#include "../include/exfat.h"
373+#include "../include/ext2.h"
374+#include "../include/ext3.h"
375+#include "../include/ext4.h"
376+#include "../include/fat16.h"
377+#include "../include/fat32.h"
378+#include "../include/linux_swap.h"
379+#include "../include/lvm2_pv.h"
380+#include "../include/reiserfs.h"
381+#include "../include/nilfs2.h"
382+#include "../include/ntfs.h"
383+#include "../include/xfs.h"
384+#include "../include/jfs.h"
385+#include "../include/hfs.h"
386+#include "../include/hfsplus.h"
387+#include "../include/reiser4.h"
388+#include "../include/ufs.h"
389+#include <set>
390+#include <cerrno>
391+#include <cstring>
392+#include <sys/statvfs.h>
393+#include <sys/types.h>
394+#include <sys/stat.h>
395+#include <unistd.h>
396+#include <dirent.h>
397+#include <mntent.h>
398+#include <gtkmm/messagedialog.h>
399+
400+std::vector<Glib::ustring> libparted_messages ; //see ped_exception_handler()
401+
402+namespace GParted
403+{
404+
405+GParted_Core::GParted_Core()
406+{
407+ lp_device = NULL ;
408+ lp_disk = NULL ;
409+ lp_partition = NULL ;
410+ p_filesystem = NULL ;
411+ thread_status_message = "" ;
412+
413+ ped_exception_set_handler( ped_exception_handler ) ;
414+
415+ //get valid flags ...
416+ for ( PedPartitionFlag flag = ped_partition_flag_next( static_cast<PedPartitionFlag>( NULL ) ) ;
417+ flag ;
418+ flag = ped_partition_flag_next( flag ) )
419+ flags .push_back( flag ) ;
420+
421+ //throw libpartedversion to the stdout to see which version is actually used.
422+ std::cout << "======================" << std::endl ;
423+ std::cout << "libparted : " << ped_get_version() << std::endl ;
424+ std::cout << "======================" << std::endl ;
425+
426+ //initialize file system list
427+ find_supported_filesystems() ;
428+}
429+
430+void GParted_Core::find_supported_filesystems()
431+{
432+ std::map< FILESYSTEM, FileSystem * >::iterator f ;
433+
434+ // TODO: determine whether it is safe to initialize this only once
435+ for ( f = FILESYSTEM_MAP .begin() ; f != FILESYSTEM_MAP .end() ; f++ ) {
436+ if ( f ->second )
437+ delete f ->second ;
438+ }
439+
440+ FILESYSTEM_MAP .clear() ;
441+
442+ FILESYSTEM_MAP[ FS_BTRFS ] = new btrfs() ;
443+ FILESYSTEM_MAP[ FS_EXFAT ] = new exfat() ;
444+ FILESYSTEM_MAP[ FS_EXT2 ] = new ext2() ;
445+ FILESYSTEM_MAP[ FS_EXT3 ] = new ext3() ;
446+ FILESYSTEM_MAP[ FS_EXT4 ] = new ext4() ;
447+ FILESYSTEM_MAP[ FS_FAT16 ] = new fat16() ;
448+ FILESYSTEM_MAP[ FS_FAT32 ] = new fat32() ;
449+ FILESYSTEM_MAP[ FS_HFS ] = new hfs() ;
450+ FILESYSTEM_MAP[ FS_HFSPLUS ] = new hfsplus() ;
451+ FILESYSTEM_MAP[ FS_JFS ] = new jfs() ;
452+ FILESYSTEM_MAP[ FS_LINUX_SWAP ] = new linux_swap() ;
453+ FILESYSTEM_MAP[ FS_LVM2_PV ] = new lvm2_pv() ;
454+ FILESYSTEM_MAP[ FS_NILFS2 ] = new nilfs2() ;
455+ FILESYSTEM_MAP[ FS_NTFS ] = new ntfs() ;
456+ FILESYSTEM_MAP[ FS_REISER4 ] = new reiser4() ;
457+ FILESYSTEM_MAP[ FS_REISERFS ] = new reiserfs() ;
458+ FILESYSTEM_MAP[ FS_UFS ] = new ufs() ;
459+ FILESYSTEM_MAP[ FS_XFS ] = new xfs() ;
460+ FILESYSTEM_MAP[ FS_LUKS ] = NULL ;
461+ FILESYSTEM_MAP[ FS_UNKNOWN ] = NULL ;
462+
463+ FILESYSTEMS .clear() ;
464+
465+ FS fs_notsupp;
466+ for ( f = FILESYSTEM_MAP .begin() ; f != FILESYSTEM_MAP .end() ; f++ ) {
467+ if ( f ->second )
468+ FILESYSTEMS .push_back( f ->second ->get_filesystem_support() ) ;
469+ else {
470+ fs_notsupp .filesystem = f ->first ;
471+ FILESYSTEMS .push_back( fs_notsupp ) ;
472+ }
473+ }
474+}
475+
476+void GParted_Core::set_user_devices( const std::vector<Glib::ustring> & user_devices )
477+{
478+ this ->device_paths = user_devices ;
479+ this ->probe_devices = ! user_devices .size() ;
480+}
481+
482+void GParted_Core::set_devices( std::vector<Device> & devices )
483+{
484+ devices .clear() ;
485+ Device temp_device ;
486+ Proc_Partitions_Info pp_info( true ) ; //Refresh cache of proc partition information
487+ FS_Info fs_info( true ) ; //Refresh cache of file system information
488+ DMRaid dmraid( true ) ; //Refresh cache of dmraid device information
489+ SWRaid swraid( true ) ; //Refresh cache of swraid device information
490+ LVM2_PV_Info lvm2_pv_info( true ) ; //Refresh cache of LVM2 PV information
491+
492+ init_maps() ;
493+
494+ //only probe if no devices were specified as arguments..
495+ if ( probe_devices )
496+ {
497+ device_paths .clear() ;
498+
499+ //FIXME: When libparted bug 194 is fixed, remove code to read:
500+ // /proc/partitions
501+ // This was a problem with no floppy drive yet BIOS indicated one existed.
502+ // http://parted.alioth.debian.org/cgi-bin/trac.cgi/ticket/194
503+ //
504+ //try to find all available devices if devices exist in /proc/partitions
505+ std::vector<Glib::ustring> temp_devices = pp_info .get_device_paths() ;
506+ if ( ! temp_devices .empty() )
507+ {
508+ //Try to find all devices in /proc/partitions
509+ for (unsigned int k=0; k < temp_devices .size(); k++)
510+ {
511+ /*TO TRANSLATORS: looks like Scanning /dev/sda */
512+ set_thread_status_message( String::ucompose ( _("Scanning %1"), temp_devices[ k ] ) ) ;
513+ ped_device_get( temp_devices[ k ] .c_str() ) ;
514+ }
515+
516+ //Try to find all swraid devices
517+ if (swraid .is_swraid_supported() ) {
518+ std::vector<Glib::ustring> swraid_devices ;
519+ swraid .get_devices( swraid_devices ) ;
520+ for ( unsigned int k=0; k < swraid_devices .size(); k++ ) {
521+ set_thread_status_message( String::ucompose ( _("Scanning %1"), swraid_devices[k] ) ) ;
522+ ped_device_get( swraid_devices[k] .c_str() ) ;
523+ }
524+ }
525+
526+ //Try to find all dmraid devices
527+ if (dmraid .is_dmraid_supported() ) {
528+ std::vector<Glib::ustring> dmraid_devices ;
529+ dmraid .get_devices( dmraid_devices ) ;
530+ for ( unsigned int k=0; k < dmraid_devices .size(); k++ ) {
531+ set_thread_status_message( String::ucompose ( _("Scanning %1"), dmraid_devices[k] ) ) ;
532+#ifndef USE_LIBPARTED_DMRAID
533+ dmraid .create_dev_map_entries( dmraid_devices[k] ) ;
534+ settle_device( 1 ) ;
535+#endif
536+ ped_device_get( dmraid_devices[k] .c_str() ) ;
537+ }
538+ }
539+ }
540+ else
541+ {
542+ //No devices found in /proc/partitions so use libparted to probe devices
543+ ped_device_probe_all();
544+ }
545+
546+ lp_device = ped_device_get_next( NULL );
547+ while ( lp_device )
548+ {
549+ //only add this device if we can read the first sector (which means it's a real device)
550+ char * buf = static_cast<char *>( malloc( lp_device ->sector_size ) ) ;
551+ if ( buf )
552+ {
553+ /*TO TRANSLATORS: looks like Confirming /dev/sda */
554+ set_thread_status_message( String::ucompose ( _("Confirming %1"), lp_device ->path ) ) ;
555+ if ( ped_device_open( lp_device ) )
556+ {
557+#ifdef HAVE_LIBPARTED_2_2_0_PLUS
558+ //Devices with sector sizes of 512 bytes and higher are supported
559+ if ( ped_device_read( lp_device, buf, 0, 1 ) )
560+ device_paths .push_back( lp_device ->path ) ;
561+#else
562+ //Only devices with sector sizes of 512 bytes are well supported
563+ if ( lp_device ->sector_size != 512 )
564+ {
565+ /*TO TRANSLATORS: looks like Ignoring device /dev/sde with logical sector size of 2048 bytes. */
566+ Glib::ustring msg = String::ucompose ( _("Ignoring device %1 with logical sector size of %2 bytes."), lp_device ->path, lp_device ->sector_size ) ;
567+ msg += "\n" ;
568+ msg += _("GParted requires libparted version 2.2 or higher to support devices with sector sizes larger than 512 bytes.") ;
569+ std::cout << msg << std::endl << std::endl ;
570+ }
571+ else
572+ {
573+ if ( ped_device_read( lp_device, buf, 0, 1 ) )
574+ device_paths .push_back( lp_device ->path ) ;
575+ }
576+#endif
577+ ped_device_close( lp_device ) ;
578+ }
579+ free( buf ) ;
580+ }
581+ lp_device = ped_device_get_next( lp_device ) ;
582+ }
583+ close_device_and_disk() ;
584+
585+ std::sort( device_paths .begin(), device_paths .end() ) ;
586+ }
587+#ifndef USE_LIBPARTED_DMRAID
588+ else
589+ {
590+ //Device paths were passed in on the command line.
591+
592+ //Ensure that dmraid device entries are created
593+ for ( unsigned int t = 0 ; t < device_paths .size() ; t++ )
594+ {
595+ if ( dmraid .is_dmraid_supported() &&
596+ dmraid .is_dmraid_device( device_paths[t] ) )
597+ {
598+ dmraid .create_dev_map_entries( dmraid .get_dmraid_name( device_paths [t] ) ) ;
599+ }
600+ }
601+ }
602+#endif
603+
604+ for ( unsigned int t = 0 ; t < device_paths .size() ; t++ )
605+ {
606+ /*TO TRANSLATORS: looks like Searching /dev/sda partitions */
607+ set_thread_status_message( String::ucompose ( _("Searching %1 partitions"), device_paths[ t ] ) ) ;
608+ if ( open_device_and_disk( device_paths[ t ], false ) )
609+ {
610+ temp_device .Reset() ;
611+
612+ //device info..
613+ temp_device .add_path( device_paths[ t ] ) ;
614+ temp_device .add_paths( pp_info .get_alternate_paths( temp_device .get_path() ) ) ;
615+
616+ temp_device .model = lp_device ->model ;
617+ temp_device .length = lp_device ->length ;
618+ temp_device .sector_size = lp_device ->sector_size ;
619+ temp_device .heads = lp_device ->bios_geom .heads ;
620+ temp_device .sectors = lp_device ->bios_geom .sectors ;
621+ temp_device .cylinders = lp_device ->bios_geom .cylinders ;
622+ temp_device .cylsize = temp_device .heads * temp_device .sectors ;
623+
624+ //make sure cylsize is at least 1 MiB
625+ if ( temp_device .cylsize < (MEBIBYTE / temp_device .sector_size) )
626+ temp_device .cylsize = (MEBIBYTE / temp_device .sector_size) ;
627+
628+ //normal harddisk
629+ if ( lp_disk )
630+ {
631+ temp_device .disktype = lp_disk ->type ->name ;
632+ temp_device .max_prims = ped_disk_get_max_primary_partition_count( lp_disk ) ;
633+
634+ set_device_partitions( temp_device ) ;
635+ set_mountpoints( temp_device .partitions ) ;
636+ set_used_sectors( temp_device .partitions ) ;
637+
638+ if ( temp_device .highest_busy )
639+ {
640+ temp_device .readonly = ! commit_to_os( 1 ) ;
641+ //Clear libparted messages. Typically these are:
642+ // The kernel was unable to re-read the partition table...
643+ libparted_messages .clear() ;
644+ }
645+ }
646+ //harddisk without disklabel
647+ else
648+ {
649+ temp_device .disktype =
650+ /* TO TRANSLATORS: unrecognized
651+ * means that the partition table for this
652+ * disk device is unknown or not recognized.
653+ */
654+ _("unrecognized") ;
655+ temp_device .max_prims = -1 ;
656+
657+ Partition partition_temp ;
658+ partition_temp .Set_Unallocated( temp_device .get_path(),
659+ 0,
660+ temp_device .length - 1,
661+ temp_device .sector_size,
662+ false );
663+ //Place libparted messages in this unallocated partition
664+ partition_temp .messages .insert( partition_temp .messages .end(),
665+ libparted_messages. begin(),
666+ libparted_messages .end() ) ;
667+ libparted_messages .clear() ;
668+ temp_device .partitions .push_back( partition_temp );
669+ }
670+
671+ devices .push_back( temp_device ) ;
672+
673+ close_device_and_disk() ;
674+ }
675+ }
676+
677+ //clear leftover information...
678+ //NOTE that we cannot clear mountinfo since it might be needed in get_all_mountpoints()
679+ set_thread_status_message("") ;
680+ fstab_info .clear() ;
681+}
682+
683+// runs gpart on the specified parameter
684+void GParted_Core::guess_partition_table(const Device & device, Glib::ustring &buff)
685+{
686+ int pid, stdoutput, stderror;
687+ std::vector<std::string> argvproc, envpproc;
688+ gunichar tmp;
689+
690+ //Get the char string of the sector_size
691+ std::ostringstream ssIn;
692+ ssIn << device.sector_size;
693+ Glib::ustring str_ssize = ssIn.str();
694+
695+ //Build the command line
696+ argvproc.push_back("gpart");
697+ argvproc.push_back(device.get_path());
698+ argvproc.push_back("-s");
699+ argvproc.push_back(str_ssize);
700+
701+ envpproc .push_back( "LC_ALL=C" ) ;
702+ envpproc .push_back( "PATH=" + Glib::getenv( "PATH" ) ) ;
703+
704+ Glib::spawn_async_with_pipes(Glib::get_current_dir(), argvproc,
705+ envpproc, Glib::SPAWN_SEARCH_PATH, sigc::slot<void>(),
706+ &pid, NULL, &stdoutput, &stderror);
707+
708+ this->iocOutput=Glib::IOChannel::create_from_fd(stdoutput);
709+
710+ while(this->iocOutput->read(tmp)==Glib::IO_STATUS_NORMAL)
711+ {
712+ buff+=tmp;
713+ }
714+ this->iocOutput->close();
715+
716+ return;
717+}
718+
719+void GParted_Core::set_thread_status_message( Glib::ustring msg )
720+{
721+ //Remember to clear status message when finished with thread.
722+ thread_status_message = msg ;
723+}
724+
725+Glib::ustring GParted_Core::get_thread_status_message( )
726+{
727+ return thread_status_message ;
728+}
729+
730+bool GParted_Core::snap_to_cylinder( const Device & device, Partition & partition, Glib::ustring & error )
731+{
732+ Sector diff = 0;
733+
734+ //Determine if partition size is less than half a disk cylinder
735+ bool less_than_half_cylinder = false;
736+ if ( ( partition .sector_end - partition .sector_start ) < ( device .cylsize / 2 ) )
737+ less_than_half_cylinder = true;
738+
739+ if ( partition.type == TYPE_LOGICAL ||
740+ partition.sector_start == device .sectors
741+ )
742+ {
743+ //Must account the relative offset between:
744+ // (A) the Extended Boot Record sector and the next track of the
745+ // logical partition (usually 63 sectors), and
746+ // (B) the Master Boot Record sector and the next track of the first
747+ // primary partition
748+ diff = (partition .sector_start - device .sectors) % device .cylsize ;
749+ }
750+ else if ( partition.sector_start == 34 )
751+ {
752+ // (C) the GUID Partition Table (GPT) and the start of the data
753+ // partition at sector 34
754+ diff = (partition .sector_start - 34 ) % device .cylsize ;
755+ }
756+ else
757+ {
758+ diff = partition .sector_start % device .cylsize ;
759+ }
760+ if ( diff && ! partition .strict_start )
761+ {
762+ if ( diff < ( device .cylsize / 2 ) || less_than_half_cylinder )
763+ partition .sector_start -= diff ;
764+ else
765+ partition .sector_start += (device .cylsize - diff ) ;
766+ }
767+
768+ diff = (partition .sector_end +1) % device .cylsize ;
769+ if ( diff )
770+ {
771+ if ( diff < ( device .cylsize / 2 ) && ! less_than_half_cylinder )
772+ partition .sector_end -= diff ;
773+ else
774+ partition .sector_end += (device .cylsize - diff ) ;
775+ }
776+
777+ return true ;
778+}
779+
780+bool GParted_Core::snap_to_mebibyte( const Device & device, Partition & partition, Glib::ustring & error )
781+{
782+ Sector diff = 0;
783+ if ( partition .sector_start < 2 || partition .type == TYPE_LOGICAL )
784+ {
785+ //Must account the relative offset between:
786+ // (A) the Master Boot Record sector and the first primary/extended partition, and
787+ // (B) the Extended Boot Record sector and the logical partition
788+
789+ //If strict_start is set then do not adjust sector start.
790+ //If this partition is not simply queued for a reformat then
791+ // add space minimum to force alignment to next mebibyte.
792+ if ( (! partition .strict_start)
793+ && (partition .free_space_before == 0)
794+ && ( partition .status != STAT_FORMATTED)
795+ )
796+ {
797+ //Unless specifically told otherwise, the Linux kernel considers extended
798+ // boot records to be two sectors long, in order to "leave room for LILO".
799+ partition .sector_start += 2 ;
800+ }
801+ }
802+
803+ //Calculate difference offset from Mebibyte boundary
804+ diff = Sector(partition .sector_start % ( MEBIBYTE / partition .sector_size ));
805+
806+ //Align start sector only if permitted to change start sector
807+ if ( diff && ( (! partition .strict_start)
808+ || ( partition .strict_start
809+ && ( partition .status == STAT_NEW
810+ || partition .status == STAT_COPY
811+ )
812+ )
813+ )
814+ )
815+ {
816+ partition .sector_start += ( (MEBIBYTE / partition .sector_size) - diff) ;
817+
818+ //If this is an extended partition then check to see if sufficient space is
819+ // available for any following logical partition Extended Boot Record
820+ if ( partition .type == TYPE_EXTENDED )
821+ {
822+ //Locate the extended partition that contains the logical partitions.
823+ int index_extended = -1 ;
824+ for ( unsigned int t = 0 ; t < device .partitions .size() ; t++ )
825+ {
826+ if ( device .partitions[ t ] .type == TYPE_EXTENDED )
827+ index_extended = t ;
828+ }
829+
830+ //If there is logical partition that starts less than 2 sectors
831+ // from the start of this partition, then reserve a mebibyte for the EBR.
832+ if ( index_extended != -1 )
833+ {
834+ for ( unsigned int t = 0; t < device .partitions[ index_extended ] .logicals .size(); t++ )
835+ {
836+ if ( ( device .partitions[ index_extended ] .logicals[ t ] .type == TYPE_LOGICAL )
837+ && ( ( ( device .partitions[ index_extended ] .logicals[ t ] .sector_start )
838+ - ( partition .sector_start )
839+ )
840+ //Unless specifically told otherwise, the Linux kernel considers extended
841+ // boot records to be two sectors long, in order to "leave room for LILO".
842+ < 2
843+ )
844+ )
845+ {
846+ partition .sector_start -= (MEBIBYTE / partition .sector_size) ;
847+ }
848+ }
849+ }
850+ }
851+ }
852+
853+ //Align end sector
854+ diff = (partition .sector_end + 1) % ( MEBIBYTE / partition .sector_size);
855+ if ( diff )
856+ partition .sector_end -= diff ;
857+
858+ //If this is a logical partition not at end of drive then check to see if space is
859+ // required for a following logical partition Extended Boot Record
860+ if ( partition .type == TYPE_LOGICAL )
861+ {
862+ //Locate the extended partition that contains the logical partitions.
863+ int index_extended = -1 ;
864+ for ( unsigned int t = 0 ; t < device .partitions .size() ; t++ )
865+ {
866+ if ( device .partitions[ t ] .type == TYPE_EXTENDED )
867+ index_extended = t ;
868+ }
869+
870+ //If there is a following logical partition that starts less than 2 sectors from
871+ // the end of this partition, then reserve at least a mebibyte for the EBR.
872+ if ( index_extended != -1 )
873+ {
874+ for ( unsigned int t = 0; t < device .partitions[ index_extended ] .logicals .size(); t++ )
875+ {
876+ if ( ( device .partitions[ index_extended ] .logicals[ t ] .type == TYPE_LOGICAL )
877+ && ( device .partitions[ index_extended ] .logicals[ t ] .sector_start > partition .sector_end )
878+ && ( ( device .partitions[ index_extended ] .logicals[ t ] .sector_start - partition .sector_end )
879+ //Unless specifically told otherwise, the Linux kernel considers extended
880+ // boot records to be two sectors long, in order to "leave room for LILO".
881+ < 2
882+ )
883+ )
884+ partition .sector_end -= ( MEBIBYTE / partition .sector_size ) ;
885+ }
886+ }
887+ }
888+
889+ //If this is a primary or an extended partition and the partition overlaps
890+ // the start of the next primary or extended partition then subtract a
891+ // mebibyte from the end of the partition to address the overlap.
892+ if ( partition .type == TYPE_PRIMARY || partition .type == TYPE_EXTENDED )
893+ {
894+ for ( unsigned int t = 0 ; t < device .partitions .size() ; t++ )
895+ {
896+ if ( ( device .partitions[ t ] .type == TYPE_PRIMARY
897+ || device .partitions[ t ] .type == TYPE_EXTENDED
898+ )
899+ && ( device .partitions[ t ] .sector_start > partition .sector_start )
900+ && ( device .partitions[ t ] .sector_start <= partition .sector_end )
901+ )
902+ partition .sector_end -= ( MEBIBYTE / partition .sector_size );
903+ }
904+ }
905+
906+ //If this is a GPT partition table and the partition ends less than 34 sectors
907+ // from the end of the device, then reserve at least a mebibyte for the
908+ // backup partition table
909+ if ( device .disktype == "gpt"
910+ && ( ( device .length - partition .sector_end ) < 34 )
911+ )
912+ {
913+ partition .sector_end -= ( MEBIBYTE / partition .sector_size ) ;
914+ }
915+
916+ return true ;
917+}
918+
919+bool GParted_Core::snap_to_alignment( const Device & device, Partition & partition, Glib::ustring & error )
920+{
921+ bool rc = true ;
922+
923+ if ( partition .alignment == ALIGN_CYLINDER )
924+ rc = snap_to_cylinder( device, partition, error ) ;
925+ else if ( partition .alignment == ALIGN_MEBIBYTE )
926+ rc = snap_to_mebibyte( device, partition, error ) ;
927+
928+ //Ensure that partition start and end are not beyond the ends of the disk device
929+ if ( partition .sector_start < 0 )
930+ partition .sector_start = 0 ;
931+ if ( partition .sector_end > device .length )
932+ partition .sector_end = device .length - 1 ;
933+
934+ //do some basic checks on the partition
935+ if ( partition .get_sector_length() <= 0 )
936+ {
937+ error = String::ucompose(
938+ /* TO TRANSLATORS: looks like A partition cannot have a length of -1 sectors */
939+ _("A partition cannot have a length of %1 sectors"),
940+ partition .get_sector_length() ) ;
941+ return false ;
942+ }
943+
944+ if ( partition .get_sector_length() < partition .sectors_used )
945+ {
946+ error = String::ucompose(
947+ /* TO TRANSLATORS: looks like A partition with used sectors (2048) greater than its length (1536) is not valid */
948+ _("A partition with used sectors (%1) greater than its length (%2) is not valid"),
949+ partition .sectors_used,
950+ partition .get_sector_length() ) ;
951+ return false ;
952+ }
953+
954+ //FIXME: it would be perfect if we could check for overlapping with adjacent partitions as well,
955+ //however, finding the adjacent partitions is not as easy as it seems and at this moment all the dialogs
956+ //already perform these checks. A perfect 'fixme-later' ;)
957+
958+ return rc ;
959+}
960+
961+bool GParted_Core::apply_operation_to_disk( Operation * operation )
962+{
963+ bool succes = false ;
964+ libparted_messages .clear() ;
965+
966+ if ( calibrate_partition( operation ->partition_original, operation ->operation_detail ) )
967+ switch ( operation ->type )
968+ {
969+ case OPERATION_DELETE:
970+ succes = Delete( operation ->partition_original, operation ->operation_detail ) ;
971+ break ;
972+ case OPERATION_CHECK:
973+ succes = check_repair_filesystem( operation ->partition_original, operation ->operation_detail ) &&
974+ maximize_filesystem( operation ->partition_original, operation ->operation_detail ) ;
975+ break ;
976+ case OPERATION_CREATE:
977+ succes = create( operation ->device,
978+ operation ->partition_new,
979+ operation ->operation_detail ) ;
980+ break ;
981+ case OPERATION_RESIZE_MOVE:
982+ //in case the to be resized/moved partition was a 'copy of..', we need a real path...
983+ operation ->partition_new .add_path( operation ->partition_original .get_path(), true ) ;
984+ succes = resize_move( operation ->device,
985+ operation ->partition_original,
986+ operation ->partition_new,
987+ operation ->operation_detail ) ;
988+ break ;
989+ case OPERATION_FORMAT:
990+ succes = format( operation ->partition_new, operation ->operation_detail ) ;
991+ break ;
992+ case OPERATION_COPY:
993+ //FIXME: in case of a new partition we should make sure the new partition is >= the source partition...
994+ //i think it's best to do this in the dialog_paste
995+ succes = ( operation ->partition_original .type == TYPE_UNALLOCATED ||
996+ calibrate_partition( operation ->partition_new, operation ->operation_detail ) ) &&
997+
998+ calibrate_partition( static_cast<OperationCopy*>( operation ) ->partition_copied,
999+ operation ->operation_detail ) &&
1000+
1001+ copy( static_cast<OperationCopy*>( operation ) ->partition_copied,
1002+ operation ->partition_new,
1003+ static_cast<OperationCopy*>( operation ) ->partition_copied .get_byte_length(),
1004+ operation ->operation_detail ) ;
1005+ break ;
1006+ case OPERATION_LABEL_PARTITION:
1007+ succes = label_partition( operation ->partition_new, operation ->operation_detail ) ;
1008+ break ;
1009+ case OPERATION_CHANGE_UUID:
1010+ succes = change_uuid( operation ->partition_new, operation ->operation_detail ) ;
1011+ break ;
1012+ }
1013+
1014+ if ( libparted_messages .size() > 0 )
1015+ {
1016+ operation ->operation_detail .add_child( OperationDetail( _("libparted messages"), STATUS_INFO ) ) ;
1017+
1018+ for ( unsigned int t = 0 ; t < libparted_messages .size() ; t++ )
1019+ operation ->operation_detail .get_last_child() .add_child(
1020+ OperationDetail( libparted_messages[ t ], STATUS_NONE, FONT_ITALIC ) ) ;
1021+ }
1022+
1023+ return succes ;
1024+}
1025+
1026+bool GParted_Core::set_disklabel( const Glib::ustring & device_path, const Glib::ustring & disklabel )
1027+{
1028+ bool return_value = false ;
1029+
1030+ if ( open_device_and_disk( device_path, false ) )
1031+ {
1032+ PedDiskType *type = NULL ;
1033+ type = ped_disk_type_get( disklabel .c_str() ) ;
1034+
1035+ if ( type )
1036+ {
1037+ lp_disk = ped_disk_new_fresh( lp_device, type );
1038+
1039+ return_value = commit() ;
1040+ }
1041+
1042+ close_device_and_disk() ;
1043+ }
1044+
1045+#ifndef USE_LIBPARTED_DMRAID
1046+ //delete and recreate disk entries if dmraid
1047+ DMRaid dmraid ;
1048+ if ( return_value && dmraid .is_dmraid_device( device_path ) )
1049+ {
1050+ dmraid .purge_dev_map_entries( device_path ) ;
1051+ dmraid .create_dev_map_entries( device_path ) ;
1052+ }
1053+#endif
1054+
1055+ return return_value ;
1056+}
1057+
1058+bool GParted_Core::toggle_flag( const Partition & partition, const Glib::ustring & flag, bool state )
1059+{
1060+ bool succes = false ;
1061+
1062+ if ( open_device_and_disk( partition .device_path ) )
1063+ {
1064+ lp_partition = NULL ;
1065+ if ( partition .type == GParted::TYPE_EXTENDED )
1066+ lp_partition = ped_disk_extended_partition( lp_disk ) ;
1067+ else
1068+ lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition .get_sector() ) ;
1069+
1070+ if ( lp_partition )
1071+ {
1072+ PedPartitionFlag lp_flag = ped_partition_flag_get_by_name( flag .c_str() ) ;
1073+
1074+ if ( lp_flag > 0 && ped_partition_set_flag( lp_partition, lp_flag, state ) )
1075+ succes = commit() ;
1076+ }
1077+
1078+ close_device_and_disk() ;
1079+ }
1080+
1081+ return succes ;
1082+}
1083+
1084+const std::vector<FS> & GParted_Core::get_filesystems() const
1085+{
1086+ return FILESYSTEMS ;
1087+}
1088+
1089+const FS & GParted_Core::get_fs( GParted::FILESYSTEM filesystem ) const
1090+{
1091+ unsigned int unknown ;
1092+
1093+ unknown = FILESYSTEMS .size() ;
1094+ for ( unsigned int t = 0 ; t < FILESYSTEMS .size() ; t++ )
1095+ {
1096+ if ( FILESYSTEMS[ t ] .filesystem == filesystem )
1097+ return FILESYSTEMS[ t ] ;
1098+ else if ( FILESYSTEMS[ t ] .filesystem == FS_UNKNOWN )
1099+ unknown = t ;
1100+ }
1101+
1102+ if ( unknown == FILESYSTEMS .size() ) {
1103+ // This shouldn't happen, but just in case...
1104+ static FS fs;
1105+ fs .filesystem = FS_UNKNOWN ;
1106+ return fs ;
1107+ } else
1108+ return FILESYSTEMS[ unknown ] ;
1109+}
1110+
1111+std::vector<Glib::ustring> GParted_Core::get_disklabeltypes()
1112+{
1113+ std::vector<Glib::ustring> disklabeltypes ;
1114+
1115+ //msdos should be first in the list
1116+ disklabeltypes .push_back( "msdos" ) ;
1117+
1118+ PedDiskType *disk_type ;
1119+ for ( disk_type = ped_disk_type_get_next( NULL ) ; disk_type ; disk_type = ped_disk_type_get_next( disk_type ) )
1120+ if ( Glib::ustring( disk_type->name ) != "msdos" )
1121+ disklabeltypes .push_back( disk_type->name ) ;
1122+
1123+ return disklabeltypes ;
1124+}
1125+
1126+std::vector<Glib::ustring> GParted_Core::get_all_mountpoints()
1127+{
1128+ std::vector<Glib::ustring> mountpoints ;
1129+
1130+ for ( iter_mp = mount_info .begin() ; iter_mp != mount_info .end() ; ++iter_mp )
1131+ mountpoints .insert( mountpoints .end(), iter_mp ->second .begin(), iter_mp ->second .end() ) ;
1132+
1133+ return mountpoints ;
1134+}
1135+
1136+std::map<Glib::ustring, bool> GParted_Core::get_available_flags( const Partition & partition )
1137+{
1138+ std::map<Glib::ustring, bool> flag_info ;
1139+
1140+ if ( open_device_and_disk( partition .device_path ) )
1141+ {
1142+ lp_partition = NULL ;
1143+ if ( partition .type == GParted::TYPE_EXTENDED )
1144+ lp_partition = ped_disk_extended_partition( lp_disk ) ;
1145+ else
1146+ lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition .get_sector() ) ;
1147+
1148+ if ( lp_partition )
1149+ {
1150+ for ( unsigned int t = 0 ; t < flags .size() ; t++ )
1151+ if ( ped_partition_is_flag_available( lp_partition, flags[ t ] ) )
1152+ flag_info[ ped_partition_flag_get_name( flags[ t ] ) ] =
1153+ ped_partition_get_flag( lp_partition, flags[ t ] ) ;
1154+ }
1155+
1156+ close_device_and_disk() ;
1157+ }
1158+
1159+ return flag_info ;
1160+}
1161+
1162+Glib::ustring GParted_Core::get_libparted_version()
1163+{
1164+ return ped_get_version() ;
1165+}
1166+
1167+//private functions...
1168+
1169+void GParted_Core::init_maps()
1170+{
1171+ mount_info .clear() ;
1172+ fstab_info .clear() ;
1173+
1174+ read_mountpoints_from_file( "/proc/mounts", mount_info ) ;
1175+ read_mountpoints_from_file_swaps( "/proc/swaps", mount_info ) ;
1176+ read_mountpoints_from_file( "/etc/mtab", mount_info ) ;
1177+ read_mountpoints_from_file( "/etc/fstab", fstab_info ) ;
1178+
1179+ //sort the mount points and remove duplicates.. (no need to do this for fstab_info)
1180+ for ( iter_mp = mount_info .begin() ; iter_mp != mount_info .end() ; ++iter_mp )
1181+ {
1182+ std::sort( iter_mp ->second .begin(), iter_mp ->second .end() ) ;
1183+
1184+ iter_mp ->second .erase(
1185+ std::unique( iter_mp ->second .begin(), iter_mp ->second .end() ),
1186+ iter_mp ->second .end() ) ;
1187+ }
1188+}
1189+
1190+void GParted_Core::read_mountpoints_from_file(
1191+ const Glib::ustring & filename,
1192+ std::map< Glib::ustring, std::vector<Glib::ustring> > & map )
1193+{
1194+ FS_Info fs_info ; //Use cache of file system information
1195+
1196+ FILE* fp = setmntent( filename .c_str(), "r" ) ;
1197+
1198+ if ( fp == NULL )
1199+ return ;
1200+
1201+ struct mntent* p = NULL ;
1202+
1203+ while ( (p = getmntent(fp)) != NULL )
1204+ {
1205+ Glib::ustring node = p->mnt_fsname ;
1206+
1207+ Glib::ustring uuid = Utils::regexp_label( node, "^UUID=(.*)" ) ;
1208+ if ( ! uuid .empty() )
1209+ node = fs_info .get_path_by_uuid( uuid ) ;
1210+
1211+ Glib::ustring label = Utils::regexp_label( node, "^LABEL=(.*)" ) ;
1212+ if ( ! label .empty() )
1213+ node = fs_info .get_path_by_label( label ) ;
1214+
1215+ if ( ! node .empty() )
1216+ {
1217+ Glib::ustring mountpoint = p->mnt_dir ;
1218+
1219+ //Only add node path(s) if mount point exists
1220+ if ( file_test( mountpoint, Glib::FILE_TEST_EXISTS ) )
1221+ {
1222+ map[ node ] .push_back( mountpoint ) ;
1223+
1224+ //If node is a symbolic link (e.g., /dev/root)
1225+ // then find real path and add entry
1226+ if ( file_test( node, Glib::FILE_TEST_IS_SYMLINK ) )
1227+ {
1228+ char c_str[4096+1] ;
1229+ //FIXME: it seems realpath is very unsafe to use (manpage)...
1230+ if ( realpath( node .c_str(), c_str ) != NULL )
1231+ map[ c_str ] .push_back( mountpoint ) ;
1232+ }
1233+ }
1234+ }
1235+ }
1236+
1237+ endmntent( fp ) ;
1238+}
1239+
1240+void GParted_Core::read_mountpoints_from_file_swaps(
1241+ const Glib::ustring & filename,
1242+ std::map< Glib::ustring, std::vector<Glib::ustring> > & map )
1243+{
1244+ std::string line ;
1245+ std::string node ;
1246+
1247+ std::ifstream file( filename .c_str() ) ;
1248+ if ( file )
1249+ {
1250+ while ( getline( file, line ) )
1251+ {
1252+ node = Utils::regexp_label( line, "^(/[^ ]+)" ) ;
1253+ if ( node .size() > 0 )
1254+ map[ node ] .push_back( "" /* no mountpoint for swap */ ) ;
1255+ }
1256+ file .close() ;
1257+ }
1258+}
1259+
1260+Glib::ustring GParted_Core::get_partition_path( PedPartition * lp_partition )
1261+{
1262+ char * lp_path; //we have to free the result of ped_partition_get_path()
1263+ Glib::ustring partition_path = "Partition path not found";
1264+
1265+ lp_path = ped_partition_get_path(lp_partition);
1266+ if ( lp_path != NULL )
1267+ {
1268+ partition_path = lp_path;
1269+ free(lp_path);
1270+ }
1271+
1272+#ifndef USE_LIBPARTED_DMRAID
1273+ //Ensure partition path name is compatible with dmraid
1274+ DMRaid dmraid; //Use cache of dmraid device information
1275+ if ( dmraid .is_dmraid_supported()
1276+ && dmraid .is_dmraid_device( partition_path )
1277+ )
1278+ {
1279+ partition_path = dmraid .make_path_dmraid_compatible(partition_path);
1280+ }
1281+#endif
1282+
1283+ return partition_path ;
1284+}
1285+
1286+void GParted_Core::set_device_partitions( Device & device )
1287+{
1288+ int EXT_INDEX = -1 ;
1289+ Proc_Partitions_Info pp_info ; //Use cache of proc partitions information
1290+ FS_Info fs_info ; //Use cache of file system information
1291+#ifndef USE_LIBPARTED_DMRAID
1292+ DMRaid dmraid ; //Use cache of dmraid device information
1293+#endif
1294+ LVM2_PV_Info lvm2_pv_info ;
1295+
1296+ //clear partitions
1297+ device .partitions .clear() ;
1298+
1299+ lp_partition = ped_disk_next_partition( lp_disk, NULL ) ;
1300+ while ( lp_partition )
1301+ {
1302+ libparted_messages .clear() ;
1303+ partition_temp .Reset() ;
1304+ bool partition_is_busy = false ;
1305+ GParted::FILESYSTEM filesystem ;
1306+
1307+ //Retrieve partition path
1308+ Glib::ustring partition_path = get_partition_path( lp_partition );
1309+
1310+ switch ( lp_partition ->type )
1311+ {
1312+ case PED_PARTITION_NORMAL:
1313+ case PED_PARTITION_LOGICAL:
1314+ filesystem = get_filesystem() ;
1315+#ifndef USE_LIBPARTED_DMRAID
1316+ //Handle dmraid devices differently because the minor number might not
1317+ // match the last number of the partition filename as shown by "ls -l /dev/mapper"
1318+ // This mismatch causes incorrect identification of busy partitions in ped_partition_is_busy().
1319+ if ( dmraid .is_dmraid_device( device .get_path() ) )
1320+ {
1321+ //Try device_name + partition_number
1322+ iter_mp = mount_info .find( device .get_path() + Utils::num_to_str( lp_partition ->num ) ) ;
1323+ if ( iter_mp != mount_info .end() )
1324+ partition_is_busy = true ;
1325+ //Try device_name + p + partition_number
1326+ iter_mp = mount_info .find( device .get_path() + "p" + Utils::num_to_str( lp_partition ->num ) ) ;
1327+ if ( iter_mp != mount_info .end() )
1328+ partition_is_busy = true ;
1329+ }
1330+ else
1331+#endif
1332+ partition_is_busy = ped_partition_is_busy( lp_partition ) ||
1333+ ( filesystem == GParted::FS_LVM2_PV && lvm2_pv_info .has_active_lvs( partition_path ) ) ;
1334+
1335+ partition_temp .Set( device .get_path(),
1336+ partition_path,
1337+ lp_partition ->num,
1338+ lp_partition ->type == 0 ? GParted::TYPE_PRIMARY : GParted::TYPE_LOGICAL,
1339+ filesystem,
1340+ lp_partition ->geom .start,
1341+ lp_partition ->geom .end,
1342+ device .sector_size,
1343+ lp_partition ->type,
1344+ partition_is_busy ) ;
1345+
1346+ partition_temp .add_paths( pp_info .get_alternate_paths( partition_temp .get_path() ) ) ;
1347+ set_flags( partition_temp ) ;
1348+
1349+ if ( partition_temp .busy && partition_temp .partition_number > device .highest_busy )
1350+ device .highest_busy = partition_temp .partition_number ;
1351+
1352+ break ;
1353+
1354+ case PED_PARTITION_EXTENDED:
1355+#ifndef USE_LIBPARTED_DMRAID
1356+ //Handle dmraid devices differently because the minor number might not
1357+ // match the last number of the partition filename as shown by "ls -l /dev/mapper"
1358+ // This mismatch causes incorrect identification of busy partitions in ped_partition_is_busy().
1359+ if ( dmraid .is_dmraid_device( device .get_path() ) )
1360+ {
1361+ for ( unsigned int k = 5; k < 255; k++ )
1362+ {
1363+ //Try device_name + [5 to 255]
1364+ iter_mp = mount_info .find( device .get_path() + Utils::num_to_str( k ) ) ;
1365+ if ( iter_mp != mount_info .end() )
1366+ partition_is_busy = true ;
1367+ //Try device_name + p + [5 to 255]
1368+ iter_mp = mount_info .find( device .get_path() + "p" + Utils::num_to_str( k ) ) ;
1369+ if ( iter_mp != mount_info .end() )
1370+ partition_is_busy = true ;
1371+ }
1372+ }
1373+ else
1374+#endif
1375+ partition_is_busy = ped_partition_is_busy( lp_partition ) ;
1376+
1377+ partition_temp .Set( device .get_path(),
1378+ partition_path,
1379+ lp_partition ->num,
1380+ GParted::TYPE_EXTENDED,
1381+ GParted::FS_EXTENDED,
1382+ lp_partition ->geom .start,
1383+ lp_partition ->geom .end,
1384+ device .sector_size,
1385+ false,
1386+ partition_is_busy ) ;
1387+
1388+ partition_temp .add_paths( pp_info .get_alternate_paths( partition_temp .get_path() ) ) ;
1389+ set_flags( partition_temp ) ;
1390+
1391+ EXT_INDEX = device .partitions .size() ;
1392+ break ;
1393+
1394+ default:
1395+ break;
1396+ }
1397+
1398+ //Avoid reading additional file system information if there is no path
1399+ if ( partition_temp .get_path() != "" )
1400+ {
1401+ //Retrieve file system label
1402+ // Use file system specific method first in an effort to ensure multi-byte
1403+ // character sets are properly displayed.
1404+ read_label( partition_temp ) ;
1405+ if ( partition_temp .label .empty() )
1406+ {
1407+ bool label_found = false ;
1408+ partition_temp .label = fs_info .get_label( partition_temp .get_path(), label_found ) ;
1409+ }
1410+
1411+ //Retrieve file system UUID
1412+ // Use cached method first in an effort to speed up device scanning.
1413+ partition_temp .uuid = fs_info .get_uuid( partition_temp .get_path() ) ;
1414+ if ( partition_temp .uuid .empty() )
1415+ {
1416+ read_uuid( partition_temp ) ;
1417+ }
1418+ }
1419+
1420+ partition_temp .messages .insert( partition_temp .messages .end(),
1421+ libparted_messages. begin(),
1422+ libparted_messages .end() ) ;
1423+
1424+ //if there's an end, there's a partition ;)
1425+ if ( partition_temp .sector_end > -1 )
1426+ {
1427+ if ( ! partition_temp .inside_extended )
1428+ device .partitions .push_back( partition_temp );
1429+ else
1430+ device .partitions[ EXT_INDEX ] .logicals .push_back( partition_temp ) ;
1431+ }
1432+
1433+ //next partition (if any)
1434+ lp_partition = ped_disk_next_partition( lp_disk, lp_partition ) ;
1435+ }
1436+
1437+ if ( EXT_INDEX > -1 )
1438+ insert_unallocated( device .get_path(),
1439+ device .partitions[ EXT_INDEX ] .logicals,
1440+ device .partitions[ EXT_INDEX ] .sector_start,
1441+ device .partitions[ EXT_INDEX ] .sector_end,
1442+ device .sector_size,
1443+ true ) ;
1444+
1445+ insert_unallocated( device .get_path(), device .partitions, 0, device .length -1, device .sector_size, false ) ;
1446+}
1447+
1448+GParted::FILESYSTEM GParted_Core::get_filesystem()
1449+{
1450+ char magic1[16] = "";
1451+ char magic2[16] = "";
1452+
1453+ //Check for LUKS encryption prior to libparted file system detection.
1454+ // Otherwise encrypted file systems such as ext3 will be detected by
1455+ // libparted as 'ext3'.
1456+
1457+ //LUKS encryption
1458+ char * buf = static_cast<char *>( malloc( lp_device ->sector_size ) ) ;
1459+ if ( buf )
1460+ {
1461+ ped_device_open( lp_device );
1462+ ped_geometry_read( & lp_partition ->geom, buf, 0, 1 ) ;
1463+ memcpy(magic1, buf+0, 6) ; //set binary magic data
1464+ ped_device_close( lp_device );
1465+ free( buf ) ;
1466+
1467+ if ( 0 == memcmp( magic1 , "LUKS\xBA\xBE", 6 ) )
1468+ {
1469+ temp = _( "Linux Unified Key Setup encryption is not yet supported." ) ;
1470+ temp += "\n" ;
1471+ partition_temp .messages .push_back( temp ) ;
1472+ return GParted::FS_LUKS ;
1473+ }
1474+ }
1475+
1476+ FS_Info fs_info ;
1477+ Glib::ustring fs_type = "" ;
1478+
1479+ //Standard libparted file system detection
1480+ if ( lp_partition && lp_partition ->fs_type )
1481+ {
1482+ fs_type = lp_partition ->fs_type ->name ;
1483+
1484+ //TODO: Temporary code to detect ext4.
1485+ // Replace when libparted >= 1.9.0 is chosen as minimum required version.
1486+ temp = fs_info .get_fs_type( get_partition_path( lp_partition ) ) ;
1487+ if ( temp == "ext4" || temp == "ext4dev" )
1488+ fs_type = temp ;
1489+ }
1490+
1491+ //FS_Info (blkid) file system detection because current libparted (v2.2) does not
1492+ // appear to detect file systems for sector sizes other than 512 bytes.
1493+ if ( fs_type .empty() )
1494+ {
1495+ //TODO: blkid does not return anything for an "extended" partition. Need to handle this somehow
1496+ fs_type = fs_info.get_fs_type( get_partition_path( lp_partition ) ) ;
1497+ }
1498+
1499+ if ( ! fs_type .empty() )
1500+ {
1501+ if ( fs_type == "extended" )
1502+ return GParted::FS_EXTENDED ;
1503+ else if ( fs_type == "btrfs" )
1504+ return GParted::FS_BTRFS ;
1505+ else if ( fs_type == "exfat" )
1506+ return GParted::FS_EXFAT ;
1507+ else if ( fs_type == "ext2" )
1508+ return GParted::FS_EXT2 ;
1509+ else if ( fs_type == "ext3" )
1510+ return GParted::FS_EXT3 ;
1511+ else if ( fs_type == "ext4" ||
1512+ fs_type == "ext4dev" )
1513+ return GParted::FS_EXT4 ;
1514+ else if ( fs_type == "linux-swap" ||
1515+ fs_type == "linux-swap(v1)" ||
1516+ fs_type == "linux-swap(new)" ||
1517+ fs_type == "linux-swap(v0)" ||
1518+ fs_type == "linux-swap(old)" ||
1519+ fs_type == "swap" )
1520+ return GParted::FS_LINUX_SWAP ;
1521+ else if ( fs_type == "LVM2_member" )
1522+ return GParted::FS_LVM2_PV ;
1523+ else if ( fs_type == "fat16" )
1524+ return GParted::FS_FAT16 ;
1525+ else if ( fs_type == "fat32" )
1526+ return GParted::FS_FAT32 ;
1527+ else if ( fs_type == "nilfs2" )
1528+ return GParted::FS_NILFS2 ;
1529+ else if ( fs_type == "ntfs" )
1530+ return GParted::FS_NTFS ;
1531+ else if ( fs_type == "reiserfs" )
1532+ return GParted::FS_REISERFS ;
1533+ else if ( fs_type == "xfs" )
1534+ return GParted::FS_XFS ;
1535+ else if ( fs_type == "jfs" )
1536+ return GParted::FS_JFS ;
1537+ else if ( fs_type == "hfs" )
1538+ return GParted::FS_HFS ;
1539+ else if ( fs_type == "hfs+" ||
1540+ fs_type == "hfsplus" )
1541+ return GParted::FS_HFSPLUS ;
1542+ else if ( fs_type == "ufs" )
1543+ return GParted::FS_UFS ;
1544+ }
1545+
1546+
1547+
1548+ //other file systems libparted couldn't detect (i've send patches for these file systems to the parted guys)
1549+ // - no patches sent to parted for lvm2, or luks
1550+
1551+ //reiser4
1552+ buf = static_cast<char *>( malloc( lp_device ->sector_size ) ) ;
1553+ if ( buf )
1554+ {
1555+ ped_device_open( lp_device );
1556+ ped_geometry_read( & lp_partition ->geom
1557+ , buf
1558+ , (65536 / lp_device ->sector_size)
1559+ , 1
1560+ ) ;
1561+ memcpy(magic1, buf+0, 7) ; //set binary magic data
1562+ ped_device_close( lp_device );
1563+ free( buf ) ;
1564+
1565+ if ( 0 == memcmp( magic1, "ReIsEr4", 7 ) )
1566+ return GParted::FS_REISER4 ;
1567+ }
1568+
1569+ //lvm2
1570+ //NOTE: lvm2 is not a file system but we do wish to recognize the Physical Volume
1571+ buf = static_cast<char *>( malloc( lp_device ->sector_size ) ) ;
1572+ if ( buf )
1573+ {
1574+ ped_device_open( lp_device );
1575+ if ( lp_device ->sector_size == 512 )
1576+ {
1577+ ped_geometry_read( & lp_partition ->geom, buf, 1, 1 ) ;
1578+ memcpy(magic1, buf+ 0, 8) ; // set binary magic data
1579+ memcpy(magic2, buf+24, 4) ; // set binary magic data
1580+ }
1581+ else
1582+ {
1583+ ped_geometry_read( & lp_partition ->geom, buf, 0, 1 ) ;
1584+ memcpy(magic1, buf+ 0+512, 8) ; // set binary magic data
1585+ memcpy(magic2, buf+24+512, 4) ; // set binary magic data
1586+ }
1587+ ped_device_close( lp_device );
1588+ free( buf ) ;
1589+
1590+ if ( 0 == memcmp( magic1, "LABELONE", 8 )
1591+ && 0 == memcmp( magic2, "LVM2", 4 ) )
1592+ {
1593+ return GParted::FS_LVM2_PV ;
1594+ }
1595+ }
1596+
1597+ //btrfs
1598+ const Sector BTRFS_SUPER_INFO_SIZE = 4096 ;
1599+ const Sector BTRFS_SUPER_INFO_OFFSET = (64 * 1024) ;
1600+ const char* const BTRFS_SIGNATURE = "_BHRfS_M" ;
1601+
1602+ char buf_btrfs[BTRFS_SUPER_INFO_SIZE] ;
1603+
1604+ ped_device_open( lp_device ) ;
1605+ ped_geometry_read( & lp_partition ->geom
1606+ , buf_btrfs
1607+ , (BTRFS_SUPER_INFO_OFFSET / lp_device ->sector_size)
1608+ , (BTRFS_SUPER_INFO_SIZE / lp_device ->sector_size)
1609+ ) ;
1610+ memcpy(magic1, buf_btrfs+64, strlen(BTRFS_SIGNATURE) ) ; //set binary magic data
1611+ ped_device_close( lp_device ) ;
1612+
1613+ if ( 0 == memcmp( magic1, BTRFS_SIGNATURE, strlen(BTRFS_SIGNATURE) ) )
1614+ {
1615+ return GParted::FS_BTRFS ;
1616+ }
1617+
1618+ //no file system found....
1619+ temp = _( "Unable to detect file system! Possible reasons are:" ) ;
1620+ temp += "\n- ";
1621+ temp += _( "The file system is damaged" ) ;
1622+ temp += "\n- " ;
1623+ temp += _( "The file system is unknown to GParted" ) ;
1624+ temp += "\n- ";
1625+ temp += _( "There is no file system available (unformatted)" ) ;
1626+ temp += "\n- ";
1627+ /* TO TRANSLATORS: looks like The device entry /dev/sda5 is missing */
1628+ temp += String::ucompose( _( "The device entry %1 is missing" ), get_partition_path( lp_partition ) ) ;
1629+
1630+ partition_temp .messages .push_back( temp ) ;
1631+
1632+ return GParted::FS_UNKNOWN ;
1633+}
1634+
1635+void GParted_Core::read_label( Partition & partition )
1636+{
1637+ if ( partition .type != TYPE_EXTENDED )
1638+ {
1639+ switch( get_fs( partition .filesystem ) .read_label )
1640+ {
1641+ case FS::EXTERNAL:
1642+ if ( set_proper_filesystem( partition .filesystem ) )
1643+ p_filesystem ->read_label( partition ) ;
1644+ break ;
1645+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
1646+ case FS::LIBPARTED:
1647+ break ;
1648+#endif
1649+
1650+ default:
1651+ break ;
1652+ }
1653+ }
1654+}
1655+
1656+void GParted_Core::read_uuid( Partition & partition )
1657+{
1658+ if ( partition .type != TYPE_EXTENDED )
1659+ {
1660+ switch( get_fs( partition .filesystem ) .read_uuid )
1661+ {
1662+ case FS::EXTERNAL:
1663+ if ( set_proper_filesystem( partition .filesystem ) )
1664+ p_filesystem ->read_uuid( partition ) ;
1665+ break ;
1666+
1667+ default:
1668+ break ;
1669+ }
1670+ }
1671+}
1672+
1673+void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
1674+ std::vector<Partition> & partitions,
1675+ Sector start,
1676+ Sector end,
1677+ Byte_Value sector_size,
1678+ bool inside_extended )
1679+{
1680+ partition_temp .Reset() ;
1681+ partition_temp .Set_Unallocated( device_path, 0, 0, sector_size, inside_extended ) ;
1682+
1683+ //if there are no partitions at all..
1684+ if ( partitions .empty() )
1685+ {
1686+ partition_temp .sector_start = start ;
1687+ partition_temp .sector_end = end ;
1688+
1689+ partitions .push_back( partition_temp );
1690+
1691+ return ;
1692+ }
1693+
1694+ //start <---> first partition start
1695+ if ( (partitions .front() .sector_start - start) > (MEBIBYTE / sector_size) )
1696+ {
1697+ partition_temp .sector_start = start ;
1698+ partition_temp .sector_end = partitions .front() .sector_start -1 ;
1699+
1700+ partitions .insert( partitions .begin(), partition_temp );
1701+ }
1702+
1703+ //look for gaps in between
1704+ for ( unsigned int t =0 ; t < partitions .size() -1 ; t++ )
1705+ {
1706+ if ( ( ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end - 1 ) > (MEBIBYTE / sector_size) )
1707+ || ( ( partitions[ t + 1 ] .type != TYPE_LOGICAL ) // Only show exactly 1 MiB if following partition is not logical.
1708+ && ( ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end - 1 ) == (MEBIBYTE / sector_size) )
1709+ )
1710+ )
1711+ {
1712+ partition_temp .sector_start = partitions[ t ] .sector_end +1 ;
1713+ partition_temp .sector_end = partitions[ t +1 ] .sector_start -1 ;
1714+
1715+ partitions .insert( partitions .begin() + ++t, partition_temp );
1716+ }
1717+ }
1718+
1719+ //last partition end <---> end
1720+ if ( (end - partitions .back() .sector_end) >= (MEBIBYTE / sector_size) )
1721+ {
1722+ partition_temp .sector_start = partitions .back() .sector_end +1 ;
1723+ partition_temp .sector_end = end ;
1724+
1725+ partitions .push_back( partition_temp );
1726+ }
1727+}
1728+
1729+void GParted_Core::set_mountpoints( std::vector<Partition> & partitions )
1730+{
1731+#ifndef USE_LIBPARTED_DMRAID
1732+ DMRaid dmraid ; //Use cache of dmraid device information
1733+#endif
1734+ LVM2_PV_Info lvm2_pv_info ;
1735+ for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
1736+ {
1737+ if ( ( partitions[ t ] .type == GParted::TYPE_PRIMARY ||
1738+ partitions[ t ] .type == GParted::TYPE_LOGICAL
1739+ ) &&
1740+ partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP &&
1741+ partitions[ t ] .filesystem != GParted::FS_LVM2_PV &&
1742+ partitions[ t ] .filesystem != GParted::FS_LUKS
1743+ )
1744+ {
1745+ if ( partitions[ t ] .busy )
1746+ {
1747+#ifndef USE_LIBPARTED_DMRAID
1748+ //Handle dmraid devices differently because there may be more
1749+ // than one partition name.
1750+ // E.g., there might be names with and/or without a 'p' between
1751+ // the device name and partition number.
1752+ if ( dmraid .is_dmraid_device( partitions[ t ] .device_path ) )
1753+ {
1754+ //Try device_name + partition_number
1755+ iter_mp = mount_info .find( partitions[ t ] .device_path + Utils::num_to_str( partitions[ t ] .partition_number ) ) ;
1756+ if ( iter_mp != mount_info .end() )
1757+ {
1758+ partitions[ t ] .add_mountpoints( iter_mp ->second ) ;
1759+ break ;
1760+ }
1761+ //Try device_name + p + partition_number
1762+ iter_mp = mount_info .find( partitions[ t ] .device_path + "p" + Utils::num_to_str( partitions[ t ] .partition_number ) ) ;
1763+ if ( iter_mp != mount_info .end() )
1764+ {
1765+ partitions[ t ] .add_mountpoints( iter_mp ->second ) ;
1766+ break ;
1767+ }
1768+ }
1769+ else
1770+ {
1771+#endif
1772+ //Normal device, not DMRaid device
1773+ for ( unsigned int i = 0 ; i < partitions[ t ] .get_paths() .size() ; i++ )
1774+ {
1775+ iter_mp = mount_info .find( partitions[ t ] .get_paths()[ i ] ) ;
1776+ if ( iter_mp != mount_info .end() )
1777+ {
1778+ partitions[ t ] .add_mountpoints( iter_mp ->second ) ;
1779+ break ;
1780+ }
1781+ }
1782+#ifndef USE_LIBPARTED_DMRAID
1783+ }
1784+#endif
1785+
1786+ if ( partitions[ t ] .get_mountpoints() .empty() )
1787+ partitions[ t ] .messages .push_back( _("Unable to find mount point") ) ;
1788+ }
1789+ else
1790+ {
1791+ iter_mp = fstab_info .find( partitions[ t ] .get_path() );
1792+ if ( iter_mp != fstab_info .end() )
1793+ partitions[ t ] .add_mountpoints( iter_mp ->second ) ;
1794+ }
1795+ }
1796+ else if ( partitions[ t ] .type == GParted::TYPE_EXTENDED )
1797+ set_mountpoints( partitions[ t ] .logicals ) ;
1798+ else if ( partitions[ t ] .filesystem == GParted::FS_LVM2_PV )
1799+ {
1800+ Glib::ustring vgname = lvm2_pv_info. get_vg_name( partitions[t].get_path() ) ;
1801+ if ( ! vgname .empty() )
1802+ partitions[ t ] .add_mountpoint( vgname ) ;
1803+ }
1804+ }
1805+}
1806+
1807+void GParted_Core::set_used_sectors( std::vector<Partition> & partitions )
1808+{
1809+ struct statvfs sfs ;
1810+
1811+ for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
1812+ {
1813+ if ( partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP &&
1814+ partitions[ t ] .filesystem != GParted::FS_LUKS &&
1815+ partitions[ t ] .filesystem != GParted::FS_UNKNOWN
1816+ )
1817+ {
1818+ if ( partitions[ t ] .type == GParted::TYPE_PRIMARY ||
1819+ partitions[ t ] .type == GParted::TYPE_LOGICAL )
1820+ {
1821+ if ( partitions[ t ] .busy && partitions[t] .filesystem != GParted::FS_LVM2_PV )
1822+ {
1823+ if ( partitions[ t ] .get_mountpoints() .size() > 0 )
1824+ {
1825+ if ( statvfs( partitions[ t ] .get_mountpoint() .c_str(), &sfs ) == 0 )
1826+ partitions[ t ] .Set_Unused( sfs .f_bfree * (sfs .f_bsize / partitions[ t ] .sector_size) ) ;
1827+ else
1828+ partitions[ t ] .messages .push_back(
1829+ "statvfs (" +
1830+ partitions[ t ] .get_mountpoint() +
1831+ "): " +
1832+ Glib::strerror( errno ) ) ;
1833+ }
1834+ }
1835+ else
1836+ {
1837+ switch( get_fs( partitions[ t ] .filesystem ) .read )
1838+ {
1839+ case GParted::FS::EXTERNAL :
1840+ if ( set_proper_filesystem( partitions[ t ] .filesystem ) )
1841+ p_filesystem ->set_used_sectors( partitions[ t ] ) ;
1842+ break ;
1843+#ifdef HAVE_LIBPARTED_FS_RESIZE
1844+ case GParted::FS::LIBPARTED :
1845+ LP_set_used_sectors( partitions[ t ] ) ;
1846+ break ;
1847+#endif
1848+
1849+ default:
1850+ break ;
1851+ }
1852+ }
1853+
1854+ if ( partitions[ t ] .sectors_used == -1 )
1855+ {
1856+ temp = _("Unable to read the contents of this file system!") ;
1857+ temp += "\n" ;
1858+ temp += _("Because of this some operations may be unavailable.") ;
1859+ if ( ! Utils::get_filesystem_software( partitions[ t ] .filesystem ) .empty() )
1860+ {
1861+ temp += "\n\n" ;
1862+ temp += _( "The cause might be a missing software package.") ;
1863+ temp += "\n" ;
1864+ /*TO TRANSLATORS: looks like The following list of software packages is required for NTFS file system support: ntfsprogs. */
1865+ temp += String::ucompose( _("The following list of software packages is required for %1 file system support: %2."),
1866+ Utils::get_filesystem_string( partitions[ t ] .filesystem ),
1867+ Utils::get_filesystem_software( partitions[ t ] .filesystem )
1868+ ) ;
1869+ }
1870+ partitions[ t ] .messages .push_back( temp ) ;
1871+ }
1872+ }
1873+ else if ( partitions[ t ] .type == GParted::TYPE_EXTENDED )
1874+ set_used_sectors( partitions[ t ] .logicals ) ;
1875+ }
1876+ }
1877+}
1878+
1879+#ifdef HAVE_LIBPARTED_FS_RESIZE
1880+void GParted_Core::LP_set_used_sectors( Partition & partition )
1881+{
1882+ PedFileSystem *fs = NULL;
1883+ PedConstraint *constraint = NULL;
1884+
1885+ if ( lp_disk )
1886+ {
1887+ lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition .get_sector() ) ;
1888+
1889+ if ( lp_partition )
1890+ {
1891+ fs = ped_file_system_open( & lp_partition ->geom );
1892+
1893+ if ( fs )
1894+ {
1895+ constraint = ped_file_system_get_resize_constraint( fs ) ;
1896+ if ( constraint )
1897+ {
1898+ partition .Set_Unused( partition .get_sector_length() - constraint ->min_size ) ;
1899+
1900+ ped_constraint_destroy( constraint );
1901+ }
1902+
1903+ ped_file_system_close( fs ) ;
1904+ }
1905+ }
1906+ }
1907+}
1908+#endif
1909+
1910+void GParted_Core::set_flags( Partition & partition )
1911+{
1912+ for ( unsigned int t = 0 ; t < flags .size() ; t++ )
1913+ if ( ped_partition_is_flag_available( lp_partition, flags[ t ] ) &&
1914+ ped_partition_get_flag( lp_partition, flags[ t ] ) )
1915+ partition .flags .push_back( ped_partition_flag_get_name( flags[ t ] ) ) ;
1916+}
1917+
1918+bool GParted_Core::create( const Device & device, Partition & new_partition, OperationDetail & operationdetail )
1919+{
1920+ if ( new_partition .type == GParted::TYPE_EXTENDED )
1921+ {
1922+ return create_partition( new_partition, operationdetail ) ;
1923+ }
1924+ else if ( create_partition( new_partition, operationdetail, (get_fs( new_partition .filesystem ) .MIN / new_partition .sector_size) ) )
1925+ {
1926+ if ( new_partition .filesystem == GParted::FS_UNFORMATTED )
1927+ return true ;
1928+ else
1929+ return set_partition_type( new_partition, operationdetail ) &&
1930+ create_filesystem( new_partition, operationdetail ) ;
1931+ }
1932+
1933+ return false ;
1934+}
1935+
1936+bool GParted_Core::create_partition( Partition & new_partition, OperationDetail & operationdetail, Sector min_size )
1937+{
1938+ operationdetail .add_child( OperationDetail( _("create empty partition") ) ) ;
1939+
1940+ new_partition .partition_number = 0 ;
1941+
1942+ if ( open_device_and_disk( new_partition .device_path ) )
1943+ {
1944+ PedPartitionType type;
1945+ lp_partition = NULL ;
1946+ PedConstraint *constraint = NULL ;
1947+ PedFileSystemType* fs_type = NULL ;
1948+
1949+ //create new partition
1950+ switch ( new_partition .type )
1951+ {
1952+ case GParted::TYPE_PRIMARY:
1953+ type = PED_PARTITION_NORMAL ;
1954+ break ;
1955+ case GParted::TYPE_LOGICAL:
1956+ type = PED_PARTITION_LOGICAL ;
1957+ break ;
1958+ case GParted::TYPE_EXTENDED:
1959+ type = PED_PARTITION_EXTENDED ;
1960+ break ;
1961+
1962+ default :
1963+ type = PED_PARTITION_FREESPACE;
1964+ }
1965+
1966+ if ( new_partition .type != GParted::TYPE_EXTENDED )
1967+ fs_type = ped_file_system_type_get( "ext2" ) ;
1968+
1969+ lp_partition = ped_partition_new( lp_disk,
1970+ type,
1971+ fs_type,
1972+ new_partition .sector_start,
1973+ new_partition .sector_end ) ;
1974+
1975+ if ( lp_partition )
1976+ {
1977+ if ( new_partition .alignment == ALIGN_STRICT
1978+ || new_partition .alignment == ALIGN_MEBIBYTE
1979+ )
1980+ {
1981+ PedGeometry *geom = ped_geometry_new( lp_device,
1982+ new_partition .sector_start,
1983+ new_partition .get_sector_length() ) ;
1984+
1985+ if ( geom )
1986+ constraint = ped_constraint_exact( geom ) ;
1987+ }
1988+ else
1989+ constraint = ped_constraint_any( lp_device );
1990+
1991+ if ( constraint )
1992+ {
1993+ if ( min_size > 0
1994+ && new_partition .filesystem != FS_XFS // Permit copying to smaller xfs partition
1995+ )
1996+ constraint ->min_size = min_size ;
1997+
1998+ if ( ped_disk_add_partition( lp_disk, lp_partition, constraint ) && commit() )
1999+ {
2000+ Glib::ustring partition_path = get_partition_path( lp_partition ) ;
2001+ new_partition .add_path( partition_path, true ) ;
2002+
2003+ new_partition .partition_number = lp_partition ->num ;
2004+ new_partition .sector_start = lp_partition ->geom .start ;
2005+ new_partition .sector_end = lp_partition ->geom .end ;
2006+
2007+ operationdetail .get_last_child() .add_child( OperationDetail(
2008+ String::ucompose( _("path: %1"), new_partition .get_path() ) + "\n" +
2009+ String::ucompose( _("start: %1"), new_partition .sector_start ) + "\n" +
2010+ String::ucompose( _("end: %1"), new_partition .sector_end ) + "\n" +
2011+ String::ucompose( _("size: %1 (%2)"),
2012+ new_partition .get_sector_length(),
2013+ Utils::format_size( new_partition .get_sector_length(), new_partition .sector_size ) ),
2014+ STATUS_NONE,
2015+ FONT_ITALIC ) ) ;
2016+ }
2017+
2018+ ped_constraint_destroy( constraint );
2019+ }
2020+ }
2021+
2022+ close_device_and_disk() ;
2023+ }
2024+
2025+ bool succes = new_partition .partition_number > 0
2026+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
2027+ && erase_filesystem_signatures( new_partition )
2028+#endif
2029+ ;
2030+
2031+#ifndef USE_LIBPARTED_DMRAID
2032+ //create dev map entries if dmraid
2033+ DMRaid dmraid ;
2034+ if ( succes && dmraid .is_dmraid_device( new_partition .device_path ) )
2035+ succes = dmraid .create_dev_map_entries( new_partition, operationdetail .get_last_child() ) ;
2036+#endif
2037+
2038+ operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
2039+
2040+ return succes ;
2041+}
2042+
2043+bool GParted_Core::create_filesystem( const Partition & partition, OperationDetail & operationdetail )
2044+{
2045+ /*TO TRANSLATORS: looks like create new ext3 file system */
2046+ operationdetail .add_child( OperationDetail( String::ucompose(
2047+ _("create new %1 file system"),
2048+ Utils::get_filesystem_string( partition .filesystem ) ) ) ) ;
2049+
2050+ bool succes = false ;
2051+ switch ( get_fs( partition .filesystem ) .create )
2052+ {
2053+ case GParted::FS::NONE:
2054+ break ;
2055+ case GParted::FS::GPARTED:
2056+ break ;
2057+#ifndef HAVE_LIBPARTED_3_0_PLUS
2058+ case GParted::FS::LIBPARTED:
2059+ break ;
2060+#endif
2061+ case GParted::FS::EXTERNAL:
2062+ succes = set_proper_filesystem( partition .filesystem ) &&
2063+ p_filesystem ->create( partition, operationdetail .get_last_child() ) ;
2064+
2065+ break ;
2066+
2067+ default:
2068+ break ;
2069+ }
2070+
2071+ operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
2072+ return succes ;
2073+}
2074+
2075+bool GParted_Core::format( const Partition & partition, OperationDetail & operationdetail )
2076+{
2077+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
2078+ //remove all file system signatures...
2079+ erase_filesystem_signatures( partition ) ;
2080+#endif
2081+
2082+ return set_partition_type( partition, operationdetail ) && create_filesystem( partition, operationdetail ) ;
2083+}
2084+
2085+bool GParted_Core::Delete( const Partition & partition, OperationDetail & operationdetail )
2086+{
2087+ operationdetail .add_child( OperationDetail( _("delete partition") ) ) ;
2088+
2089+ bool succes = false ;
2090+ if ( open_device_and_disk( partition .device_path ) )
2091+ {
2092+ if ( partition .type == TYPE_EXTENDED )
2093+ lp_partition = ped_disk_extended_partition( lp_disk ) ;
2094+ else
2095+ lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition .get_sector() ) ;
2096+
2097+ succes = ped_disk_delete_partition( lp_disk, lp_partition ) && commit() ;
2098+
2099+ close_device_and_disk() ;
2100+ }
2101+
2102+#ifndef USE_LIBPARTED_DMRAID
2103+ //delete partition dev mapper entry, and delete and recreate all other affected dev mapper entries if dmraid
2104+ DMRaid dmraid ;
2105+ if ( succes && dmraid .is_dmraid_device( partition .device_path ) )
2106+ {
2107+ //Open disk handle before and close after to prevent application crash.
2108+ if ( open_device_and_disk( partition .device_path ) )
2109+ {
2110+ if ( ! dmraid .delete_affected_dev_map_entries( partition, operationdetail .get_last_child() ) )
2111+ succes = false ; //comand failed
2112+
2113+ if ( ! dmraid .create_dev_map_entries( partition, operationdetail .get_last_child() ) )
2114+ succes = false ; //command failed
2115+
2116+ close_device_and_disk() ;
2117+ }
2118+ }
2119+#endif
2120+
2121+ operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
2122+ return succes ;
2123+}
2124+
2125+bool GParted_Core::label_partition( const Partition & partition, OperationDetail & operationdetail )
2126+{
2127+ if( partition .label .empty() ) {
2128+ operationdetail .add_child( OperationDetail( String::ucompose(
2129+ _("Clear partition label on %1"),
2130+ partition .get_path()
2131+ ) ) ) ;
2132+ } else {
2133+ operationdetail .add_child( OperationDetail( String::ucompose(
2134+ _("Set partition label to \"%1\" on %2"),
2135+ partition .label, partition .get_path()
2136+ ) ) ) ;
2137+ }
2138+
2139+ bool succes = false ;
2140+ if ( partition .type != TYPE_EXTENDED )
2141+ {
2142+ switch( get_fs( partition .filesystem ) .write_label )
2143+ {
2144+ case FS::EXTERNAL:
2145+ succes = set_proper_filesystem( partition .filesystem ) &&
2146+ p_filesystem ->write_label( partition, operationdetail .get_last_child() ) ;
2147+ break ;
2148+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
2149+ case FS::LIBPARTED:
2150+ break ;
2151+#endif
2152+
2153+ default:
2154+ break ;
2155+ }
2156+ }
2157+
2158+ operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
2159+
2160+ return succes ;
2161+}
2162+
2163+bool GParted_Core::change_uuid( const Partition & partition, OperationDetail & operationdetail )
2164+{
2165+ if ( partition .uuid == UUID_RANDOM_NTFS_HALF ) {
2166+ operationdetail .add_child( OperationDetail( String::ucompose(
2167+ _("Set half of the UUID on %1 to a new, random value"),
2168+ partition .get_path()
2169+ ) ) ) ;
2170+ } else {
2171+ operationdetail .add_child( OperationDetail( String::ucompose(
2172+ _("Set UUID on %1 to a new, random value"),
2173+ partition .get_path()
2174+ ) ) ) ;
2175+ }
2176+
2177+ bool succes = false ;
2178+ if ( partition .type != TYPE_EXTENDED )
2179+ {
2180+ switch( get_fs( partition .filesystem ) .write_uuid )
2181+ {
2182+ case FS::EXTERNAL:
2183+ succes = set_proper_filesystem( partition .filesystem ) &&
2184+ p_filesystem ->write_uuid( partition, operationdetail .get_last_child() ) ;
2185+ break ;
2186+
2187+ default:
2188+ break;
2189+ }
2190+ }
2191+
2192+ operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
2193+
2194+ return succes ;
2195+}
2196+
2197+bool GParted_Core::resize_move( const Device & device,
2198+ const Partition & partition_old,
2199+ Partition & partition_new,
2200+ OperationDetail & operationdetail )
2201+{
2202+ if ( (partition_new .alignment == ALIGN_STRICT)
2203+ || (partition_new .alignment == ALIGN_MEBIBYTE)
2204+ || partition_new .strict_start
2205+ || calculate_exact_geom( partition_old, partition_new, operationdetail )
2206+ )
2207+ {
2208+ if ( partition_old .type == TYPE_EXTENDED )
2209+ return resize_move_partition( partition_old, partition_new, operationdetail ) ;
2210+
2211+ if ( partition_new .sector_start == partition_old .sector_start )
2212+ return resize( partition_old, partition_new, operationdetail ) ;
2213+
2214+ if ( partition_new .get_sector_length() == partition_old .get_sector_length() )
2215+ return move( device, partition_old, partition_new, operationdetail ) ;
2216+
2217+ Partition temp ;
2218+ if ( partition_new .get_sector_length() > partition_old .get_sector_length() )
2219+ {
2220+ //first move, then grow. Since old.length < new.length and new.start is valid, temp is valid.
2221+ temp = partition_new ;
2222+ temp .sector_end = temp .sector_start + partition_old .get_sector_length() -1 ;
2223+ }
2224+
2225+ if ( partition_new .get_sector_length() < partition_old .get_sector_length() )
2226+ {
2227+ //first shrink, then move. Since new.length < old.length and old.start is valid, temp is valid.
2228+ temp = partition_old ;
2229+ temp .sector_end = partition_old .sector_start + partition_new .get_sector_length() -1 ;
2230+ }
2231+
2232+ PartitionAlignment previous_alignment = temp .alignment ;
2233+ temp .alignment = ALIGN_STRICT ;
2234+ bool succes = resize_move( device, partition_old, temp, operationdetail ) ;
2235+ temp .alignment = previous_alignment ;
2236+
2237+ return succes && resize_move( device, temp, partition_new, operationdetail ) ;
2238+ }
2239+
2240+ return false ;
2241+}
2242+
2243+bool GParted_Core::move( const Device & device,
2244+ const Partition & partition_old,
2245+ const Partition & partition_new,
2246+ OperationDetail & operationdetail )
2247+{
2248+ if ( partition_old .get_sector_length() != partition_new .get_sector_length() )
2249+ {
2250+ operationdetail .add_child( OperationDetail(
2251+ /* TO TRANSLATORS: moving requires old and new length to be the same
2252+ * means that the length in bytes of the old partition and new partition
2253+ * must be the same. If the sector sizes of the old partition and the
2254+ * new partition are the same, then the length in sectors must be the same.
2255+ */
2256+ _("moving requires old and new length to be the same"), STATUS_ERROR, FONT_ITALIC ) ) ;
2257+
2258+ return false ;
2259+ }
2260+
2261+ bool succes = false ;
2262+ if ( check_repair_filesystem( partition_old, operationdetail ) )
2263+ {
2264+ //NOTE: Logical partitions are preceded by meta data. To prevent this
2265+ // meta data from being overwritten we first expand the partition to
2266+ // encompass all of the space involved in the move. In this way we
2267+ // prevent overwriting the meta data for this partition when we move
2268+ // this partition to the left. We also prevent overwriting the meta
2269+ // data of a following partition when we move this partition to the
2270+ // right.
2271+ Partition partition_all_space = partition_old ;
2272+ partition_all_space .alignment = ALIGN_STRICT ;
2273+ if ( partition_new .sector_start < partition_all_space. sector_start )
2274+ partition_all_space .sector_start = partition_new. sector_start ;
2275+ if ( partition_new .sector_end > partition_all_space.sector_end )
2276+ partition_all_space .sector_end = partition_new. sector_end ;
2277+
2278+ //Make old partition all encompassing and if move file system fails
2279+ // then return partition table to original state
2280+ if ( resize_move_partition( partition_old, partition_all_space, operationdetail ) )
2281+ {
2282+ //Note move of file system is from old values to new values, not from
2283+ // the all encompassing values.
2284+ if ( ! move_filesystem( partition_old, partition_new, operationdetail ) )
2285+ {
2286+ operationdetail .add_child( OperationDetail( _("rollback last change to the partition table") ) ) ;
2287+
2288+ Partition partition_restore = partition_old ;
2289+ partition_restore .alignment = ALIGN_STRICT ; //Ensure that old partition boundaries are not modified
2290+ if ( resize_move_partition( partition_all_space, partition_restore, operationdetail .get_last_child() ) )
2291+ operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
2292+ else
2293+ operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
2294+ }
2295+ else
2296+ succes = true ;
2297+ }
2298+
2299+ //Make new partition from all encompassing partition
2300+ succes = succes && resize_move_partition( partition_all_space, partition_new, operationdetail ) ;
2301+
2302+ succes = ( succes
2303+ && update_bootsector( partition_new, operationdetail )
2304+ && ( //Do not maximize file system if FS not linux-swap and new size <= old
2305+ ( partition_new .filesystem != FS_LINUX_SWAP //linux-swap is recreated, not moved
2306+ && partition_new .get_sector_length() <= partition_old .get_sector_length()
2307+ )
2308+ || ( check_repair_filesystem( partition_new, operationdetail )
2309+ && maximize_filesystem( partition_new, operationdetail )
2310+ )
2311+ )
2312+ );
2313+
2314+ }
2315+
2316+ return succes ;
2317+}
2318+
2319+bool GParted_Core::move_filesystem( const Partition & partition_old,
2320+ const Partition & partition_new,
2321+ OperationDetail & operationdetail )
2322+{
2323+ if ( partition_new .sector_start < partition_old .sector_start )
2324+ operationdetail .add_child( OperationDetail( _("move file system to the left") ) ) ;
2325+ else if ( partition_new .sector_start > partition_old .sector_start )
2326+ operationdetail .add_child( OperationDetail( _("move file system to the right") ) ) ;
2327+ else
2328+ {
2329+ operationdetail .add_child( OperationDetail( _("move file system") ) ) ;
2330+ operationdetail .get_last_child() .add_child(
2331+ OperationDetail( _("new and old file system have the same position. Hence skipping this operation"),
2332+ STATUS_NONE,
2333+ FONT_ITALIC ) ) ;
2334+
2335+ operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
2336+ return true ;
2337+ }
2338+
2339+ bool succes = false ;
2340+ switch ( get_fs( partition_old .filesystem ) .move )
2341+ {
2342+ case GParted::FS::NONE:
2343+ break ;
2344+ case GParted::FS::GPARTED:
2345+ succes = false ;
2346+ if ( partition_new .test_overlap( partition_old ) )
2347+ {
2348+ if ( copy_filesystem_simulation( partition_old, partition_new, operationdetail .get_last_child() ) )
2349+ {
2350+ operationdetail .get_last_child() .add_child( OperationDetail( _("perform real move") ) ) ;
2351+
2352+ Sector total_done ;
2353+ succes = copy_filesystem( partition_old,
2354+ partition_new,
2355+ operationdetail .get_last_child() .get_last_child(),
2356+ total_done ) ;
2357+
2358+ operationdetail .get_last_child() .get_last_child()
2359+ .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
2360+ if ( ! succes )
2361+ {
2362+ rollback_transaction( partition_old,
2363+ partition_new,
2364+ operationdetail .get_last_child(),
2365+ total_done ) ;
2366+
2367+ check_repair_filesystem( partition_old, operationdetail ) ;
2368+ }
2369+ }
2370+ }
2371+ else
2372+ succes = copy_filesystem( partition_old, partition_new, operationdetail .get_last_child() ) ;
2373+
2374+ break ;
2375+#ifdef HAVE_LIBPARTED_FS_RESIZE
2376+ case GParted::FS::LIBPARTED:
2377+ succes = resize_move_filesystem_using_libparted( partition_old,
2378+ partition_new,
2379+ operationdetail .get_last_child() ) ;
2380+ break ;
2381+#endif
2382+ case GParted::FS::EXTERNAL:
2383+ succes = set_proper_filesystem( partition_new .filesystem ) &&
2384+ p_filesystem ->move( partition_old
2385+ , partition_new
2386+ , operationdetail .get_last_child()
2387+ ) ;
2388+ break ;
2389+
2390+ default:
2391+ break ;
2392+ }
2393+
2394+ operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
2395+ return succes ;
2396+}
2397+
2398+#ifdef HAVE_LIBPARTED_FS_RESIZE
2399+bool GParted_Core::resize_move_filesystem_using_libparted( const Partition & partition_old,
2400+ const Partition & partition_new,
2401+ OperationDetail & operationdetail )
2402+{
2403+ operationdetail .add_child( OperationDetail( _("using libparted"), STATUS_NONE ) ) ;
2404+
2405+ bool return_value = false ;
2406+ if ( open_device_and_disk( partition_old .device_path ) )
2407+ {
2408+ PedFileSystem * fs = NULL ;
2409+ PedGeometry * lp_geom = NULL ;
2410+
2411+ lp_geom = ped_geometry_new( lp_device,
2412+ partition_old .sector_start,
2413+ partition_old .get_sector_length() ) ;
2414+ if ( lp_geom )
2415+ {
2416+ fs = ped_file_system_open( lp_geom );
2417+ if ( fs )
2418+ {
2419+ lp_geom = NULL ;
2420+ lp_geom = ped_geometry_new( lp_device,
2421+ partition_new .sector_start,
2422+ partition_new .get_sector_length() ) ;
2423+ if ( lp_geom )
2424+ return_value = ped_file_system_resize( fs, lp_geom, NULL ) && commit() ;
2425+
2426+ ped_file_system_close( fs );
2427+ }
2428+ }
2429+
2430+ close_device_and_disk() ;
2431+ }
2432+
2433+ return return_value ;
2434+}
2435+#endif
2436+
2437+bool GParted_Core::resize( const Partition & partition_old,
2438+ const Partition & partition_new,
2439+ OperationDetail & operationdetail )
2440+{
2441+ if ( partition_old .sector_start != partition_new .sector_start )
2442+ {
2443+ operationdetail .add_child( OperationDetail(
2444+ _("resizing requires old and new start to be the same"), STATUS_ERROR, FONT_ITALIC ) ) ;
2445+
2446+ return false ;
2447+ }
2448+
2449+ bool succes = false ;
2450+ if ( check_repair_filesystem( partition_new, operationdetail ) )
2451+ {
2452+ succes = true ;
2453+
2454+ if ( succes && partition_new .get_sector_length() < partition_old .get_sector_length() )
2455+ succes = resize_filesystem( partition_old, partition_new, operationdetail ) ;
2456+
2457+ if ( succes )
2458+ succes = resize_move_partition( partition_old, partition_new, operationdetail ) ;
2459+
2460+ //expand file system to fit exactly in partition
2461+ if ( ! ( //Do not maximize file system if FS not linux-swap and new size <= old
2462+ ( partition_new .filesystem != FS_LINUX_SWAP //linux-swap is recreated, not resized
2463+ && partition_new .get_sector_length() <= partition_old .get_sector_length()
2464+ )
2465+ || ( check_repair_filesystem( partition_new, operationdetail )
2466+ && maximize_filesystem( partition_new, operationdetail )
2467+ )
2468+ )
2469+ )
2470+ succes = false ;
2471+
2472+ return succes ;
2473+ }
2474+
2475+ return false ;
2476+}
2477+
2478+bool GParted_Core::resize_move_partition( const Partition & partition_old,
2479+ const Partition & partition_new,
2480+ OperationDetail & operationdetail )
2481+{
2482+ //i'm not too happy with this, but i think it is the correct way from a i18n POV
2483+ enum Action
2484+ {
2485+ NONE = 0,
2486+ MOVE_RIGHT = 1,
2487+ MOVE_LEFT = 2,
2488+ GROW = 3,
2489+ SHRINK = 4,
2490+ MOVE_RIGHT_GROW = 5,
2491+ MOVE_RIGHT_SHRINK = 6,
2492+ MOVE_LEFT_GROW = 7,
2493+ MOVE_LEFT_SHRINK = 8
2494+ } ;
2495+ Action action = NONE ;
2496+
2497+ if ( partition_new .get_sector_length() > partition_old .get_sector_length() )
2498+ action = GROW ;
2499+ else if ( partition_new .get_sector_length() < partition_old .get_sector_length() )
2500+ action = SHRINK ;
2501+
2502+ if ( partition_new .sector_start > partition_old .sector_start &&
2503+ partition_new .sector_end > partition_old .sector_end )
2504+ action = action == GROW ? MOVE_RIGHT_GROW : action == SHRINK ? MOVE_RIGHT_SHRINK : MOVE_RIGHT ;
2505+ else if ( partition_new .sector_start < partition_old .sector_start &&
2506+ partition_new .sector_end < partition_old .sector_end )
2507+ action = action == GROW ? MOVE_LEFT_GROW : action == SHRINK ? MOVE_LEFT_SHRINK : MOVE_LEFT ;
2508+
2509+ Glib::ustring description ;
2510+ switch ( action )
2511+ {
2512+ case NONE :
2513+ description = _("resize/move partition") ;
2514+ break ;
2515+ case MOVE_RIGHT :
2516+ description = _("move partition to the right") ;
2517+ break ;
2518+ case MOVE_LEFT :
2519+ description = _("move partition to the left") ;
2520+ break ;
2521+ case GROW :
2522+ description = _("grow partition from %1 to %2") ;
2523+ break ;
2524+ case SHRINK :
2525+ description = _("shrink partition from %1 to %2") ;
2526+ break ;
2527+ case MOVE_RIGHT_GROW :
2528+ description = _("move partition to the right and grow it from %1 to %2") ;
2529+ break ;
2530+ case MOVE_RIGHT_SHRINK :
2531+ description = _("move partition to the right and shrink it from %1 to %2") ;
2532+ break ;
2533+ case MOVE_LEFT_GROW :
2534+ description = _("move partition to the left and grow it from %1 to %2") ;
2535+ break ;
2536+ case MOVE_LEFT_SHRINK :
2537+ description = _("move partition to the left and shrink it from %1 to %2") ;
2538+ break ;
2539+ }
2540+
2541+ if ( ! description .empty() && action != NONE && action != MOVE_LEFT && action != MOVE_RIGHT )
2542+ description = String::ucompose( description,
2543+ Utils::format_size( partition_old .get_sector_length(), partition_old .sector_size ),
2544+ Utils::format_size( partition_new .get_sector_length(), partition_new .sector_size ) ) ;
2545+
2546+ operationdetail .add_child( OperationDetail( description ) ) ;
2547+
2548+
2549+ if ( action == NONE )
2550+ {
2551+ operationdetail .get_last_child() .add_child(
2552+ OperationDetail( _("new and old partition have the same size and position. Hence skipping this operation"),
2553+ STATUS_NONE,
2554+ FONT_ITALIC ) ) ;
2555+
2556+ operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
2557+ return true ;
2558+ }
2559+
2560+ operationdetail .get_last_child() .add_child(
2561+ OperationDetail(
2562+ String::ucompose( _("old start: %1"), partition_old .sector_start ) + "\n" +
2563+ String::ucompose( _("old end: %1"), partition_old .sector_end ) + "\n" +
2564+ String::ucompose( _("old size: %1 (%2)"),
2565+ partition_old .get_sector_length(),
2566+ Utils::format_size( partition_old .get_sector_length(), partition_old .sector_size ) ),
2567+ STATUS_NONE,
2568+ FONT_ITALIC ) ) ;
2569+
2570+ //finally the actual resize/move
2571+ bool return_value = false ;
2572+
2573+ PedConstraint *constraint = NULL ;
2574+ lp_partition = NULL ;
2575+
2576+ //sometimes the lp_partition ->geom .start,end and length values display random numbers
2577+ //after going out of the 'if ( lp_partition)' scope. That's why we use some variables here.
2578+ Sector new_start = -1, new_end = -1 ;
2579+
2580+ if ( open_device_and_disk( partition_old .device_path ) )
2581+ {
2582+ if ( partition_old .type == GParted::TYPE_EXTENDED )
2583+ lp_partition = ped_disk_extended_partition( lp_disk ) ;
2584+ else
2585+ lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition_old .get_sector() ) ;
2586+
2587+ if ( lp_partition )
2588+ {
2589+ if ( (partition_new .alignment == ALIGN_STRICT)
2590+ || (partition_new .alignment == ALIGN_MEBIBYTE)
2591+ || partition_new .strict_start
2592+ ) {
2593+ PedGeometry *geom = ped_geometry_new( lp_device,
2594+ partition_new .sector_start,
2595+ partition_new .get_sector_length() ) ;
2596+ constraint = ped_constraint_exact( geom ) ;
2597+ }
2598+ else
2599+ constraint = ped_constraint_any( lp_device ) ;
2600+
2601+ if ( constraint )
2602+ {
2603+ if ( ped_disk_set_partition_geom( lp_disk,
2604+ lp_partition,
2605+ constraint,
2606+ partition_new .sector_start,
2607+ partition_new .sector_end ) )
2608+ {
2609+ new_start = lp_partition ->geom .start ;
2610+ new_end = lp_partition ->geom .end ;
2611+
2612+ return_value = commit() ;
2613+ }
2614+
2615+ ped_constraint_destroy( constraint );
2616+ }
2617+ }
2618+
2619+ close_device_and_disk() ;
2620+ }
2621+
2622+ if ( return_value )
2623+ {
2624+ //Change to partition succeeded
2625+ operationdetail .get_last_child() .add_child(
2626+ OperationDetail(
2627+ String::ucompose( _("new start: %1"), new_start ) + "\n" +
2628+ String::ucompose( _("new end: %1"), new_end ) + "\n" +
2629+ String::ucompose( _("new size: %1 (%2)"),
2630+ new_end - new_start + 1,
2631+ Utils::format_size( new_end - new_start + 1, partition_new .sector_size ) ),
2632+ STATUS_NONE,
2633+ FONT_ITALIC ) ) ;
2634+
2635+#ifndef USE_LIBPARTED_DMRAID
2636+ //update dev mapper entry if partition is dmraid.
2637+ DMRaid dmraid ;
2638+ if ( return_value && dmraid .is_dmraid_device( partition_new .device_path ) )
2639+ {
2640+ //Open disk handle before and close after to prevent application crash.
2641+ if ( open_device_and_disk( partition_new .device_path ) )
2642+ {
2643+ return_value = dmraid .update_dev_map_entry( partition_new, operationdetail .get_last_child() ) ;
2644+ close_device_and_disk() ;
2645+ }
2646+ }
2647+#endif
2648+ }
2649+ else
2650+ {
2651+ //Change to partition failed
2652+ operationdetail .get_last_child() .add_child(
2653+ OperationDetail(
2654+ String::ucompose( _("requested start: %1"), partition_new .sector_start ) + "\n" +
2655+ String::ucompose( _("requested end: %1"), partition_new . sector_end ) + "\n" +
2656+ String::ucompose( _("requested size: %1 (%2)"),
2657+ partition_new .get_sector_length(),
2658+ Utils::format_size( partition_new .get_sector_length(), partition_new .sector_size ) ),
2659+ STATUS_NONE,
2660+ FONT_ITALIC )
2661+ ) ;
2662+ }
2663+
2664+ operationdetail .get_last_child() .set_status( return_value ? STATUS_SUCCES : STATUS_ERROR ) ;
2665+
2666+ return return_value ;
2667+}
2668+
2669+bool GParted_Core::resize_filesystem( const Partition & partition_old,
2670+ const Partition & partition_new,
2671+ OperationDetail & operationdetail,
2672+ bool fill_partition )
2673+{
2674+ //by default 'grow' to accomodate expand_filesystem()
2675+ GParted::FS::Support action = get_fs( partition_old .filesystem ) .grow ;
2676+
2677+ if ( ! fill_partition )
2678+ {
2679+ if ( partition_new .get_sector_length() < partition_old .get_sector_length() )
2680+ {
2681+ operationdetail .add_child( OperationDetail( _("shrink file system") ) ) ;
2682+ action = get_fs( partition_old .filesystem ) .shrink ;
2683+ }
2684+ else if ( partition_new .get_sector_length() > partition_old .get_sector_length() )
2685+ operationdetail .add_child( OperationDetail( _("grow file system") ) ) ;
2686+ else
2687+ {
2688+ operationdetail .add_child( OperationDetail( _("resize file system") ) ) ;
2689+ operationdetail .get_last_child() .add_child(
2690+ OperationDetail(
2691+ _("new and old file system have the same size. Hence skipping this operation"),
2692+ STATUS_NONE,
2693+ FONT_ITALIC ) ) ;
2694+
2695+ operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
2696+ return true ;
2697+ }
2698+ }
2699+
2700+ bool succes = false ;
2701+ switch ( action )
2702+ {
2703+ case GParted::FS::NONE:
2704+ break ;
2705+ case GParted::FS::GPARTED:
2706+ break ;
2707+#ifdef HAVE_LIBPARTED_FS_RESIZE
2708+ case GParted::FS::LIBPARTED:
2709+ succes = resize_move_filesystem_using_libparted( partition_old,
2710+ partition_new,
2711+ operationdetail .get_last_child() ) ;
2712+ break ;
2713+#endif
2714+ case GParted::FS::EXTERNAL:
2715+ succes = set_proper_filesystem( partition_new .filesystem ) &&
2716+ p_filesystem ->resize( partition_new,
2717+ operationdetail .get_last_child(),
2718+ fill_partition ) ;
2719+ break ;
2720+
2721+ default:
2722+ break ;
2723+ }
2724+
2725+ operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
2726+ return succes ;
2727+}
2728+
2729+bool GParted_Core::maximize_filesystem( const Partition & partition, OperationDetail & operationdetail )
2730+{
2731+ operationdetail .add_child( OperationDetail( _("grow file system to fill the partition") ) ) ;
2732+
2733+ if ( get_fs( partition .filesystem ) .grow == GParted::FS::NONE )
2734+ {
2735+ operationdetail .get_last_child() .add_child(
2736+ OperationDetail( _("growing is not available for this file system"),
2737+ STATUS_NONE,
2738+ FONT_ITALIC ) ) ;
2739+
2740+ operationdetail .get_last_child() .set_status( STATUS_N_A ) ;
2741+ return true ;
2742+ }
2743+
2744+ return resize_filesystem( partition, partition, operationdetail, true ) ;
2745+}
2746+
2747+bool GParted_Core::copy( const Partition & partition_src,
2748+ Partition & partition_dst,
2749+ Byte_Value min_size,
2750+ OperationDetail & operationdetail )
2751+{
2752+ if ( partition_dst .get_byte_length() < partition_src .get_byte_length()
2753+ && partition_src .filesystem != FS_XFS // Permit copying to smaller xfs partition
2754+ )
2755+ {
2756+ operationdetail .add_child( OperationDetail(
2757+ _("the destination is smaller than the source partition"), STATUS_ERROR, FONT_ITALIC ) ) ;
2758+
2759+ return false ;
2760+ }
2761+
2762+ if ( check_repair_filesystem( partition_src, operationdetail ) )
2763+ {
2764+ bool succes = true ;
2765+ if ( partition_dst .status == GParted::STAT_COPY )
2766+ {
2767+ /* Handle situation where src sector size is smaller than dst sector size and an additional partial dst sector is required. */
2768+ succes = create_partition( partition_dst, operationdetail, ( (min_size + (partition_dst .sector_size - 1)) / partition_dst .sector_size ) ) ;
2769+ }
2770+
2771+ if ( succes && set_partition_type( partition_dst, operationdetail ) )
2772+ {
2773+ operationdetail .add_child( OperationDetail(
2774+ String::ucompose( _("copy file system of %1 to %2"),
2775+ partition_src .get_path(),
2776+ partition_dst .get_path() ) ) ) ;
2777+
2778+ switch ( get_fs( partition_dst .filesystem ) .copy )
2779+ {
2780+ case GParted::FS::GPARTED :
2781+ succes = copy_filesystem( partition_src,
2782+ partition_dst,
2783+ operationdetail .get_last_child() ) ;
2784+ break ;
2785+
2786+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
2787+ case GParted::FS::LIBPARTED :
2788+ //FIXME: see if copying through libparted has any advantages
2789+ break ;
2790+#endif
2791+
2792+ case GParted::FS::EXTERNAL :
2793+ succes = set_proper_filesystem( partition_dst .filesystem ) &&
2794+ p_filesystem ->copy( partition_src .get_path(),
2795+ partition_dst .get_path(),
2796+ operationdetail .get_last_child() ) ;
2797+ break ;
2798+
2799+ default :
2800+ succes = false ;
2801+ break ;
2802+ }
2803+
2804+ operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
2805+
2806+ return ( succes
2807+ && update_bootsector( partition_dst, operationdetail )
2808+ && ( //Do not maximize file system if FS not linux-swap and destination size <= source
2809+ ( partition_dst .filesystem != FS_LINUX_SWAP //linux-swap is recreated, not copied
2810+ && partition_dst .get_sector_length() <= partition_src .get_sector_length()
2811+ )
2812+ || ( check_repair_filesystem( partition_dst, operationdetail )
2813+ && maximize_filesystem( partition_dst, operationdetail )
2814+ )
2815+ )
2816+ );
2817+ }
2818+ }
2819+
2820+ return false ;
2821+}
2822+
2823+bool GParted_Core::copy_filesystem_simulation( const Partition & partition_src,
2824+ const Partition & partition_dst,
2825+ OperationDetail & operationdetail )
2826+{
2827+ operationdetail .add_child( OperationDetail( _("perform read-only test") ) ) ;
2828+
2829+ bool succes = copy_filesystem( partition_src, partition_dst, operationdetail .get_last_child(), true ) ;
2830+
2831+ operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
2832+ return succes ;
2833+}
2834+
2835+bool GParted_Core::copy_filesystem( const Partition & partition_src,
2836+ const Partition & partition_dst,
2837+ OperationDetail & operationdetail,
2838+ bool readonly )
2839+{
2840+ Sector dummy ;
2841+ return copy_filesystem( partition_src .device_path,
2842+ partition_dst .device_path,
2843+ partition_src .sector_start,
2844+ partition_dst .sector_start,
2845+ partition_src .sector_size,
2846+ partition_dst .sector_size,
2847+ partition_src .get_byte_length(),
2848+ operationdetail,
2849+ readonly,
2850+ dummy ) ;
2851+}
2852+
2853+bool GParted_Core::copy_filesystem( const Partition & partition_src,
2854+ const Partition & partition_dst,
2855+ OperationDetail & operationdetail,
2856+ Byte_Value & total_done )
2857+{
2858+ return copy_filesystem( partition_src .device_path,
2859+ partition_dst .device_path,
2860+ partition_src .sector_start,
2861+ partition_dst .sector_start,
2862+ partition_src .sector_size,
2863+ partition_dst .sector_size,
2864+ partition_src .get_byte_length(),
2865+ operationdetail,
2866+ false,
2867+ total_done ) ;
2868+}
2869+
2870+bool GParted_Core::copy_filesystem( const Glib::ustring & src_device,
2871+ const Glib::ustring & dst_device,
2872+ Sector src_start,
2873+ Sector dst_start,
2874+ Byte_Value src_sector_size,
2875+ Byte_Value dst_sector_size,
2876+ Byte_Value src_length,
2877+ OperationDetail & operationdetail,
2878+ bool readonly,
2879+ Byte_Value & total_done )
2880+{
2881+ operationdetail .add_child( OperationDetail( _("using internal algorithm"), STATUS_NONE ) ) ;
2882+ operationdetail .add_child( OperationDetail(
2883+ String::ucompose( readonly ?
2884+ /*TO TRANSLATORS: looks like read 1.00 MiB */
2885+ _("read %1") :
2886+ /*TO TRANSLATORS: looks like copy 1.00 MiB */
2887+ _("copy %1"),
2888+ Utils::format_size( src_length, 1 ) ),
2889+ STATUS_NONE ) ) ;
2890+
2891+ operationdetail .add_child( OperationDetail( _("finding optimal block size"), STATUS_NONE ) ) ;
2892+
2893+ Byte_Value benchmark_blocksize = readonly ? (2 * MEBIBYTE) : (1 * MEBIBYTE), N = (16 * MEBIBYTE) ;
2894+ Byte_Value optimal_blocksize = benchmark_blocksize ;
2895+ Sector offset_read = src_start ;
2896+ Sector offset_write = dst_start ;
2897+
2898+ //Handle situation where we need to perform the copy beginning
2899+ // with the end of the partition and finishing with the start.
2900+ if ( dst_start > src_start )
2901+ {
2902+ offset_read += (src_length/src_sector_size) - (N/src_sector_size) ;
2903+ /* Handle situation where src sector size is smaller than dst sector size and an additional partial dst sector is required. */
2904+ offset_write += ((src_length + (dst_sector_size - 1))/dst_sector_size) - (N/dst_sector_size) ;
2905+ }
2906+
2907+ total_done = 0 ;
2908+ Byte_Value done = 0 ;
2909+ Glib::Timer timer ;
2910+ double smallest_time = 1000000 ;
2911+ bool succes = true ;
2912+
2913+ //Benchmark copy times using different block sizes to determine optimal size
2914+ while ( succes &&
2915+ llabs( done ) + N <= src_length &&
2916+ benchmark_blocksize <= N )
2917+ {
2918+ timer .reset() ;
2919+ succes = copy_blocks( src_device,
2920+ dst_device,
2921+ offset_read + (done / src_sector_size),
2922+ offset_write + (done / dst_sector_size),
2923+ N,
2924+ benchmark_blocksize,
2925+ operationdetail .get_last_child(),
2926+ readonly,
2927+ total_done ) ;
2928+ timer.stop() ;
2929+
2930+ operationdetail .get_last_child() .get_last_child() .add_child( OperationDetail(
2931+ String::ucompose( _("%1 seconds"), timer .elapsed() ), STATUS_NONE, FONT_ITALIC ) ) ;
2932+
2933+ if ( timer .elapsed() <= smallest_time )
2934+ {
2935+ smallest_time = timer .elapsed() ;
2936+ optimal_blocksize = benchmark_blocksize ;
2937+ }
2938+ benchmark_blocksize *= 2 ;
2939+
2940+ if ( ( dst_start > src_start ) )
2941+ done -= N ;
2942+ else
2943+ done += N ;
2944+ }
2945+
2946+ if ( succes )
2947+ operationdetail .get_last_child() .add_child( OperationDetail( String::ucompose(
2948+ /*TO TRANSLATORS: looks like optimal block size is 1.00 MiB */
2949+ _("optimal block size is %1"),
2950+ Utils::format_size( optimal_blocksize, 1 ) ),
2951+ STATUS_NONE ) ) ;
2952+
2953+ if ( succes && llabs( done ) < src_length )
2954+ succes = copy_blocks( src_device,
2955+ dst_device,
2956+ src_start + ( dst_start > src_start ? 0 : (done / src_sector_size) ),
2957+ dst_start + ( dst_start > src_start ? 0 : (done / dst_sector_size) ),
2958+ src_length - llabs( done ),
2959+ optimal_blocksize,
2960+ operationdetail,
2961+ readonly,
2962+ total_done ) ;
2963+
2964+ operationdetail .add_child( OperationDetail(
2965+ String::ucompose( readonly ?
2966+ /*TO TRANSLATORS: looks like 1.00 MiB (1048576 B) read */
2967+ _("%1 (%2 B) read") :
2968+ /*TO TRANSLATORS: looks like 1.00 MiB (1048576 B) copied */
2969+ _("%1 (%2 B) copied"),
2970+ Utils::format_size( total_done, 1 ), total_done ),
2971+ STATUS_NONE ) ) ;
2972+ return succes ;
2973+}
2974+
2975+void GParted_Core::rollback_transaction( const Partition & partition_src,
2976+ const Partition & partition_dst,
2977+ OperationDetail & operationdetail,
2978+ Byte_Value total_done )
2979+{
2980+ if ( total_done > 0 )
2981+ {
2982+ operationdetail .add_child( OperationDetail( _("roll back last transaction") ) ) ;
2983+
2984+ //find out exactly which part of the file system was copied (and to where it was copied)..
2985+ Partition temp_src = partition_src ;
2986+ Partition temp_dst = partition_dst ;
2987+
2988+ if ( partition_dst .sector_start > partition_src .sector_start )
2989+ {
2990+ temp_src .sector_start = temp_src .sector_end - ( (total_done / temp_src .sector_size) - 1 ) ;
2991+ temp_dst .sector_start = temp_dst .sector_end - ( (total_done / temp_dst .sector_size) - 1 ) ;
2992+ }
2993+ else
2994+ {
2995+ temp_src .sector_end = temp_src .sector_start + ( (total_done / temp_src .sector_size) - 1 ) ;
2996+ temp_dst .sector_end = temp_dst .sector_start + ( (total_done / temp_dst .sector_size) - 1 ) ;
2997+ }
2998+
2999+ //and copy it back (NOTE the reversed dst and src)
3000+ bool succes = copy_filesystem( temp_dst, temp_src, operationdetail .get_last_child() ) ;
3001+
3002+ operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
3003+ }
3004+}
3005+
3006+bool GParted_Core::check_repair_filesystem( const Partition & partition, OperationDetail & operationdetail )
3007+{
3008+ operationdetail .add_child( OperationDetail(
3009+ String::ucompose(
3010+ /* TO TRANSLATORS: looks like check file system on /dev/sda5 for errors and (if possible) fix them */
3011+ _("check file system on %1 for errors and (if possible) fix them"),
3012+ partition .get_path() ) ) ) ;
3013+
3014+ bool succes = false ;
3015+ switch ( get_fs( partition .filesystem ) .check )
3016+ {
3017+ case GParted::FS::NONE:
3018+ operationdetail .get_last_child() .add_child(
3019+ OperationDetail( _("checking is not available for this file system"),
3020+ STATUS_NONE,
3021+ FONT_ITALIC ) ) ;
3022+
3023+ operationdetail .get_last_child() .set_status( STATUS_N_A ) ;
3024+ return true ;
3025+
3026+ break ;
3027+ case GParted::FS::GPARTED:
3028+ break ;
3029+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
3030+ case GParted::FS::LIBPARTED:
3031+ break ;
3032+#endif
3033+ case GParted::FS::EXTERNAL:
3034+ succes = set_proper_filesystem( partition .filesystem ) &&
3035+ p_filesystem ->check_repair( partition, operationdetail .get_last_child() ) ;
3036+
3037+ break ;
3038+
3039+ default:
3040+ break ;
3041+ }
3042+
3043+ operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
3044+ return succes ;
3045+}
3046+
3047+bool GParted_Core::set_partition_type( const Partition & partition, OperationDetail & operationdetail )
3048+{
3049+ operationdetail .add_child( OperationDetail(
3050+ String::ucompose( _("set partition type on %1"), partition .get_path() ) ) ) ;
3051+
3052+ bool return_value = false ;
3053+
3054+ if ( open_device_and_disk( partition .device_path ) )
3055+ {
3056+ PedFileSystemType * fs_type =
3057+ ped_file_system_type_get( Utils::get_filesystem_string( partition .filesystem ) .c_str() ) ;
3058+
3059+ //If not found, and FS is linux-swap, then try linux-swap(v1)
3060+ if ( ! fs_type && Utils::get_filesystem_string( partition .filesystem ) == "linux-swap" )
3061+ fs_type = ped_file_system_type_get( "linux-swap(v1)" ) ;
3062+
3063+ //If not found, and FS is linux-swap, then try linux-swap(new)
3064+ if ( ! fs_type && Utils::get_filesystem_string( partition .filesystem ) == "linux-swap" )
3065+ fs_type = ped_file_system_type_get( "linux-swap(new)" ) ;
3066+
3067+ //default is Linux (83)
3068+ if ( ! fs_type )
3069+ fs_type = ped_file_system_type_get( "ext2" ) ;
3070+
3071+ if ( fs_type )
3072+ {
3073+ lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition .get_sector() ) ;
3074+
3075+ if ( lp_partition &&
3076+ ped_partition_set_system( lp_partition, fs_type ) &&
3077+ commit() )
3078+ {
3079+ operationdetail .get_last_child() .add_child(
3080+ OperationDetail( String::ucompose( _("new partition type: %1"),
3081+ lp_partition ->fs_type ->name ),
3082+ STATUS_NONE,
3083+ FONT_ITALIC ) ) ;
3084+
3085+ return_value = true ;
3086+ }
3087+ }
3088+
3089+ close_device_and_disk() ;
3090+ }
3091+
3092+ operationdetail .get_last_child() .set_status( return_value ? STATUS_SUCCES : STATUS_ERROR ) ;
3093+ return return_value ;
3094+}
3095+
3096+void GParted_Core::set_progress_info( Byte_Value total,
3097+ Byte_Value done,
3098+ const Glib::Timer & timer,
3099+ OperationDetail & operationdetail,
3100+ bool readonly )
3101+{
3102+ operationdetail .fraction = done / static_cast<double>( total ) ;
3103+
3104+ std::time_t time_remaining = Utils::round( (total - done) / ( done / timer .elapsed() ) ) ;
3105+
3106+ operationdetail .progress_text =
3107+ String::ucompose( readonly ?
3108+ /*TO TRANSLATORS: looks like 1.00 MiB of 16.00 MiB read (00:01:59 remaining) */
3109+ _("%1 of %2 read (%3 remaining)") :
3110+ /*TO TRANSLATORS: looks like 1.00 MiB of 16.00 MiB copied (00:01:59 remaining) */
3111+ _("%1 of %2 copied (%3 remaining)"),
3112+ Utils::format_size( done, 1 ),
3113+ Utils::format_size( total,1 ),
3114+ Utils::format_time( time_remaining) ) ;
3115+
3116+ operationdetail .set_description(
3117+ String::ucompose( readonly ?
3118+ /*TO TRANSLATORS: looks like 1.00 MiB of 16.00 MiB read */
3119+ _("%1 of %2 read") :
3120+ /*TO TRANSLATORS: looks like 1.00 MiB of 16.00 MiB copied */
3121+ _("%1 of %2 copied"),
3122+ Utils::format_size( done, 1 ), Utils::format_size( total, 1 ) ),
3123+ FONT_ITALIC ) ;
3124+}
3125+
3126+bool GParted_Core::copy_blocks( const Glib::ustring & src_device,
3127+ const Glib::ustring & dst_device,
3128+ Sector src_start,
3129+ Sector dst_start,
3130+ Byte_Value length,
3131+ Byte_Value blocksize,
3132+ OperationDetail & operationdetail,
3133+ bool readonly,
3134+ Byte_Value & total_done )
3135+{
3136+ if ( blocksize > length )
3137+ blocksize = length ;
3138+
3139+ if ( readonly )
3140+ operationdetail .add_child( OperationDetail(
3141+ /*TO TRANSLATORS: looks like read 16.00 MiB using a block size of 1.00 MiB */
3142+ String::ucompose( _("read %1 using a block size of %2"), Utils::format_size( length, 1 ),
3143+ Utils::format_size( blocksize, 1 ) ) ) ) ;
3144+ else
3145+ operationdetail .add_child( OperationDetail(
3146+ /*TO TRANSLATORS: looks like copy 16.00 MiB using a block size of 1.00 MiB */
3147+ String::ucompose( _("copy %1 using a block size of %2"), Utils::format_size( length, 1 ),
3148+ Utils::format_size( blocksize, 1 ) ) ) ) ;
3149+
3150+ Byte_Value done = length % blocksize ;
3151+
3152+ bool succes = false ;
3153+ PedDevice *lp_device_src = ped_device_get( src_device .c_str() );
3154+ PedDevice *lp_device_dst = src_device != dst_device ? ped_device_get( dst_device .c_str() ) : lp_device_src ;
3155+
3156+ if ( lp_device_src && lp_device_dst && ped_device_open( lp_device_src ) && ped_device_open( lp_device_dst ) )
3157+ {
3158+ Byte_Value src_sector_size = lp_device_src ->sector_size ;
3159+ Byte_Value dst_sector_size = lp_device_dst ->sector_size ;
3160+
3161+ //Handle situation where we need to perform the copy beginning
3162+ // with the end of the partition and finishing with the start.
3163+ if ( dst_start > src_start )
3164+ {
3165+ blocksize -= 2*blocksize ;
3166+ done -= 2*done ;
3167+ src_start += ( (length / src_sector_size) - 1 ) ;
3168+ /* Handle situation where src sector size is smaller than dst sector size and an additional partial dst sector is required. */
3169+ dst_start += ( ((length + (dst_sector_size - 1))/ dst_sector_size) - 1 ) ;
3170+ }
3171+
3172+ Glib::ustring error_message ;
3173+ buf = static_cast<char *>( malloc( llabs( blocksize ) ) ) ;
3174+ if ( buf )
3175+ {
3176+ ped_device_sync( lp_device_dst ) ;
3177+
3178+ succes = true ;
3179+ if ( done != 0 )
3180+ succes = copy_block( lp_device_src,
3181+ lp_device_dst,
3182+ src_start,
3183+ dst_start,
3184+ done,
3185+ error_message,
3186+ readonly ) ;
3187+ if ( ! succes )
3188+ done = 0 ;
3189+
3190+ //add an empty sub which we will constantly update in the loop
3191+ operationdetail .get_last_child() .add_child( OperationDetail( "", STATUS_NONE ) ) ;
3192+
3193+ Glib::Timer timer_progress_timeout, timer_total ;
3194+ while( succes && llabs( done ) < length )
3195+ {
3196+ succes = copy_block( lp_device_src,
3197+ lp_device_dst,
3198+ src_start + (done / src_sector_size),
3199+ dst_start + (done / dst_sector_size),
3200+ blocksize,
3201+ error_message,
3202+ readonly ) ;
3203+ if ( succes )
3204+ done += blocksize ;
3205+
3206+ if ( timer_progress_timeout .elapsed() >= 0.5 )
3207+ {
3208+ set_progress_info( length,
3209+ llabs( done + blocksize ),
3210+ timer_total,
3211+ operationdetail .get_last_child() .get_last_child(),
3212+ readonly ) ;
3213+
3214+ timer_progress_timeout .reset() ;
3215+ }
3216+ }
3217+ //set progress bar current info on completion
3218+ set_progress_info( length,
3219+ llabs( done ),
3220+ timer_total,
3221+ operationdetail .get_last_child() .get_last_child(),
3222+ readonly ) ;
3223+
3224+ free( buf ) ;
3225+ }
3226+ else
3227+ error_message = Glib::strerror( errno ) ;
3228+
3229+ //reset fraction to -1 to make room for a new one (or a pulsebar)
3230+ operationdetail .get_last_child() .get_last_child() .fraction = -1 ;
3231+
3232+ //final description
3233+ operationdetail .get_last_child() .get_last_child() .set_description(
3234+ String::ucompose( readonly ?
3235+ /*TO TRANSLATORS: looks like 1.00 MiB of 16.00 MiB read */
3236+ _("%1 of %2 read") :
3237+ /*TO TRANSLATORS: looks like 1.00 MiB of 16.00 MiB copied */
3238+ _("%1 of %2 copied"),
3239+ Utils::format_size( llabs( done ), 1 ),
3240+ Utils::format_size( length, 1 ) ),
3241+ FONT_ITALIC ) ;
3242+
3243+ if ( ! succes && ! error_message .empty() )
3244+ operationdetail .get_last_child() .add_child(
3245+ OperationDetail( error_message, STATUS_NONE, FONT_ITALIC ) ) ;
3246+
3247+ total_done += llabs( done ) ;
3248+
3249+ //close and destroy the devices..
3250+ ped_device_close( lp_device_src ) ;
3251+ ped_device_destroy( lp_device_src ) ;
3252+
3253+ if ( src_device != dst_device )
3254+ {
3255+ ped_device_close( lp_device_dst ) ;
3256+ ped_device_destroy( lp_device_dst ) ;
3257+ }
3258+ }
3259+
3260+ operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
3261+ return succes ;
3262+}
3263+
3264+bool GParted_Core::copy_block( PedDevice * lp_device_src,
3265+ PedDevice * lp_device_dst,
3266+ Sector offset_src,
3267+ Sector offset_dst,
3268+ Byte_Value block_length,
3269+ Glib::ustring & error_message,
3270+ bool readonly )
3271+{
3272+ Byte_Value sector_size_src = lp_device_src ->sector_size ;
3273+ Byte_Value sector_size_dst = lp_device_dst ->sector_size ;
3274+
3275+ //Handle case where src and dst sector sizes are different.
3276+ // E.g., 5 sectors x 512 bytes/sector = ??? 2048 byte sectors
3277+ Sector num_blocks_src = (llabs(block_length) + (sector_size_src - 1) ) / sector_size_src ;
3278+ Sector num_blocks_dst = (llabs(block_length) + (sector_size_dst - 1) ) / sector_size_dst ;
3279+
3280+ //Handle situation where we are performing copy operation beginning
3281+ // with the end of the partition and finishing with the start.
3282+ if ( block_length < 0 )
3283+ {
3284+ block_length = llabs( block_length ) ;
3285+ offset_src -= ( (block_length / sector_size_src) - 1 ) ;
3286+ /* Handle situation where src sector size is smaller than dst sector size and an additional partial dst sector is required. */
3287+ offset_dst -= ( ( (block_length + (sector_size_dst - 1)) / sector_size_dst) - 1 ) ;
3288+ }
3289+
3290+ if ( block_length != 0 )
3291+ {
3292+ if ( ped_device_read( lp_device_src, buf, offset_src, num_blocks_src ) )
3293+ {
3294+ if ( readonly || ped_device_write( lp_device_dst, buf, offset_dst, num_blocks_dst ) )
3295+ return true ;
3296+ else
3297+ error_message = String::ucompose( _("Error while writing block at sector %1"), offset_dst ) ;
3298+ }
3299+ else
3300+ error_message = String::ucompose( _("Error while reading block at sector %1"), offset_src ) ;
3301+ }
3302+
3303+ return false ;
3304+}
3305+
3306+bool GParted_Core::calibrate_partition( Partition & partition, OperationDetail & operationdetail )
3307+{
3308+ if ( partition .type == TYPE_PRIMARY || partition .type == TYPE_LOGICAL || partition .type == TYPE_EXTENDED )
3309+ {
3310+ operationdetail .add_child( OperationDetail( String::ucompose( _("calibrate %1"), partition .get_path() ) ) ) ;
3311+
3312+ bool succes = false ;
3313+ if ( open_device_and_disk( partition .device_path ) )
3314+ {
3315+ if ( partition .type == GParted::TYPE_EXTENDED )
3316+ lp_partition = ped_disk_extended_partition( lp_disk ) ;
3317+ else
3318+ lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition .get_sector() ) ;
3319+
3320+ if ( lp_partition )//FIXME: add check to see if lp_partition ->type matches partition .type..
3321+ {
3322+ partition .add_path( get_partition_path( lp_partition ) ) ;
3323+
3324+ partition .sector_start = lp_partition ->geom .start ;
3325+ partition .sector_end = lp_partition ->geom .end ;
3326+
3327+ operationdetail .get_last_child() .add_child(
3328+ OperationDetail(
3329+ String::ucompose( _("path: %1"), partition .get_path() ) + "\n" +
3330+ String::ucompose( _("start: %1"), partition .sector_start ) + "\n" +
3331+ String::ucompose( _("end: %1"), partition .sector_end ) + "\n" +
3332+ String::ucompose( _("size: %1 (%2)"),
3333+ partition .get_sector_length(),
3334+ Utils::format_size( partition .get_sector_length(), partition .sector_size ) ),
3335+ STATUS_NONE,
3336+ FONT_ITALIC ) ) ;
3337+ succes = true ;
3338+ }
3339+
3340+ close_device_and_disk() ;
3341+ }
3342+
3343+ operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
3344+ return succes ;
3345+ }
3346+ else //nothing to calibrate...
3347+ return true ;
3348+}
3349+
3350+bool GParted_Core::calculate_exact_geom( const Partition & partition_old,
3351+ Partition & partition_new,
3352+ OperationDetail & operationdetail )
3353+{
3354+ operationdetail .add_child( OperationDetail(
3355+ String::ucompose( _("calculate new size and position of %1"), partition_new .get_path() ) ) ) ;
3356+
3357+ operationdetail .get_last_child() .add_child(
3358+ OperationDetail(
3359+ String::ucompose( _("requested start: %1"), partition_new .sector_start ) + "\n" +
3360+ String::ucompose( _("requested end: %1"), partition_new .sector_end ) + "\n" +
3361+ String::ucompose( _("requested size: %1 (%2)"),
3362+ partition_new .get_sector_length(),
3363+ Utils::format_size( partition_new .get_sector_length(), partition_new .sector_size ) ),
3364+ STATUS_NONE,
3365+ FONT_ITALIC ) ) ;
3366+
3367+ bool succes = false ;
3368+ if ( open_device_and_disk( partition_old .device_path ) )
3369+ {
3370+ lp_partition = NULL ;
3371+
3372+ if ( partition_old .type == GParted::TYPE_EXTENDED )
3373+ lp_partition = ped_disk_extended_partition( lp_disk ) ;
3374+ else
3375+ lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition_old .get_sector() ) ;
3376+
3377+ if ( lp_partition )
3378+ {
3379+ PedConstraint *constraint = NULL ;
3380+ constraint = ped_constraint_any( lp_device ) ;
3381+
3382+ if ( constraint )
3383+ {
3384+ //FIXME: if we insert a weird partitionnew geom here (e.g. start > end)
3385+ //ped_disk_set_partition_geom() will still return true (althoug an lp exception is written
3386+ //to stdout.. see if this also affect create_partition and resize_move_partition
3387+ //sended a patch to fix this to libparted list. will probably be in 1.7.2
3388+ if ( ped_disk_set_partition_geom( lp_disk,
3389+ lp_partition,
3390+ constraint,
3391+ partition_new .sector_start,
3392+ partition_new .sector_end ) )
3393+ {
3394+ partition_new .sector_start = lp_partition ->geom .start ;
3395+ partition_new .sector_end = lp_partition ->geom .end ;
3396+ succes = true ;
3397+ }
3398+
3399+ ped_constraint_destroy( constraint );
3400+ }
3401+ }
3402+
3403+ close_device_and_disk() ;
3404+ }
3405+
3406+ if ( succes )
3407+ {
3408+ operationdetail .get_last_child() .add_child(
3409+ OperationDetail(
3410+ String::ucompose( _("new start: %1"), partition_new .sector_start ) + "\n" +
3411+ String::ucompose( _("new end: %1"), partition_new .sector_end ) + "\n" +
3412+ String::ucompose( _("new size: %1 (%2)"),
3413+ partition_new .get_sector_length(),
3414+ Utils::format_size( partition_new .get_sector_length(), partition_new .sector_size ) ),
3415+ STATUS_NONE,
3416+ FONT_ITALIC ) ) ;
3417+
3418+#ifndef USE_LIBPARTED_DMRAID
3419+ //Update dev mapper entry if partition is dmraid.
3420+ DMRaid dmraid ;
3421+ if ( succes && dmraid .is_dmraid_device( partition_new .device_path ) )
3422+ {
3423+ //Open disk handle before and close after to prevent application crash.
3424+ if ( open_device_and_disk( partition_new .device_path ) )
3425+ {
3426+ succes = dmraid .update_dev_map_entry( partition_new, operationdetail .get_last_child() ) ;
3427+ close_device_and_disk() ;
3428+ }
3429+ }
3430+#endif
3431+ }
3432+
3433+ operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
3434+ return succes ;
3435+}
3436+
3437+bool GParted_Core::set_proper_filesystem( const FILESYSTEM & filesystem )
3438+{
3439+ p_filesystem = get_filesystem_object( filesystem ) ;
3440+
3441+ return p_filesystem ;
3442+}
3443+
3444+FileSystem * GParted_Core::get_filesystem_object( const FILESYSTEM & filesystem )
3445+{
3446+ if ( FILESYSTEM_MAP .count( filesystem ) )
3447+ return FILESYSTEM_MAP[ filesystem ] ;
3448+ else
3449+ return NULL ;
3450+}
3451+
3452+#ifndef HAVE_LIBPARTED_3_0_0_PLUS
3453+bool GParted_Core::erase_filesystem_signatures( const Partition & partition )
3454+{
3455+ bool return_value = false ;
3456+
3457+ if ( open_device_and_disk( partition .device_path ) )
3458+ {
3459+ lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition .get_sector() ) ;
3460+
3461+ if ( lp_partition && ped_file_system_clobber( & lp_partition ->geom ) )
3462+ {
3463+ //file systems not yet supported by libparted
3464+ if ( ped_device_open( lp_device ) )
3465+ {
3466+ //reiser4 stores "ReIsEr4" at sector 128 with a sector size of 512 bytes
3467+ // FIXME writing block of partially uninitialized bytes (security/privacy)
3468+ return_value = ped_geometry_write( & lp_partition ->geom, "0000000", (65536 / lp_device ->sector_size), 1 ) ;
3469+
3470+ ped_device_close( lp_device ) ;
3471+ }
3472+ }
3473+
3474+ close_device_and_disk() ;
3475+ }
3476+
3477+ return return_value ;
3478+}
3479+#endif
3480+
3481+bool GParted_Core::update_bootsector( const Partition & partition, OperationDetail & operationdetail )
3482+{
3483+ //only for ntfs atm...
3484+ //FIXME: this should probably be done in the fs classes...
3485+ if ( partition .filesystem == FS_NTFS )
3486+ {
3487+ //The NTFS file system stores a value in the boot record called the
3488+ // Number of Hidden Sectors. This value must match the partition start
3489+ // sector number in order for Windows to boot from the file system.
3490+ // For more details, refer to the NTFS Volume Boot Record at:
3491+ // http://www.geocities.com/thestarman3/asm/mbr/NTFSBR.htm
3492+
3493+ operationdetail .add_child( OperationDetail(
3494+ /*TO TRANSLATORS: update boot sector of ntfs file system on /dev/sdd1 */
3495+ String::ucompose( _("update boot sector of %1 file system on %2"),
3496+ Utils::get_filesystem_string( partition .filesystem ),
3497+ partition .get_path() ) ) ) ;
3498+
3499+ //convert start sector to hex string
3500+ std::stringstream ss ;
3501+ ss << std::hex << partition .sector_start ;
3502+ Glib::ustring hex = ss .str() ;
3503+
3504+ //fill with zeros and reverse...
3505+ hex .insert( 0, 8 - hex .length(), '0' ) ;
3506+ Glib::ustring reversed_hex ;
3507+ for ( int t = 6 ; t >= 0 ; t -=2 )
3508+ reversed_hex .append( hex .substr( t, 2 ) ) ;
3509+
3510+ //convert reversed hex codes into ascii characters
3511+ char buf[4] ;
3512+ for ( unsigned int k = 0; (k < 4 && k < (reversed_hex .length() / 2)); k++ )
3513+ {
3514+ Glib::ustring tmp_hex = "0x" + reversed_hex .substr( k * 2, 2 ) ;
3515+ buf[k] = (char)( std::strtol( tmp_hex .c_str(), NULL, 16 ) ) ;
3516+ }
3517+
3518+ //write new Number of Hidden Sectors value into NTFS boot sector at offset 0x1C
3519+ Glib::ustring error_message = "" ;
3520+ std::ofstream dev_file ;
3521+ dev_file .open( partition .get_path() .c_str(), std::ios::out | std::ios::binary ) ;
3522+ if ( dev_file .is_open() )
3523+ {
3524+ dev_file .seekp( 0x1C ) ;
3525+ if ( dev_file .good() )
3526+ {
3527+ dev_file .write( buf, 4 ) ;
3528+ if ( dev_file .bad() )
3529+ {
3530+ /*TO TRANSLATORS: looks like Error trying to write to boot sector in /dev/sdd1 */
3531+ error_message = String::ucompose( _("Error trying to write to boot sector in %1"), partition .get_path() ) ;
3532+ }
3533+ }
3534+ else
3535+ {
3536+ /*TO TRANSLATORS: looks like Error trying to seek to position 0x1C in /dev/sdd1 */
3537+ error_message = String::ucompose( _("Error trying to seek to position 0x1c in %1"), partition .get_path() ) ;
3538+ }
3539+ dev_file .close( ) ;
3540+ }
3541+ else
3542+ {
3543+ /*TO TRANSLATORS: looks like Error trying to open /dev/sdd1 */
3544+ error_message = String::ucompose( _("Error trying to open %1"), partition .get_path() ) ;
3545+ }
3546+
3547+ //append error messages if any found
3548+ bool succes = true ;
3549+ if ( ! error_message .empty() )
3550+ {
3551+ succes = false ;
3552+ error_message += "\n" ;
3553+ /*TO TRANSLATORS: looks like Failed to set the number of hidden sectors to 05ab4f00 in the ntfs boot record. */
3554+ error_message += String::ucompose( _("Failed to set the number of hidden sectors to %1 in the NTFS boot record."), reversed_hex ) ;
3555+ error_message += "\n" ;
3556+ error_message += String::ucompose( _("You might try the following command to correct the problem:"), reversed_hex ) ;
3557+ error_message += "\n" ;
3558+ error_message += String::ucompose( "echo %1 | xxd -r -p | dd conv=notrunc of=%2 bs=1 seek=28", reversed_hex, partition .get_path() ) ;
3559+ operationdetail .get_last_child() .add_child( OperationDetail( error_message, STATUS_NONE, FONT_ITALIC ) ) ;
3560+ }
3561+
3562+ operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
3563+ return succes ;
3564+ }
3565+
3566+ return true ;
3567+}
3568+
3569+bool GParted_Core::open_device( const Glib::ustring & device_path )
3570+{
3571+ lp_device = ped_device_get( device_path .c_str() );
3572+
3573+ return lp_device ;
3574+}
3575+
3576+bool GParted_Core::open_device_and_disk( const Glib::ustring & device_path, bool strict )
3577+{
3578+ lp_device = NULL ;
3579+ lp_disk = NULL ;
3580+
3581+ if ( open_device( device_path ) )
3582+ {
3583+ lp_disk = ped_disk_new( lp_device );
3584+
3585+ //if ! disk and writeable it's probably a HD without disklabel.
3586+ //We return true here and deal with them in GParted_Core::get_devices
3587+ if ( lp_disk || ( ! strict && ! lp_device ->read_only ) )
3588+ return true ;
3589+
3590+ close_device_and_disk() ;
3591+ }
3592+
3593+ return false ;
3594+}
3595+
3596+void GParted_Core::close_disk()
3597+{
3598+ if ( lp_disk )
3599+ ped_disk_destroy( lp_disk ) ;
3600+
3601+ lp_disk = NULL ;
3602+}
3603+
3604+void GParted_Core::close_device_and_disk()
3605+{
3606+ close_disk() ;
3607+
3608+ if ( lp_device )
3609+ ped_device_destroy( lp_device ) ;
3610+
3611+ lp_device = NULL ;
3612+}
3613+
3614+bool GParted_Core::commit()
3615+{
3616+ bool succes = ped_disk_commit_to_dev( lp_disk ) ;
3617+
3618+ succes = commit_to_os( 10 ) && succes ;
3619+
3620+ return succes ;
3621+}
3622+
3623+bool GParted_Core::commit_to_os( std::time_t timeout )
3624+{
3625+ bool succes ;
3626+#ifndef USE_LIBPARTED_DMRAID
3627+ DMRaid dmraid ;
3628+ if ( dmraid .is_dmraid_device( lp_disk ->dev ->path ) )
3629+ succes = true ;
3630+ else
3631+ {
3632+#endif
3633+ succes = ped_disk_commit_to_os( lp_disk ) ;
3634+#ifndef HAVE_LIBPARTED_2_2_0_PLUS
3635+ //Work around to try to alleviate problems caused by
3636+ // bug #604298 - Failure to inform kernel of partition changes
3637+ // If not successful the first time, try one more time.
3638+ if ( ! succes )
3639+ {
3640+ sleep( 1 ) ;
3641+ succes = ped_disk_commit_to_os( lp_disk ) ;
3642+ }
3643+#endif
3644+#ifndef USE_LIBPARTED_DMRAID
3645+ }
3646+#endif
3647+
3648+ settle_device( timeout ) ;
3649+
3650+ return succes ;
3651+}
3652+
3653+void GParted_Core::settle_device( std::time_t timeout )
3654+{
3655+ if ( ! Glib::find_program_in_path( "udevsettle" ) .empty() )
3656+ Utils::execute_command( "udevsettle --timeout=" + Utils::num_to_str( timeout ) ) ;
3657+ else if ( ! Glib::find_program_in_path( "udevadm" ) .empty() )
3658+ Utils::execute_command( "udevadm settle --timeout=" + Utils::num_to_str( timeout ) ) ;
3659+ else
3660+ sleep( timeout ) ;
3661+}
3662+
3663+class PedExceptionMsg : public Gtk::MessageDialog
3664+{
3665+public:
3666+ PedExceptionMsg( PedException &e ) : MessageDialog( Glib::ustring(e.message), false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_NONE, true )
3667+ {
3668+ switch( e.type )
3669+ {
3670+ case PED_EXCEPTION_WARNING:
3671+ set_title( _("Libparted Warning") );
3672+ property_message_type() = Gtk::MESSAGE_WARNING;
3673+ break;
3674+ case PED_EXCEPTION_INFORMATION:
3675+ set_title( _("Libparted Information") );
3676+ property_message_type() = Gtk::MESSAGE_INFO;
3677+ break;
3678+ case PED_EXCEPTION_ERROR:
3679+ set_title( _("Libparted Error") );
3680+ default:
3681+ set_title( _("Libparted Bug Found!") );
3682+ }
3683+ if (e.options & PED_EXCEPTION_FIX)
3684+ add_button( _("Fix"), PED_EXCEPTION_FIX );
3685+ if (e.options & PED_EXCEPTION_YES)
3686+ add_button( _("Yes"), PED_EXCEPTION_YES );
3687+ if (e.options & PED_EXCEPTION_OK)
3688+ add_button( _("Ok"), PED_EXCEPTION_OK );
3689+ if (e.options & PED_EXCEPTION_RETRY)
3690+ add_button( _("Retry"), PED_EXCEPTION_RETRY );
3691+ if (e.options & PED_EXCEPTION_NO)
3692+ add_button( _("No"), PED_EXCEPTION_NO );
3693+ if (e.options & PED_EXCEPTION_CANCEL)
3694+ add_button( _("Cancel"), PED_EXCEPTION_CANCEL );
3695+ if (e.options & PED_EXCEPTION_IGNORE)
3696+ add_button( _("Ignore"), PED_EXCEPTION_IGNORE );
3697+ }
3698+};
3699+
3700+PedExceptionOption GParted_Core::ped_exception_handler( PedException * e )
3701+{
3702+ PedExceptionOption ret = PED_EXCEPTION_UNHANDLED;
3703+ std::cout << e ->message << std::endl ;
3704+
3705+ libparted_messages .push_back( e->message ) ;
3706+ char optcount = 0;
3707+ int opt = 0;
3708+ for( char c = 0; c < 10; c++ )
3709+ if( e->options & (1 << c) ) {
3710+ opt = (1 << c);
3711+ optcount++;
3712+ }
3713+ // if only one option was given, choose it without popup
3714+ if( optcount == 1 && e->type != PED_EXCEPTION_BUG && e->type != PED_EXCEPTION_FATAL )
3715+ return (PedExceptionOption)opt;
3716+ if (Glib::Thread::self() != GParted_Core::mainthread)
3717+ gdk_threads_enter();
3718+ PedExceptionMsg msg( *e );
3719+ msg.show_all();
3720+ ret = (PedExceptionOption)msg.run();
3721+ if (Glib::Thread::self() != GParted_Core::mainthread)
3722+ gdk_threads_leave();
3723+ if (ret < 0)
3724+ ret = PED_EXCEPTION_UNHANDLED;
3725+ return ret;
3726+}
3727+
3728+GParted_Core::~GParted_Core()
3729+{
3730+ delete p_filesystem;
3731+}
3732+
3733+Glib::Thread *GParted_Core::mainthread;
3734+
3735+} //GParted
3736
3737=== added file '.pc/drop-swraid.patch/src/Makefile.am'
3738--- .pc/drop-swraid.patch/src/Makefile.am 1970-01-01 00:00:00 +0000
3739+++ .pc/drop-swraid.patch/src/Makefile.am 2013-01-14 18:58:25 +0000
3740@@ -0,0 +1,78 @@
3741+INCLUDES = \
3742+ $(GTHREAD_CFLAGS) \
3743+ $(GTKMM_CFLAGS) \
3744+ -DGPARTED_DATADIR=\""$(datadir)"\" \
3745+ -DGNOMELOCALEDIR=\""$(datadir)/locale"\"
3746+
3747+AM_CFLAGS = -Wall
3748+
3749+AM_CXXFLAGS = -Wall
3750+
3751+sbin_PROGRAMS = gpartedbin
3752+
3753+gpartedbin_SOURCES = \
3754+ Device.cc \
3755+ Dialog_Base_Partition.cc \
3756+ Dialog_Disklabel.cc \
3757+ Dialog_Rescue_Data.cc \
3758+ Dialog_Partition_Copy.cc \
3759+ Dialog_Partition_Info.cc \
3760+ Dialog_Partition_Label.cc \
3761+ Dialog_Partition_New.cc \
3762+ Dialog_Partition_Resize_Move.cc \
3763+ Dialog_Progress.cc \
3764+ DialogFeatures.cc \
3765+ DialogManageFlags.cc \
3766+ DrawingAreaVisualDisk.cc \
3767+ DMRaid.cc \
3768+ FileSystem.cc \
3769+ Frame_Resizer_Base.cc \
3770+ Frame_Resizer_Extended.cc \
3771+ FS_Info.cc \
3772+ GParted_Core.cc \
3773+ HBoxOperations.cc \
3774+ LVM2_PV_Info.cc \
3775+ Operation.cc \
3776+ OperationChangeUUID.cc \
3777+ OperationCopy.cc \
3778+ OperationCheck.cc \
3779+ OperationCreate.cc \
3780+ OperationDelete.cc \
3781+ OperationDetail.cc \
3782+ OperationFormat.cc \
3783+ OperationResizeMove.cc \
3784+ OperationLabelPartition.cc \
3785+ Partition.cc \
3786+ Proc_Partitions_Info.cc \
3787+ SWRaid.cc \
3788+ TreeView_Detail.cc \
3789+ Utils.cc \
3790+ Win_GParted.cc \
3791+ btrfs.cc \
3792+ exfat.cc \
3793+ ext2.cc \
3794+ ext3.cc \
3795+ ext4.cc \
3796+ fat16.cc \
3797+ fat32.cc \
3798+ hfs.cc \
3799+ hfsplus.cc \
3800+ jfs.cc \
3801+ linux_swap.cc \
3802+ lvm2_pv.cc \
3803+ main.cc \
3804+ nilfs2.cc \
3805+ ntfs.cc \
3806+ reiser4.cc \
3807+ reiserfs.cc \
3808+ ufs.cc \
3809+ xfs.cc
3810+
3811+gpartedbin_LDFLAGS = -lparted
3812+
3813+if USE_LIBPARTED_FS_RESIZE_LIBRARY
3814+gpartedbin_LDFLAGS += -lparted-fs-resize
3815+endif
3816+
3817+gpartedbin_LDADD = $(GTHREAD_LIBS) $(GTKMM_LIBS)
3818+
3819
3820=== added file '.pc/drop-swraid.patch/src/Makefile.in'
3821--- .pc/drop-swraid.patch/src/Makefile.in 1970-01-01 00:00:00 +0000
3822+++ .pc/drop-swraid.patch/src/Makefile.in 2013-01-14 18:58:25 +0000
3823@@ -0,0 +1,700 @@
3824+# Makefile.in generated by automake 1.11.1 from Makefile.am.
3825+# @configure_input@
3826+
3827+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3828+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
3829+# Inc.
3830+# This Makefile.in is free software; the Free Software Foundation
3831+# gives unlimited permission to copy and/or distribute it,
3832+# with or without modifications, as long as this notice is preserved.
3833+
3834+# This program is distributed in the hope that it will be useful,
3835+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
3836+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
3837+# PARTICULAR PURPOSE.
3838+
3839+@SET_MAKE@
3840+
3841+VPATH = @srcdir@
3842+pkgdatadir = $(datadir)/@PACKAGE@
3843+pkgincludedir = $(includedir)/@PACKAGE@
3844+pkglibdir = $(libdir)/@PACKAGE@
3845+pkglibexecdir = $(libexecdir)/@PACKAGE@
3846+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
3847+install_sh_DATA = $(install_sh) -c -m 644
3848+install_sh_PROGRAM = $(install_sh) -c
3849+install_sh_SCRIPT = $(install_sh) -c
3850+INSTALL_HEADER = $(INSTALL_DATA)
3851+transform = $(program_transform_name)
3852+NORMAL_INSTALL = :
3853+PRE_INSTALL = :
3854+POST_INSTALL = :
3855+NORMAL_UNINSTALL = :
3856+PRE_UNINSTALL = :
3857+POST_UNINSTALL = :
3858+build_triplet = @build@
3859+host_triplet = @host@
3860+sbin_PROGRAMS = gpartedbin$(EXEEXT)
3861+@USE_LIBPARTED_FS_RESIZE_LIBRARY_TRUE@am__append_1 = -lparted-fs-resize
3862+subdir = src
3863+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
3864+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
3865+am__aclocal_m4_deps = $(top_srcdir)/m4/intltool.m4 \
3866+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
3867+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
3868+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.in
3869+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
3870+ $(ACLOCAL_M4)
3871+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
3872+CONFIG_HEADER = $(top_builddir)/config.h
3873+CONFIG_CLEAN_FILES =
3874+CONFIG_CLEAN_VPATH_FILES =
3875+am__installdirs = "$(DESTDIR)$(sbindir)"
3876+PROGRAMS = $(sbin_PROGRAMS)
3877+am_gpartedbin_OBJECTS = Device.$(OBJEXT) \
3878+ Dialog_Base_Partition.$(OBJEXT) Dialog_Disklabel.$(OBJEXT) \
3879+ Dialog_Rescue_Data.$(OBJEXT) Dialog_Partition_Copy.$(OBJEXT) \
3880+ Dialog_Partition_Info.$(OBJEXT) \
3881+ Dialog_Partition_Label.$(OBJEXT) \
3882+ Dialog_Partition_New.$(OBJEXT) \
3883+ Dialog_Partition_Resize_Move.$(OBJEXT) \
3884+ Dialog_Progress.$(OBJEXT) DialogFeatures.$(OBJEXT) \
3885+ DialogManageFlags.$(OBJEXT) DrawingAreaVisualDisk.$(OBJEXT) \
3886+ DMRaid.$(OBJEXT) FileSystem.$(OBJEXT) \
3887+ Frame_Resizer_Base.$(OBJEXT) Frame_Resizer_Extended.$(OBJEXT) \
3888+ FS_Info.$(OBJEXT) GParted_Core.$(OBJEXT) \
3889+ HBoxOperations.$(OBJEXT) LVM2_PV_Info.$(OBJEXT) \
3890+ Operation.$(OBJEXT) OperationChangeUUID.$(OBJEXT) \
3891+ OperationCopy.$(OBJEXT) OperationCheck.$(OBJEXT) \
3892+ OperationCreate.$(OBJEXT) OperationDelete.$(OBJEXT) \
3893+ OperationDetail.$(OBJEXT) OperationFormat.$(OBJEXT) \
3894+ OperationResizeMove.$(OBJEXT) \
3895+ OperationLabelPartition.$(OBJEXT) Partition.$(OBJEXT) \
3896+ Proc_Partitions_Info.$(OBJEXT) SWRaid.$(OBJEXT) \
3897+ TreeView_Detail.$(OBJEXT) Utils.$(OBJEXT) \
3898+ Win_GParted.$(OBJEXT) btrfs.$(OBJEXT) exfat.$(OBJEXT) \
3899+ ext2.$(OBJEXT) ext3.$(OBJEXT) ext4.$(OBJEXT) fat16.$(OBJEXT) \
3900+ fat32.$(OBJEXT) hfs.$(OBJEXT) hfsplus.$(OBJEXT) jfs.$(OBJEXT) \
3901+ linux_swap.$(OBJEXT) lvm2_pv.$(OBJEXT) main.$(OBJEXT) \
3902+ nilfs2.$(OBJEXT) ntfs.$(OBJEXT) reiser4.$(OBJEXT) \
3903+ reiserfs.$(OBJEXT) ufs.$(OBJEXT) xfs.$(OBJEXT)
3904+gpartedbin_OBJECTS = $(am_gpartedbin_OBJECTS)
3905+am__DEPENDENCIES_1 =
3906+gpartedbin_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
3907+gpartedbin_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
3908+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
3909+ $(CXXFLAGS) $(gpartedbin_LDFLAGS) $(LDFLAGS) -o $@
3910+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
3911+depcomp = $(SHELL) $(top_srcdir)/depcomp
3912+am__depfiles_maybe = depfiles
3913+am__mv = mv -f
3914+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
3915+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
3916+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
3917+ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
3918+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
3919+CXXLD = $(CXX)
3920+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
3921+ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
3922+ $(LDFLAGS) -o $@
3923+SOURCES = $(gpartedbin_SOURCES)
3924+DIST_SOURCES = $(gpartedbin_SOURCES)
3925+ETAGS = etags
3926+CTAGS = ctags
3927+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
3928+ACLOCAL = @ACLOCAL@
3929+ALL_LINGUAS = @ALL_LINGUAS@
3930+AMTAR = @AMTAR@
3931+AR = @AR@
3932+AUTOCONF = @AUTOCONF@
3933+AUTOHEADER = @AUTOHEADER@
3934+AUTOMAKE = @AUTOMAKE@
3935+AWK = @AWK@
3936+CATALOGS = @CATALOGS@
3937+CATOBJEXT = @CATOBJEXT@
3938+CC = @CC@
3939+CCDEPMODE = @CCDEPMODE@
3940+CFLAGS = @CFLAGS@
3941+CPP = @CPP@
3942+CPPFLAGS = @CPPFLAGS@
3943+CXX = @CXX@
3944+CXXCPP = @CXXCPP@
3945+CXXDEPMODE = @CXXDEPMODE@
3946+CXXFLAGS = @CXXFLAGS@
3947+CYGPATH_W = @CYGPATH_W@
3948+DATADIRNAME = @DATADIRNAME@
3949+DEFS = @DEFS@
3950+DEPDIR = @DEPDIR@
3951+DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@
3952+DOC_USER_FORMATS = @DOC_USER_FORMATS@
3953+DSYMUTIL = @DSYMUTIL@
3954+DUMPBIN = @DUMPBIN@
3955+ECHO_C = @ECHO_C@
3956+ECHO_N = @ECHO_N@
3957+ECHO_T = @ECHO_T@
3958+EGREP = @EGREP@
3959+EXEEXT = @EXEEXT@
3960+FGREP = @FGREP@
3961+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
3962+GKSUPROG = @GKSUPROG@
3963+GMOFILES = @GMOFILES@
3964+GMSGFMT = @GMSGFMT@
3965+GREP = @GREP@
3966+GTHREAD_CFLAGS = @GTHREAD_CFLAGS@
3967+GTHREAD_LIBS = @GTHREAD_LIBS@
3968+GTKMM_CFLAGS = @GTKMM_CFLAGS@
3969+GTKMM_LIBS = @GTKMM_LIBS@
3970+HELP_DIR = @HELP_DIR@
3971+INSTALL = @INSTALL@
3972+INSTALL_DATA = @INSTALL_DATA@
3973+INSTALL_PROGRAM = @INSTALL_PROGRAM@
3974+INSTALL_SCRIPT = @INSTALL_SCRIPT@
3975+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
3976+INSTOBJEXT = @INSTOBJEXT@
3977+INTLLIBS = @INTLLIBS@
3978+INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@
3979+INTLTOOL_MERGE = @INTLTOOL_MERGE@
3980+INTLTOOL_PERL = @INTLTOOL_PERL@
3981+INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
3982+LD = @LD@
3983+LDFLAGS = @LDFLAGS@
3984+LIBOBJS = @LIBOBJS@
3985+LIBS = @LIBS@
3986+LIBTOOL = @LIBTOOL@
3987+LIPO = @LIPO@
3988+LN_S = @LN_S@
3989+LTLIBOBJS = @LTLIBOBJS@
3990+MAINT = @MAINT@
3991+MAKEINFO = @MAKEINFO@
3992+MKDIR_P = @MKDIR_P@
3993+MKINSTALLDIRS = @MKINSTALLDIRS@
3994+MSGFMT = @MSGFMT@
3995+MSGFMT_OPTS = @MSGFMT_OPTS@
3996+MSGMERGE = @MSGMERGE@
3997+NM = @NM@
3998+NMEDIT = @NMEDIT@
3999+OBJDUMP = @OBJDUMP@
4000+OBJEXT = @OBJEXT@
4001+OMF_DIR = @OMF_DIR@
4002+OTOOL = @OTOOL@
4003+OTOOL64 = @OTOOL64@
4004+PACKAGE = @PACKAGE@
4005+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
4006+PACKAGE_NAME = @PACKAGE_NAME@
4007+PACKAGE_STRING = @PACKAGE_STRING@
4008+PACKAGE_TARNAME = @PACKAGE_TARNAME@
4009+PACKAGE_URL = @PACKAGE_URL@
4010+PACKAGE_VERSION = @PACKAGE_VERSION@
4011+PATH_SEPARATOR = @PATH_SEPARATOR@
4012+PKG_CONFIG = @PKG_CONFIG@
4013+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
4014+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
4015+POFILES = @POFILES@
4016+POSUB = @POSUB@
4017+PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@
4018+PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@
4019+RANLIB = @RANLIB@
4020+SED = @SED@
4021+SET_MAKE = @SET_MAKE@
4022+SHELL = @SHELL@
4023+STRIP = @STRIP@
4024+USE_NLS = @USE_NLS@
4025+VERSION = @VERSION@
4026+XGETTEXT = @XGETTEXT@
4027+abs_builddir = @abs_builddir@
4028+abs_srcdir = @abs_srcdir@
4029+abs_top_builddir = @abs_top_builddir@
4030+abs_top_srcdir = @abs_top_srcdir@
4031+ac_ct_CC = @ac_ct_CC@
4032+ac_ct_CXX = @ac_ct_CXX@
4033+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
4034+am__include = @am__include@
4035+am__leading_dot = @am__leading_dot@
4036+am__quote = @am__quote@
4037+am__tar = @am__tar@
4038+am__untar = @am__untar@
4039+bindir = @bindir@
4040+build = @build@
4041+build_alias = @build_alias@
4042+build_cpu = @build_cpu@
4043+build_os = @build_os@
4044+build_vendor = @build_vendor@
4045+builddir = @builddir@
4046+datadir = @datadir@
4047+datarootdir = @datarootdir@
4048+docdir = @docdir@
4049+dvidir = @dvidir@
4050+exec_prefix = @exec_prefix@
4051+host = @host@
4052+host_alias = @host_alias@
4053+host_cpu = @host_cpu@
4054+host_os = @host_os@
4055+host_vendor = @host_vendor@
4056+htmldir = @htmldir@
4057+includedir = @includedir@
4058+infodir = @infodir@
4059+install_sh = @install_sh@
4060+libdir = @libdir@
4061+libexecdir = @libexecdir@
4062+localedir = @localedir@
4063+localstatedir = @localstatedir@
4064+lt_ECHO = @lt_ECHO@
4065+mandir = @mandir@
4066+mkdir_p = @mkdir_p@
4067+oldincludedir = @oldincludedir@
4068+pdfdir = @pdfdir@
4069+prefix = @prefix@
4070+program_transform_name = @program_transform_name@
4071+psdir = @psdir@
4072+sbindir = @sbindir@
4073+sharedstatedir = @sharedstatedir@
4074+srcdir = @srcdir@
4075+sysconfdir = @sysconfdir@
4076+target_alias = @target_alias@
4077+top_build_prefix = @top_build_prefix@
4078+top_builddir = @top_builddir@
4079+top_srcdir = @top_srcdir@
4080+INCLUDES = \
4081+ $(GTHREAD_CFLAGS) \
4082+ $(GTKMM_CFLAGS) \
4083+ -DGPARTED_DATADIR=\""$(datadir)"\" \
4084+ -DGNOMELOCALEDIR=\""$(datadir)/locale"\"
4085+
4086+AM_CFLAGS = -Wall
4087+AM_CXXFLAGS = -Wall
4088+gpartedbin_SOURCES = \
4089+ Device.cc \
4090+ Dialog_Base_Partition.cc \
4091+ Dialog_Disklabel.cc \
4092+ Dialog_Rescue_Data.cc \
4093+ Dialog_Partition_Copy.cc \
4094+ Dialog_Partition_Info.cc \
4095+ Dialog_Partition_Label.cc \
4096+ Dialog_Partition_New.cc \
4097+ Dialog_Partition_Resize_Move.cc \
4098+ Dialog_Progress.cc \
4099+ DialogFeatures.cc \
4100+ DialogManageFlags.cc \
4101+ DrawingAreaVisualDisk.cc \
4102+ DMRaid.cc \
4103+ FileSystem.cc \
4104+ Frame_Resizer_Base.cc \
4105+ Frame_Resizer_Extended.cc \
4106+ FS_Info.cc \
4107+ GParted_Core.cc \
4108+ HBoxOperations.cc \
4109+ LVM2_PV_Info.cc \
4110+ Operation.cc \
4111+ OperationChangeUUID.cc \
4112+ OperationCopy.cc \
4113+ OperationCheck.cc \
4114+ OperationCreate.cc \
4115+ OperationDelete.cc \
4116+ OperationDetail.cc \
4117+ OperationFormat.cc \
4118+ OperationResizeMove.cc \
4119+ OperationLabelPartition.cc \
4120+ Partition.cc \
4121+ Proc_Partitions_Info.cc \
4122+ SWRaid.cc \
4123+ TreeView_Detail.cc \
4124+ Utils.cc \
4125+ Win_GParted.cc \
4126+ btrfs.cc \
4127+ exfat.cc \
4128+ ext2.cc \
4129+ ext3.cc \
4130+ ext4.cc \
4131+ fat16.cc \
4132+ fat32.cc \
4133+ hfs.cc \
4134+ hfsplus.cc \
4135+ jfs.cc \
4136+ linux_swap.cc \
4137+ lvm2_pv.cc \
4138+ main.cc \
4139+ nilfs2.cc \
4140+ ntfs.cc \
4141+ reiser4.cc \
4142+ reiserfs.cc \
4143+ ufs.cc \
4144+ xfs.cc
4145+
4146+gpartedbin_LDFLAGS = -lparted $(am__append_1)
4147+gpartedbin_LDADD = $(GTHREAD_LIBS) $(GTKMM_LIBS)
4148+all: all-am
4149+
4150+.SUFFIXES:
4151+.SUFFIXES: .cc .lo .o .obj
4152+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
4153+ @for dep in $?; do \
4154+ case '$(am__configure_deps)' in \
4155+ *$$dep*) \
4156+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
4157+ && { if test -f $@; then exit 0; else break; fi; }; \
4158+ exit 1;; \
4159+ esac; \
4160+ done; \
4161+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
4162+ $(am__cd) $(top_srcdir) && \
4163+ $(AUTOMAKE) --gnu src/Makefile
4164+.PRECIOUS: Makefile
4165+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
4166+ @case '$?' in \
4167+ *config.status*) \
4168+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
4169+ *) \
4170+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
4171+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
4172+ esac;
4173+
4174+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
4175+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
4176+
4177+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
4178+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
4179+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
4180+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
4181+$(am__aclocal_m4_deps):
4182+install-sbinPROGRAMS: $(sbin_PROGRAMS)
4183+ @$(NORMAL_INSTALL)
4184+ test -z "$(sbindir)" || $(MKDIR_P) "$(DESTDIR)$(sbindir)"
4185+ @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \
4186+ for p in $$list; do echo "$$p $$p"; done | \
4187+ sed 's/$(EXEEXT)$$//' | \
4188+ while read p p1; do if test -f $$p || test -f $$p1; \
4189+ then echo "$$p"; echo "$$p"; else :; fi; \
4190+ done | \
4191+ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
4192+ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
4193+ sed 'N;N;N;s,\n, ,g' | \
4194+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
4195+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
4196+ if ($$2 == $$4) files[d] = files[d] " " $$1; \
4197+ else { print "f", $$3 "/" $$4, $$1; } } \
4198+ END { for (d in files) print "f", d, files[d] }' | \
4199+ while read type dir files; do \
4200+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
4201+ test -z "$$files" || { \
4202+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(sbindir)$$dir'"; \
4203+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(sbindir)$$dir" || exit $$?; \
4204+ } \
4205+ ; done
4206+
4207+uninstall-sbinPROGRAMS:
4208+ @$(NORMAL_UNINSTALL)
4209+ @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \
4210+ files=`for p in $$list; do echo "$$p"; done | \
4211+ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
4212+ -e 's/$$/$(EXEEXT)/' `; \
4213+ test -n "$$list" || exit 0; \
4214+ echo " ( cd '$(DESTDIR)$(sbindir)' && rm -f" $$files ")"; \
4215+ cd "$(DESTDIR)$(sbindir)" && rm -f $$files
4216+
4217+clean-sbinPROGRAMS:
4218+ @list='$(sbin_PROGRAMS)'; test -n "$$list" || exit 0; \
4219+ echo " rm -f" $$list; \
4220+ rm -f $$list || exit $$?; \
4221+ test -n "$(EXEEXT)" || exit 0; \
4222+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
4223+ echo " rm -f" $$list; \
4224+ rm -f $$list
4225+gpartedbin$(EXEEXT): $(gpartedbin_OBJECTS) $(gpartedbin_DEPENDENCIES)
4226+ @rm -f gpartedbin$(EXEEXT)
4227+ $(gpartedbin_LINK) $(gpartedbin_OBJECTS) $(gpartedbin_LDADD) $(LIBS)
4228+
4229+mostlyclean-compile:
4230+ -rm -f *.$(OBJEXT)
4231+
4232+distclean-compile:
4233+ -rm -f *.tab.c
4234+
4235+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DMRaid.Po@am__quote@
4236+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Device.Po@am__quote@
4237+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DialogFeatures.Po@am__quote@
4238+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DialogManageFlags.Po@am__quote@
4239+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Dialog_Base_Partition.Po@am__quote@
4240+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Dialog_Disklabel.Po@am__quote@
4241+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Dialog_Partition_Copy.Po@am__quote@
4242+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Dialog_Partition_Info.Po@am__quote@
4243+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Dialog_Partition_Label.Po@am__quote@
4244+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Dialog_Partition_New.Po@am__quote@
4245+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Dialog_Partition_Resize_Move.Po@am__quote@
4246+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Dialog_Progress.Po@am__quote@
4247+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Dialog_Rescue_Data.Po@am__quote@
4248+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DrawingAreaVisualDisk.Po@am__quote@
4249+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FS_Info.Po@am__quote@
4250+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FileSystem.Po@am__quote@
4251+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Frame_Resizer_Base.Po@am__quote@
4252+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Frame_Resizer_Extended.Po@am__quote@
4253+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GParted_Core.Po@am__quote@
4254+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HBoxOperations.Po@am__quote@
4255+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LVM2_PV_Info.Po@am__quote@
4256+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Operation.Po@am__quote@
4257+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OperationChangeUUID.Po@am__quote@
4258+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OperationCheck.Po@am__quote@
4259+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OperationCopy.Po@am__quote@
4260+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OperationCreate.Po@am__quote@
4261+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OperationDelete.Po@am__quote@
4262+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OperationDetail.Po@am__quote@
4263+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OperationFormat.Po@am__quote@
4264+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OperationLabelPartition.Po@am__quote@
4265+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OperationResizeMove.Po@am__quote@
4266+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Partition.Po@am__quote@
4267+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Proc_Partitions_Info.Po@am__quote@
4268+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SWRaid.Po@am__quote@
4269+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TreeView_Detail.Po@am__quote@
4270+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Utils.Po@am__quote@
4271+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Win_GParted.Po@am__quote@
4272+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/btrfs.Po@am__quote@
4273+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exfat.Po@am__quote@
4274+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ext2.Po@am__quote@
4275+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ext3.Po@am__quote@
4276+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ext4.Po@am__quote@
4277+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fat16.Po@am__quote@
4278+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fat32.Po@am__quote@
4279+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hfs.Po@am__quote@
4280+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hfsplus.Po@am__quote@
4281+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jfs.Po@am__quote@
4282+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linux_swap.Po@am__quote@
4283+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lvm2_pv.Po@am__quote@
4284+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
4285+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nilfs2.Po@am__quote@
4286+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntfs.Po@am__quote@
4287+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reiser4.Po@am__quote@
4288+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reiserfs.Po@am__quote@
4289+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ufs.Po@am__quote@
4290+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xfs.Po@am__quote@
4291+
4292+.cc.o:
4293+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
4294+@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
4295+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
4296+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
4297+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
4298+
4299+.cc.obj:
4300+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
4301+@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
4302+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
4303+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
4304+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
4305+
4306+.cc.lo:
4307+@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
4308+@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
4309+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
4310+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
4311+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
4312+
4313+mostlyclean-libtool:
4314+ -rm -f *.lo
4315+
4316+clean-libtool:
4317+ -rm -rf .libs _libs
4318+
4319+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
4320+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
4321+ unique=`for i in $$list; do \
4322+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
4323+ done | \
4324+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
4325+ END { if (nonempty) { for (i in files) print i; }; }'`; \
4326+ mkid -fID $$unique
4327+tags: TAGS
4328+
4329+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
4330+ $(TAGS_FILES) $(LISP)
4331+ set x; \
4332+ here=`pwd`; \
4333+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
4334+ unique=`for i in $$list; do \
4335+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
4336+ done | \
4337+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
4338+ END { if (nonempty) { for (i in files) print i; }; }'`; \
4339+ shift; \
4340+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
4341+ test -n "$$unique" || unique=$$empty_fix; \
4342+ if test $$# -gt 0; then \
4343+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
4344+ "$$@" $$unique; \
4345+ else \
4346+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
4347+ $$unique; \
4348+ fi; \
4349+ fi
4350+ctags: CTAGS
4351+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
4352+ $(TAGS_FILES) $(LISP)
4353+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
4354+ unique=`for i in $$list; do \
4355+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
4356+ done | \
4357+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
4358+ END { if (nonempty) { for (i in files) print i; }; }'`; \
4359+ test -z "$(CTAGS_ARGS)$$unique" \
4360+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
4361+ $$unique
4362+
4363+GTAGS:
4364+ here=`$(am__cd) $(top_builddir) && pwd` \
4365+ && $(am__cd) $(top_srcdir) \
4366+ && gtags -i $(GTAGS_ARGS) "$$here"
4367+
4368+distclean-tags:
4369+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
4370+
4371+distdir: $(DISTFILES)
4372+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
4373+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
4374+ list='$(DISTFILES)'; \
4375+ dist_files=`for file in $$list; do echo $$file; done | \
4376+ sed -e "s|^$$srcdirstrip/||;t" \
4377+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
4378+ case $$dist_files in \
4379+ */*) $(MKDIR_P) `echo "$$dist_files" | \
4380+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
4381+ sort -u` ;; \
4382+ esac; \
4383+ for file in $$dist_files; do \
4384+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
4385+ if test -d $$d/$$file; then \
4386+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
4387+ if test -d "$(distdir)/$$file"; then \
4388+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
4389+ fi; \
4390+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
4391+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
4392+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
4393+ fi; \
4394+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
4395+ else \
4396+ test -f "$(distdir)/$$file" \
4397+ || cp -p $$d/$$file "$(distdir)/$$file" \
4398+ || exit 1; \
4399+ fi; \
4400+ done
4401+check-am: all-am
4402+check: check-am
4403+all-am: Makefile $(PROGRAMS)
4404+installdirs:
4405+ for dir in "$(DESTDIR)$(sbindir)"; do \
4406+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
4407+ done
4408+install: install-am
4409+install-exec: install-exec-am
4410+install-data: install-data-am
4411+uninstall: uninstall-am
4412+
4413+install-am: all-am
4414+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
4415+
4416+installcheck: installcheck-am
4417+install-strip:
4418+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
4419+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
4420+ `test -z '$(STRIP)' || \
4421+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
4422+mostlyclean-generic:
4423+
4424+clean-generic:
4425+
4426+distclean-generic:
4427+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
4428+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
4429+
4430+maintainer-clean-generic:
4431+ @echo "This command is intended for maintainers to use"
4432+ @echo "it deletes files that may require special tools to rebuild."
4433+clean: clean-am
4434+
4435+clean-am: clean-generic clean-libtool clean-sbinPROGRAMS \
4436+ mostlyclean-am
4437+
4438+distclean: distclean-am
4439+ -rm -rf ./$(DEPDIR)
4440+ -rm -f Makefile
4441+distclean-am: clean-am distclean-compile distclean-generic \
4442+ distclean-tags
4443+
4444+dvi: dvi-am
4445+
4446+dvi-am:
4447+
4448+html: html-am
4449+
4450+html-am:
4451+
4452+info: info-am
4453+
4454+info-am:
4455+
4456+install-data-am:
4457+
4458+install-dvi: install-dvi-am
4459+
4460+install-dvi-am:
4461+
4462+install-exec-am: install-sbinPROGRAMS
4463+
4464+install-html: install-html-am
4465+
4466+install-html-am:
4467+
4468+install-info: install-info-am
4469+
4470+install-info-am:
4471+
4472+install-man:
4473+
4474+install-pdf: install-pdf-am
4475+
4476+install-pdf-am:
4477+
4478+install-ps: install-ps-am
4479+
4480+install-ps-am:
4481+
4482+installcheck-am:
4483+
4484+maintainer-clean: maintainer-clean-am
4485+ -rm -rf ./$(DEPDIR)
4486+ -rm -f Makefile
4487+maintainer-clean-am: distclean-am maintainer-clean-generic
4488+
4489+mostlyclean: mostlyclean-am
4490+
4491+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
4492+ mostlyclean-libtool
4493+
4494+pdf: pdf-am
4495+
4496+pdf-am:
4497+
4498+ps: ps-am
4499+
4500+ps-am:
4501+
4502+uninstall-am: uninstall-sbinPROGRAMS
4503+
4504+.MAKE: install-am install-strip
4505+
4506+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
4507+ clean-libtool clean-sbinPROGRAMS ctags distclean \
4508+ distclean-compile distclean-generic distclean-libtool \
4509+ distclean-tags distdir dvi dvi-am html html-am info info-am \
4510+ install install-am install-data install-data-am install-dvi \
4511+ install-dvi-am install-exec install-exec-am install-html \
4512+ install-html-am install-info install-info-am install-man \
4513+ install-pdf install-pdf-am install-ps install-ps-am \
4514+ install-sbinPROGRAMS install-strip installcheck \
4515+ installcheck-am installdirs maintainer-clean \
4516+ maintainer-clean-generic mostlyclean mostlyclean-compile \
4517+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
4518+ tags uninstall uninstall-am uninstall-sbinPROGRAMS
4519+
4520+
4521+# Tell versions [3.59,3.63) of GNU make to not export all variables.
4522+# Otherwise a system limit (for SysV at least) may be exceeded.
4523+.NOEXPORT:
4524
4525=== added file '.pc/drop-swraid.patch/src/Proc_Partitions_Info.cc'
4526--- .pc/drop-swraid.patch/src/Proc_Partitions_Info.cc 1970-01-01 00:00:00 +0000
4527+++ .pc/drop-swraid.patch/src/Proc_Partitions_Info.cc 2013-01-14 18:58:25 +0000
4528@@ -0,0 +1,134 @@
4529+/* Copyright (C) 2010 Curtis Gedak
4530+ *
4531+ * This program is free software; you can redistribute it and/or modify
4532+ * it under the terms of the GNU General Public License as published by
4533+ * the Free Software Foundation; either version 2 of the License, or
4534+ * (at your option) any later version.
4535+ *
4536+ * This program is distributed in the hope that it will be useful,
4537+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4538+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4539+ * GNU Library General Public License for more details.
4540+ *
4541+ * You should have received a copy of the GNU General Public License
4542+ * along with this program; if not, write to the Free Software
4543+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
4544+ */
4545+
4546+#include "../include/Proc_Partitions_Info.h"
4547+
4548+#include <fstream>
4549+
4550+namespace GParted
4551+{
4552+
4553+//Initialize static data elements
4554+bool Proc_Partitions_Info::proc_partitions_info_cache_initialized = false ;
4555+std::vector<Glib::ustring> Proc_Partitions_Info::device_paths_cache ;
4556+std::map< Glib::ustring, Glib::ustring > Proc_Partitions_Info::alternate_paths_cache ;
4557+
4558+Proc_Partitions_Info::Proc_Partitions_Info()
4559+{
4560+ //Ensure that cache has been loaded at least once
4561+ if ( ! proc_partitions_info_cache_initialized )
4562+ {
4563+ proc_partitions_info_cache_initialized = true ;
4564+ load_proc_partitions_info_cache() ;
4565+ }
4566+}
4567+
4568+Proc_Partitions_Info::Proc_Partitions_Info( bool do_refresh )
4569+{
4570+ //Ensure that cache has been loaded at least once
4571+ if ( ! proc_partitions_info_cache_initialized )
4572+ {
4573+ proc_partitions_info_cache_initialized = true ;
4574+ if ( do_refresh == false )
4575+ load_proc_partitions_info_cache() ;
4576+ }
4577+
4578+ if ( do_refresh )
4579+ load_proc_partitions_info_cache() ;
4580+}
4581+
4582+Proc_Partitions_Info::~Proc_Partitions_Info()
4583+{
4584+}
4585+
4586+std::vector<Glib::ustring> Proc_Partitions_Info::get_device_paths()
4587+{
4588+ return device_paths_cache ;
4589+}
4590+
4591+std::vector<Glib::ustring> Proc_Partitions_Info::get_alternate_paths( const Glib::ustring & path )
4592+{
4593+ std::vector<Glib::ustring> paths ;
4594+ std::map< Glib::ustring, Glib::ustring >::iterator iter ;
4595+
4596+ iter = alternate_paths_cache .find( path ) ;
4597+ if ( iter != alternate_paths_cache .end() )
4598+ paths .push_back( iter ->second ) ;
4599+
4600+ return paths ;
4601+}
4602+
4603+//Private Methods
4604+void Proc_Partitions_Info::load_proc_partitions_info_cache()
4605+{
4606+ alternate_paths_cache .clear();
4607+ device_paths_cache .clear() ;
4608+
4609+ //Initialize alternate_paths
4610+ std::ifstream proc_partitions( "/proc/partitions" ) ;
4611+ if ( proc_partitions )
4612+ {
4613+ std::string line ;
4614+ std::string device ;
4615+ char c_str[4096+1] ;
4616+
4617+ while ( getline( proc_partitions, line ) )
4618+ {
4619+ //Build cache of disk devices.
4620+ //Whole disk devices are the ones we want.
4621+ //Device names without a trailing digit refer to the whole disk.
4622+ device = Utils::regexp_label(line, "^[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+([^0-9]+)$") ;
4623+ //Recognize /dev/mmcblk* devices.
4624+ //E.g., device = /dev/mmcblk0, partition = /dev/mmcblk0p1
4625+ if ( device == "" )
4626+ device = Utils::regexp_label(line, "^[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+(mmcblk[0-9]+)$") ;
4627+ //Device names that end with a #[^p]# are HP Smart Array Devices (disks)
4628+ //E.g., device = /dev/cciss/c0d0, partition = /dev/cciss/c0d0p1
4629+ if ( device == "" )
4630+ device = Utils::regexp_label(line, "^[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+(.*[0-9]+[^p]{1}[0-9]+)$") ;
4631+ if ( device != "" )
4632+ {
4633+ //add potential device to the list
4634+ device = "/dev/" + device;
4635+ device_paths_cache .push_back( device ) ;
4636+ }
4637+
4638+ //Build cache of potential alternate paths
4639+ if ( sscanf( line .c_str(), "%*d %*d %*d %4096s", c_str ) == 1 )
4640+ {
4641+ line = "/dev/" ;
4642+ line += c_str ;
4643+
4644+ //FIXME: it seems realpath is very unsafe to use (manpage)...
4645+ if ( file_test( line, Glib::FILE_TEST_EXISTS )
4646+ && realpath( line .c_str(), c_str )
4647+ //&& line != c_str
4648+ )
4649+ {
4650+ //Because we can make no assumption about which path libparted will
4651+ //detect, we add all combinations.
4652+ alternate_paths_cache[ c_str ] = line ;
4653+ alternate_paths_cache[ line ] = c_str ;
4654+ }
4655+ }
4656+
4657+ }
4658+ proc_partitions .close() ;
4659+ }
4660+}
4661+
4662+}//GParted
4663
4664=== added file '.pc/drop-swraid.patch/src/SWRaid.cc'
4665--- .pc/drop-swraid.patch/src/SWRaid.cc 1970-01-01 00:00:00 +0000
4666+++ .pc/drop-swraid.patch/src/SWRaid.cc 2013-01-14 18:58:25 +0000
4667@@ -0,0 +1,104 @@
4668+/* Copyright (C) 2009 Curtis Gedak
4669+ *
4670+ * This program is free software; you can redistribute it and/or modify
4671+ * it under the terms of the GNU General Public License as published by
4672+ * the Free Software Foundation; either version 2 of the License, or
4673+ * (at your option) any later version.
4674+ *
4675+ * This program is distributed in the hope that it will be useful,
4676+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4677+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4678+ * GNU Library General Public License for more details.
4679+ *
4680+ * You should have received a copy of the GNU General Public License
4681+ * along with this program; if not, write to the Free Software
4682+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
4683+ */
4684+
4685+#include "../include/SWRaid.h"
4686+
4687+namespace GParted
4688+{
4689+
4690+//Initialize static data elements
4691+bool SWRaid::swraid_cache_initialized = false ;
4692+bool SWRaid::mdadm_found = false ;
4693+std::vector<Glib::ustring> SWRaid::swraid_devices ;
4694+
4695+SWRaid::SWRaid()
4696+{
4697+ //Ensure that cache has been loaded at least once
4698+ if ( ! swraid_cache_initialized )
4699+ {
4700+ swraid_cache_initialized = true ;
4701+ set_commands_found() ;
4702+ load_swraid_cache() ;
4703+ }
4704+}
4705+
4706+SWRaid::SWRaid( const bool & do_refresh )
4707+{
4708+ //Ensure that cache has been loaded at least once
4709+ if ( ! swraid_cache_initialized )
4710+ {
4711+ swraid_cache_initialized = true ;
4712+ set_commands_found() ;
4713+ if ( do_refresh == false )
4714+ load_swraid_cache() ;
4715+ }
4716+
4717+ if ( do_refresh )
4718+ load_swraid_cache() ;
4719+}
4720+
4721+SWRaid::~SWRaid()
4722+{
4723+}
4724+
4725+void SWRaid::load_swraid_cache()
4726+{
4727+ //Load data into swraid structures
4728+ Glib::ustring output, error ;
4729+ swraid_devices .clear() ;
4730+
4731+ if ( mdadm_found )
4732+ {
4733+ if ( ! Utils::execute_command( "mdadm --examine --scan", output, error, true ) )
4734+ {
4735+ if ( output .size() > 0 )
4736+ {
4737+ std::vector<Glib::ustring> temp_arr ;
4738+ Utils::tokenize( output, temp_arr, "\n" ) ;
4739+ for ( unsigned int k = 0; k < temp_arr .size(); k++ )
4740+ {
4741+ Glib::ustring temp = Utils::regexp_label( temp_arr[k], "^[^/]*(/dev/[^\t ]*)" ) ;
4742+ if ( temp .size() > 0 )
4743+ swraid_devices .push_back( temp ) ;
4744+ }
4745+ }
4746+ }
4747+ }
4748+}
4749+
4750+void SWRaid::set_commands_found()
4751+{
4752+ //Set status of commands found
4753+ mdadm_found = (! Glib::find_program_in_path( "mdadm" ) .empty() ) ;
4754+}
4755+
4756+bool SWRaid::is_swraid_supported()
4757+{
4758+ //Determine if Linux software RAID is supported
4759+ return ( mdadm_found ) ;
4760+}
4761+
4762+void SWRaid::get_devices( std::vector<Glib::ustring> & device_list )
4763+{
4764+ //Retrieve list of Linux software RAID devices
4765+ device_list .clear() ;
4766+
4767+ for ( unsigned int k=0; k < swraid_devices .size(); k++ )
4768+ device_list .push_back( swraid_devices[k] ) ;
4769+}
4770+
4771+}//GParted
4772
4773=== modified file 'README'
4774--- README 2012-06-14 10:00:43 +0000
4775+++ README 2013-01-14 18:58:25 +0000
4776@@ -149,10 +149,6 @@
4777 package before that.
4778
4779
4780-For Linux software RAID support, the following package is required:
4781- mdadm - tool to administer Linux MD arrays
4782-
4783-
4784 For dmraid support, the following packages are required:
4785
4786 dmsetup - removes /dev/mapper entries
4787
4788=== modified file 'debian/changelog'
4789--- debian/changelog 2012-06-14 10:00:43 +0000
4790+++ debian/changelog 2013-01-14 18:58:25 +0000
4791@@ -1,3 +1,11 @@
4792+gparted (0.12.1-1ubuntu1) quantal; urgency=low
4793+
4794+ * debian/patches/drop-swraid.patch: Upstream patch to remove broken and
4795+ uneeded swraid support that was causing errors with mdadm devices
4796+ (LP: #1074606).
4797+
4798+ -- Phillip Susi <psusi@ubuntu.com> Thu, 29 Nov 2012 13:55:11 -0500
4799+
4800 gparted (0.12.1-1) unstable; urgency=low
4801
4802 * New upstream release
4803
4804=== added file 'debian/patches/drop-swraid.patch'
4805--- debian/patches/drop-swraid.patch 1970-01-01 00:00:00 +0000
4806+++ debian/patches/drop-swraid.patch 2013-01-14 18:58:25 +0000
4807@@ -0,0 +1,286 @@
4808+Author: Curtis Gedak <gedakc@gmail.com>
4809+Description: Upstream patch to remove broken and uneeded swraid
4810+ support that was causing errors with mdadm devices (LP: #1074606)
4811+
4812+--- a/src/Proc_Partitions_Info.cc
4813++++ b/src/Proc_Partitions_Info.cc
4814+@@ -92,6 +92,10 @@
4815+ //Whole disk devices are the ones we want.
4816+ //Device names without a trailing digit refer to the whole disk.
4817+ device = Utils::regexp_label(line, "^[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+([^0-9]+)$") ;
4818++ //Recognize /dev/md* devices (Linux software RAID - mdadm).
4819++ //E.g., device = /dev/md127, partition = /dev/md127p1
4820++ if ( device == "" )
4821++ device = Utils::regexp_label(line, "^[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+(md[0-9]+)$") ;
4822+ //Recognize /dev/mmcblk* devices.
4823+ //E.g., device = /dev/mmcblk0, partition = /dev/mmcblk0p1
4824+ if ( device == "" )
4825+@@ -99,7 +103,7 @@
4826+ //Device names that end with a #[^p]# are HP Smart Array Devices (disks)
4827+ //E.g., device = /dev/cciss/c0d0, partition = /dev/cciss/c0d0p1
4828+ if ( device == "" )
4829+- device = Utils::regexp_label(line, "^[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+(.*[0-9]+[^p]{1}[0-9]+)$") ;
4830++ device = Utils::regexp_label(line, "^[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+(cciss/c[0-9]+d[0-9]+)$") ;
4831+ if ( device != "" )
4832+ {
4833+ //add potential device to the list
4834+--- a/README
4835++++ b/README
4836+@@ -149,10 +149,6 @@
4837+ package before that.
4838+
4839+
4840+-For Linux software RAID support, the following package is required:
4841+- mdadm - tool to administer Linux MD arrays
4842+-
4843+-
4844+ For dmraid support, the following packages are required:
4845+
4846+ dmsetup - removes /dev/mapper entries
4847+--- a/include/Makefile.am
4848++++ b/include/Makefile.am
4849+@@ -34,7 +34,6 @@
4850+ OperationLabelPartition.h \
4851+ Partition.h \
4852+ Proc_Partitions_Info.h \
4853+- SWRaid.h \
4854+ TreeView_Detail.h \
4855+ Utils.h \
4856+ Win_GParted.h \
4857+--- a/include/SWRaid.h
4858++++ /dev/null
4859+@@ -1,55 +0,0 @@
4860+-/* Copyright (C) 2009 Curtis Gedak
4861+- *
4862+- * This program is free software; you can redistribute it and/or modify
4863+- * it under the terms of the GNU General Public License as published by
4864+- * the Free Software Foundation; either version 2 of the License, or
4865+- * (at your option) any later version.
4866+- *
4867+- * This program is distributed in the hope that it will be useful,
4868+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
4869+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4870+- * GNU Library General Public License for more details.
4871+- *
4872+- * You should have received a copy of the GNU General Public License
4873+- * along with this program; if not, write to the Free Software
4874+- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
4875+- */
4876+-
4877+-/* READ THIS!
4878+- * This class was created in an effort to reduce the complexity of the
4879+- * GParted_Core class.
4880+- * This class provides support for Linux software RAID devices (mdadm).
4881+- * Static elements are used in order to reduce the disk accesses required to
4882+- * load the data structures upon each initialization of the class.
4883+- */
4884+-
4885+-#ifndef SWRAID_H_
4886+-#define SWRAID_H_
4887+-
4888+-#include "../include/Utils.h"
4889+-
4890+-#include <vector>
4891+-
4892+-namespace GParted
4893+-{
4894+-
4895+-
4896+-class SWRaid
4897+-{
4898+-public:
4899+- SWRaid() ;
4900+- SWRaid( const bool & do_refresh ) ;
4901+- ~SWRaid() ;
4902+- bool is_swraid_supported() ;
4903+- void get_devices( std::vector<Glib::ustring> & swraid_devices ) ;
4904+-private:
4905+- void load_swraid_cache() ;
4906+- void set_commands_found() ;
4907+- static bool swraid_cache_initialized ;
4908+- static bool mdadm_found ;
4909+- static std::vector<Glib::ustring> swraid_devices ;
4910+-};
4911+-
4912+-}//GParted
4913+-
4914+-#endif /* SWRAID_H_ */
4915+--- a/src/GParted_Core.cc
4916++++ b/src/GParted_Core.cc
4917+@@ -19,7 +19,6 @@
4918+ #include "../include/Win_GParted.h"
4919+ #include "../include/GParted_Core.h"
4920+ #include "../include/DMRaid.h"
4921+-#include "../include/SWRaid.h"
4922+ #include "../include/FS_Info.h"
4923+ #include "../include/LVM2_PV_Info.h"
4924+ #include "../include/OperationCopy.h"
4925+@@ -149,7 +148,6 @@
4926+ Proc_Partitions_Info pp_info( true ) ; //Refresh cache of proc partition information
4927+ FS_Info fs_info( true ) ; //Refresh cache of file system information
4928+ DMRaid dmraid( true ) ; //Refresh cache of dmraid device information
4929+- SWRaid swraid( true ) ; //Refresh cache of swraid device information
4930+ LVM2_PV_Info lvm2_pv_info( true ) ; //Refresh cache of LVM2 PV information
4931+
4932+ init_maps() ;
4933+@@ -176,16 +174,6 @@
4934+ ped_device_get( temp_devices[ k ] .c_str() ) ;
4935+ }
4936+
4937+- //Try to find all swraid devices
4938+- if (swraid .is_swraid_supported() ) {
4939+- std::vector<Glib::ustring> swraid_devices ;
4940+- swraid .get_devices( swraid_devices ) ;
4941+- for ( unsigned int k=0; k < swraid_devices .size(); k++ ) {
4942+- set_thread_status_message( String::ucompose ( _("Scanning %1"), swraid_devices[k] ) ) ;
4943+- ped_device_get( swraid_devices[k] .c_str() ) ;
4944+- }
4945+- }
4946+-
4947+ //Try to find all dmraid devices
4948+ if (dmraid .is_dmraid_supported() ) {
4949+ std::vector<Glib::ustring> dmraid_devices ;
4950+--- a/src/Makefile.am
4951++++ b/src/Makefile.am
4952+@@ -44,7 +44,6 @@
4953+ OperationLabelPartition.cc \
4954+ Partition.cc \
4955+ Proc_Partitions_Info.cc \
4956+- SWRaid.cc \
4957+ TreeView_Detail.cc \
4958+ Utils.cc \
4959+ Win_GParted.cc \
4960+--- a/src/SWRaid.cc
4961++++ /dev/null
4962+@@ -1,104 +0,0 @@
4963+-/* Copyright (C) 2009 Curtis Gedak
4964+- *
4965+- * This program is free software; you can redistribute it and/or modify
4966+- * it under the terms of the GNU General Public License as published by
4967+- * the Free Software Foundation; either version 2 of the License, or
4968+- * (at your option) any later version.
4969+- *
4970+- * This program is distributed in the hope that it will be useful,
4971+- * but WITHOUT ANY WARRANTY; without even the implied warranty of
4972+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4973+- * GNU Library General Public License for more details.
4974+- *
4975+- * You should have received a copy of the GNU General Public License
4976+- * along with this program; if not, write to the Free Software
4977+- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
4978+- */
4979+-
4980+-#include "../include/SWRaid.h"
4981+-
4982+-namespace GParted
4983+-{
4984+-
4985+-//Initialize static data elements
4986+-bool SWRaid::swraid_cache_initialized = false ;
4987+-bool SWRaid::mdadm_found = false ;
4988+-std::vector<Glib::ustring> SWRaid::swraid_devices ;
4989+-
4990+-SWRaid::SWRaid()
4991+-{
4992+- //Ensure that cache has been loaded at least once
4993+- if ( ! swraid_cache_initialized )
4994+- {
4995+- swraid_cache_initialized = true ;
4996+- set_commands_found() ;
4997+- load_swraid_cache() ;
4998+- }
4999+-}
5000+-
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: