diff --git a/configure.in b/configure.in index 5d58ed91..ffaf6ddc 100644 --- a/configure.in +++ b/configure.in @@ -173,13 +173,74 @@ int main () } ], [AC_MSG_RESULT([yes]) AC_DEFINE([HAVE_LIBPARTED_3_0_0_PLUS], [1], [Define to 1 if libparted >= 3.0]) - have_lp_fs_resize_api=no] + have_old_lp_fs_resize_api=no] , [AC_MSG_RESULT([no]) - have_lp_fs_resize_api=yes] + have_old_lp_fs_resize_api=yes] ) LIBS="$LIBS_save" +dnl====================== +dnl check whether libparted >= 3.1 (libparted has new file system resizing LIB) +dnl====================== +LIBPARTED_VERSION=3.1 +AC_MSG_CHECKING([if libparted >= $LIBPARTED_VERSION (libparted has new file system resizing LIB)]) +LIBS_save="$LIBS" +LIBS="-lparted -luuid -ldl" +need_work_around=yes +AC_TRY_RUN([ +#include +#include + +int main () +{ + int min_major = 0; + int min_minor = 0; + int min_micro = 0; + int major = 0; + int minor = 0; + int micro = 0; + + if ( ( sscanf( "$LIBPARTED_VERSION", "%d.%d.%d", &min_major, &min_minor, &min_micro ) == 3 ) || + ( sscanf( "$LIBPARTED_VERSION", "%d.%d", &min_major, &min_minor ) == 2 ) || + ( sscanf( "$LIBPARTED_VERSION", "%d", &min_major ) == 1 ) + ) + { + if ( ( sscanf( ped_get_version(), "%d.%d.%d", &major, &minor, µ ) == 3 ) || + ( sscanf( ped_get_version(), "%d.%d", &major, &minor ) == 2 ) || + ( sscanf( ped_get_version(), "%d", &major ) == 1 ) + ) + { + return ! ( (major > min_major) || + ( (major == min_major) && (minor > min_minor) ) || + ( (major == min_major) && (minor == min_minor) && (micro >= min_micro) ) + ) ; + } + } + + return 1 ; +} +], [ AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_LIBPARTED_3_1_0_PLUS], [1], [Define to 1 if libparted >= 3.1]) + have_new_lp_fs_resize_lib=yes + ] + , [ AC_MSG_RESULT([no]) + have_new_lp_fs_resize_lib=no + ] +) +LIBS="$LIBS_save" + + +dnl Check for availability of libparted fs resize library +AM_CONDITIONAL([USE_LIBPARTED_FS_RESIZE_LIBRARY], [ test ${have_new_lp_fs_resize_lib} = yes]) + + +dnl Check if have libparted fs resize capability +if test [ ${have_old_lp_fs_resize_api} = yes -o ${have_new_lp_fs_resize_lib} = yes ]; then + AC_DEFINE([HAVE_LIBPARTED_FS_RESIZE], [1], [Define to 1 if have libparted fs resize capability]) +fi + + dnl gthread PKG_CHECK_MODULES([GTHREAD], [gthread-2.0]) AC_SUBST([GTHREAD_LIBS]) @@ -264,17 +325,18 @@ dnl Summary dnl====================== echo "" -echo "===================== Final configuration ========================" -echo " Installing into prefix : $prefix" +echo "======================== Final configuration ===========================" +echo " Installing into prefix : $prefix" echo "" -echo " Build documentation? : $enable_doc" +echo " Build documentation? : $enable_doc" echo "" -echo " Use native libparted dmraid support? : $enable_libparted_dmraid" +echo " Use native libparted dmraid support? : $enable_libparted_dmraid" echo "" -echo " --- Features Based On Libparted Version ---" -echo " Need partition table re-read work around? : $need_pt_reread_work_around" -echo " Supports sector sizes > 512 bytes? : $support_sector_size_gt_512" -echo " Have libparted file system resizing API? : $have_lp_fs_resize_api" +echo " --- Features Based On Libparted Version ---" +echo " Need partition table re-read work around? : $need_pt_reread_work_around" +echo " Supports sector sizes > 512 bytes? : $support_sector_size_gt_512" +echo " Have old libparted file system resizing API? : $have_old_lp_fs_resize_api" +echo " Have new libparted file system resizing LIB? : $have_new_lp_fs_resize_lib" echo "" -echo " If all settings are OK, type make and make install " -echo "==================================================================" +echo " If all settings are OK, type make and then (as root) make install" +echo "========================================================================" diff --git a/include/GParted_Core.h b/include/GParted_Core.h index fe30e269..4317da00 100644 --- a/include/GParted_Core.h +++ b/include/GParted_Core.h @@ -1,5 +1,5 @@ /* Copyright (C) 2004 Bart - * Copyright (C) 2008, 2009, 2010, 2011 Curtis Gedak + * Copyright (C) 2008, 2009, 2010, 2011, 2012 Curtis Gedak * * 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 @@ -23,6 +23,9 @@ #include "../include/Operation.h" #include +#ifdef HAVE_LIBPARTED_3_1_0_PLUS +#include +#endif #include #include @@ -81,7 +84,7 @@ private: bool inside_extended ) ; void set_mountpoints( std::vector & partitions ) ; void set_used_sectors( std::vector & partitions ) ; -#ifndef HAVE_LIBPARTED_3_0_0_PLUS +#ifdef HAVE_LIBPARTED_FS_RESIZE void LP_set_used_sectors( Partition & partition ); #endif void set_flags( Partition & partition ) ; @@ -110,7 +113,7 @@ private: bool move_filesystem( const Partition & partition_old, const Partition & partition_new, OperationDetail & operationdetail ) ; -#ifndef HAVE_LIBPARTED_3_0_0_PLUS +#ifdef HAVE_LIBPARTED_FS_RESIZE bool resize_move_filesystem_using_libparted( const Partition & partition_old, const Partition & partition_new, OperationDetail & operationdetail ) ; diff --git a/include/Utils.h b/include/Utils.h index fee138b1..e56fb11c 100644 --- a/include/Utils.h +++ b/include/Utils.h @@ -1,5 +1,5 @@ /* Copyright (C) 2004 Bart - * Copyright (C) 2008, 2009, 2010, 2011 Curtis Gedak + * Copyright (C) 2008, 2009, 2010, 2011, 2012 Curtis Gedak * * 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 @@ -109,9 +109,7 @@ struct FS { NONE = 0, GPARTED = 1, -#ifndef HAVE_LIBPARTED_3_0_0_PLUS LIBPARTED = 2, -#endif EXTERNAL = 3 }; diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index fa722313..cefd0846 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -1442,7 +1442,7 @@ void GParted_Core::set_used_sectors( std::vector & partitions ) if ( set_proper_filesystem( partitions[ t ] .filesystem ) ) p_filesystem ->set_used_sectors( partitions[ t ] ) ; break ; -#ifndef HAVE_LIBPARTED_3_0_0_PLUS +#ifdef HAVE_LIBPARTED_FS_RESIZE case GParted::FS::LIBPARTED : LP_set_used_sectors( partitions[ t ] ) ; break ; @@ -1478,7 +1478,7 @@ void GParted_Core::set_used_sectors( std::vector & partitions ) } } -#ifndef HAVE_LIBPARTED_3_0_0_PLUS +#ifdef HAVE_LIBPARTED_FS_RESIZE void GParted_Core::LP_set_used_sectors( Partition & partition ) { PedFileSystem *fs = NULL; @@ -1656,7 +1656,7 @@ bool GParted_Core::create_filesystem( const Partition & partition, OperationDeta break ; case GParted::FS::GPARTED: break ; -#ifndef HAVE_LIBPARTED_3_0_0_PLUS +#ifndef HAVE_LIBPARTED_3_0_PLUS case GParted::FS::LIBPARTED: break ; #endif @@ -1665,6 +1665,9 @@ bool GParted_Core::create_filesystem( const Partition & partition, OperationDeta p_filesystem ->create( partition, operationdetail .get_last_child() ) ; break ; + + default: + break ; } operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ; @@ -1971,7 +1974,7 @@ bool GParted_Core::move_filesystem( const Partition & partition_old, succes = copy_filesystem( partition_old, partition_new, operationdetail .get_last_child() ) ; break ; -#ifndef HAVE_LIBPARTED_3_0_0_PLUS +#ifdef HAVE_LIBPARTED_FS_RESIZE case GParted::FS::LIBPARTED: succes = resize_move_filesystem_using_libparted( partition_old, partition_new, @@ -1985,13 +1988,16 @@ bool GParted_Core::move_filesystem( const Partition & partition_old, , operationdetail .get_last_child() ) ; break ; + + default: + break ; } operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ; return succes ; } -#ifndef HAVE_LIBPARTED_3_0_0_PLUS +#ifdef HAVE_LIBPARTED_FS_RESIZE bool GParted_Core::resize_move_filesystem_using_libparted( const Partition & partition_old, const Partition & partition_new, OperationDetail & operationdetail ) @@ -2285,7 +2291,7 @@ bool GParted_Core::resize_filesystem( const Partition & partition_old, break ; case GParted::FS::GPARTED: break ; -#ifndef HAVE_LIBPARTED_3_0_0_PLUS +#ifdef HAVE_LIBPARTED_FS_RESIZE case GParted::FS::LIBPARTED: succes = resize_move_filesystem_using_libparted( partition_old, partition_new, @@ -2298,6 +2304,9 @@ bool GParted_Core::resize_filesystem( const Partition & partition_old, operationdetail .get_last_child(), fill_partition ) ; break ; + + default: + break ; } operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ; @@ -2613,6 +2622,9 @@ bool GParted_Core::check_repair_filesystem( const Partition & partition, Operati p_filesystem ->check_repair( partition, operationdetail .get_last_child() ) ; break ; + + default: + break ; } operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ; diff --git a/src/Makefile.am b/src/Makefile.am index 5fe75fb0..7c65fb29 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -70,5 +70,9 @@ gpartedbin_SOURCES = \ gpartedbin_LDFLAGS = -lparted +if USE_LIBPARTED_FS_RESIZE_LIBRARY +gpartedbin_LDFLAGS += -lparted-fs-resize +endif + gpartedbin_LDADD = $(GTHREAD_LIBS) $(GTKMM_LIBS) diff --git a/src/fat16.cc b/src/fat16.cc index e4ad5136..bd0485bd 100644 --- a/src/fat16.cc +++ b/src/fat16.cc @@ -1,5 +1,5 @@ /* Copyright (C) 2004 Bart - * Copyright (C) 2008, 2009, 2010, 2011 Curtis Gedak + * Copyright (C) 2008, 2009, 2010, 2011, 2012 Curtis Gedak * * 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 @@ -82,13 +82,15 @@ FS fat16::get_filesystem_support() fs .write_uuid = FS::EXTERNAL ; } -#ifndef HAVE_LIBPARTED_3_0_0_PLUS +#ifdef HAVE_LIBPARTED_FS_RESIZE //resizing of start and endpoint are provided by libparted fs .grow = GParted::FS::LIBPARTED ; fs .shrink = GParted::FS::LIBPARTED ; - fs .move = GParted::FS::LIBPARTED ; +#endif +#ifdef HAVE_LIBPARTED_3_0_0_PLUS + fs .move = FS::GPARTED ; #else - fs.move = FS::GPARTED ; + fs .move = GParted::FS::LIBPARTED ; #endif fs .copy = GParted::FS::GPARTED ; diff --git a/src/fat32.cc b/src/fat32.cc index aa77cd16..c49ed50c 100644 --- a/src/fat32.cc +++ b/src/fat32.cc @@ -1,5 +1,5 @@ /* Copyright (C) 2004 Bart - * Copyright (C) 2008, 2009, 2010, 2011 Curtis Gedak + * Copyright (C) 2008, 2009, 2010, 2011, 2012 Curtis Gedak * * 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 @@ -70,13 +70,15 @@ FS fat32::get_filesystem_support() fs .write_uuid = FS::EXTERNAL ; } -#ifndef HAVE_LIBPARTED_3_0_0_PLUS +#ifdef HAVE_LIBPARTED_FS_RESIZE //resizing of start and endpoint are provided by libparted fs .grow = GParted::FS::LIBPARTED ; fs .shrink = GParted::FS::LIBPARTED ; - fs .move = GParted::FS::LIBPARTED ; -#else +#endif +#ifdef HAVE_LIBPARTED_3_0_0_PLUS fs .move = FS::GPARTED ; +#else + fs .move = GParted::FS::LIBPARTED ; #endif fs .copy = GParted::FS::GPARTED ; diff --git a/src/hfs.cc b/src/hfs.cc index 525ea14f..84e1b602 100644 --- a/src/hfs.cc +++ b/src/hfs.cc @@ -1,5 +1,5 @@ /* Copyright (C) 2004 Bart - * Copyright (C) 2008, 2009, 2010, 2011 Curtis Gedak + * Copyright (C) 2008, 2009, 2010, 2011, 2012 Curtis Gedak * * 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 @@ -28,9 +28,9 @@ FS hfs::get_filesystem_support() fs .filesystem = GParted::FS_HFS ; -#ifndef HAVE_LIBPARTED_3_0_0_PLUS - fs .read = GParted::FS::LIBPARTED ; - fs .shrink = GParted::FS::LIBPARTED ; +#ifdef HAVE_LIBPARTED_FS_RESIZE + fs .read = GParted::FS::LIBPARTED ; + fs .shrink = GParted::FS::LIBPARTED ; #endif if ( ! Glib::find_program_in_path( "hformat" ) .empty() ) diff --git a/src/hfsplus.cc b/src/hfsplus.cc index f6c08e26..66c868ba 100644 --- a/src/hfsplus.cc +++ b/src/hfsplus.cc @@ -1,5 +1,5 @@ /* Copyright (C) 2004 Bart - * Copyright (C) 2008, 2009, 2010, 2011 Curtis Gedak + * Copyright (C) 2008, 2009, 2010, 2011, 2012 Curtis Gedak * * 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 @@ -28,9 +28,9 @@ FS hfsplus::get_filesystem_support() fs .filesystem = GParted::FS_HFSPLUS ; -#ifndef HAVE_LIBPARTED_3_0_0_PLUS - fs .read = GParted::FS::LIBPARTED ; - fs .shrink = GParted::FS::LIBPARTED ; +#ifdef HAVE_LIBPARTED_FS_RESIZE + fs .read = GParted::FS::LIBPARTED ; + fs .shrink = GParted::FS::LIBPARTED ; #endif if ( ! Glib::find_program_in_path( "mkfs.hfsplus" ) .empty() )