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