"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/GParted_Core.cc" between
gparted-1.2.0.tar.gz and gparted-1.3.0.tar.gz

About: GParted is a graphical partition editor for creating, reorganizing, and deleting disk partitions (using GNU libparted).

GParted_Core.cc  (gparted-1.2.0):GParted_Core.cc  (gparted-1.3.0)
skipping to change at line 145 skipping to change at line 145
static bool _mainquit( void *dummy ) static bool _mainquit( void *dummy )
{ {
Gtk::Main::quit(); Gtk::Main::quit();
return false; return false;
} }
void GParted_Core::set_devices_thread( std::vector<Device> * pdevices ) void GParted_Core::set_devices_thread( std::vector<Device> * pdevices )
{ {
std::vector<Device> &devices = *pdevices; std::vector<Device> &devices = *pdevices;
devices .clear() ; devices .clear() ;
// Initialise and load caches needed for device discovery.
BlockSpecial::clear_cache(); // MUST BE FIRST. Cache of name to major, minor BlockSpecial::clear_cache(); // MUST BE FIRST. Cache of name to major, minor
// numbers incrementally loaded w hen BlockSpecial // numbers incrementally loaded w hen BlockSpecial
// objects are created in the fol lowing caches. // objects are created in the fol lowing caches.
Proc_Partitions_Info::load_cache(); // SHOULD BE SECOND. Caches /pro c/partitions and Proc_Partitions_Info::load_cache(); // SHOULD BE SECOND. Caches /pro c/partitions and
// pre-populates BlockSpecial cac he. // pre-populates BlockSpecial cac he.
FS_Info::load_cache(); // SHOULD BE THRID. Caches file
system details
// from blkid output.
DMRaid dmraid( true ) ; //Refresh cache of dmraid device information DMRaid dmraid( true ) ; //Refresh cache of dmraid device information
LVM2_PV_Info::clear_cache(); // Cache automatically loaded if
and when needed
btrfs::clear_cache(); // Cache incrementally loaded if
and when needed
SWRaid_Info::load_cache();
LUKS_Info::clear_cache(); // Cache automatically loaded if
and when needed
Mount_Info::load_cache();
//only probe if no devices were specified as arguments.. //only probe if no devices were specified as arguments..
if ( probe_devices ) if ( probe_devices )
{ {
device_paths .clear() ; device_paths .clear() ;
//FIXME: When libparted bug 194 is fixed, remove code to read: //FIXME: When libparted bug 194 is fixed, remove code to read:
// /proc/partitions // /proc/partitions
// This was a problem with no floppy drive yet BIOS indica ted one existed. // This was a problem with no floppy drive yet BIOS indica ted one existed.
// http://parted.alioth.debian.org/cgi-bin/trac.cgi/ticket /194 // http://parted.alioth.debian.org/cgi-bin/trac.cgi/ticket /194
skipping to change at line 251 skipping to change at line 246
PedDevice* lp_device = ped_device_get( device_paths[t].c_ str() ); PedDevice* lp_device = ped_device_get( device_paths[t].c_ str() );
if ( lp_device == NULL || ! useable_device( lp_device ) ) if ( lp_device == NULL || ! useable_device( lp_device ) )
{ {
// Remove this disk device which isn't useable // Remove this disk device which isn't useable
device_paths.erase( device_paths.begin() + t-- ); device_paths.erase( device_paths.begin() + t-- );
} }
} }
} }
// Ensure all named paths have FS_Info blkid cache entries specifically s // Initialise and load caches needed for content discovery.
o that FS_Info::clear_cache();
// command line named file system image files, which blkid can't otherwis const std::vector<Glib::ustring>& device_and_partition_paths =
e know Proc_Partitions_Info::get_device_and_partition_paths_for(
// about, can be identified. device_paths);
FS_Info::load_cache_for_paths( device_paths ); FS_Info::load_cache_for_paths(device_and_partition_paths);
Mount_Info::load_cache();
LVM2_PV_Info::clear_cache();
btrfs::clear_cache();
SWRaid_Info::load_cache();
LUKS_Info::clear_cache();
for ( unsigned int t = 0 ; t < device_paths .size() ; t++ ) for ( unsigned int t = 0 ; t < device_paths .size() ; t++ )
{ {
/*TO TRANSLATORS: looks like Searching /dev/sda partitions */ /*TO TRANSLATORS: looks like Searching /dev/sda partitions */
set_thread_status_message( Glib::ustring::compose( _("Searching % 1 partitions"), device_paths[ t ] ) ) ; set_thread_status_message( Glib::ustring::compose( _("Searching % 1 partitions"), device_paths[ t ] ) ) ;
Device temp_device; Device temp_device;
set_device_from_disk( temp_device, device_paths[t] ); set_device_from_disk( temp_device, device_paths[t] );
devices.push_back( temp_device ); devices.push_back( temp_device );
} }
skipping to change at line 612 skipping to change at line 613
} }
destroy_device_and_disk( lp_device, lp_disk ) ; destroy_device_and_disk( lp_device, lp_disk ) ;
} }
return flag_info ; return flag_info ;
} }
//private functions... //private functions...
Glib::ustring GParted_Core::get_partition_path( PedPartition * lp_partition ) Glib::ustring GParted_Core::get_partition_path(const PedPartition *lp_partition)
{ {
g_assert(lp_partition != NULL); // Bug: Not initialised by suitable ped_
disk_*partition*() call
char * lp_path; //we have to free the result of ped_partition_get_path() char * lp_path; //we have to free the result of ped_partition_get_path()
Glib::ustring partition_path = "Partition path not found"; Glib::ustring partition_path = "Partition path not found";
lp_path = ped_partition_get_path(lp_partition); lp_path = ped_partition_get_path(lp_partition);
if ( lp_path != NULL ) if ( lp_path != NULL )
{ {
partition_path = lp_path; partition_path = lp_path;
free(lp_path); free(lp_path);
} }
skipping to change at line 642 skipping to change at line 645
} }
#endif #endif
return partition_path ; return partition_path ;
} }
void GParted_Core::set_device_from_disk( Device & device, const Glib::ustring & device_path ) void GParted_Core::set_device_from_disk( Device & device, const Glib::ustring & device_path )
{ {
PedDevice* lp_device = NULL; PedDevice* lp_device = NULL;
PedDisk* lp_disk = NULL; PedDisk* lp_disk = NULL;
if ( get_device( device_path, lp_device, true ) )
{
device.Reset();
// Device info ... if (! get_device(device_path, lp_device, true))
device.set_path( device_path ); return;
device.model = lp_device->model;
device.length = lp_device->length; device.Reset();
device.sector_size = lp_device->sector_size;
device.heads = lp_device->bios_geom.heads; // Device info ...
device.sectors = lp_device->bios_geom.sectors; device.set_path(device_path);
device.cylinders = lp_device->bios_geom.cylinders; device.model = lp_device->model;
device.cylsize = device.heads * device.sectors; device.length = lp_device->length;
set_device_serial_number( device ); device.sector_size = lp_device->sector_size;
device.heads = lp_device->bios_geom.heads;
// Make sure cylsize is at least 1 MiB device.sectors = lp_device->bios_geom.sectors;
if ( device.cylsize < (MEBIBYTE / device.sector_size) ) device.cylinders = lp_device->bios_geom.cylinders;
device.cylsize = MEBIBYTE / device.sector_size; device.cylsize = device.heads * device.sectors;
set_device_serial_number(device);
std::vector<Glib::ustring> messages;
FSType fstype = detect_filesystem( lp_device, NULL, messages ); // Make sure cylsize is at least 1 MiB
// FS_Info (blkid) recognised file system signature on whole disk if (device.cylsize < (MEBIBYTE / device.sector_size))
device. device.cylsize = MEBIBYTE / device.sector_size;
// Need to detect before libparted reported partitioning to avoid
bug in std::vector<Glib::ustring> messages;
// libparted 1.9.0 to 2.3 inclusive which recognised FAT file sys FSType fstype = detect_filesystem(lp_device, NULL, messages);
tems as
// MSDOS partition tables. Fixed in parted 2.4 by commit: if (fstype != FS_UNKNOWN)
{
// Case 1/4: Recognised whole disk device file system
//
// FS_Info (blkid) or GParted internal detection recognised file
system
// signature on whole disk device. Need to detect before libpart
ed
// reported partitioning to avoid bug in libparted 1.9.0 to 2.3 i
nclusive
// which recognised FAT file systems as MSDOS partition tables.
Fixed in
// parted 2.4 by commit:
// 616a2a1659d89ff90f9834016a451da8722df509 // 616a2a1659d89ff90f9834016a451da8722df509
// libparted: avoid regression when processing a whole-disk F AT partition // libparted: avoid regression when processing a whole-disk F AT partition
if ( fstype != FS_UNKNOWN )
{
// Clear the possible "unrecognised disk label" message
libparted_messages.clear();
device.disktype = "none"; // Clear the possible "unrecognised disk label" message
device.max_prims = 1; libparted_messages.clear();
set_device_one_partition( device, lp_device, fstype, mess
ages );
}
// Partitioned drive
else if ( get_disk( lp_device, lp_disk, false ) )
{
// Partitioned drive (excluding "loop"), as recognised by
libparted
if ( lp_disk && lp_disk->type && lp_disk->type->name &&
strcmp( lp_disk->type->name, "loop" ) != 0 )
{
device.disktype = lp_disk->type->name;
device.max_prims = ped_disk_get_max_primary_parti
tion_count( lp_disk );
// Determine if partition naming is supported. device.disktype = "none";
if ( ped_disk_type_check_feature( lp_disk->type, device.max_prims = 1;
PED_DISK_TYPE_PARTITION_NAME ) ) set_device_one_partition(device, lp_device, fstype, messages);
{ }
device.enable_partition_naming( else if (! get_disk(lp_device, lp_disk))
Utils::get_max_partition_ {
name_length( device.disktype ) ); // Case 2/4: Empty drive
} //
// Empty drive without a disk label (partition table).
set_device_partitions( device, lp_device, lp_disk device.disktype =
); /* TO TRANSLATORS: unrecognized
* means that the partition table for this disk device is
unknown
* or not recognized.
*/
_("unrecognized");
device.max_prims = 1;
if ( device.highest_busy ) Partition* partition_temp = new Partition();
{ partition_temp->set_unpartitioned(device.get_path(),
device.readonly = ! commit_to_os( lp_disk "", // Overridden with "unallo
, SETTLE_DEVICE_PROBE_MAX_WAIT_SECONDS ); cated"
// Clear libparted messages. Typically t FS_UNALLOCATED,
hese are: device.length,
// The kernel was unable to re-read t device.sector_size,
he partition table... false);
libparted_messages.clear(); // Place libparted messages in this unallocated partition
} partition_temp->append_messages(libparted_messages);
} libparted_messages.clear();
// Drive just containing libparted "loop" signature and n device.partitions.push_back_adopt(partition_temp);
othing }
// else. (Actually any drive reported by libparted as "l else if (lp_disk && lp_disk->type && lp_disk->type->name &&
oop" but strcmp(lp_disk->type->name, "loop") == 0 )
// not recognised by blkid on the whole disk device). {
else if ( lp_disk && lp_disk->type && lp_disk->type->name // Case 3/4: Libparted "loop" signature only
&& //
strcmp( lp_disk->type->name, "loop" ) == 0 // Drive just containing libparted "loop" signature and nothing e
) lse.
{ // (Actually any drive reported by libparted as "loop" but not re
device.disktype = lp_disk->type->name; cognised
device.max_prims = 1; // in case 1/4 as whole disk device file system).
// Create virtual partition covering the whole di device.disktype = lp_disk->type->name;
sk device device.max_prims = 1;
// with unknown contents.
Partition * partition_temp = new Partition(); // Create virtual partition covering the whole disk device with u
partition_temp->set_unpartitioned( device.get_pat nknown
h(), // contents.
lp_device->pat Partition* partition_temp = new Partition();
h, partition_temp->set_unpartitioned(device.get_path(),
FS_UNKNOWN, lp_device->path,
device.length, FS_UNKNOWN,
device.sector_ device.length,
size, device.sector_size,
false ); false);
// Place unknown file system message in this part // Place unknown file system message in this partition.
ition. partition_temp->append_messages(messages);
partition_temp->append_messages( messages ); device.partitions.push_back_adopt(partition_temp);
device.partitions.push_back_adopt( partition_temp }
); else
} {
// Unrecognised, unpartitioned drive. // Case 4/4: Partitioned drive
else //
{ // (excluding libparted "loop" recognised in case 3/4).
device.disktype =
/* TO TRANSLATORS: unrecognized device.disktype = lp_disk->type->name;
* means that the partition table for thi device.max_prims = ped_disk_get_max_primary_partition_count(lp_di
s disk sk);
* device is unknown or not recognized.
*/ // Determine if partition naming is supported.
_("unrecognized"); if (ped_disk_type_check_feature(lp_disk->type, PED_DISK_TYPE_PART
device.max_prims = 1; ITION_NAME))
device.enable_partition_naming(Utils::get_max_partition_n
Partition * partition_temp = new Partition(); ame_length(device.disktype));
partition_temp->set_unpartitioned( device.get_pat
h(),
"", // Overri
dden with "unallocated"
FS_UNALLOCATED
,
device.length,
device.sector_
size,
false );
// Place libparted messages in this unallocated p
artition
partition_temp->append_messages( libparted_messag
es );
libparted_messages.clear();
device.partitions.push_back_adopt( partition_temp
);
}
}
destroy_device_and_disk( lp_device, lp_disk); set_device_partitions(device, lp_device, lp_disk);
if (device.highest_busy)
{
device.readonly = ! commit_to_os(lp_disk, SETTLE_DEVICE_P
ROBE_MAX_WAIT_SECONDS);
// Clear libparted messages. Typically these are:
// The kernel was unable to re-read the partition tab
le...
libparted_messages.clear();
}
} }
destroy_device_and_disk(lp_device, lp_disk);
return;
} }
void GParted_Core::set_device_serial_number( Device & device ) void GParted_Core::set_device_serial_number( Device & device )
{ {
if ( ! hdparm_found ) if ( ! hdparm_found )
// Serial number left blank when the hdparm command is not instal led. // Serial number left blank when the hdparm command is not instal led.
return; return;
Glib::ustring output; Glib::ustring output;
Glib::ustring error; Glib::ustring error;
skipping to change at line 1001 skipping to change at line 1012
void GParted_Core::set_luks_partition( PartitionLUKS & partition ) void GParted_Core::set_luks_partition( PartitionLUKS & partition )
{ {
LUKS_Mapping mapping = LUKS_Info::get_cache_entry( partition.get_path() ) ; LUKS_Mapping mapping = LUKS_Info::get_cache_entry( partition.get_path() ) ;
if ( mapping.name.empty() ) if ( mapping.name.empty() )
// No LUKS mapping found so no device file with which to query th e // No LUKS mapping found so no device file with which to query th e
// encrypted file system. Assume no open dm-crypt mapping exists . // encrypted file system. Assume no open dm-crypt mapping exists .
// Details of encrypted file system left blank. // Details of encrypted file system left blank.
return; return;
Glib::ustring mapping_path = DEV_MAPPER_PATH + mapping.name; Glib::ustring mapping_path = DEV_MAPPER_PATH + mapping.name;
PedDevice* lp_device = NULL;
std::vector<Glib::ustring> detect_messages; std::vector<Glib::ustring> detect_messages;
FSType fstype = FS_UNKNOWN; FSType fstype = detect_filesystem_in_encryption_mapping(mapping_path, det
if ( get_device( mapping_path, lp_device ) ) ect_messages);
{
fstype = detect_filesystem( lp_device, NULL, detect_messages );
PedDisk* lp_disk = NULL;
destroy_device_and_disk( lp_device, lp_disk );
}
bool fs_busy = is_busy( fstype, mapping_path ); bool fs_busy = is_busy( fstype, mapping_path );
partition.set_luks( mapping_path, partition.set_luks( mapping_path,
fstype, fstype,
mapping.offset / partition.sector_size, mapping.offset / partition.sector_size,
mapping.length / partition.sector_size, mapping.length / partition.sector_size,
partition.sector_size, partition.sector_size,
fs_busy ); fs_busy );
Partition & encrypted = partition.get_encrypted(); Partition & encrypted = partition.get_encrypted();
skipping to change at line 1069 skipping to change at line 1073
// Retrieve file system UUID. Use cached method first in an effort to sp eed up // Retrieve file system UUID. Use cached method first in an effort to sp eed up
// device scanning. // device scanning.
partition.uuid = FS_Info::get_uuid( partition_path ); partition.uuid = FS_Info::get_uuid( partition_path );
if ( partition.uuid.empty() ) if ( partition.uuid.empty() )
{ {
read_uuid( partition ); read_uuid( partition );
} }
} }
FSType GParted_Core::detect_filesystem_in_encryption_mapping(const Glib::ustring
& path,
std::vector<Glib::u
string>& messages)
{
// Run blkid identification on this one encryption mapping.
std::vector<Glib::ustring> one_path;
one_path.push_back(path);
FS_Info::load_cache_for_paths(one_path);
FSType fstype = FS_UNKNOWN;
PedDevice *lp_device = NULL;
if (get_device(path, lp_device))
{
// Run libparted partition table and file system identification.
Only use
// (get the first partition) if it's a "loop" table; because GPar
ted only
// supports one block device to one encryption mapping to one fil
e system.
PedDisk *lp_disk = NULL;
PedPartition *lp_partition = NULL;
if (get_disk(lp_device, lp_disk) && lp_disk && lp_disk->type
&&
lp_disk->type->name && strcmp(lp_disk->type->name, "loop") ==
0 )
{
lp_partition = ped_disk_next_partition(lp_disk, NULL);
}
// Clear the "unrecognised disk label" message reported when libp
arted
// fails to detect anything.
libparted_messages.clear();
fstype = detect_filesystem(lp_device, lp_partition, messages);
destroy_device_and_disk(lp_device, lp_disk);
}
return fstype;
}
// GParted simple internal file system signature detection. Use sparingly. Onl y when // GParted simple internal file system signature detection. Use sparingly. Onl y when
// (old versions of) blkid and libparted don't recognise a signature. // (old versions of) blkid and libparted don't recognise a signature.
FSType GParted_Core::detect_filesystem_internal(const Glib::ustring& path, Byte_ Value sector_size) FSType GParted_Core::detect_filesystem_internal(const Glib::ustring& path, Byte_ Value sector_size)
{ {
char magic1[16]; // Big enough for largest signatures[].sig1 or sig2 char magic1[16]; // Big enough for largest signatures[].sig1 or sig2
char magic2[16]; char magic2[16];
FSType fstype = FS_UNKNOWN; FSType fstype = FS_UNKNOWN;
char* buf = static_cast<char *>(malloc(sector_size)); char* buf = static_cast<char *>(malloc(sector_size));
if ( ! buf ) if ( ! buf )
skipping to change at line 1113 skipping to change at line 1152
{ 0LL, "\x52\x56\xBE\x56", 0LL, NULL , FS_GRUB2_CORE_IMG }, { 0LL, "\x52\x56\xBE\x56", 0LL, NULL , FS_GRUB2_CORE_IMG },
{ 24LL, "\x01\x00" , 32LL, "NXSB", FS_APFS }, { 24LL, "\x01\x00" , 32LL, "NXSB", FS_APFS },
{ 512LL, "LABELONE" , 536LL, "LVM2", FS_LVM2_PV }, { 512LL, "LABELONE" , 536LL, "LVM2", FS_LVM2_PV },
{ 1030LL, "\x34\x34" , 0LL, NULL , FS_NILFS2 }, { 1030LL, "\x34\x34" , 0LL, NULL , FS_NILFS2 },
{ 65536LL, "ReIsEr4" , 0LL, NULL , FS_REISER4 }, { 65536LL, "ReIsEr4" , 0LL, NULL , FS_REISER4 },
{ 65600LL, "_BHRfS_M" , 0LL, NULL , FS_BTRFS } { 65600LL, "_BHRfS_M" , 0LL, NULL , FS_BTRFS }
}; };
// For simple BitLocker recognition consider validation of BIOS Parameter block // For simple BitLocker recognition consider validation of BIOS Parameter block
// fields unnecessary. // fields unnecessary.
// * Detecting BitLocker // * Detecting BitLocker
// http://blogs.msdn.com/b/si_team/archive/2006/10/26/detecting-bitlo // https://docs.microsoft.com/en-us/archive/blogs/si_team/detecting-b
cker.aspx itlocker
// https://web.archive.org/web/20200720030153/https://docs.microsoft.
com/en-us/archive/blogs/si_team/detecting-bitlocker
// //
// Recognise GRUB2 core.img just by any of the possible first 4 bytes of x86 CPU // Recognise GRUB2 core.img just by any of the possible first 4 bytes of x86 CPU
// instructions it starts with. // instructions it starts with.
// * bootinfoscript v0.77 line 1990 [GRUB2 core.img possible staring 4 bytes] // * bootinfoscript v0.77 line 1990 [GRUB2 core.img possible staring 4 bytes]
// https://github.com/arvidjaar/bootinfoscript/blob/009f509d59e2f0d39 b8d44692e2a81720f5af7b6/bootinfoscript#L1990 // https://github.com/arvidjaar/bootinfoscript/blob/009f509d59e2f0d39 b8d44692e2a81720f5af7b6/bootinfoscript#L1990
// //
// Simple APFS recognition based on matching the following fields in the // Simple APFS recognition based on matching the following fields in the
// superblock: // superblock:
// 1) Object type is OBJECT_TYPE_NX_SUPERBLOCK, lower 16-bits of the obj ect type // 1) Object type is OBJECT_TYPE_NX_SUPERBLOCK, lower 16-bits of the obj ect type
// field is 0x0001 stored as little endian bytes 0x01, 0x00. // field is 0x0001 stored as little endian bytes 0x01, 0x00.
skipping to change at line 1184 skipping to change at line 1224
break; break;
} }
} }
close(fd); close(fd);
free( buf ); free( buf );
return fstype; return fstype;
} }
FSType GParted_Core::detect_filesystem( PedDevice * lp_device, PedPartition * lp FSType GParted_Core::detect_filesystem(const PedDevice *lp_device, const PedPart
_partition, ition *lp_partition,
std::vector<Glib::ustring> & messages ) std::vector<Glib::ustring> &messages)
{ {
g_assert(lp_device != NULL); // Bug: Not initialised by call to ped_devi
ce_get() or ped_device_get_next()
Glib::ustring fsname = ""; Glib::ustring fsname = "";
Glib::ustring path; Glib::ustring path;
DMRaid dmraid; DMRaid dmraid;
if ( lp_partition ) if ( lp_partition )
// Will query partition using methods: (Q1) RAID, (Q2) blkid, // Will query partition using methods: (Q1) RAID, (Q2) blkid,
// (Q3) libparted, (Q4) internal // (Q3) libparted, (Q4) internal
path = get_partition_path( lp_partition ); path = get_partition_path( lp_partition );
else else
// Will query whole disk device using methods: (Q1) RAID, (Q2) bl kid, // Will query whole disk device using methods: (Q1) RAID, (Q2) bl kid,
skipping to change at line 3550 skipping to change at line 3592
{ {
PedPartition* lp_partition = get_lp_partition( lp_disk, partition _old ); PedPartition* lp_partition = get_lp_partition( lp_disk, partition _old );
if ( lp_partition ) if ( lp_partition )
{ {
PedConstraint *constraint = NULL ; PedConstraint *constraint = NULL ;
constraint = ped_constraint_any( lp_device ) ; constraint = ped_constraint_any( lp_device ) ;
if ( constraint ) if ( constraint )
{ {
//FIXME: if we insert a weird partitionnew geom h ere (e.g. start > end) //FIXME: if we insert a weird partitionnew geom h ere (e.g. start > end)
//ped_disk_set_partition_geom() will still return true (althoug an lp exception is written //ped_disk_set_partition_geom() will still return true (although an lp exception is written
//to stdout.. see if this also affect create_part ition and resize_move_partition //to stdout.. see if this also affect create_part ition and resize_move_partition
//sended a patch to fix this to libparted list. w ill probably be in 1.7.2 //sended a patch to fix this to libparted list. w ill probably be in 1.7.2
if ( ped_disk_set_partition_geom( lp_disk, if ( ped_disk_set_partition_geom( lp_disk,
lp_partition, lp_partition,
constraint, constraint,
partition_new . sector_start, partition_new . sector_start,
partition_new . sector_end ) ) partition_new . sector_end ) )
{ {
partition_new .sector_start = lp_partitio n ->geom .start ; partition_new .sector_start = lp_partitio n ->geom .start ;
partition_new .sector_end = lp_partition ->geom .end ; partition_new .sector_end = lp_partition ->geom .end ;
skipping to change at line 4059 skipping to change at line 4101
// table so that libparted reading the whole disk device and the // table so that libparted reading the whole disk device and the
// file system tools reading the partition devices read t he same // file system tools reading the partition devices read t he same
// data. // data.
flush_device( lp_device ); flush_device( lp_device );
return true; return true;
} }
return false; return false;
} }
bool GParted_Core::get_disk( PedDevice *& lp_device, PedDisk *& lp_disk, bool st rict ) bool GParted_Core::get_disk(PedDevice *lp_device, PedDisk*& lp_disk)
{ {
if ( lp_device ) g_assert(lp_device != NULL); // Bug: Not initialised by call to ped_devi
{ ce_get() or ped_device_get_next()
lp_disk = ped_disk_new( lp_device );
// (#762941)(!46) After ped_disk_new() wait for triggered udev ru lp_disk = ped_disk_new(lp_device);
les to
// to complete which remove and re-add all the partition specific
/dev
// entries to avoid FS specific commands failing because they hap
pen to
// be running when the needed /dev/PTN entries don't exist.
settle_device(SETTLE_DEVICE_PROBE_MAX_WAIT_SECONDS);
// if ! disk and writable it's probably a HD without disklabel.
// We return true here and deal with them in
// GParted_Core::set_device_from_disk().
if ( lp_disk || ( ! strict && ! lp_device ->read_only ) )
return true;
destroy_device_and_disk( lp_device, lp_disk ); // (#762941)(!46) After ped_disk_new() wait for triggered udev rules to c
} omplete
// which remove and re-add all the partition specific /dev entries to avo
id FS
// specific commands failing because they happen to be running when the n
eeded
// /dev/PTN entries don't exist.
settle_device(SETTLE_DEVICE_PROBE_MAX_WAIT_SECONDS);
return false; return (lp_disk != NULL);
} }
bool GParted_Core::get_device_and_disk( const Glib::ustring & device_path, bool GParted_Core::get_device_and_disk(const Glib::ustring& device_path,
PedDevice*& lp_device, PedDisk*& lp_disk PedDevice*& lp_device, PedDisk*& lp_disk,
, bool strict, bool flush ) bool flush)
{ {
if ( get_device( device_path, lp_device, flush ) ) if ( get_device( device_path, lp_device, flush ) )
{ {
return get_disk( lp_device, lp_disk, strict ); if (get_disk(lp_device, lp_disk))
return true;
destroy_device_and_disk(lp_device, lp_disk);
} }
return false; return false;
} }
void GParted_Core::destroy_device_and_disk( PedDevice*& lp_device, PedDisk*& lp_ disk ) void GParted_Core::destroy_device_and_disk( PedDevice*& lp_device, PedDisk*& lp_ disk )
{ {
if ( lp_disk ) if ( lp_disk )
ped_disk_destroy( lp_disk ) ; ped_disk_destroy( lp_disk ) ;
lp_disk = NULL ; lp_disk = NULL ;
 End of changes. 29 change blocks. 
190 lines changed or deleted 218 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)