Enable resizing of FAT and HPFS filesystems with parted >= 3.1.

FEATURE:295339

svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1327259
This commit is contained in:
Andrius Štikonas 2012-12-04 15:29:17 +00:00
parent 98ce049950
commit 0fe0fb40e7
5 changed files with 18 additions and 12 deletions

View File

@ -32,11 +32,16 @@ endif (LIBPARTED_INCLUDE_DIR AND LIBPARTED_LIBRARY)
FIND_PATH(LIBPARTED_INCLUDE_DIR parted.h PATH_SUFFIXES parted )
FIND_LIBRARY(LIBPARTED_LIBRARY NAMES parted)
FIND_LIBRARY(LIBPARTED_FS_RESIZE_LIBRARY NAMES parted-fs-resize)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBPARTED DEFAULT_MSG LIBPARTED_LIBRARY LIBPARTED_INCLUDE_DIR)
SET(LIBPARTED_LIBS ${LIBPARTED_LIBRARY})
if (LIBPARTED_FS_RESIZE_LIBRARY)
set(LIBPARTED_LIBS ${LIBPARTED_LIBRARY} ${LIBPARTED_FS_RESIZE_LIBRARY})
else (LIBPARTED_FS_RESIZE_LIBRARY)
set(LIBPARTED_LIBS ${LIBPARTED_LIBRARY})
endif (LIBPARTED_FS_RESIZE_LIBRARY)
# KDE adds -ansi to the C make flags, parted headers use GNU extensions, so
# undo that
@ -45,9 +50,7 @@ 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)
CHECK_FUNCTION_EXISTS("ped_file_system_clobber" LIBPARTED_FILESYSTEM_SUPPORT) # parted < 3.0
CHECK_FUNCTION_EXISTS("ped_file_system_resize" LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT) # parted != 3.0
MARK_AS_ADVANCED(LIBPARTED_LIBRARY LIBPARTED_INCLUDE_DIR LIBPARTED_FILESYSTEM_SUPPORT)
MARK_AS_ADVANCED(LIBPARTED_LIBRARY LIBPARTED_INCLUDE_DIR LIBPARTED_FILESYSTEM_SUPPORT LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT)

View File

@ -91,7 +91,6 @@ namespace FS
return "---";
}
bool luks::updateUUID(Report& report, const QString& deviceNode) const
{
QUuid uuid = QUuid::createUuid();

View File

@ -21,6 +21,10 @@ if (LIBPARTED_FILESYSTEM_SUPPORT)
add_definitions(-DLIBPARTED_FILESYSTEM_SUPPORT)
endif (LIBPARTED_FILESYSTEM_SUPPORT)
if (LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT)
add_definitions(-DLIBPARTED_FS_RESIZE_LIBRARY_SUPPORT)
endif (LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT)
include_directories(${LIBPARTED_INCLUDE_DIR})
file (GLOB pmlibpartedbackendplugin_SRCS *.cpp)

View File

@ -191,7 +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
#if defined LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT
static qint64 readSectorsUsedLibParted(PedDisk* pedDisk, const Partition& p)
{
Q_ASSERT(pedDisk);
@ -235,7 +235,7 @@ 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
#if defined LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT
else if (p.fileSystem().supportGetUsed() == FileSystem::cmdSupportCore)
p.fileSystem().setSectorsUsed(readSectorsUsedLibParted(pedDisk, p));
#else
@ -289,7 +289,7 @@ LibPartedBackend::LibPartedBackend(QObject*, const QList<QVariant>&) :
void LibPartedBackend::initFSSupport()
{
#if defined LIBPARTED_FILESYSTEM_SUPPORT
#if defined LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT
if (FS::fat16::m_Shrink == FileSystem::cmdSupportNone)
FS::fat16::m_Shrink = FileSystem::cmdSupportBackend;

View File

@ -301,7 +301,7 @@ bool LibPartedPartitionTable::clobberFileSystem(Report& report, const Partition&
return rval;
}
#if defined LIBPARTED_FILESYSTEM_SUPPORT
#if defined LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT
static void pedTimerHandler(PedTimer* pedTimer, void*)
{
CoreBackendManager::self()->backend()->emitProgress(pedTimer->frac * 100);
@ -312,7 +312,7 @@ bool LibPartedPartitionTable::resizeFileSystem(Report& report, const Partition&
{
bool rval = false;
#if defined LIBPARTED_FILESYSTEM_SUPPORT
#if defined LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT
if (PedGeometry* originalGeometry = ped_geometry_new(pedDevice(), partition.fileSystem().firstSector(), partition.fileSystem().length()))
{
if (PedFileSystem* pedFileSystem = ped_file_system_open(originalGeometry))