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_PATH(LIBPARTED_INCLUDE_DIR parted.h PATH_SUFFIXES parted )
FIND_LIBRARY(LIBPARTED_LIBRARY NAMES parted) FIND_LIBRARY(LIBPARTED_LIBRARY NAMES parted)
FIND_LIBRARY(LIBPARTED_FS_RESIZE_LIBRARY NAMES parted-fs-resize)
INCLUDE(FindPackageHandleStandardArgs) INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBPARTED DEFAULT_MSG LIBPARTED_LIBRARY LIBPARTED_INCLUDE_DIR) 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 # KDE adds -ansi to the C make flags, parted headers use GNU extensions, so
# undo that # undo that
@ -45,9 +50,7 @@ unset(CMAKE_C_FLAGS)
set(CMAKE_REQUIRED_INCLUDES ${LIBPARTED_INCLUDE_DIR}) set(CMAKE_REQUIRED_INCLUDES ${LIBPARTED_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${LIBPARTED_LIBS}) set(CMAKE_REQUIRED_LIBRARIES ${LIBPARTED_LIBS})
CHECK_C_SOURCE_COMPILES(" CHECK_FUNCTION_EXISTS("ped_file_system_clobber" LIBPARTED_FILESYSTEM_SUPPORT) # parted < 3.0
#include <parted/parted.h> CHECK_FUNCTION_EXISTS("ped_file_system_resize" LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT) # parted != 3.0
int main() { ped_file_system_clobber(0); }
" LIBPARTED_FILESYSTEM_SUPPORT)
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 "---"; return "---";
} }
bool luks::updateUUID(Report& report, const QString& deviceNode) const bool luks::updateUUID(Report& report, const QString& deviceNode) const
{ {
QUuid uuid = QUuid::createUuid(); QUuid uuid = QUuid::createUuid();

View File

@ -21,6 +21,10 @@ if (LIBPARTED_FILESYSTEM_SUPPORT)
add_definitions(-DLIBPARTED_FILESYSTEM_SUPPORT) add_definitions(-DLIBPARTED_FILESYSTEM_SUPPORT)
endif (LIBPARTED_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}) include_directories(${LIBPARTED_INCLUDE_DIR})
file (GLOB pmlibpartedbackendplugin_SRCS *.cpp) 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 @param p the Partition the FileSystem is on
@return the number of sectors used @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) static qint64 readSectorsUsedLibParted(PedDisk* pedDisk, const Partition& p)
{ {
Q_ASSERT(pedDisk); 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()); p.fileSystem().setSectorsUsed(freeSpaceInfo.used() / d.logicalSectorSize());
else if (p.fileSystem().supportGetUsed() == FileSystem::cmdSupportFileSystem) else if (p.fileSystem().supportGetUsed() == FileSystem::cmdSupportFileSystem)
p.fileSystem().setSectorsUsed(p.fileSystem().readUsedCapacity(p.deviceNode()) / d.logicalSectorSize()); 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) else if (p.fileSystem().supportGetUsed() == FileSystem::cmdSupportCore)
p.fileSystem().setSectorsUsed(readSectorsUsedLibParted(pedDisk, p)); p.fileSystem().setSectorsUsed(readSectorsUsedLibParted(pedDisk, p));
#else #else
@ -289,7 +289,7 @@ LibPartedBackend::LibPartedBackend(QObject*, const QList<QVariant>&) :
void LibPartedBackend::initFSSupport() void LibPartedBackend::initFSSupport()
{ {
#if defined LIBPARTED_FILESYSTEM_SUPPORT #if defined LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT
if (FS::fat16::m_Shrink == FileSystem::cmdSupportNone) if (FS::fat16::m_Shrink == FileSystem::cmdSupportNone)
FS::fat16::m_Shrink = FileSystem::cmdSupportBackend; FS::fat16::m_Shrink = FileSystem::cmdSupportBackend;

View File

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