mirror of
https://gitlab.gnome.org/GNOME/gparted
synced 2024-10-12 10:52:59 +00:00
9f08875997
Until now an encryption mapping has been modelled as a Partition object similar to a partition like this: .encrypted.device_path = "/dev/sdb1" .encrypted.path = "/dev/mapper/sdb1_crypt" .encrypted.whole_device = false .encrypted.sector_start = // start of the mapping in the partition .encrypted.sector_end = // end of the mapping in the partition However accessing device_path in the start to end sector range is not equivalent to accessing the partition path as it doesn't provide access to the encrypted data. Therefore existing functions which read and write partition data (GParted file system copying and signature erasure) via libparted using the device_path won't work and will in fact destroy the encrypted data. This could be coded around with an extra case in the device opening code, however it is not necessary. An encrypted block special device /dev/mapper/CRYPTNAME looks just like a whole disk device because it doesn't contain a partition and the file system it contains starts at sector 0 and goes to the end. Therefore model an encryption mapping in the same way a whole disk device is modelled as a Partition object like this: .encrypted.device_path = "/dev/mapper/sdb1_crypt" .encrypted.path = "/dev/mapper/sdb1_crypt" .encrypted.whole_device = true .encrypted.sector_start = 0 .encrypted.sector_end = // size of the encryption mapping - 1 Now GParted file system copy and erasure will just work without any change. Just need to additionally store the LUKS header size, which was previous stored in the sector_start, for use in the get_sectors_{used,unused,unallocated}() calculations. Bug 775932 - Refactor mostly applying of operations
64 lines
1.9 KiB
C++
64 lines
1.9 KiB
C++
/* Copyright (C) 2015 Mike Fleetwood
|
|
*
|
|
* 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 2 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 <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
|
|
#ifndef GPARTED_PARTITIONLUKS_H
|
|
#define GPARTED_PARTITIONLUKS_H
|
|
|
|
#include "../include/Partition.h"
|
|
#include "../include/Utils.h"
|
|
|
|
#include <glibmm/ustring.h>
|
|
|
|
namespace GParted
|
|
{
|
|
|
|
class PartitionLUKS : public Partition
|
|
{
|
|
public:
|
|
PartitionLUKS();
|
|
virtual ~PartitionLUKS();
|
|
virtual PartitionLUKS * clone() const;
|
|
|
|
void set_luks( const Glib::ustring & path,
|
|
FILESYSTEM fstype,
|
|
Sector header_size,
|
|
Sector mapping_size,
|
|
Byte_Value sector_size,
|
|
bool busy );
|
|
|
|
Partition & get_encrypted() { return encrypted; };
|
|
const Partition & get_encrypted() const { return encrypted; };
|
|
|
|
virtual bool sector_usage_known() const;
|
|
virtual Sector estimated_min_size() const;
|
|
virtual Sector get_sectors_used() const;
|
|
virtual Sector get_sectors_unused() const;
|
|
virtual Sector get_sectors_unallocated() const;
|
|
virtual Glib::ustring get_filesystem_label() const;
|
|
virtual bool have_messages() const;
|
|
virtual std::vector<Glib::ustring> get_messages() const;
|
|
virtual void clear_messages();
|
|
|
|
private:
|
|
Partition encrypted;
|
|
Sector header_size; // Size of the LUKS header (everything up to the start of the mapping)
|
|
};
|
|
|
|
}//GParted
|
|
|
|
#endif /* GPARTED_PARTITIONLUKS_H */
|