Make KDE Partition Manager build and work with libparted 3.x. This mostly means
anything that libparted used to do regarding file systems (mainly resizing fat16 and fat32) is now no longer possible. BUG:278569 svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1249901
This commit is contained in:
parent
3e8a7c0f13
commit
6a2b4c5c09
|
@ -1,4 +1,4 @@
|
|||
# Copyright (C) 2008,2010 by Volker Lanz <vl@fidra.de>
|
||||
# Copyright (C) 2008,2010,2011 by Volker Lanz <vl@fidra.de>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
|
@ -21,6 +21,8 @@
|
|||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
INCLUDE(CheckCSourceCompiles)
|
||||
|
||||
if (LIBPARTED_INCLUDE_DIR AND LIBPARTED_LIBRARY)
|
||||
# Already in cache, be silent
|
||||
set(LIBPARTED_FIND_QUIETLY TRUE)
|
||||
|
@ -36,4 +38,16 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBPARTED DEFAULT_MSG LIBPARTED_LIBRARY LIBPAR
|
|||
|
||||
SET(LIBPARTED_LIBS ${LIBPARTED_LIBRARY})
|
||||
|
||||
MARK_AS_ADVANCED(LIBPARTED_LIBRARY LIBPARTED_INCLUDE_DIR)
|
||||
# KDE adds -ansi to the C make flags, parted headers use GNU extensions, so
|
||||
# undo that
|
||||
unset(CMAKE_C_FLAGS)
|
||||
|
||||
set(CMAKE_REQUIRED_INCLUDES ${LIBPARTED_INCLUDE_DIR})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${LIBPARTED_LIBS})
|
||||
|
||||
CHECK_C_SOURCE_COMPILES("
|
||||
#include <parted/parted.h>
|
||||
int main() { ped_file_system_clobber(0); }
|
||||
" LIBPARTED_FILESYSTEM_SUPPORT)
|
||||
|
||||
MARK_AS_ADVANCED(LIBPARTED_LIBRARY LIBPARTED_INCLUDE_DIR LIBPARTED_FILESYSTEM_SUPPORT)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008,2009 by Volker Lanz <vl@fidra.de> *
|
||||
* Copyright (C) 2008,2009,2011 by Volker Lanz <vl@fidra.de> *
|
||||
* *
|
||||
* 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 *
|
||||
|
@ -60,8 +60,6 @@ namespace FS
|
|||
m_GetUsed = m_Check = findExternal("fsck.msdos", QStringList(), 2) ? cmdSupportFileSystem : cmdSupportNone;
|
||||
m_GetLabel = cmdSupportCore;
|
||||
m_SetLabel = cmdSupportFileSystem;
|
||||
m_Grow = cmdSupportNone;
|
||||
m_Shrink = cmdSupportNone;
|
||||
m_Move = cmdSupportCore;
|
||||
m_Copy = cmdSupportCore;
|
||||
m_Backup = cmdSupportCore;
|
||||
|
@ -78,8 +76,8 @@ namespace FS
|
|||
m_Create != cmdSupportNone &&
|
||||
m_Check != cmdSupportNone &&
|
||||
m_UpdateUUID != cmdSupportNone &&
|
||||
m_Grow != cmdSupportNone &&
|
||||
m_Shrink != cmdSupportNone &&
|
||||
// m_Grow != cmdSupportNone &&
|
||||
// m_Shrink != cmdSupportNone &&
|
||||
m_Copy != cmdSupportNone &&
|
||||
m_Move != cmdSupportNone &&
|
||||
m_Backup != cmdSupportNone &&
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
|
||||
* Copyright (C) 2008,2011 by Volker Lanz <vl@fidra.de> *
|
||||
* *
|
||||
* 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 *
|
||||
|
@ -46,10 +46,6 @@ namespace FS
|
|||
m_GetLabel = cmdSupportCore;
|
||||
m_Create = findExternal("hformat") ? cmdSupportFileSystem : cmdSupportNone;
|
||||
m_Check = findExternal("hfsck") ? cmdSupportFileSystem : cmdSupportNone;
|
||||
|
||||
m_GetUsed = cmdSupportCore;
|
||||
m_Shrink = cmdSupportNone;
|
||||
|
||||
m_Move = m_Copy = (m_Check != cmdSupportNone) ? cmdSupportCore : cmdSupportNone;
|
||||
m_Backup = cmdSupportCore;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
|
||||
* Copyright (C) 2008,2011 by Volker Lanz <vl@fidra.de> *
|
||||
* *
|
||||
* 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 *
|
||||
|
@ -41,9 +41,6 @@ namespace FS
|
|||
void hfsplus::init()
|
||||
{
|
||||
m_Check = findExternal("hpfsck") ? cmdSupportFileSystem : cmdSupportNone;
|
||||
|
||||
m_GetUsed = cmdSupportCore;
|
||||
m_Shrink = cmdSupportNone;
|
||||
m_Copy = (m_Check != cmdSupportNone) ? cmdSupportCore : cmdSupportNone;
|
||||
m_Move = (m_Check != cmdSupportNone) ? cmdSupportCore : cmdSupportNone;
|
||||
m_Backup = cmdSupportCore;
|
||||
|
@ -52,7 +49,7 @@ namespace FS
|
|||
bool hfsplus::supportToolFound() const
|
||||
{
|
||||
return
|
||||
m_GetUsed != cmdSupportNone &&
|
||||
// m_GetUsed != cmdSupportNone &&
|
||||
// m_GetLabel != cmdSupportNone &&
|
||||
// m_SetLabel != cmdSupportNone &&
|
||||
// m_Create != cmdSupportNone &&
|
||||
|
|
|
@ -17,6 +17,10 @@
|
|||
|
||||
find_package(LIBPARTED REQUIRED)
|
||||
|
||||
if (LIBPARTED_FILESYSTEM_SUPPORT)
|
||||
add_definitions(-DLIBPARTED_FILESYSTEM_SUPPORT)
|
||||
endif (LIBPARTED_FILESYSTEM_SUPPORT)
|
||||
|
||||
include_directories(${LIBPARTED_INCLUDE_DIR})
|
||||
|
||||
file (GLOB pmlibpartedbackendplugin_SRCS *.cpp)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008,2009,2010 by Volker Lanz <vl@fidra.de> *
|
||||
* Copyright (C) 2008,2009,2010,2011 by Volker Lanz <vl@fidra.de> *
|
||||
* *
|
||||
* 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 *
|
||||
|
@ -191,6 +191,7 @@ static quint64 lastUsableSector(const Device& d)
|
|||
@param p the Partition the FileSystem is on
|
||||
@return the number of sectors used
|
||||
*/
|
||||
#if defined LIBPARTED_FILESYSTEM_SUPPORT
|
||||
static qint64 readSectorsUsedLibParted(PedDisk* pedDisk, const Partition& p)
|
||||
{
|
||||
Q_ASSERT(pedDisk);
|
||||
|
@ -217,6 +218,7 @@ static qint64 readSectorsUsedLibParted(PedDisk* pedDisk, const Partition& p)
|
|||
|
||||
return rval;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Reads the sectors used in a FileSystem and stores the result in the Partition's FileSystem object.
|
||||
@param pedDisk pointer to pedDisk where the Partition and its FileSystem are
|
||||
|
@ -233,8 +235,12 @@ static void readSectorsUsed(PedDisk* pedDisk, const Device& d, Partition& p, con
|
|||
p.fileSystem().setSectorsUsed(freeSpaceInfo.used() / d.logicalSectorSize());
|
||||
else if (p.fileSystem().supportGetUsed() == FileSystem::cmdSupportFileSystem)
|
||||
p.fileSystem().setSectorsUsed(p.fileSystem().readUsedCapacity(p.deviceNode()) / d.logicalSectorSize());
|
||||
#if defined LIBPARTED_FILESYSTEM_SUPPORT
|
||||
else if (p.fileSystem().supportGetUsed() == FileSystem::cmdSupportCore)
|
||||
p.fileSystem().setSectorsUsed(readSectorsUsedLibParted(pedDisk, p));
|
||||
#else
|
||||
Q_UNUSED(pedDisk);
|
||||
#endif
|
||||
}
|
||||
|
||||
static PartitionTable::Flags activeFlags(PedPartition* p)
|
||||
|
@ -283,10 +289,14 @@ LibPartedBackend::LibPartedBackend(QObject*, const QList<QVariant>&) :
|
|||
|
||||
void LibPartedBackend::initFSSupport()
|
||||
{
|
||||
#if defined LIBPARTED_FILESYSTEM_SUPPORT
|
||||
FS::fat16::m_Shrink = FileSystem::cmdSupportBackend;
|
||||
FS::fat16::m_Grow = FileSystem::cmdSupportBackend;
|
||||
FS::hfs::m_Shrink = FileSystem::cmdSupportBackend;
|
||||
FS::hfsplus::m_Shrink = FileSystem::cmdSupportBackend;
|
||||
FS::hfs::m_GetUsed = FileSystem::cmdSupportBackend;
|
||||
FS::hfsplus::m_GetUsed = FileSystem::cmdSupportBackend;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Scans a Device for Partitions.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2010 by Volker Lanz <vl@fidra.de *
|
||||
* Copyright (C) 2010,2011 by Volker Lanz <vl@fidra.de *
|
||||
* *
|
||||
* 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 *
|
||||
|
@ -56,7 +56,6 @@ bool LibPartedPartitionTable::open()
|
|||
return m_PedDisk != NULL;
|
||||
}
|
||||
|
||||
|
||||
bool LibPartedPartitionTable::commit(quint32 timeout)
|
||||
{
|
||||
return commit(pedDisk(), timeout);
|
||||
|
@ -260,6 +259,7 @@ bool LibPartedPartitionTable::clobberFileSystem(Report& report, const Partition&
|
|||
{
|
||||
bool rval = false;
|
||||
|
||||
#if defined LIBPARTED_FILESYSTEM_SUPPORT
|
||||
if (PedPartition* pedPartition = ped_disk_get_partition_by_sector(pedDisk(), partition.firstSector()))
|
||||
{
|
||||
if (ped_file_system_clobber(&pedPartition->geom))
|
||||
|
@ -285,19 +285,33 @@ bool LibPartedPartitionTable::clobberFileSystem(Report& report, const Partition&
|
|||
}
|
||||
else
|
||||
report.line() << i18nc("@info/plain", "Could not delete file system on partition <filename>%1</filename>: Failed to get partition.", partition.deviceNode());
|
||||
#else
|
||||
// One would assume we'd need to implement clobbering ourselves here, now that libparted does not
|
||||
// support it anymore.
|
||||
// Strangely enough, creating a partition with a valid file system, then deleting it without any
|
||||
// removing of file system signatues, then creating a new unfortmatted partition in its place with
|
||||
// the exact same geometry does NOT result in the old file system being magically restored. So
|
||||
// it appears to be ok to just skip clobbering altogether.
|
||||
Q_UNUSED(report);
|
||||
Q_UNUSED(partition);
|
||||
rval = true;
|
||||
#endif
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
#if defined LIBPARTED_FILESYSTEM_SUPPORT
|
||||
static void pedTimerHandler(PedTimer* pedTimer, void*)
|
||||
{
|
||||
CoreBackendManager::self()->backend()->emitProgress(pedTimer->frac * 100);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool LibPartedPartitionTable::resizeFileSystem(Report& report, const Partition& partition, qint64 newLength)
|
||||
{
|
||||
bool rval = false;
|
||||
|
||||
#if defined LIBPARTED_FILESYSTEM_SUPPORT
|
||||
if (PedGeometry* originalGeometry = ped_geometry_new(pedDevice(), partition.fileSystem().firstSector(), partition.fileSystem().length()))
|
||||
{
|
||||
if (PedFileSystem* pedFileSystem = ped_file_system_open(originalGeometry))
|
||||
|
@ -321,6 +335,11 @@ bool LibPartedPartitionTable::resizeFileSystem(Report& report, const Partition&
|
|||
}
|
||||
else
|
||||
report.line() << i18nc("@info/plain", "Could not read geometry for partition <filename>%1</filename> while trying to resize the file system.", partition.deviceNode());
|
||||
#else
|
||||
Q_UNUSED(report);
|
||||
Q_UNUSED(partition);
|
||||
Q_UNUSED(newLength);
|
||||
#endif
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue