2010-02-20 15:12:26 -07:00
|
|
|
/* Copyright (C) 2004 Bart
|
|
|
|
* Copyright (C) 2010 Curtis Gedak
|
2004-09-19 14:24:53 -06:00
|
|
|
*
|
|
|
|
* 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
|
2014-01-23 03:59:48 -07:00
|
|
|
* GNU General Public License for more details.
|
2004-09-19 14:24:53 -06:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-23 03:59:48 -07:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2004-09-19 14:24:53 -06:00
|
|
|
*/
|
2013-05-27 05:20:16 -06:00
|
|
|
|
|
|
|
#ifndef GPARTED_DEVICE_H
|
|
|
|
#define GPARTED_DEVICE_H
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2016-10-18 16:45:28 -06:00
|
|
|
#include "Partition.h"
|
|
|
|
#include "PartitionVector.h"
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
namespace GParted
|
|
|
|
{
|
|
|
|
|
|
|
|
class Device
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2006-01-05 13:01:34 -07:00
|
|
|
Device() ;
|
|
|
|
~Device() ;
|
2006-03-14 14:37:47 -07:00
|
|
|
|
2015-05-24 07:13:37 -06:00
|
|
|
Device get_copy_without_partitions() const;
|
2016-06-02 05:55:45 -06:00
|
|
|
void set_path( const Glib::ustring & path );
|
2006-03-15 14:44:24 -07:00
|
|
|
Glib::ustring get_path() const ;
|
2015-03-13 16:36:08 -06:00
|
|
|
void enable_partition_naming( int length ); // > 0 => enable partition naming support
|
|
|
|
bool partition_naming_supported() const;
|
|
|
|
int get_max_partition_name_length() const;
|
|
|
|
|
2006-03-15 14:44:24 -07:00
|
|
|
bool operator==( const Device & device ) const ;
|
|
|
|
bool operator!=( const Device & device ) const ;
|
2004-11-06 04:55:03 -07:00
|
|
|
|
2006-01-05 13:01:34 -07:00
|
|
|
void Reset() ;
|
2015-05-23 13:22:37 -06:00
|
|
|
PartitionVector partitions;
|
2004-10-01 15:09:19 -06:00
|
|
|
Sector length;
|
2006-12-08 06:14:05 -07:00
|
|
|
Sector heads ;
|
|
|
|
Sector sectors ;
|
|
|
|
Sector cylinders ;
|
2006-02-25 03:09:30 -07:00
|
|
|
Sector cylsize ;
|
2004-10-01 15:09:19 -06:00
|
|
|
Glib::ustring model;
|
2015-06-22 07:08:02 -06:00
|
|
|
Glib::ustring serial_number;
|
2004-10-01 15:09:19 -06:00
|
|
|
Glib::ustring disktype;
|
2010-02-20 15:12:26 -07:00
|
|
|
int sector_size ;
|
2004-11-17 06:00:25 -07:00
|
|
|
int max_prims ;
|
2004-12-27 11:56:57 -07:00
|
|
|
int highest_busy ;
|
2004-11-29 06:20:05 -07:00
|
|
|
bool readonly ;
|
2014-12-12 00:00:02 -07:00
|
|
|
|
2004-11-17 06:00:25 -07:00
|
|
|
private:
|
Simplify Device object to a single path (#767842)
Background
GParted stored a list of paths for Device and Partition objects. It
sorted this list [1][2] and treated the first specially as that is what
get_path() returned and was used almost everywhere; with the file system
specific tools, looked up in various *_Info caches, etc.
[1] Device::add_path(), ::add_paths()
[2] Partition::add_path(), ::add_paths()
Mount point display [3] was the only bit of GParted which really worked
with the path list. Busy file system detection [4] just used the path
provided by libparted, or for LUKS /dev/mapper/* names. It checked that
single path against the mounted file systems found from /proc/mounts,
expanded with additional block device names when symlinks were
encountered.
[3] GParted_Core::set_mountpoints() -> set_mountpoints_helper()
[4] GParted_Core::set_device_partitions() -> is_busy()
GParted_Core::set_device_one_partition() -> is_busy()
GParted_Core::set_luks_partition() -> is_busy()
Having the first path, by sort order, treated specially by being used
everywhere and virtually ignoring the others was wrong, complicated to
remember and difficult code with. As all the additional paths were
virtually unused and made no difference, remove them. The "improved
detection of mountpoins, free space, etc.." benefit from commit [5]
doesn't seem to exist. Therefore simplify to a single path for Device
and Partition objects.
[5] commit 6d8b169e734e1ecb191d5164689f24400010a7b4
changed the way devices and partitions store their device paths.
Instead of holding a 'realpath' and a symbolic path we store paths
in a list. This allows for improved detection of mountpoins, free
space, etc..
This patch
Simplify the Device object from a vector of paths to a single path.
Remove add_paths() and get_paths() methods. Keep add_path() and
get_path() for now.
Bug 767842 - File system usage missing when tools report alternate block
device names
2016-06-02 00:49:53 -06:00
|
|
|
Glib::ustring path;
|
2015-03-13 16:36:08 -06:00
|
|
|
int max_partition_name_length; // > 0 => naming of partitions is supported on this device
|
2004-11-17 06:00:25 -07:00
|
|
|
};
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2004-11-17 06:00:25 -07:00
|
|
|
} //GParted
|
2013-05-27 05:20:16 -06:00
|
|
|
|
|
|
|
#endif /* GPARTED_DEVICE_H */
|