Commit Graph

370 Commits

Author SHA1 Message Date
ivan tkachenko 9b015661aa
Present SMART status duration in more human-readable spellout format
BUG: 449386
2022-05-29 16:56:27 +03:00
Andrius Štikonas e483bab0d5 Restrict CreateFile method to WriteFstab method in polkit helper. 2022-02-20 19:42:25 +00:00
Andrius Štikonas 5174dce64f Remove unused forward declaration. 2022-01-16 13:59:01 +00:00
Andrius Štikonas 5ffc5c6f23 Fix davfs entries being omitted from fstab file.
BUG: 447961
2022-01-05 23:00:17 +00:00
Tomaz Canabrava e1774d4026 Remove unused member 2021-12-28 15:07:35 +00:00
Tomaz Canabrava 9093b27bd8 Move the changePosixPermission to the Filesystem
And implement it on ext2, 3, 4. I don't know all the filesystems
that can have posix permissions, those three will do. if we need
more in the future we implement them, it's two lines of code.
2021-12-28 15:07:35 +00:00
Tomaz Canabrava 6c14ddb043 Add new job to change permission of the newly created partition 2021-12-28 15:07:35 +00:00
Andrius Štikonas 31921c59fa Fix broken fstab when mount point includes space.
fstab column width was calculated before spaces were escaped which would
result in no space between mount point and file system type columns.

BUG: 446218
2021-12-04 23:31:02 +00:00
Artem Grinev 00e6b77c29 Initialize all fields in Partition 2021-08-29 00:16:57 +04:00
Yaroslav Sidlovsky 8746ef72fd Fix smartctl exit status success check
According to the smartctl man page:
```
EXIT STATUS
The  exit  statuses of smartctl are defined by a bitmask.  If all is well with the disk, the exit status (return value) of smartctl is 0 (all bits turned off).  If a problem occurs, or an error, potential error, or fault is detected, then a non-zero status is
returned.  In this case, the eight different bits in the exit status have the following meanings for ATA disks; some of these values may also be returned for SCSI disks.

Bit 0: Command line did not parse.

Bit 1: Device open failed, device did not return an IDENTIFY DEVICE structure, or device is in a low-power mode (see '-n' option above).

Bit 2: Some SMART or other ATA command to the disk failed, or there was a checksum error in a SMART data structure (see '-b' option above).

Bit 3: SMART status check returned "DISK FAILING".

Bit 4: We found prefail Attributes <= threshold.

Bit 5: SMART status check returned "DISK OK" but we found that some (usage or prefail) Attributes have been <= threshold at some time in the past.

Bit 6: The device error log contains records of errors.

Bit 7: The device self-test log contains records of errors.  [ATA only] Failed self-tests outdated by a newer successful extended self-test are ignored.
```

BUG: 429028
2021-03-17 16:03:32 +03:00
Andrius Štikonas ad888767bb Use QStringLiteral. 2021-02-23 21:39:41 +00:00
Oxalica -- eea84fb605 Fix out of bounds read when parsing fstab.
Some fstab files only have 3 fields and mount options are completely omitted.
2021-02-22 16:45:48 +00:00
Andrius Štikonas 31706cffdc Fix out of bounds read when parsing fstab.
BUG: 429191
2021-01-07 01:25:12 +00:00
Andrius Štikonas 26acd7c10d Remove extra semicolon. 2020-11-14 01:09:23 +00:00
Andrius Štikonas 2e91730f7a Fix parsing fstab mountpoints when they contain spaces or tabs.
If the name of the mount point contains spaces or tabs these
can be escaped as `\040' and '\011' respectively.

BUG: 428932
2020-11-14 00:55:29 +00:00
Andrius Štikonas 19f78ef76a Port away from qAsConst. 2020-10-24 22:01:45 +01:00
Andrius Štikonas ec3479f302 Add overrides to destructors. 2020-10-24 01:33:52 +01:00
Andrius Štikonas 85396708f4 Use Qt::SplitBehavior
Old version QString::SplitBehavious is now deprecated.
2020-10-13 01:23:29 +01:00
Adriaan de Groot 08c1acb6b4 Missing include (clang/FreeBSD triggers this) 2020-10-10 21:59:57 +02:00
Andrius Štikonas d396e56694 Add support for importing "PartitionTable" of whole device filesystems. 2020-10-04 15:20:58 +01:00
Andrius Štikonas 9ca3a5740a Add information about PartitionTable::TableType::none. 2020-10-03 14:03:59 +01:00
Andrius Štikonas de346177b5 Do not allow moving partitions without partition table. 2020-10-03 12:41:18 +01:00
Andrius Štikonas 81f8939cb1 Add a new type of partition table "none".
This would be useful for block devices without partition table.
2020-10-03 12:39:26 +01:00
Andrius Štikonas 0c25d1f9c4 Use QFile::decodeFileName for decoding device node names.
BUG: 384321
2020-10-01 23:51:59 +01:00
Andrius Štikonas d68ffeadef REUSE: SPDX style license headers for src/util. 2020-10-01 00:33:19 +01:00
Andrius Štikonas 11bb5799ec REUSE: SPDX license headers for backend and core folders. 2020-09-20 20:33:16 +01:00
Andrius Štikonas fc826690b9 SPDX licenses for tests and CMakeLists.txt. 2020-09-17 02:15:16 +01:00
Andrius Štikonas c5c21849b9 Compile kpmcore with QT_NO_KEYWORDS. 2020-09-15 02:36:46 +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 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
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
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 6921398ba3 Merge branch 'gportay/kpmcore-partition-type' 2020-03-22 01:49:35 +00: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
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
Andrius Štikonas 4b0261230d Make S.M.A.R.T. disk temperature label show only integers.
BUG: 411226
2019-09-07 11:51:05 +01:00
Shubham Jangra 78f29ae8b5 Reduce temperature's precision from six decimal places to two
Summary: BUG: 411226

Test Plan: I couldn't test it since my device does not support SMART

Reviewers: stikonas

Reviewed By: stikonas

Subscribers: #kde_partition_manager

Tags: #kde_partition_manager

Differential Revision: https://phabricator.kde.org/D23572
2019-09-01 23:11:43 +05:30
Andrius Štikonas 6a3b1e02b6 smart: obtain disk size in blocks.
Also drop pre 7.0 support as any earlier version was not supported.
2019-06-05 18:32:11 +01:00
Valerii Malov 9565ef61ab Add support for smartmontools 7.0 user_capacity json output
Summary:
smartmontools 7.0 reports user capacity as an object that contains bytes and blocks value, instead of being an int that just contains bytes
This should fix incorrect calculation of bad blocks threshold and incorrect display of "Overall" status

Test Plan:
run partitionmanager on a system that has smartmontools 7, open smart status
overall status should be reported correctly

Reviewers: stikonas

Reviewed By: stikonas

Differential Revision: https://phabricator.kde.org/D21311
2019-05-23 17:43:44 +03:00
Caio Carvalho 43da873c36 Fixing device scanning process 2019-04-03 15:37:47 -06:00
Andrius Štikonas 92065f7a23
Add a function to convert QStringList of flag names to flags.
CCBUG: 400331
2019-02-28 00:15:26 +00:00
Albert Astals Cid 7f6fa41bce Mark override members as such 2019-02-16 00:17:48 +01:00
Andrius Štikonas 39a5645c38 Explicitely specify underlying type for Capacity enums. 2019-02-10 01:43:05 +00:00
Andrius Štikonas 28e1308ec5
Switch to scoped name PartitionTable::Flag::
Deprecated old style enum PartitionTable::FlagName.
This will allow to switch to scoped enum class in some future version.
2019-02-09 18:04:44 +00:00
Andrius Štikonas 3df5acb9e3
Add scanDevices function that uses flags instead of bools.
Add and option to scan for loopback devices.
2019-02-09 15:40:06 +00:00