mirror of
https://gitlab.gnome.org/GNOME/gparted
synced 2024-08-27 11:40:03 +00:00
![Mike Fleetwood](/assets/img/avatar_default.png)
In some cases creating an LVM2 Physical Volume on top of a DMRaid array reports no usage information and this partition warning: Unable to read the contents of this file system! Because of this some operations may be unavailable. The cause might be a missing software package. The following list of software packages is required for lvm2 pv file system support: lvm2. For example on Ubuntu 14.04 LTS (with GParted built with --enable-libparted-dmraid) create an LVM2 PV in a DMRaid array partition. GParted uses this command: # lvm pvcreate -M 2 /dev/mapper/isw_bacdehijbd_MyArray0p2 But LVM reports the PV having a different name: # lvm pvs PV VG Fmt Attr PSize PFree /dev/disk/by-id/dm-name-isw_bacdehijbd_MyArray0p2 lvm2 a-- 1.00g 1.00g This alternate name is loaded into the LVM2_PV_Info module cache. Hence when GParted queries partition /dev/mapper/isw_bacdehijbd_MyArray0p2 it has no PV information against that name and reports unknown usage. However they are actually the same block special device; major 252, minor 2: # ls -l /dev/mapper/isw_bacdehijbd_MyArray0p2 brw-rw---- 1 root disk 252, 2 Jul 2 11:09 /dev/mapper/isw_bacdehijbd_MyArray0p2 # ls -l /dev/disk/by-id/dm-name-isw_bacdehijbd_MyArray0p2 lrwxrwxrwx 1 root root 10 Jul 2 11:09 /dev/disk/by-id/dm-name-isw_bacdehijbd_MyArray0p2 -> ../../dm-2 # ls -l /dev/dm-2 brw-rw---- 1 root disk 252, 2 Jul 2 11:09 /dev/dm-2 To determine if two names refer to the same block special device their major, minor numbers need to be compared, instead of string comparing their names. Implement class BlockSpecial which encapsulates the name and major, minor numbers for a block special device. Also performs comparison as needed. See bug 767842 comments 4 and 5 for further investigation and decision for choosing to implement a class. Replace name strings in the LVM2_PV_Info module with BlockSpecial objects performing correct block special device comparison. Bug 767842 - File system usage missing when tools report alternate block device names
55 lines
1.7 KiB
C++
55 lines
1.7 KiB
C++
/* Copyright (C) 2016 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/>.
|
|
*/
|
|
|
|
|
|
/* BlockSpecial
|
|
*
|
|
* Representation of a POSIX block special file, e.g. /dev/sda1. Also
|
|
* tracks the major, minor device numbers so that different names for
|
|
* the same block device can be compared equal.
|
|
* Refs: mknod(1) and mknod(2).
|
|
*/
|
|
|
|
#ifndef GPARTED_BLOCKSPECIAL_H
|
|
#define GPARTED_BLOCKSPECIAL_H
|
|
|
|
#include <glibmm/ustring.h>
|
|
|
|
namespace GParted
|
|
{
|
|
|
|
class BlockSpecial
|
|
{
|
|
public:
|
|
BlockSpecial();
|
|
BlockSpecial( const Glib::ustring & name );
|
|
~BlockSpecial();
|
|
|
|
Glib::ustring m_name; // E.g. Block special file {"/dev/sda1", 8, 1},
|
|
unsigned long m_major; // plain file {"FILENAME", 0, 0} and empty object
|
|
unsigned long m_minor; // {"", 0, 0}.
|
|
};
|
|
|
|
// Operator overloading > The Decision between Member and Non-member
|
|
// http://stackoverflow.com/questions/4421706/operator-overloading/4421729#4421729
|
|
// "2. If a binary operator treats both operands equally (it leaves them unchanged),
|
|
// implement this operator as a non-member function."
|
|
bool operator==( const BlockSpecial & lhs, const BlockSpecial & rhs );
|
|
|
|
}//GParted
|
|
|
|
#endif /* GPARTED_BLOCKSPECIAL_H */
|