Compare commits

...

61 Commits

Author SHA1 Message Date
Andrius Štikonas 4a52757009 Merge branch 'master' into raid-support 2020-09-17 01:55:09 +01:00
Andrius Štikonas 6d110ca6a5 Move GPL3 license to LICENSES folder. 2020-09-17 01:32:54 +01:00
Andrius Štikonas 37d373cfe0 Fix missing parenthesis in README. 2020-09-15 18:22:08 +01:00
Andrius Štikonas c5c21849b9 Compile kpmcore with QT_NO_KEYWORDS. 2020-09-15 02:36:46 +01:00
Andrius Štikonas fbe54e21f3 Merge branch 'fstab' 2020-09-15 01:09:38 +01:00
Andrius Štikonas ba46ea64ba defaults option in fstab is not necessary, e.g. defaults,ro is the same as defaults. 2020-09-14 02:25:36 +01:00
Andrius Štikonas a928c62a7d Make fstab parsing slightly more readable. 2020-09-14 02:19:14 +01:00
Andrius Štikonas 1d195b00da Prettier formatting of fstab file. 2020-09-14 02:15:20 +01:00
Andrius Štikonas 1782a9d4bb Port away from deprecated QTime::elapsed. 2020-09-13 17:25:51 +01:00
Andrius Štikonas 2ed9953694 Simplify some External Command functions. 2020-09-11 20:27:24 +01:00
Andrius Štikonas 5b80c6045c Fix fstab editing functionality.
In the old code QByteArray fstabContents was actually empty.
Also, writeData function was opening file in append mode,
thus nothing was actually written.

Split writeData function into two:
  * one for block devices
  * another for writing fstab file

BUG: 417205
2020-09-10 23:54:23 +01:00
Adriaan de Groot 45bd205e79 Typofix: the function was half-renamed before the merge 2020-09-01 13:44:22 +02:00
Andrius Štikonas 997e8df183 Add a note about json fixes in util-linux 2.37 2020-08-28 22:41:43 +01:00
Adriaan de Groot 6aa9d93728 Workaround bad JSON output from sfdisk.
The output of `sfdisk --json /dev/sdb` is not necessarily
valid JSON. Then, no partition information is stored,
no first-valid-lba in particular. This leads to new partitions
being made from sector 0, which is invalid on a GPT table.

The workaround is to manually fix the known-broken JSON
from sfdisk. This is amply documented in a standalone
static function.

FIXES #425097
2020-08-24 22:53:54 +02:00
l10n daemon script 394859444f SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-07-26 05:51:19 +02:00
l10n daemon script 73a1deb092 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-07-25 05:37:40 +02:00
Andrius Štikonas dc604c4d31 sfdisk: simplify scanDevice by moving out partition setup logic. 2020-06-19 01:52:16 +01:00
l10n daemon script ffb7147f01 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-06-18 05:48:51 +02:00
l10n daemon script 1843a99895 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-06-17 14:16:14 +02:00
Gaël PORTAY 6f4b883130 sfdisk: Move GPT Attributes functions to new sfdiskgptattributes
This centralizes the two get functions related to GPT Attributes.
2020-06-16 20:15:56 -04:00
Gaël PORTAY 547fa609fe sfdisk: Read GPT type and attributes at scanning
The GPT type and attributes can be set since the commits 0529ebf (Add
support for setting the specific GPT type) and 0ffec31 (Add new job to
set the GPT partition attributes).

But these two data from existing partitions are not read and are missing
though.

This reads the GPT type and attributes data at scanning from the json
output, after the GPT name/label and uuid are read.
2020-06-16 15:45:53 -04:00
Gaël PORTAY 0ffec31e2b Add new job to set the GPT partition attributes
The GPT partition layout supports partition attributes.

The CLI sfdisk sets the partition attributes using the option
--part-attrs. See the examples below:

	$ cat <<EOF | sfdisk disk.img
	label: gpt
	type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, size=64M
	type=0FC63DAF-8483-4772-8E79-3D69D8477DE4
	EOF
	(...)

	$ sfdisk --part-attrs disk.img 1 RequiredPartition,NoBlockIOProtocol,LegacyBIOSBootable,48
	(...)

	$ sfdisk --part-attrs disk.img 2 60,61,62,63
	(...)

	$ sfdisk --dump disk.img
	(...)
	disk.img1 : start=        2048, size=      131072, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=BBE806BB-8567-A843-9FF5-9B6B35D2908E, attrs="RequiredPartition NoBlockIOProtocol LegacyBIOSBootable GUID:48"
	disk.img2 : start=      133120, size=     1963999, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=7DB39F08-C138-664B-B38E-ED2DEB549AA6, attrs="GUID:60,61,62,63"

This commit introduces the new job set-partition-attributes that is used
in the new-operation to set the attributes of the partition. The job
uses the newly introduced method setPartitionAttributes that is
implemented by the sfdisk and dummy backends.

Note: This is a copypaste of what was done for GPT partition label in
commit f585f6c (Add new job to set the GPT partition label) and GPT
partition UUID in commit 1dde035 (Add new job to set the GPT partition
UUID).

Note: RequiredPartition, NoBlockIOProtocol, LegacyBIOSBootable are
key words for 0, 1 and 2.
2020-06-15 17:51:42 -04:00
Andrius Štikonas 9dd118c58b Merge branch 'partition-uuid' into 'master'
Partition uuid

See merge request kde/kpmcore!8
2020-05-15 16:52:23 +00:00
Gaël PORTAY e12f0ec391 Store the generated partitition UUID after creation
The GPT UUID are generated by the backends automatically once a
partition is created.

This reads the UUID that was generated after the creation of a partition
and stores it back to the object Partition.
2020-05-15 12:13:41 -04:00
Gaël PORTAY 1dde035705 Add new job to set the GPT partition UUID
The GPT partition layout supports unique GUID partitions.

The CLI sfdisk sets the partition UUID using the option --part-uuid.
See the examples below:

	$ cat <<EOF | sfdisk disk.img
	label: gpt
	type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, size=64M
	type=0FC63DAF-8483-4772-8E79-3D69D8477DE4
	EOF
	(...)

	$ sfdisk --dump disk.img
	(...)
	disk.img1 : start=        2048, size=      131072, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=BBE806BB-8567-A843-9FF5-9B6B35D2908E
	disk.img2 : start=      133120, size=     1963999, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=7DB39F08-C138-664B-B38E-ED2DEB549AA6

	$ sfdisk --part-uuid disk.img 1 00000000^C000-0000-0000-000000000000
	(...)

	$ sfdisk --part-uuid disk.img 2 11111111-1111-1111-1111-111111111111
	(...)

	$ sfdisk --dump disk.img
	(...)
	disk.img1 : start=        2048, size=      131072, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=00000000-0000-0000-0000-000000000000
	disk.img2 : start=      133120, size=     1963999, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=11111111-1111-1111-1111-111111111111

This commit introduces the new job set-partition-uuid that is used in
the new-operation to set the UUID of the partition. The job uses the
newly introduced method setPartitionUUID that is implemented by the
sfdisk and dummy backends.

Note: This is a copypaste of what was done for GTP partition label in
commit f585f6c (Add new job to set the GPT partition label).
2020-05-15 12:13:17 -04:00
Andrius Štikonas df4e2332f4 Merge branch 'fix-typos' into 'master'
Fix typos

See merge request kde/kpmcore!7
2020-05-15 15:51:06 +00:00
Gaël PORTAY e9992714a1 Fix typos 2020-05-15 11:39:55 -04:00
l10n daemon script 3c6ee043f6 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-05-09 06:34:55 +02:00
Adriaan de Groot 1d9b1161d4 On non-Linux, findBlkIdDevice() has unused parameters
Summary: Add Q_UNUSED() to mark the unused parameters

Test Plan: Builds with fewer warnings on FreeBSD

Differential Revision: https://phabricator.kde.org/D24155
2020-05-08 16:18:14 +02:00
Andrius Štikonas cacdb7b634 Fix some issues spotted by David Faure.
In particular, add a check for partition capacity to be positive.
2020-05-08 15:10:56 +01:00
l10n daemon script a2a9bb8301 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-04-04 06:23:31 +02:00
Andrius Štikonas d6b2584d1b Merge branch 'partition-name' into 'master'
Add support for setting the GPT partition name.

See merge request kde/kpmcore!4
2020-03-28 00:42:09 +00:00
l10n daemon script a4379583b3 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-03-27 06:21:07 +01:00
Gaël PORTAY f585f6c3ad Add new job to set the GPT partition label
The GPT partition layout supports naming partitions.

The support for the partition label was added in the backend libparted
since commit 28fa6ac (Add support for GTP partition labels).

The libparted was removed later by commit 8fa1814 (Remove libparted
backend) and no backend sets the partition label.

The CLI sfdisk sets the partition label using the option --part-label.
See the examples below:

	$ cat <<EOF | sfdisk disk.img
	label: gpt
	type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, size=64M
	type=0FC63DAF-8483-4772-8E79-3D69D8477DE4
	EOF
	(...)

	$ sfdisk --part-label disk.img 1 efi
	(...)

	$ sfdisk --part-label disk.img 2 rootfs
	(...)

	$ sfdisk --dump disk.img
	(...)
	disk.img1 : start=        2048, size=      131072, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=D08E5B2A-4649-9F4A-AEA3-6C3048888EAA, name="efi"
	disk.img2 : start=      133120, size=     1963999, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=0BEEFE82-19EA-DC4C-BB6A-27B6DA0C3BD2, name="rootfs"

This commit introduces the new job set-partition-label that is used in
the new-operation to set the label of the partition. The job uses the
newly introduced method setPartitionLabel that is implemented by the
sfdisk and dummy backends.
2020-03-25 11:20:01 -04:00
l10n daemon script 52c29aaf10 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-03-25 06:42:28 +01:00
Andrius Štikonas 6921398ba3 Merge branch 'gportay/kpmcore-partition-type' 2020-03-22 01:49:35 +00:00
Andrius Štikonas 4fdaf6b1c8 Bump soversion of kpmcore. 2020-03-22 01:49:25 +00:00
Andrius Štikonas a810d0d2fd Merge branch 'gportay/kpmcore-update-filesystem-features-api' 2020-03-22 01:24:57 +00:00
Gaël PORTAY 9d6c98ff4a Replace FSFeature by QVariantMap
The object QVariant is a native object in the Qt world that represents
any type of value: boolean, integer, string, floating point, date,
UUID...

This change updates the API to use the object QVariant and provide a
more flexible API to represent the filesystem features.
2020-03-21 18:09:01 -04:00
Yuri Chornoivan 62aaa90a29
Fix minor EBN issues 2020-03-21 11:22:15 +00:00
Gaël PORTAY 0529ebfb01 Add support for setting the specific GPT type
The GPT partition layout defines the type of the partition using a
UUID[1]. The type of the partition is not related to the underlying
filesystem but to its functionality: rootfs, home, var, swap, esp...

The UUID 4f68bce3-e8cd-4db1-96e7-fbcaf984b709 defines the root partition
(/), the UUID 933ac7e1-2eb4-4f13-b844-0e14e2aef915 defines the home
partition (/home), the UUID 4d21b016-b534-45c2-a9fb-5c16e091fd2d defines
the variable partition (/var)... Also, the UUIDs may vary depending on
the architecture (x86, x86_64, arm or aarch64).

KPMcore guesses the type depending on the underlying filesystem.

This commit enables the setting of a more specific GPT type if it is
specified through the method Partition::setType(). It falls back to the
previous guess type if the type is left unset.

[1]: https://systemd.io/DISCOVERABLE_PARTITIONS/
2020-03-20 22:15:50 -04:00
l10n daemon script 59269f63df SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-03-11 06:00:21 +01:00
Andrius Štikonas efb970ba11 Add a missing features.h include. 2020-02-08 22:01:24 +00:00
Andrius Štikonas f47a83408b Bump kpmcore soversion to 9. 2020-02-08 20:47:23 +00:00
l10n daemon script b7306d2d19 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-02-07 05:43:45 +01:00
Andrius Štikonas aa34937185 Bump kpmcore version to 4.1.0. 2020-02-01 15:20:46 +00:00
Arnaud Ferraris d24191ebd8 Add support for filesystem-specific features
In some cases, it may be necessary to create a filesystem with specific features
enabled/disabled.

This PR makes it possible to create filesystems this way. It does so
by introducing a new m_Features member variable and the createWithFeatures()
function to the FileSystem base class. The latter function is implemented
for the btrfs, ext2/3/4 and FAT filesystems.

Additionnally, the CreateFileSystemJob has been modified to enable
creating/formatting filesystems with specific features enabled.

Differential Revision: https://phabricator.kde.org/D21903
CCBUG: 342178
2020-01-12 11:58:32 +00:00
l10n daemon script 50697be784 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2019-12-08 05:22:07 +01:00
Andrius Štikonas dfce039421 Only trigger udev events for block device subsystem.
Triggerring other subsystems is not necessary and occasionally
results in triggering unrelated bugs.

BUG: 413973
2019-12-02 22:01:10 +00:00
Yuri Chornoivan ca2180f526 Fix minor typo 2019-11-22 15:45:18 +02:00
Yuri Chornoivan 1a7b673792 Fix minor issues found by EBN 2019-11-22 15:45:12 +02:00
Yuri Chornoivan 2980b21b8d Update references 2019-11-22 15:45:04 +02:00
Andrius Štikonas bb7bf3ca03 Make FileSystemFactory::init reentrant.
BUG: 413927
2019-11-18 22:45:58 +02:00
Andrius Štikonas 2c7b3f2bfa Fix resizing of encrypted partitions.
BUG: 413883
2019-11-18 21:16:05 +02:00
Andrius Štikonas 13beb99319 Use partx instead of blockdev to update partition table in the kernel.
CCBUG: 413883
2019-11-18 20:42:36 +02:00
l10n daemon script c4c6ca18ba SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2019-11-12 05:31:35 +01:00
Andrius Štikonas 660aa6a55e Fix a failing test. 2019-11-07 22:28:01 +00:00
Andrius Štikonas 1c771436d4 Merge branch '4.0' 2019-11-07 22:13:39 +00:00
Andrius Štikonas c9a08a593b Remove broken smart unit test.
BUG: 413853
2019-11-07 22:12:00 +00:00
l10n daemon script 5eae2e1625 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2019-11-04 05:16:18 +01:00
Andrius Štikonas 59c9ba2f8d Set MBR partition type of FAT32 partitions to 0x0c.
BUG: 412959
2019-10-15 21:37:58 +01:00
146 changed files with 1569 additions and 1187 deletions

View File

@ -32,10 +32,10 @@ set(BLKID_MIN_VERSION "2.33.2")
# Qca plugin (botan or ossl)
set(VERSION_MAJOR "4")
set(VERSION_MINOR "0")
set(VERSION_RELEASE "1")
set(VERSION_MINOR "1")
set(VERSION_RELEASE "0")
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_RELEASE})
set(SOVERSION "8")
set(SOVERSION "10")
add_definitions(-D'VERSION="${VERSION}"') #"
set(CMAKE_CXX_STANDARD 14)
@ -82,8 +82,8 @@ add_definitions(
-DQT_NO_URL_CAST_FROM_STRING
-DQT_NO_CAST_FROM_BYTEARRAY
-DQT_NO_CAST_TO_BYTEARRAY
-DQT_NO_SIGNALS_SLOTS_KEYWORDS
-DQT_USE_FAST_OPERATOR_PLUS
-DQT_NO_KEYWORDS
)
kde_enable_exceptions()

View File

@ -1,675 +0,0 @@
### GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
<https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
### Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom
to share and change all versions of a program--to make sure it remains
free software for all its users. We, the Free Software Foundation, use
the GNU General Public License for most of our software; it applies
also to any other work released this way by its authors. You can apply
it to your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you
have certain responsibilities if you distribute copies of the
software, or if you modify it: responsibilities to respect the freedom
of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the
manufacturer can do so. This is fundamentally incompatible with the
aim of protecting users' freedom to change the software. The
systematic pattern of such abuse occurs in the area of products for
individuals to use, which is precisely where it is most unacceptable.
Therefore, we have designed this version of the GPL to prohibit the
practice for those products. If such problems arise substantially in
other domains, we stand ready to extend this provision to those
domains in future versions of the GPL, as needed to protect the
freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish
to avoid the special danger that patents applied to a free program
could make it effectively proprietary. To prevent this, the GPL
assures that patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
### TERMS AND CONDITIONS
#### 0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds
of works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of
an exact copy. The resulting work is called a "modified version" of
the earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user
through a computer network, with no transfer of a copy, is not
conveying.
An interactive user interface displays "Appropriate Legal Notices" to
the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
#### 1. Source Code.
The "source code" for a work means the preferred form of the work for
making modifications to it. "Object code" means any non-source form of
a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users can
regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same
work.
#### 2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey,
without conditions so long as your license otherwise remains in force.
You may convey covered works to others for the sole purpose of having
them make modifications exclusively for you, or provide you with
facilities for running those works, provided that you comply with the
terms of this License in conveying all material for which you do not
control copyright. Those thus making or running the covered works for
you must do so exclusively on your behalf, under your direction and
control, on terms that prohibit them from making any copies of your
copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the
conditions stated below. Sublicensing is not allowed; section 10 makes
it unnecessary.
#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such
circumvention is effected by exercising rights under this License with
respect to the covered work, and you disclaim any intention to limit
operation or modification of the work as a means of enforcing, against
the work's users, your or third parties' legal rights to forbid
circumvention of technological measures.
#### 4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
#### 5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these
conditions:
- a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
- b) The work must carry prominent notices stating that it is
released under this License and any conditions added under
section 7. This requirement modifies the requirement in section 4
to "keep intact all notices".
- c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
- d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
#### 6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of
sections 4 and 5, provided that you also convey the machine-readable
Corresponding Source under the terms of this License, in one of these
ways:
- a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
- b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the Corresponding
Source from a network server at no charge.
- c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
- d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
- e) Convey the object code using peer-to-peer transmission,
provided you inform other peers where the object code and
Corresponding Source of the work are being offered to the general
public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal,
family, or household purposes, or (2) anything designed or sold for
incorporation into a dwelling. In determining whether a product is a
consumer product, doubtful cases shall be resolved in favor of
coverage. For a particular product received by a particular user,
"normally used" refers to a typical or common use of that class of
product, regardless of the status of the particular user or of the way
in which the particular user actually uses, or expects or is expected
to use, the product. A product is a consumer product regardless of
whether the product has substantial commercial, industrial or
non-consumer uses, unless such uses represent the only significant
mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to
install and execute modified versions of a covered work in that User
Product from a modified version of its Corresponding Source. The
information must suffice to ensure that the continued functioning of
the modified object code is in no case prevented or interfered with
solely because modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or
updates for a work that has been modified or installed by the
recipient, or for the User Product in which it has been modified or
installed. Access to a network may be denied when the modification
itself materially and adversely affects the operation of the network
or violates the rules and protocols for communication across the
network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
#### 7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders
of that material) supplement the terms of this License with terms:
- a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
- b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
- c) Prohibiting misrepresentation of the origin of that material,
or requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
- d) Limiting the use for publicity purposes of names of licensors
or authors of the material; or
- e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
- f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions
of it) with contractual assumptions of liability to the recipient,
for any liability that these contractual assumptions directly
impose on those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions; the
above requirements apply either way.
#### 8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your license
from a particular copyright holder is reinstated (a) provisionally,
unless and until the copyright holder explicitly and finally
terminates your license, and (b) permanently, if the copyright holder
fails to notify you of the violation by some reasonable means prior to
60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
#### 9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run
a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
#### 10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
#### 11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims owned
or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within the
scope of its coverage, prohibits the exercise of, or is conditioned on
the non-exercise of one or more of the rights that are specifically
granted under this License. You may not convey a covered work if you
are a party to an arrangement with a third party that is in the
business of distributing software, under which you make payment to the
third party based on the extent of your activity of conveying the
work, and under which the third party grants, to any of the parties
who would receive the covered work from you, a discriminatory patent
license (a) in connection with copies of the covered work conveyed by
you (or copies made from those copies), or (b) primarily for and in
connection with specific products or compilations that contain the
covered work, unless you entered into that arrangement, or that patent
license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
#### 12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under
this License and any other pertinent obligations, then as a
consequence you may not convey it at all. For example, if you agree to
terms that obligate you to collect a royalty for further conveying
from those to whom you convey the Program, the only way you could
satisfy both those terms and this License would be to refrain entirely
from conveying the Program.
#### 13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
#### 14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions
of the GNU General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in
detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies that a certain numbered version of the GNU General Public
License "or any later version" applies to it, you have the option of
following the terms and conditions either of that numbered version or
of any later version published by the Free Software Foundation. If the
Program does not specify a version number of the GNU General Public
License, you may choose any version ever published by the Free
Software Foundation.
If the Program specifies that a proxy can decide which future versions
of the GNU General Public License can be used, that proxy's public
statement of acceptance of a version permanently authorizes you to
choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
#### 15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
CORRECTION.
#### 16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
#### 17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
### How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.
To do so, attach the following notices to the program. It is safest to
attach them to the start of each source file to most effectively state
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper
mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands \`show w' and \`show c' should show the
appropriate parts of the General Public License. Of course, your
program's commands might be different; for a GUI interface, you would
use an "about box".
You should also get your employer (if you work as a programmer) or
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. For more information on this, and how to apply and follow
the GNU GPL, see <https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your
program into proprietary programs. If your program is a subroutine
library, you may consider it more useful to permit linking proprietary
applications with the library. If this is what you want to do, use the
GNU Lesser General Public License instead of this License. But first,
please read <https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

View File

@ -55,7 +55,7 @@ class `KPMCoreInitializer` from `test/helpers.h`):
QByteArray env = qgetenv( "KPMCORE_BACKEND" );
auto backendName = env.isEmpty() ? CoreBackendManager::defaultBackendName() : env;
if ( !CoreBackendManager::self()->load( backendName )
if ( !CoreBackendManager::self()->load( backendName ) )
{
qWarning() << "Failed to load backend plugin" << backendName;
return false;

View File

@ -40,12 +40,12 @@ CoreBackend::~CoreBackend()
void CoreBackend::emitProgress(int i)
{
emit progress(i);
Q_EMIT progress(i);
}
void CoreBackend::emitScanProgress(const QString& deviceNode, int i)
{
emit scanProgress(deviceNode, i);
Q_EMIT scanProgress(deviceNode, i);
}
void CoreBackend::setPartitionTableForDevice(Device& d, PartitionTable* p)

View File

@ -39,7 +39,7 @@ class Report;
class CoreBackendDevice
{
public:
CoreBackendDevice(const QString& deviceNode);
explicit CoreBackendDevice(const QString& deviceNode);
virtual ~CoreBackendDevice() {}
public:

View File

@ -103,6 +103,47 @@ public:
*/
virtual bool updateGeometry(Report& report, const Partition& partition, qint64 sector_start, qint64 sector_end) = 0;
/**
* Get the UUID of a partition in the partition table (GPT only).
* The partition UUID is known as PARTUUID by several utilities. The device-manager links
* the device under /dev/disk/by-partuuid/<uuid>.
* @param report the report to write information to
* @param partition the partition to get the UUID for
* @return the partition UUID
*/
virtual QString getPartitionUUID(Report& report, const Partition& partition) = 0;
/**
* Set the label of a partition in the partition table (GPT only).
* The label is set in the GPT partition name entry. The partition name is known as PARTLABEL by
* several utilities. The device-manager links the device under /dev/disk/by-partlabel/<label>.
* @param report the report to write information to
* @param partition the partition to set the label for
* @param label the new label for the partition
* @return true on success
*/
virtual bool setPartitionLabel(Report& report, const Partition& partition, const QString& label) = 0;
/**
* Set the UUID of a partition in the partition table (GPT only).
* The partition UUID is known as PARTUUID by several utilities. The device-manager links
* the device under /dev/disk/by-partuuid/<uuid>.
* @param report the report to write information to
* @param partition the partition to set the UUID for
* @param uuid the new UUID for the partition
* @return true on success
*/
virtual bool setPartitionUUID(Report& report, const Partition& partition, const QString& uuid) = 0;
/**
* Set the attributes of a partition in the partition table (GPT only).
* @param report the report to write information to
* @param partition the partition to set the attributes for
* @param attrs the new attributes for the partition
* @return true on success
*/
virtual bool setPartitionAttributes(Report& report, const Partition& partition, quint64 attrs) = 0;
/**
* Set the system type (e.g. 83 for Linux) of a partition. The type to set is taken from
* the partition's file system.

View File

@ -36,7 +36,7 @@ class CopyTarget;
class CopySourceFile : public CopySource
{
public:
CopySourceFile(const QString& filename);
explicit CopySourceFile(const QString& filename);
public:
bool open() override;

View File

@ -34,7 +34,7 @@
class CopyTargetByteArray : public CopyTarget
{
public:
CopyTargetByteArray(QByteArray& array);
explicit CopyTargetByteArray(QByteArray& array);
public:
bool open() override {

View File

@ -36,7 +36,7 @@ class QString;
class CopyTargetFile : public CopyTarget
{
public:
CopyTargetFile(const QString& filename);
explicit CopyTargetFile(const QString& filename);
public:
bool open() override;

View File

@ -59,7 +59,7 @@ void DeviceScanner::run()
void DeviceScanner::scan()
{
emit progress(QString(), 0);
Q_EMIT progress(QString(), 0);
clear();

View File

@ -21,6 +21,8 @@
#include "util/externalcommand.h"
#include "util/report.h"
#include <algorithm>
#if defined(Q_OS_LINUX)
#include <blkid/blkid.h>
#endif
@ -34,6 +36,8 @@
static void parseFsSpec(const QString& m_fsSpec, FstabEntry::Type& m_entryType, QString& m_deviceNode);
static QString findBlkIdDevice(const char *token, const QString& value);
static void writeEntry(QTextStream& s, const FstabEntry& entry, std::array<unsigned int, 4> columnWidth);
std::array<unsigned int, 4> fstabColumnWidth(const FstabEntryList& fstabEntries);
struct FstabEntryPrivate
{
@ -59,6 +63,7 @@ FstabEntry::FstabEntry(const QString& fsSpec, const QString& mountPoint, const Q
d->m_comment = comment;
d->m_options = options.split(QLatin1Char(','));
d->m_options.removeAll(QStringLiteral("defaults"));
parseFsSpec(d->m_fsSpec, d->m_entryType, d->m_deviceNode);
}
@ -88,15 +93,20 @@ FstabEntryList readFstabEntries( const QString& fstabPath )
// (4) dump frequency (optional, defaults to 0), no comment is allowed if omitted,
// (5) pass number (optional, defaults to 0), no comment is allowed if omitted,
// (#) comment (optional).
auto fsSpec = splitLine.at(0);
auto mountPoint = splitLine.at(1);
auto fsType = splitLine.at(2);
auto options = splitLine.at(3);
switch (splitLine.length()) {
case 4:
fstabEntries.push_back( {splitLine.at(0), splitLine.at(1), splitLine.at(2), splitLine.at(3) } );
fstabEntries.push_back( {fsSpec, mountPoint, fsType, options } );
break;
case 5:
fstabEntries.push_back( {splitLine.at(0), splitLine.at(1), splitLine.at(2), splitLine.at(3), splitLine.at(4).toInt() } );
fstabEntries.push_back( {fsSpec, mountPoint, fsType, options, splitLine.at(4).toInt() } );
break;
case 6:
fstabEntries.push_back( {splitLine.at(0), splitLine.at(1), splitLine.at(2), splitLine.at(3), splitLine.at(4).toInt(), splitLine.at(5).toInt(), comment.isEmpty() ? QString() : QLatin1Char('#') + comment } );
fstabEntries.push_back( {fsSpec, mountPoint, fsType, options, splitLine.at(4).toInt(), splitLine.at(5).toInt(), comment.isEmpty() ? QString() : QLatin1Char('#') + comment } );
break;
default:
fstabEntries.push_back( { {}, {}, {}, {}, {}, {}, QLatin1Char('#') + line } );
@ -142,6 +152,11 @@ const QStringList& FstabEntry::options() const
return d->m_options;
}
const QString FstabEntry::optionsString() const
{
return options().size() > 0 ? options().join(QLatin1Char(',')) : QStringLiteral("defaults");
}
int FstabEntry::dumpFreq() const
{
return d->m_dumpFreq;
@ -203,6 +218,9 @@ static QString findBlkIdDevice(const char *token, const QString& value)
rval = QString::fromLocal8Bit(c);
free(c);
}
#else
Q_UNUSED(token);
Q_UNUSED(value);
#endif
return rval;
@ -229,40 +247,50 @@ static void parseFsSpec(const QString& m_fsSpec, FstabEntry::Type& m_entryType,
}
}
static void writeEntry(QTextStream& s, const FstabEntry& entry)
// Used to nicely format fstab file
std::array<unsigned int, 4> fstabColumnWidth(const FstabEntryList& fstabEntries)
{
std::array<unsigned int, 4> columnWidth;
#define FIELD_WIDTH(x) 3 + std::max_element(fstabEntries.begin(), fstabEntries.end(), [](const FstabEntry& a, const FstabEntry& b) {return a.x().length() < b.x().length(); })->x().length();
columnWidth[0] = FIELD_WIDTH(fsSpec);
columnWidth[1] = FIELD_WIDTH(mountPoint);
columnWidth[2] = FIELD_WIDTH(type);
columnWidth[3] = FIELD_WIDTH(optionsString);
return columnWidth;
}
static void writeEntry(QTextStream& s, const FstabEntry& entry, std::array<unsigned int, 4> columnWidth)
{
if (entry.entryType() == FstabEntry::Type::comment) {
s << entry.comment() << "\n";
return;
}
QString options;
if (entry.options().size() > 0) {
options = entry.options().join(QLatin1Char(','));
if (options.isEmpty())
options = QStringLiteral("defaults");
}
else
options = QStringLiteral("defaults");
s << entry.fsSpec() << "\t"
<< (entry.mountPoint().isEmpty() ? QStringLiteral("none") : entry.mountPoint()) << "\t"
<< entry.type() << "\t"
<< options << "\t"
<< entry.dumpFreq() << "\t"
<< entry.passNumber() << "\t"
s.setFieldAlignment(QTextStream::AlignLeft);
s.setFieldWidth(columnWidth[0]);
s << entry.fsSpec()
<< qSetFieldWidth(columnWidth[1]) << (entry.mountPoint().isEmpty() ? QStringLiteral("none") : entry.mountPoint())
<< qSetFieldWidth(columnWidth[2]) << entry.type()
<< qSetFieldWidth(columnWidth[3]) << entry.optionsString() << qSetFieldWidth(0)
<< entry.dumpFreq() << " "
<< entry.passNumber() << " "
<< entry.comment() << "\n";
}
bool writeMountpoints(const FstabEntryList& fstabEntries, const QString& filename)
{
Report report(nullptr);
QByteArray fstabContents;
QString fstabContents;
QTextStream out(&fstabContents);
std::array<unsigned int, 4> columnWidth = fstabColumnWidth(fstabEntries);
for (const auto &e : fstabEntries)
writeEntry(out, e);
writeEntry(out, e, columnWidth);
ExternalCommand cmd;
return cmd.writeData(report, fstabContents, filename, 0);
return cmd.createFile(fstabContents.toLocal8Bit(), filename);
}

View File

@ -66,6 +66,11 @@ public:
*/
const QStringList& options() const;
/**
* @return the mount options associated with the file system
*/
const QString optionsString() const;
/**
* @return the fs_freq field of fstab entry
*/

View File

@ -170,7 +170,7 @@ Partition* LvmDevice::scanPartition(const QString& lvPath, PartitionTable* pTabl
mountPoint = FileSystem::detectMountPoint(fs, lvPath);
mounted = FileSystem::detectMountStatus(fs, lvPath);
if (mountPoint != QString() && fs->type() != FileSystem::Type::LinuxSwap) {
if (!mountPoint.isEmpty() && fs->type() != FileSystem::Type::LinuxSwap) {
const QStorageInfo storage = QStorageInfo(mountPoint);
if (logicalSize() > 0 && fs->type() != FileSystem::Type::Luks && mounted && storage.isValid())
fs->setSectorsUsed( (storage.bytesTotal() - storage.bytesFree()) / logicalSize() );

View File

@ -48,7 +48,7 @@ class LIBKPMCORE_EXPORT LvmDevice : public VolumeManagerDevice
friend class VolumeManagerDevice;
public:
LvmDevice(const QString& name, const QString& iconName = QString());
explicit LvmDevice(const QString& name, const QString& iconName = QString());
~LvmDevice();
public:

View File

@ -69,7 +69,7 @@ void OperationRunner::run()
Operation* op = operationStack().operations()[i];
op->setStatus(Operation::StatusRunning);
emit opStarted(i + 1, op);
Q_EMIT opStarted(i + 1, op);
connect(op, &Operation::progress, this, &OperationRunner::progressSub);
@ -78,18 +78,18 @@ void OperationRunner::run()
disconnect(op, &Operation::progress, this, &OperationRunner::progressSub);
emit opFinished(i + 1, op);
Q_EMIT opFinished(i + 1, op);
}
if (automounter)
kdedInterface.call( QStringLiteral("loadModule"), automounterService );
if (!status)
emit error();
Q_EMIT error();
else if (isCancelling())
emit cancelled();
Q_EMIT cancelled();
else
emit finished();
Q_EMIT finished();
}
/** @return the number of Operations to run */

View File

@ -452,9 +452,9 @@ void OperationStack::push(Operation* o)
o->setStatus(Operation::StatusPending);
}
// emit operationsChanged even if o is nullptr because it has been merged: merging might
// Q_EMIT operationsChanged even if o is nullptr because it has been merged: merging might
// have led to an existing operation changing.
emit operationsChanged();
Q_EMIT operationsChanged();
}
/** Removes the topmost Operation from the OperationStack, calls Operation::undo() on it and deletes it. */
@ -463,7 +463,7 @@ void OperationStack::pop()
Operation* o = operations().takeLast();
o->undo();
delete o;
emit operationsChanged();
Q_EMIT operationsChanged();
}
/** Check whether previous operations involve given partition.
@ -499,7 +499,7 @@ void OperationStack::clearOperations()
delete o;
}
emit operationsChanged();
Q_EMIT operationsChanged();
}
/** Clears the list of Devices. */
@ -509,7 +509,7 @@ void OperationStack::clearDevices()
qDeleteAll(previewDevices());
previewDevices().clear();
emit devicesChanged();
Q_EMIT devicesChanged();
}
/** Finds a Device a Partition is on.
@ -549,7 +549,7 @@ void OperationStack::addDevice(Device* d)
QWriteLocker lockDevices(&lock());
previewDevices().append(d);
emit devicesChanged();
Q_EMIT devicesChanged();
}
static bool deviceLessThan(const Device* d1, const Device* d2)
@ -567,5 +567,5 @@ void OperationStack::sortDevices()
std::sort(previewDevices().begin(), previewDevices().end(), deviceLessThan);
emit devicesChanged();
Q_EMIT devicesChanged();
}

View File

@ -51,7 +51,7 @@ public:
typedef QList<Operation*> Operations;
public:
OperationStack(QObject* parent = nullptr);
explicit OperationStack(QObject* parent = nullptr);
~OperationStack();
Q_SIGNALS:

View File

@ -24,7 +24,6 @@
#include "util/libpartitionmanagerexport.h"
#include <QStringList>
#include <QtGlobal>
#include <QPointer>
@ -125,9 +124,15 @@ public:
const QString& label() const {
return m_Label; /**< @return the GPT Partition label */
}
const QString& type() const {
return m_Type; /**< @return the GPT Partition type */
}
const QString& uuid() const {
return m_UUID; /**< @return the GPT Partition UUID */
}
quint64 attributes() const {
return m_Attributes; /**< @return the GPT Partition attributes */
}
qint64 firstSector() const {
return m_FirstSector; /**< @return the Partition's first sector on the Device */
}
@ -210,9 +215,15 @@ public:
void setLabel(const QString& s) {
m_Label = s; /**< @param s the new label */
}
void setType(const QString& s) {
m_Type = s; /**< @param s the new type */
}
void setUUID(const QString& s) {
m_UUID = s; /**< @param s the new UUID */
}
void setAttributes(quint64 f) {
m_Attributes = f; /**< @param f the new attributes */
}
void append(Partition* p) override {
m_Children.append(p);
@ -266,7 +277,9 @@ private:
qint64 m_LastSector;
QString m_DevicePath;
QString m_Label;
QString m_Type;
QString m_UUID;
quint64 m_Attributes;
QString m_PartitionPath;
QString m_MountPoint;
PartitionTable::Flags m_AvailableFlags;

View File

@ -75,7 +75,7 @@ bool PartitionAlignment::isLengthAligned(const Device& d, const Partition& p)
@param d device the partition is on
@param p the partition to check
@param quiet if true, will not print warning
@return true if propertly aligned
@return true if properly aligned
*/
bool PartitionAlignment::isAligned(const Device& d, const Partition& p, bool quiet)
{

View File

@ -36,7 +36,7 @@ public:
Recovery,
};
SoftwareRAID(const QString& name,
explicit SoftwareRAID(const QString& name,
SoftwareRAID::Status status = SoftwareRAID::Status::Active,
const QString& iconName = QString());

View File

@ -46,7 +46,7 @@ public:
};
public:
SmartAttribute(const SmartAttributeParsedData& a);
explicit SmartAttribute(const SmartAttributeParsedData& a);
public:
qint32 id() const {

View File

@ -31,7 +31,7 @@
#include <QString>
/** Creates a new SmartParser object
@param device_path device path that indicates the device that SMART must analyse
@param device_path device path that indicates the device that SMART must analyze
*/
SmartParser::SmartParser(const QString &device_path) :
m_DevicePath(device_path),

View File

@ -32,7 +32,7 @@ class SmartDiskInformation;
class SmartParser
{
public:
SmartParser(const QString &device_path);
explicit SmartParser(const QString &device_path);
~SmartParser();
public:
@ -41,7 +41,7 @@ public:
public:
const QString &devicePath() const
{
return m_DevicePath; /**< @return the device path that SMART must analyse */
return m_DevicePath; /**< @return the device path that SMART must analyze */
}
SmartDiskInformation *diskInformation() const

View File

@ -57,7 +57,7 @@ public:
typedef QList<SmartAttribute> Attributes;
public:
SmartStatus(const QString &device_path);
explicit SmartStatus(const QString &device_path);
public:
void update();

View File

@ -16,10 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
*************************************************************************/
#include "core/device_p.h"
#include "core/partition.h"
#include "core/volumemanagerdevice.h"
#include "core/volumemanagerdevice_p.h"
#include "core/device_p.h"
#include "core/partition.h"
#include "core/lvmdevice.h"
#include "core/raid/softwareraid.h"

View File

@ -23,8 +23,8 @@ FileSystem::CommandSupportType apfs::m_Move = FileSystem::cmdSupportCore;
FileSystem::CommandSupportType apfs::m_Copy = FileSystem::cmdSupportCore;
FileSystem::CommandSupportType apfs::m_Backup = FileSystem::cmdSupportCore;
apfs::apfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Apfs)
apfs::apfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Apfs)
{
}
}

View File

@ -34,7 +34,7 @@ namespace FS
class LIBKPMCORE_EXPORT apfs : public FileSystem
{
public:
apfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
apfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
CommandSupportType supportMove() const override {

View File

@ -23,8 +23,8 @@ FileSystem::CommandSupportType bitlocker::m_Move = FileSystem::cmdSupportCore;
FileSystem::CommandSupportType bitlocker::m_Copy = FileSystem::cmdSupportCore;
FileSystem::CommandSupportType bitlocker::m_Backup = FileSystem::cmdSupportCore;
bitlocker::bitlocker(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::BitLocker)
bitlocker::bitlocker(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::BitLocker)
{
}
}

View File

@ -34,7 +34,7 @@ namespace FS
class LIBKPMCORE_EXPORT bitlocker : public FileSystem
{
public:
bitlocker(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
bitlocker(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
CommandSupportType supportMove() const override {

View File

@ -43,8 +43,8 @@ FileSystem::CommandSupportType btrfs::m_SetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType btrfs::m_UpdateUUID = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType btrfs::m_GetUUID = FileSystem::cmdSupportNone;
btrfs::btrfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Btrfs)
btrfs::btrfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Btrfs)
{
}
@ -65,6 +65,22 @@ void btrfs::init()
m_GetLabel = cmdSupportCore;
m_Backup = cmdSupportCore;
m_GetUUID = cmdSupportCore;
if (m_Create == cmdSupportFileSystem) {
ExternalCommand cmd(QStringLiteral("mkfs.btrfs"), QStringList() << QStringLiteral("-O") << QStringLiteral("list-all"));
if (cmd.run(-1) && cmd.exitCode() == 0) {
QStringList lines = cmd.output().split(QStringLiteral("\n"));
// First line is introductory text, we don't need it
lines.removeFirst();
for (const auto& l: lines) {
if (!l.isEmpty())
addAvailableFeature(l.split(QStringLiteral(" ")).first());
}
}
}
}
bool btrfs::supportToolFound() const
@ -86,7 +102,7 @@ bool btrfs::supportToolFound() const
FileSystem::SupportTool btrfs::supportToolName() const
{
return SupportTool(QStringLiteral("btrfs-tools"), QUrl(QStringLiteral("http://btrfs.wiki.kernel.org/")));
return SupportTool(QStringLiteral("btrfs-tools"), QUrl(QStringLiteral("https://btrfs.wiki.kernel.org/")));
}
qint64 btrfs::minCapacity() const
@ -128,7 +144,26 @@ bool btrfs::check(Report& report, const QString& deviceNode) const
bool btrfs::create(Report& report, const QString& deviceNode)
{
ExternalCommand cmd(report, QStringLiteral("mkfs.btrfs"), { QStringLiteral("--force"), deviceNode });
QStringList args = QStringList();
if (!this->features().isEmpty()) {
QStringList feature_list = QStringList();
for (const auto& k : this->features().keys()) {
const auto& v = this->features().value(k);
if (v.type() == QVariant::Type::Bool) {
if (v.toBool())
feature_list << k;
else
feature_list << (QStringLiteral("^") + k);
} else {
qWarning() << "Ignoring feature" << k << "of type" << v.type() << "; requires type QVariant::bool.";
}
}
args << QStringLiteral("--features") << feature_list.join(QStringLiteral(","));
}
args << QStringLiteral("--force") << deviceNode;
ExternalCommand cmd(report, QStringLiteral("mkfs.btrfs"), args);
return cmd.run(-1) && cmd.exitCode() == 0;
}

View File

@ -38,7 +38,7 @@ namespace FS
class LIBKPMCORE_EXPORT btrfs : public FileSystem
{
public:
btrfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
btrfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
void init() override;
@ -61,6 +61,9 @@ public:
CommandSupportType supportCreate() const override {
return m_Create;
}
CommandSupportType supportCreateWithFeatures() const override {
return m_Create;
}
CommandSupportType supportGrow() const override {
return m_Grow;
}

View File

@ -38,8 +38,8 @@ FileSystem::CommandSupportType exfat::m_SetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType exfat::m_UpdateUUID = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType exfat::m_GetUUID = FileSystem::cmdSupportNone;
exfat::exfat(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Exfat)
exfat::exfat(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Exfat)
{
}
@ -79,7 +79,7 @@ bool exfat::supportToolFound() const
FileSystem::SupportTool exfat::supportToolName() const
{
return SupportTool(QStringLiteral("exfat-utils"), QUrl(QStringLiteral("http://code.google.com/p/exfat/")));
return SupportTool(QStringLiteral("exfat-utils"), QUrl(QStringLiteral("https://github.com/relan/exfat")));
}
qint64 exfat::maxCapacity() const

View File

@ -37,7 +37,7 @@ namespace FS
class LIBKPMCORE_EXPORT exfat : public FileSystem
{
public:
exfat(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
exfat(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
void init() override;

View File

@ -39,8 +39,8 @@ FileSystem::CommandSupportType ext2::m_SetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType ext2::m_UpdateUUID = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType ext2::m_GetUUID = FileSystem::cmdSupportNone;
ext2::ext2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t) :
FileSystem(firstsector, lastsector, sectorsused, label, t)
ext2::ext2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features, FileSystem::Type t) :
FileSystem(firstsector, lastsector, sectorsused, label, features, t)
{
}
@ -58,6 +58,37 @@ void ext2::init()
m_Move = (m_Check != cmdSupportNone) ? cmdSupportCore : cmdSupportNone;
m_Backup = cmdSupportCore;
m_GetUUID = cmdSupportCore;
if (m_Create == cmdSupportFileSystem) {
addAvailableFeature(QStringLiteral("64bit"));
addAvailableFeature(QStringLiteral("bigalloc"));
addAvailableFeature(QStringLiteral("casefold"));
addAvailableFeature(QStringLiteral("dir_index"));
addAvailableFeature(QStringLiteral("dir_nlink"));
addAvailableFeature(QStringLiteral("ea_inode"));
addAvailableFeature(QStringLiteral("encrypt"));
addAvailableFeature(QStringLiteral("ext_attr"));
addAvailableFeature(QStringLiteral("extent"));
addAvailableFeature(QStringLiteral("extra_isize"));
addAvailableFeature(QStringLiteral("filetype"));
addAvailableFeature(QStringLiteral("flex_bg"));
addAvailableFeature(QStringLiteral("has_journal"));
addAvailableFeature(QStringLiteral("huge_file"));
addAvailableFeature(QStringLiteral("inline_data"));
addAvailableFeature(QStringLiteral("journal_dev"));
addAvailableFeature(QStringLiteral("large_dir"));
addAvailableFeature(QStringLiteral("large_file"));
addAvailableFeature(QStringLiteral("metadata_csum"));
addAvailableFeature(QStringLiteral("metadata_csum_seed"));
addAvailableFeature(QStringLiteral("meta_bg"));
addAvailableFeature(QStringLiteral("mmp"));
addAvailableFeature(QStringLiteral("project"));
addAvailableFeature(QStringLiteral("quota"));
addAvailableFeature(QStringLiteral("resize_inode"));
addAvailableFeature(QStringLiteral("sparse_super"));
addAvailableFeature(QStringLiteral("sparse_super2"));
addAvailableFeature(QStringLiteral("uninit_bg"));
}
}
bool ext2::supportToolFound() const
@ -133,7 +164,26 @@ bool ext2::check(Report& report, const QString& deviceNode) const
bool ext2::create(Report& report, const QString& deviceNode)
{
ExternalCommand cmd(report, QStringLiteral("mkfs.ext2"), { QStringLiteral("-qF"), deviceNode });
QStringList args = QStringList();
if (!this->features().isEmpty()) {
QStringList feature_list = QStringList();
for (const auto& k : this->features().keys()) {
const auto& v = this->features().value(k);
if (v.type() == QVariant::Type::Bool) {
if (v.toBool())
feature_list << k;
else
feature_list << (QStringLiteral("^") + k);
} else {
qWarning() << "Ignoring feature" << k << "of type" << v.type() << "; requires type QVariant::bool.";
}
}
args << QStringLiteral("-O") << feature_list.join(QStringLiteral(","));
}
args << QStringLiteral("-qF") << deviceNode;
ExternalCommand cmd(report, QStringLiteral("mkfs.ext2"), args);
return cmd.run(-1) && cmd.exitCode() == 0;
}

View File

@ -37,7 +37,7 @@ namespace FS
class LIBKPMCORE_EXPORT ext2 : public FileSystem
{
public:
ext2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t = FileSystem::Type::Ext2);
ext2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {}, FileSystem::Type t = FileSystem::Type::Ext2);
public:
void init() override;
@ -59,6 +59,9 @@ public:
CommandSupportType supportCreate() const override {
return m_Create;
}
CommandSupportType supportCreateWithFeatures() const override {
return m_Create;
}
CommandSupportType supportGrow() const override {
return m_Grow;
}

View File

@ -24,8 +24,8 @@
namespace FS
{
ext3::ext3(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
ext2(firstsector, lastsector, sectorsused, label, FileSystem::Type::Ext3)
ext3::ext3(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
ext2(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Ext3)
{
}
@ -36,7 +36,26 @@ qint64 ext3::maxCapacity() const
bool ext3::create(Report& report, const QString& deviceNode)
{
ExternalCommand cmd(report, QStringLiteral("mkfs.ext3"), QStringList() << QStringLiteral("-qF") << deviceNode);
QStringList args = QStringList();
if (!this->features().isEmpty()) {
QStringList feature_list = QStringList();
for (const auto& k : this->features().keys()) {
const auto& v = this->features().value(k);
if (v.type() == QVariant::Type::Bool) {
if (v.toBool())
feature_list << k;
else
feature_list << (QStringLiteral("^") + k);
} else {
qWarning() << "Ignoring feature" << k << "of type" << v.type() << "; requires type QVariant::bool.";
}
}
args << QStringLiteral("-O") << feature_list.join(QStringLiteral(","));
}
args << QStringLiteral("-qF") << deviceNode;
ExternalCommand cmd(report, QStringLiteral("mkfs.ext3"), args);
return cmd.run(-1) && cmd.exitCode() == 0;
}

View File

@ -40,7 +40,7 @@ namespace FS
class LIBKPMCORE_EXPORT ext3 : public ext2
{
public:
ext3(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
ext3(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
bool create(Report& report, const QString& deviceNode) override;

View File

@ -24,8 +24,8 @@
namespace FS
{
ext4::ext4(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
ext2(firstsector, lastsector, sectorsused, label, FileSystem::Type::Ext4)
ext4::ext4(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
ext2(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Ext4)
{
}
@ -36,7 +36,26 @@ qint64 ext4::maxCapacity() const
bool ext4::create(Report& report, const QString& deviceNode)
{
ExternalCommand cmd(report, QStringLiteral("mkfs.ext4"), QStringList() << QStringLiteral("-qF") << deviceNode);
QStringList args = QStringList();
if (!this->features().isEmpty()) {
QStringList feature_list = QStringList();
for (const auto& k : this->features().keys()) {
const auto& v = this->features().value(k);
if (v.type() == QVariant::Type::Bool) {
if (v.toBool())
feature_list << k;
else
feature_list << (QStringLiteral("^") + k);
} else {
qWarning() << "Ignoring feature" << k << "of type" << v.type() << "; requires type QVariant::bool.";
}
}
args << QStringLiteral("-O") << feature_list.join(QStringLiteral(","));
}
args << QStringLiteral("-qF") << deviceNode;
ExternalCommand cmd(report, QStringLiteral("mkfs.ext4"), args);
return cmd.run(-1) && cmd.exitCode() == 0;
}

View File

@ -40,7 +40,7 @@ namespace FS
class LIBKPMCORE_EXPORT ext4 : public ext2
{
public:
ext4(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
ext4(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
bool create(Report& report, const QString& deviceNode) override;

View File

@ -24,8 +24,8 @@ FileSystem::CommandSupportType extended::m_Grow = FileSystem::cmdSupportCore;
FileSystem::CommandSupportType extended::m_Shrink = FileSystem::cmdSupportCore;
FileSystem::CommandSupportType extended::m_Move = FileSystem::cmdSupportCore;
extended::extended(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Extended)
extended::extended(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Extended)
{
}

View File

@ -40,7 +40,7 @@ namespace FS
class LIBKPMCORE_EXPORT extended : public FileSystem
{
public:
extended(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
extended(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:

View File

@ -45,8 +45,8 @@ FileSystem::CommandSupportType f2fs::m_UpdateUUID = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType f2fs::m_GetUUID = FileSystem::cmdSupportNone;
bool f2fs::oldVersion = false; // 1.8.x or older
f2fs::f2fs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::F2fs)
f2fs::f2fs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::F2fs)
{
}

View File

@ -36,7 +36,7 @@ namespace FS
class LIBKPMCORE_EXPORT f2fs : public FileSystem
{
public:
f2fs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
f2fs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
void init() override;

View File

@ -29,6 +29,9 @@
#include <QString>
#include <QStringList>
#include <QDebug>
#include <QtMath>
#include <ctime>
namespace FS
@ -46,8 +49,8 @@ FileSystem::CommandSupportType fat12::m_Backup = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType fat12::m_UpdateUUID = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType fat12::m_GetUUID = FileSystem::cmdSupportNone;
fat12::fat12(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t) :
FileSystem(firstsector, lastsector, sectorsused, label, t)
fat12::fat12(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features, FileSystem::Type t) :
FileSystem(firstsector, lastsector, sectorsused, label, features, t)
{
}
@ -61,6 +64,11 @@ void fat12::init()
m_Backup = cmdSupportCore;
m_UpdateUUID = cmdSupportCore;
m_GetUUID = cmdSupportCore;
if (m_Create == cmdSupportFileSystem) {
addAvailableFeature(QStringLiteral("sector-size"));
addAvailableFeature(QStringLiteral("sectors-per-cluster"));
}
}
bool fat12::supportToolFound() const
@ -151,7 +159,39 @@ bool fat12::check(Report& report, const QString& deviceNode) const
bool fat12::create(Report& report, const QString& deviceNode)
{
ExternalCommand cmd(report, QStringLiteral("mkfs.fat"), { QStringLiteral("-F12"), QStringLiteral("-I"), QStringLiteral("-v"), deviceNode });
return createWithFatSize(report, deviceNode, 12);
}
bool fat12::createWithFatSize(Report &report, const QString& deviceNode, int fatSize)
{
QStringList args = QStringList();
if (fatSize != 12 && fatSize != 16 && fatSize != 32)
return false;
for (const auto& k : this->features().keys()) {
const auto& v = this->features().value(k);
if (k == QStringLiteral("sector-size")) {
quint32 sectorSize = v.toInt();
/* sectorSize has to be a power of 2 between 512 and 32768 */
if (sectorSize >= 512 && sectorSize <= 32768 && sectorSize == qNextPowerOfTwo(sectorSize - 1))
args << QStringLiteral("-S%1").arg(sectorSize);
else
qWarning() << QStringLiteral("FAT sector size %1 is invalid, using default").arg(sectorSize);
} else if (k == QStringLiteral("sectors-per-cluster")) {
quint32 sectorsPerCluster = v.toInt();
/* sectorsPerCluster has to be a power of 2 between 2 and 128 */
if (sectorsPerCluster <= 128 && sectorsPerCluster == qNextPowerOfTwo(sectorsPerCluster - 1))
args << QStringLiteral("-s%1").arg(sectorsPerCluster);
else
qWarning() << QStringLiteral("FAT sector size %1 is invalid, using default").arg(sectorsPerCluster);
}
}
args << QStringLiteral("-F%1").arg(fatSize) << QStringLiteral("-I") << QStringLiteral("-v") << deviceNode;
ExternalCommand cmd(report, QStringLiteral("mkfs.fat"), args);
return cmd.run(-1) && cmd.exitCode() == 0;
}

View File

@ -37,7 +37,7 @@ namespace FS
class LIBKPMCORE_EXPORT fat12 : public FileSystem
{
public:
fat12(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t = FileSystem::Type::Fat12);
fat12(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {}, FileSystem::Type t = FileSystem::Type::Fat12);
public:
void init() override;
@ -92,6 +92,9 @@ public:
SupportTool supportToolName() const override;
bool supportToolFound() const override;
protected:
bool createWithFatSize(Report &report, const QString& deviceNode, int fatSize);
public:
static CommandSupportType m_GetUsed;
static CommandSupportType m_GetLabel;

View File

@ -31,13 +31,8 @@
namespace FS
{
fat16::fat16(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
fat12(firstsector, lastsector, sectorsused, label, FileSystem::Type::Fat16)
{
}
fat16::fat16(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type type) :
fat12(firstsector, lastsector, sectorsused, label, type)
fat16::fat16(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features, FileSystem::Type type) :
fat12(firstsector, lastsector, sectorsused, label, features, type)
{
}
@ -53,6 +48,11 @@ void fat16::init()
m_Grow = findExternal(QStringLiteral("fatresize")) ? cmdSupportFileSystem : cmdSupportNone;
m_Shrink = findExternal(QStringLiteral("fatresize")) ? cmdSupportFileSystem : cmdSupportNone;
m_GetUUID = cmdSupportCore;
if (m_Create == cmdSupportFileSystem) {
addAvailableFeature(QStringLiteral("sector-size"));
addAvailableFeature(QStringLiteral("sectors-per-cluster"));
}
}
bool fat16::supportToolFound() const
@ -84,8 +84,7 @@ qint64 fat16::maxCapacity() const
bool fat16::create(Report& report, const QString& deviceNode)
{
ExternalCommand cmd(report, QStringLiteral("mkfs.fat"), { QStringLiteral("-F16"), QStringLiteral("-I"), QStringLiteral("-v"), deviceNode });
return cmd.run(-1) && cmd.exitCode() == 0;
return createWithFatSize(report, deviceNode, 16);
}
bool fat16::resize(Report& report, const QString& deviceNode, qint64 length) const

View File

@ -33,8 +33,7 @@ namespace FS
class LIBKPMCORE_EXPORT fat16 : public fat12
{
public:
fat16(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
fat16(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type type);
fat16(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {}, FileSystem::Type type = FileSystem::Type::Fat16);
public:
void init() override;

View File

@ -26,8 +26,8 @@
namespace FS
{
fat32::fat32(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
fat16(firstsector, lastsector, sectorsused, label, FileSystem::Type::Fat32)
fat32::fat32(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
fat16(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Fat32)
{
}
@ -43,8 +43,7 @@ qint64 fat32::maxCapacity() const
bool fat32::create(Report& report, const QString& deviceNode)
{
ExternalCommand cmd(report, QStringLiteral("mkfs.fat"), { QStringLiteral("-F32"), QStringLiteral("-I"), QStringLiteral("-v"), deviceNode });
return cmd.run(-1) && cmd.exitCode() == 0;
return createWithFatSize(report, deviceNode, 32);
}
bool fat32::updateUUID(Report& report, const QString& deviceNode) const

View File

@ -40,7 +40,7 @@ namespace FS
class LIBKPMCORE_EXPORT fat32 : public fat16
{
public:
fat32(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
fat32(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
bool create(Report& report, const QString& deviceNode) override;

View File

@ -17,10 +17,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
*************************************************************************/
#include "fs/filesystem.h"
#include "core/fstab.h"
#include "core/raid/softwareraid.h"
#include "fs/filesystem.h"
#include "fs/lvm2_pv.h"
#include "backend/corebackend.h"
@ -85,6 +85,8 @@ struct FileSystemPrivate {
qint64 m_SectorsUsed;
QString m_Label;
QString m_UUID;
QStringList m_AvailableFeatures;
QVariantMap m_Features;
};
/** Creates a new FileSystem object
@ -105,6 +107,26 @@ FileSystem::FileSystem(qint64 firstsector, qint64 lastsector, qint64 sectorsused
d->m_UUID = QString();
}
/** Creates a new FileSystem object
@param firstsector the first sector used by this FileSystem on the Device
@param lastsector the last sector used by this FileSystem on the Device
@param sectorsused the number of sectors in use on the FileSystem
@param label the FileSystem label
@param features the FileSystem features
@param type the FileSystem type
*/
FileSystem::FileSystem(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features, FileSystem::Type type) :
d(std::make_unique<FileSystemPrivate>())
{
d->m_Type = type;
d->m_FirstSector = firstsector;
d->m_LastSector = lastsector;
d->m_SectorsUsed = sectorsused;
d->m_Label = label;
d->m_Features = features;
d->m_UUID = QString();
}
FileSystem::~FileSystem()
{
}
@ -155,7 +177,7 @@ bool FileSystem::detectMountStatus(FileSystem* fs, const QString& partitionPath)
bool mounted = false;
if (fs->type() == FileSystem::Type::Lvm2_PV) {
mounted = FS::lvm2_pv::getVGName(partitionPath) != QString();
mounted = !FS::lvm2_pv::getVGName(partitionPath).isEmpty();
} else {
mounted = isMounted(partitionPath);
}
@ -585,6 +607,23 @@ bool FileSystem::findExternal(const QString& cmdName, const QStringList& args, i
return cmd.exitCode() == 0 || cmd.exitCode() == expectedCode;
}
void FileSystem::addAvailableFeature(const QString& name)
{
d->m_AvailableFeatures.append(name);
}
void FileSystem::addFeature(const QString& name, const QVariant& value)
{
d->m_Features.insert(name, value);
}
void FileSystem::addFeatures(const QVariantMap& features)
{
for (const auto& k : features.keys()) {
d->m_Features.insert(k, features.value(k));
}
}
bool FileSystem::supportToolFound() const
{
return false;
@ -610,6 +649,16 @@ const QString& FileSystem::label() const
return d->m_Label;
}
const QStringList& FileSystem::availableFeatures() const
{
return d->m_AvailableFeatures;
}
const QVariantMap& FileSystem::features() const
{
return d->m_Features;
}
qint64 FileSystem::sectorSize() const
{
return d->m_SectorSize;

View File

@ -20,8 +20,10 @@
#ifndef KPMCORE_FILESYSTEM_H
#define KPMCORE_FILESYSTEM_H
#include "util/libpartitionmanagerexport.h"
#include <QVariant>
#include <QList>
#include <QStringList>
#include <QString>
@ -113,6 +115,7 @@ public:
protected:
FileSystem(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type type);
FileSystem(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features, FileSystem::Type type);
public:
virtual ~FileSystem();
@ -149,6 +152,9 @@ public:
virtual CommandSupportType supportCreateWithLabel() const {
return cmdSupportNone; /**< @return CommandSupportType for creating */
}
virtual CommandSupportType supportCreateWithFeatures() const {
return cmdSupportNone; /**< @return CommandSupportType for creating */
}
virtual CommandSupportType supportGrow() const {
return cmdSupportNone; /**< @return CommandSupportType for growing */
}
@ -263,6 +269,19 @@ public:
/**< @return the FileSystem's label */
const QString& label() const;
/**< @return the FileSystem's available features */
const QStringList& availableFeatures() const;
/**< @return the FileSystem's features */
const QVariantMap& features() const;
/**< @param the feature's name to add to the FileSystem */
/**< @param the feature's value to add to the FileSystem */
void addFeature(const QString& name, const QVariant& value);
/**< @param features the list of features to add to the FileSystem */
void addFeatures(const QVariantMap& features);
/**< @return the sector size in the underlying Device */
qint64 sectorSize() const;
@ -286,6 +305,7 @@ public:
protected:
static bool findExternal(const QString& cmdName, const QStringList& args = QStringList(), int exptectedCode = 1);
void addAvailableFeature(const QString& name);
std::unique_ptr<FileSystemPrivate> d;
};

View File

@ -62,46 +62,48 @@ FileSystemFactory::FileSystems FileSystemFactory::m_FileSystems;
/** Initializes the instance. */
void FileSystemFactory::init()
{
FileSystems fileSystems;
fileSystems.insert(FileSystem::Type::Apfs, new FS::apfs(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::BitLocker, new FS::bitlocker(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Btrfs, new FS::btrfs(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Exfat, new FS::exfat(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Ext2, new FS::ext2(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Ext3, new FS::ext3(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Ext4, new FS::ext4(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Extended, new FS::extended(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::F2fs, new FS::f2fs(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Fat12, new FS::fat12(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Fat16, new FS::fat16(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Fat32, new FS::fat32(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Hfs, new FS::hfs(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::HfsPlus, new FS::hfsplus(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Hpfs, new FS::hpfs(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Iso9660, new FS::iso9660(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Jfs, new FS::jfs(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::LinuxRaidMember, new FS::linuxraidmember(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::LinuxSwap, new FS::linuxswap(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Luks, new FS::luks(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Luks2, new FS::luks2(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Lvm2_PV, new FS::lvm2_pv(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Minix, new FS::minix(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Nilfs2, new FS::nilfs2(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Ntfs, new FS::ntfs(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Ocfs2, new FS::ocfs2(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::ReiserFS, new FS::reiserfs(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Reiser4, new FS::reiser4(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Udf, new FS::udf(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Ufs, new FS::ufs(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Unformatted, new FS::unformatted(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Unknown, new FS::unknown(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Xfs, new FS::xfs(-1, -1, -1, QString()));
fileSystems.insert(FileSystem::Type::Zfs, new FS::zfs(-1, -1, -1, QString()));
for (const auto &fs : qAsConst(fileSystems))
fs->init();
qDeleteAll(m_FileSystems);
m_FileSystems.clear();
m_FileSystems.insert(FileSystem::Type::Apfs, new FS::apfs(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::BitLocker, new FS::bitlocker(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Btrfs, new FS::btrfs(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Exfat, new FS::exfat(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Ext2, new FS::ext2(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Ext3, new FS::ext3(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Ext4, new FS::ext4(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Extended, new FS::extended(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::F2fs, new FS::f2fs(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Fat12, new FS::fat12(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Fat16, new FS::fat16(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Fat32, new FS::fat32(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Hfs, new FS::hfs(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::HfsPlus, new FS::hfsplus(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Hpfs, new FS::hpfs(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Iso9660, new FS::iso9660(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Jfs, new FS::jfs(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::LinuxRaidMember, new FS::linuxraidmember(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::LinuxSwap, new FS::linuxswap(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Luks, new FS::luks(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Luks2, new FS::luks2(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Lvm2_PV, new FS::lvm2_pv(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Minix, new FS::minix(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Nilfs2, new FS::nilfs2(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Ntfs, new FS::ntfs(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Ocfs2, new FS::ocfs2(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::ReiserFS, new FS::reiserfs(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Reiser4, new FS::reiser4(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Udf, new FS::udf(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Ufs, new FS::ufs(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Unformatted, new FS::unformatted(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Unknown, new FS::unknown(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Xfs, new FS::xfs(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Zfs, new FS::zfs(-1, -1, -1, QString()));
for (const auto &fs : FileSystemFactory::map())
fs->init();
m_FileSystems = fileSystems;
CoreBackendManager::self()->backend()->initFSSupport();
}
@ -114,45 +116,45 @@ void FileSystemFactory::init()
@param label the FileSystem's label
@return pointer to the newly created FileSystem object or nullptr if FileSystem could not be created
*/
FileSystem* FileSystemFactory::create(FileSystem::Type t, qint64 firstsector, qint64 lastsector, qint64 sectorSize, qint64 sectorsused, const QString& label, const QString& uuid)
FileSystem* FileSystemFactory::create(FileSystem::Type t, qint64 firstsector, qint64 lastsector, qint64 sectorSize, qint64 sectorsused, const QString& label, const QVariantMap& features, const QString& uuid)
{
FileSystem* fs = nullptr;
switch (t) {
case FileSystem::Type::Apfs: fs = new FS::apfs (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::BitLocker: fs = new FS::bitlocker (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Btrfs: fs = new FS::btrfs (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Exfat: fs = new FS::exfat (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Ext2: fs = new FS::ext2 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Ext3: fs = new FS::ext3 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Ext4: fs = new FS::ext4 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Extended: fs = new FS::extended (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::F2fs: fs = new FS::f2fs (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Fat12: fs = new FS::fat12 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Fat16: fs = new FS::fat16 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Fat32: fs = new FS::fat32 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Hfs: fs = new FS::hfs (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::HfsPlus: fs = new FS::hfsplus (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Hpfs: fs = new FS::hpfs (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Iso9660: fs = new FS::iso9660 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Jfs: fs = new FS::jfs (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::LinuxRaidMember: fs = new FS::linuxraidmember(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::LinuxSwap: fs = new FS::linuxswap (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Luks: fs = new FS::luks (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Luks2: fs = new FS::luks2 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Lvm2_PV: fs = new FS::lvm2_pv (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Minix: fs = new FS::minix (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Nilfs2: fs = new FS::nilfs2 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Ntfs: fs = new FS::ntfs (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Ocfs2: fs = new FS::ocfs2 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::ReiserFS: fs = new FS::reiserfs (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Reiser4: fs = new FS::reiser4 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Udf: fs = new FS::udf (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Ufs: fs = new FS::ufs (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Unformatted: fs = new FS::unformatted (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Unknown: fs = new FS::unknown (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Xfs: fs = new FS::xfs (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Zfs: fs = new FS::zfs (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Apfs: fs = new FS::apfs (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::BitLocker: fs = new FS::bitlocker (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Btrfs: fs = new FS::btrfs (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Exfat: fs = new FS::exfat (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Ext2: fs = new FS::ext2 (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Ext3: fs = new FS::ext3 (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Ext4: fs = new FS::ext4 (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Extended: fs = new FS::extended (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::F2fs: fs = new FS::f2fs (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Fat12: fs = new FS::fat12 (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Fat16: fs = new FS::fat16 (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Fat32: fs = new FS::fat32 (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Hfs: fs = new FS::hfs (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::HfsPlus: fs = new FS::hfsplus (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Hpfs: fs = new FS::hpfs (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Iso9660: fs = new FS::iso9660 (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Jfs: fs = new FS::jfs (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::LinuxRaidMember: fs = new FS::linuxraidmember(firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::LinuxSwap: fs = new FS::linuxswap (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Luks: fs = new FS::luks (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Luks2: fs = new FS::luks2 (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Lvm2_PV: fs = new FS::lvm2_pv (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Minix: fs = new FS::minix (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Nilfs2: fs = new FS::nilfs2 (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Ntfs: fs = new FS::ntfs (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Ocfs2: fs = new FS::ocfs2 (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::ReiserFS: fs = new FS::reiserfs (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Reiser4: fs = new FS::reiser4 (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Udf: fs = new FS::udf (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Ufs: fs = new FS::ufs (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Unformatted: fs = new FS::unformatted (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Unknown: fs = new FS::unknown (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Xfs: fs = new FS::xfs (firstsector, lastsector, sectorsused, label, features); break;
case FileSystem::Type::Zfs: fs = new FS::zfs (firstsector, lastsector, sectorsused, label, features); break;
default: break;
}
@ -169,7 +171,7 @@ FileSystem* FileSystemFactory::create(FileSystem::Type t, qint64 firstsector, qi
*/
FileSystem* FileSystemFactory::create(const FileSystem& other)
{
return create(other.type(), other.firstSector(), other.lastSector(), other.sectorSize(), other.sectorsUsed(), other.label(), other.uuid());
return create(other.type(), other.firstSector(), other.lastSector(), other.sectorSize(), other.sectorsUsed(), other.label(), other.features(), other.uuid());
}
/** @return the map of FileSystems */
@ -185,5 +187,5 @@ const FileSystemFactory::FileSystems& FileSystemFactory::map()
*/
FileSystem* FileSystemFactory::cloneWithNewType(FileSystem::Type newType, const FileSystem& other)
{
return create(newType, other.firstSector(), other.lastSector(), other.sectorSize(), other.sectorsUsed(), other.label());
return create(newType, other.firstSector(), other.lastSector(), other.sectorSize(), other.sectorsUsed(), other.label(), other.features());
}

View File

@ -41,7 +41,7 @@ private:
public:
static void init();
static FileSystem* create(FileSystem::Type t, qint64 firstsector, qint64 lastsector, qint64 sectorSize, qint64 sectorsused = -1, const QString& label = QString(), const QString& uuid = QString());
static FileSystem* create(FileSystem::Type t, qint64 firstsector, qint64 lastsector, qint64 sectorSize, qint64 sectorsused = -1, const QString& label = QString(), const QVariantMap& features = {}, const QString& uuid = QString());
static FileSystem* create(const FileSystem& other);
static FileSystem* cloneWithNewType(FileSystem::Type newType, const FileSystem& other);
static const FileSystems& map();

View File

@ -34,8 +34,8 @@ FileSystem::CommandSupportType hfs::m_Check = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hfs::m_Copy = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hfs::m_Backup = FileSystem::cmdSupportNone;
hfs::hfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Hfs)
hfs::hfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Hfs)
{
}
@ -67,7 +67,7 @@ bool hfs::supportToolFound() const
FileSystem::SupportTool hfs::supportToolName() const
{
return SupportTool(QStringLiteral("hfsutils"), QUrl(QStringLiteral("http://www.mars.org/home/rob/proj/hfs/")));
return SupportTool(QStringLiteral("hfsutils"), QUrl(QStringLiteral("https://www.mars.org/home/rob/proj/hfs/")));
}

View File

@ -37,7 +37,7 @@ namespace FS
class LIBKPMCORE_EXPORT hfs : public FileSystem
{
public:
hfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
hfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
void init() override;

View File

@ -34,8 +34,8 @@ FileSystem::CommandSupportType hfsplus::m_Create = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hfsplus::m_Copy = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hfsplus::m_Backup = FileSystem::cmdSupportNone;
hfsplus::hfsplus(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::HfsPlus)
hfsplus::hfsplus(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::HfsPlus)
{
}
@ -68,7 +68,7 @@ bool hfsplus::supportToolFound() const
FileSystem::SupportTool hfsplus::supportToolName() const
{
return SupportTool(QStringLiteral("diskdev_cmds"), QUrl(QStringLiteral("http://opendarwin.org")));
return SupportTool(QStringLiteral("diskdev_cmds"), QUrl(QStringLiteral("https://opensource.apple.com/tarballs/diskdev_cmds/")));
}
qint64 hfsplus::maxCapacity() const

View File

@ -37,7 +37,7 @@ namespace FS
class LIBKPMCORE_EXPORT hfsplus : public FileSystem
{
public:
hfsplus(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
hfsplus(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
void init() override;

View File

@ -36,8 +36,8 @@ FileSystem::CommandSupportType hpfs::m_SetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hpfs::m_UpdateUUID = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hpfs::m_GetUUID = FileSystem::cmdSupportNone;
hpfs::hpfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Hpfs)
hpfs::hpfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Hpfs)
{
}

View File

@ -37,7 +37,7 @@ namespace FS
class LIBKPMCORE_EXPORT hpfs : public FileSystem
{
public:
hpfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
hpfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
CommandSupportType supportGetUsed() const override {

View File

@ -20,8 +20,8 @@
namespace FS
{
iso9660::iso9660(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Iso9660)
iso9660::iso9660(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Iso9660)
{
}

View File

@ -35,7 +35,7 @@ namespace FS
class LIBKPMCORE_EXPORT iso9660 : public FileSystem
{
public:
iso9660(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
iso9660(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
};

View File

@ -39,8 +39,8 @@ FileSystem::CommandSupportType jfs::m_Copy = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType jfs::m_Backup = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType jfs::m_SetLabel = FileSystem::cmdSupportNone;
jfs::jfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Jfs)
jfs::jfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Jfs)
{
}

View File

@ -37,7 +37,7 @@ namespace FS
class LIBKPMCORE_EXPORT jfs : public FileSystem
{
public:
jfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
jfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
void init() override;

View File

@ -20,8 +20,8 @@
namespace FS
{
linuxraidmember::linuxraidmember(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::LinuxRaidMember)
linuxraidmember::linuxraidmember(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::LinuxRaidMember)
{
}

View File

@ -34,7 +34,7 @@ namespace FS
class LIBKPMCORE_EXPORT linuxraidmember : public FileSystem
{
public:
linuxraidmember(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
linuxraidmember(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
};
}

View File

@ -39,8 +39,8 @@ FileSystem::CommandSupportType linuxswap::m_SetLabel = FileSystem::cmdSupportNon
FileSystem::CommandSupportType linuxswap::m_GetUUID = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType linuxswap::m_UpdateUUID = FileSystem::cmdSupportNone;
linuxswap::linuxswap(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::LinuxSwap)
linuxswap::linuxswap(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::LinuxSwap)
{
}
@ -73,7 +73,7 @@ bool linuxswap::supportToolFound() const
FileSystem::SupportTool linuxswap::supportToolName() const
{
return SupportTool(QStringLiteral("util-linux"), QUrl(QStringLiteral("http://www.kernel.org/pub/linux/utils/util-linux-ng/")));
return SupportTool(QStringLiteral("util-linux"), QUrl(QStringLiteral("https://github.com/karelzak/util-linux")));
}
int linuxswap::maxLabelLength() const

View File

@ -37,7 +37,7 @@ namespace FS
class LIBKPMCORE_EXPORT linuxswap : public FileSystem
{
public:
linuxswap(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
linuxswap(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
void init() override;

View File

@ -63,8 +63,9 @@ luks::luks(qint64 firstsector,
qint64 lastsector,
qint64 sectorsused,
const QString& label,
const QVariantMap& features,
FileSystem::Type t)
: FileSystem(firstsector, lastsector, sectorsused, label, t)
: FileSystem(firstsector, lastsector, sectorsused, label, features, t)
, m_innerFs(nullptr)
, m_isCryptOpen(false)
, m_cryptsetupFound(m_Create != cmdSupportNone)
@ -492,18 +493,20 @@ bool luks::resize(Report& report, const QString& deviceNode, qint64 newLength) c
if (mapperName().isEmpty())
return false;
if ( newLength - length() * sectorSize() > 0 )
const qint64 sizeDiff = newLength - length() * sectorSize();
const qint64 newPayloadSize = m_PayloadSize + sizeDiff;
if ( sizeDiff > 0 ) // grow
{
ExternalCommand cryptResizeCmd(report, QStringLiteral("cryptsetup"), { QStringLiteral("resize"), mapperName() });
report.line() << xi18nc("@info:progress", "Resizing LUKS crypt on partition <filename>%1</filename>.", deviceNode);
if (cryptResizeCmd.run(-1) && cryptResizeCmd.exitCode() == 0)
return m_innerFs->resize(report, mapperName(), m_PayloadSize);
return m_innerFs->resize(report, mapperName(), newPayloadSize);
}
else if (m_innerFs->resize(report, mapperName(), m_PayloadSize))
else if (m_innerFs->resize(report, mapperName(), newPayloadSize)) // shrink
{
ExternalCommand cryptResizeCmd(report, QStringLiteral("cryptsetup"),
{ QStringLiteral("--size"), QString::number(m_PayloadSize / 512), // LUKS1 payload length is specified in multiples of 512 bytes
{ QStringLiteral("--size"), QString::number(newPayloadSize / 512), // LUKS1 payload length is specified in multiples of 512 bytes
QStringLiteral("resize"), mapperName() });
report.line() << xi18nc("@info:progress", "Resizing LUKS crypt on partition <filename>%1</filename>.", deviceNode);
if (cryptResizeCmd.run(-1) && cryptResizeCmd.exitCode() == 0)

View File

@ -39,7 +39,7 @@ namespace FS
class LIBKPMCORE_EXPORT luks : public FileSystem
{
public:
luks(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t = FileSystem::Type::Luks);
luks(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {}, FileSystem::Type t = FileSystem::Type::Luks);
~luks() override;
enum class KeyLocation {

View File

@ -27,8 +27,8 @@
namespace FS
{
luks2::luks2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label)
: luks(firstsector, lastsector, sectorsused, label, FileSystem::Type::Luks2)
luks2::luks2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features)
: luks(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Luks2)
{
}
@ -89,7 +89,9 @@ bool luks2::resize(Report& report, const QString& deviceNode, qint64 newLength)
if (mapperName().isEmpty())
return false;
if ( newLength - length() * sectorSize() > 0 )
const qint64 sizeDiff = newLength - length() * sectorSize();
const qint64 newPayloadSize = m_PayloadSize + sizeDiff;
if ( sizeDiff > 0 ) // grow
{
ExternalCommand cryptResizeCmd(report, QStringLiteral("cryptsetup"), { QStringLiteral("resize"), mapperName() });
report.line() << xi18nc("@info:progress", "Resizing LUKS crypt on partition <filename>%1</filename>.", deviceNode);
@ -102,12 +104,12 @@ bool luks2::resize(Report& report, const QString& deviceNode, qint64 newLength)
if (!cryptResizeCmd.start(-1))
return false;
if ( cryptResizeCmd.exitCode() == 0 )
return m_innerFs->resize(report, mapperName(), m_PayloadSize);
return m_innerFs->resize(report, mapperName(), newPayloadSize);
}
else if (m_innerFs->resize(report, mapperName(), m_PayloadSize))
else if (m_innerFs->resize(report, mapperName(), newPayloadSize))
{
ExternalCommand cryptResizeCmd(report, QStringLiteral("cryptsetup"),
{ QStringLiteral("--size"), QString::number(m_PayloadSize / 512), // FIXME, LUKS2 can have different sector sizes
{ QStringLiteral("--size"), QString::number(newPayloadSize / 512), // FIXME, LUKS2 can have different sector sizes
QStringLiteral("resize"), mapperName() });
report.line() << xi18nc("@info:progress", "Resizing LUKS crypt on partition <filename>%1</filename>.", deviceNode);
if (m_KeyLocation == KeyLocation::keyring) {

View File

@ -35,7 +35,7 @@ namespace FS
class LIBKPMCORE_EXPORT luks2 : public luks
{
public:
luks2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
luks2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
~luks2() override;
bool create(Report& report, const QString& deviceNode) override;

View File

@ -42,8 +42,8 @@ FileSystem::CommandSupportType lvm2_pv::m_UpdateUUID = FileSystem::cmdSupportNon
FileSystem::CommandSupportType lvm2_pv::m_GetUUID = FileSystem::cmdSupportNone;
lvm2_pv::lvm2_pv(qint64 firstsector, qint64 lastsector,
qint64 sectorsused, const QString& label)
: FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Lvm2_PV)
qint64 sectorsused, const QString& label, const QVariantMap& features)
: FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Lvm2_PV)
, m_PESize(0)
, m_TotalPE(0)
, m_AllocatedPE(0)
@ -94,7 +94,7 @@ bool lvm2_pv::supportToolFound() const
FileSystem::SupportTool lvm2_pv::supportToolName() const
{
return SupportTool(QStringLiteral("lvm2"), QUrl(QStringLiteral("http://sourceware.org/lvm2/")));
return SupportTool(QStringLiteral("lvm2"), QUrl(QStringLiteral("https://sourceware.org/lvm2/")));
}
qint64 lvm2_pv::maxCapacity() const

View File

@ -89,7 +89,7 @@ class LIBKPMCORE_EXPORT lvm2_pv : public FileSystem
{
public:
lvm2_pv(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
lvm2_pv(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
void init() override;

View File

@ -33,8 +33,8 @@ FileSystem::CommandSupportType minix::m_Create = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType minix::m_Copy = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType minix::m_Backup = FileSystem::cmdSupportNone;
minix::minix(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Minix)
minix::minix(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Minix)
{
}

View File

@ -34,8 +34,8 @@ namespace FS
class LIBKPMCORE_EXPORT minix : public FileSystem
{
public:
minix(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
minix(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
void init() override;
bool check(Report& report, const QString&deviceNode) const override;

View File

@ -46,8 +46,8 @@ FileSystem::CommandSupportType nilfs2::m_SetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType nilfs2::m_UpdateUUID = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType nilfs2::m_GetUUID = FileSystem::cmdSupportNone;
nilfs2::nilfs2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Nilfs2)
nilfs2::nilfs2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Nilfs2)
{
}
@ -91,7 +91,7 @@ bool nilfs2::supportToolFound() const
FileSystem::SupportTool nilfs2::supportToolName() const
{
return SupportTool(QStringLiteral("nilfs2-utils"), QUrl(QStringLiteral("http://code.google.com/p/nilfs2/")));
return SupportTool(QStringLiteral("nilfs2-utils"), QUrl(QStringLiteral("https://github.com/nilfs-dev/nilfs-utils")));
}
qint64 nilfs2::minCapacity() const

View File

@ -38,7 +38,7 @@ namespace FS
class LIBKPMCORE_EXPORT nilfs2 : public FileSystem
{
public:
nilfs2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
nilfs2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
void init() override;

View File

@ -48,8 +48,8 @@ FileSystem::CommandSupportType ntfs::m_SetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType ntfs::m_UpdateUUID = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType ntfs::m_GetUUID = FileSystem::cmdSupportNone;
ntfs::ntfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Ntfs)
ntfs::ntfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Ntfs)
{
}
@ -85,7 +85,7 @@ bool ntfs::supportToolFound() const
FileSystem::SupportTool ntfs::supportToolName() const
{
return SupportTool(QStringLiteral("ntfs-3g"), QUrl(QStringLiteral("http://www.tuxera.com/community/ntfs-3g-download/")));
return SupportTool(QStringLiteral("ntfs-3g"), QUrl(QStringLiteral("https://www.tuxera.com/community/open-source-ntfs-3g/")));
}
qint64 ntfs::minCapacity() const

View File

@ -37,7 +37,7 @@ namespace FS
class LIBKPMCORE_EXPORT ntfs : public FileSystem
{
public:
ntfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
ntfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
void init() override;

View File

@ -39,8 +39,8 @@ FileSystem::CommandSupportType ocfs2::m_SetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType ocfs2::m_UpdateUUID = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType ocfs2::m_GetUUID = FileSystem::cmdSupportNone;
ocfs2::ocfs2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Ocfs2)
ocfs2::ocfs2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Ocfs2)
{
}
@ -84,7 +84,7 @@ bool ocfs2::supportToolFound() const
FileSystem::SupportTool ocfs2::supportToolName() const
{
return SupportTool(QStringLiteral("ocfs2-tools"), QUrl(QStringLiteral("http://oss.oracle.com/projects/ocfs2-tools/")));
return SupportTool(QStringLiteral("ocfs2-tools"), QUrl(QStringLiteral("https://oss.oracle.com/projects/ocfs2-tools/")));
}
qint64 ocfs2::minCapacity() const

View File

@ -37,7 +37,7 @@ namespace FS
class LIBKPMCORE_EXPORT ocfs2 : public FileSystem
{
public:
ocfs2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
ocfs2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
void init() override;

View File

@ -34,8 +34,8 @@ FileSystem::CommandSupportType reiser4::m_Check = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType reiser4::m_Copy = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType reiser4::m_Backup = FileSystem::cmdSupportNone;
reiser4::reiser4(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Reiser4)
reiser4::reiser4(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Reiser4)
{
}
@ -68,13 +68,13 @@ bool reiser4::supportToolFound() const
FileSystem::SupportTool reiser4::supportToolName() const
{
return SupportTool(QStringLiteral("reiser4progs"), QUrl(QStringLiteral("http://www.kernel.org/pub/linux/utils/fs/reiser4/reiser4progs/")));
return SupportTool(QStringLiteral("reiser4progs"), QUrl(QStringLiteral("https://github.com/edward6/reiser4progs")));
}
qint64 reiser4::maxCapacity() const
{
// looks like it's actually unknown. see
// http://en.wikipedia.org/wiki/Comparison_of_file_systems
// https://en.wikipedia.org/wiki/Comparison_of_file_systems
return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB);
}

View File

@ -37,7 +37,7 @@ namespace FS
class LIBKPMCORE_EXPORT reiser4 : public FileSystem
{
public:
reiser4(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
reiser4(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
void init() override;

View File

@ -41,8 +41,8 @@ FileSystem::CommandSupportType reiserfs::m_SetLabel = FileSystem::cmdSupportNone
FileSystem::CommandSupportType reiserfs::m_UpdateUUID = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType reiserfs::m_GetUUID = FileSystem::cmdSupportNone;
reiserfs::reiserfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::ReiserFS)
reiserfs::reiserfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::ReiserFS)
{
}
@ -80,7 +80,7 @@ bool reiserfs::supportToolFound() const
FileSystem::SupportTool reiserfs::supportToolName() const
{
return SupportTool(QStringLiteral("reiserfsprogs"), QUrl(QStringLiteral("http://www.kernel.org/pub/linux/utils/fs/reiserfs/")));
return SupportTool(QStringLiteral("reiserfsprogs"), QUrl(QStringLiteral("https://reiser4.wiki.kernel.org/index.php/Reiserfsprogs")));
}
qint64 reiserfs::minCapacity() const

View File

@ -39,7 +39,7 @@ namespace FS
class LIBKPMCORE_EXPORT reiserfs : public FileSystem
{
public:
reiserfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
reiserfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
void init() override;

View File

@ -39,8 +39,8 @@ FileSystem::CommandSupportType udf::m_UpdateUUID = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType udf::m_Create = FileSystem::cmdSupportNone;
bool udf::oldMkudffsVersion = false;
udf::udf(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Udf)
udf::udf(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Udf)
{
}

View File

@ -37,7 +37,7 @@ namespace FS
class LIBKPMCORE_EXPORT udf : public FileSystem
{
public:
udf(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
udf(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
void init() override;

View File

@ -23,8 +23,8 @@ FileSystem::CommandSupportType ufs::m_Move = FileSystem::cmdSupportCore;
FileSystem::CommandSupportType ufs::m_Copy = FileSystem::cmdSupportCore;
FileSystem::CommandSupportType ufs::m_Backup = FileSystem::cmdSupportCore;
ufs::ufs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Ufs)
ufs::ufs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Ufs)
{
}
}

View File

@ -35,7 +35,7 @@ namespace FS
class LIBKPMCORE_EXPORT ufs : public FileSystem
{
public:
ufs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
ufs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
CommandSupportType supportMove() const override {

View File

@ -21,8 +21,8 @@ namespace FS
{
FileSystem::CommandSupportType unformatted::m_Create = FileSystem::cmdSupportFileSystem;
unformatted::unformatted(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Unformatted)
unformatted::unformatted(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Unformatted)
{
}

View File

@ -37,7 +37,7 @@ namespace FS
class LIBKPMCORE_EXPORT unformatted : public FileSystem
{
public:
unformatted(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
unformatted(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
bool create(Report&, const QString&) override;

View File

@ -22,8 +22,8 @@ namespace FS
FileSystem::CommandSupportType unknown::m_Move = FileSystem::cmdSupportNone;
unknown::unknown(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Unknown)
unknown::unknown(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Unknown)
{
}

View File

@ -32,7 +32,7 @@ namespace FS
class LIBKPMCORE_EXPORT unknown : public FileSystem
{
public:
unknown(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
unknown(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
bool supportToolFound() const override {

View File

@ -41,8 +41,8 @@ FileSystem::CommandSupportType xfs::m_Copy = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType xfs::m_Backup = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType xfs::m_SetLabel = FileSystem::cmdSupportNone;
xfs::xfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Xfs)
xfs::xfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Xfs)
{
}
@ -78,7 +78,7 @@ bool xfs::supportToolFound() const
FileSystem::SupportTool xfs::supportToolName() const
{
return SupportTool(QStringLiteral("xfsprogs"), QUrl(QStringLiteral("http://oss.sgi.com/projects/xfs/")));
return SupportTool(QStringLiteral("xfsprogs"), QUrl(QStringLiteral("https://xfs.org/index.php/Getting_the_latest_source_code")));
}
qint64 xfs::minCapacity() const
@ -153,7 +153,7 @@ bool xfs::copy(Report& report, const QString& targetDeviceNode, const QString& s
// xfs_copy behaves a little strangely. It apparently kills itself at the end of main, causing QProcess
// to report that it crashed.
// See http://oss.sgi.com/archives/xfs/2004-11/msg00169.html
// See https://marc.info/?l=linux-xfs&m=110178337825926&w=2
// So we cannot rely on QProcess::exitStatus() and thus not on ExternalCommand::run() returning true.
cmd.run(-1);

View File

@ -37,7 +37,7 @@ namespace FS
class LIBKPMCORE_EXPORT xfs : public FileSystem
{
public:
xfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
xfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
void init() override;

View File

@ -39,8 +39,8 @@ FileSystem::CommandSupportType zfs::m_SetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType zfs::m_UpdateUUID = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType zfs::m_GetUUID = FileSystem::cmdSupportNone;
zfs::zfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Zfs)
zfs::zfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Zfs)
{
}
@ -72,7 +72,7 @@ bool zfs::supportToolFound() const
FileSystem::SupportTool zfs::supportToolName() const
{
return SupportTool(QStringLiteral("zfs"), QUrl(QStringLiteral("http://zfsonlinux.org/")));
return SupportTool(QStringLiteral("zfs"), QUrl(QStringLiteral("https://zfsonlinux.org/")));
}
qint64 zfs::minCapacity() const

View File

@ -38,7 +38,7 @@ namespace FS
class LIBKPMCORE_EXPORT zfs : public FileSystem
{
public:
zfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
zfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
public:
void init() override;

View File

@ -278,8 +278,8 @@ bool PartResizerWidget::movePartition(qint64 newFirstSector)
updatePositions();
emit firstSectorChanged(partition().firstSector());
emit lastSectorChanged(partition().lastSector());
Q_EMIT firstSectorChanged(partition().firstSector());
Q_EMIT lastSectorChanged(partition().lastSector());
return true;
}
@ -335,7 +335,7 @@ bool PartResizerWidget::updateFirstSector(qint64 newFirstSector)
updatePositions();
emit firstSectorChanged(partition().firstSector());
Q_EMIT firstSectorChanged(partition().firstSector());
return true;
}
@ -416,7 +416,7 @@ bool PartResizerWidget::updateLastSector(qint64 newLastSector)
resizeLogicals(0, deltaLast);
updatePositions();
emit lastSectorChanged(partition().lastSector());
Q_EMIT lastSectorChanged(partition().lastSector());
return true;
}

View File

@ -45,7 +45,7 @@ class LIBKPMCORE_EXPORT PartResizerWidget : public QWidget
Q_DISABLE_COPY(PartResizerWidget)
public:
PartResizerWidget(QWidget* parent);
explicit PartResizerWidget(QWidget* parent);
public:
void init(Device& d, Partition& p, qint64 minFirst, qint64 maxLast, bool read_only = false, bool move_allowed = true);

Some files were not shown because too many files have changed in this diff Show More