[gparted] Make mounted partition usage method selectable per file system (#683255)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Make mounted partition usage method selectable per file system (#683255)
- Date: Tue, 2 Oct 2012 19:23:49 +0000 (UTC)
commit 01150758c30ddfc49d03f1e2beeb22e93a768d44
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Mon Sep 10 16:41:58 2012 +0100
Make mounted partition usage method selectable per file system (#683255)
Each file system class can now choose how the size and free space of the
file system is determined when it is mounted.
.fs.online_read = FS::NONE (default)
Do nothing. Don't get the file system size and free space.
.fs.online_read = FS::GPARTED
Use internal GParted method which calls statvfs() system call on
the mounted file system.
.fs.online_read = FS::EXTERNAL
Call the file system's member function set_used_sectors(). This
is the same function as called when the file system is not
mounted. It can determine if the file system is mounted or not
by testing partition.busy and acting accordingly.
This means that determining the size and free space of active LVM2
Physical Volumes is no longer a special case. Instead the lvm2_pv class
just elects to have its set_used_sectors() method called for both the
active and deactive cases.
Bug #683255 - ext2: statvfs differs from dumpe2fs (x MB unallocated
space within the partition)
include/GParted_Core.h | 1 +
include/Utils.h | 5 ++-
src/GParted_Core.cc | 50 ++++++++++++++++++++++++++++-------------------
src/btrfs.cc | 2 +
src/exfat.cc | 1 +
src/ext2.cc | 4 ++-
src/ext3.cc | 4 ++-
src/ext4.cc | 2 +
src/fat16.cc | 3 +-
src/fat32.cc | 3 +-
src/hfs.cc | 3 +-
src/hfsplus.cc | 3 +-
src/jfs.cc | 4 ++-
src/lvm2_pv.cc | 1 +
src/nilfs2.cc | 1 +
src/ntfs.cc | 4 ++-
src/reiser4.cc | 4 ++-
src/reiserfs.cc | 2 +
src/ufs.cc | 3 +-
src/xfs.cc | 2 +
20 files changed, 70 insertions(+), 32 deletions(-)
---
diff --git a/include/GParted_Core.h b/include/GParted_Core.h
index 052773b..35cd535 100644
--- a/include/GParted_Core.h
+++ b/include/GParted_Core.h
@@ -85,6 +85,7 @@ private:
bool inside_extended ) ;
void set_mountpoints( std::vector<Partition> & partitions ) ;
void set_used_sectors( std::vector<Partition> & partitions ) ;
+ void mounted_set_used_sectors( Partition & partition ) ;
#ifdef HAVE_LIBPARTED_FS_RESIZE
void LP_set_used_sectors( Partition & partition );
#endif
diff --git a/include/Utils.h b/include/Utils.h
index 9269f73..116d7f4 100644
--- a/include/Utils.h
+++ b/include/Utils.h
@@ -118,7 +118,7 @@ struct FS
};
FILESYSTEM filesystem ;
- Support read ; //can we get the amount of used sectors?
+ Support read ; //Can and how to read sector usage while inactive
Support read_label ;
Support write_label ;
Support read_uuid ;
@@ -130,6 +130,7 @@ struct FS
Support check ; //some checktool available?
Support copy ;
Support remove ;
+ Support online_read ; //Can and how to read sector usage while active
Byte_Value MIN ;
Byte_Value MAX ;
@@ -137,7 +138,7 @@ struct FS
FS()
{
read = read_label = write_label = read_uuid = write_uuid = create = grow = shrink =
- move = check = copy = remove = NONE ;
+ move = check = copy = remove = online_read = NONE ;
MIN = MAX = 0 ;
}
} ;
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index dc54b9d..d5f2b5b 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1496,8 +1496,6 @@ void GParted_Core::set_mountpoints( std::vector<Partition> & partitions )
void GParted_Core::set_used_sectors( std::vector<Partition> & partitions )
{
- struct statvfs sfs ;
-
for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
{
if ( partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP &&
@@ -1508,26 +1506,20 @@ void GParted_Core::set_used_sectors( std::vector<Partition> & partitions )
if ( partitions[ t ] .type == GParted::TYPE_PRIMARY ||
partitions[ t ] .type == GParted::TYPE_LOGICAL )
{
- if ( partitions[ t ] .busy && partitions[t] .filesystem != GParted::FS_LVM2_PV )
+ if ( partitions[ t ] .busy )
{
- if ( partitions[ t ] .get_mountpoints() .size() > 0 )
+ switch( get_fs( partitions[ t ] .filesystem ) .online_read )
{
- if ( statvfs( partitions[ t ] .get_mountpoint() .c_str(), &sfs ) == 0 )
- {
- Sector fs_size = static_cast<Sector>( sfs .f_blocks ) *
- sfs .f_frsize /
- partitions[ t ] .sector_size ;
- Sector fs_free = static_cast<Sector>( sfs .f_bfree ) *
- sfs .f_bsize /
- partitions[ t ] .sector_size ;
- partitions[ t ] .set_sector_usage( fs_size, fs_free ) ;
- }
- else
- partitions[ t ] .messages .push_back(
- "statvfs (" +
- partitions[ t ] .get_mountpoint() +
- "): " +
- Glib::strerror( errno ) ) ;
+ case FS::EXTERNAL:
+ if ( set_proper_filesystem( partitions[ t ] .filesystem ) )
+ p_filesystem ->set_used_sectors( partitions[ t ] ) ;
+ break ;
+ case FS::GPARTED:
+ mounted_set_used_sectors( partitions[ t ] ) ;
+ break ;
+
+ default:
+ break ;
}
}
else
@@ -1603,6 +1595,24 @@ void GParted_Core::set_used_sectors( std::vector<Partition> & partitions )
}
}
+void GParted_Core::mounted_set_used_sectors( Partition & partition )
+{
+ struct statvfs sfs ;
+
+ if ( partition .get_mountpoints() .size() > 0 )
+ {
+ if ( statvfs( partition .get_mountpoint() .c_str(), &sfs ) == 0 )
+ {
+ Sector fs_size = static_cast<Sector>( sfs .f_blocks ) * sfs .f_frsize / partition .sector_size ;
+ Sector fs_free = static_cast<Sector>( sfs .f_bfree ) * sfs .f_bsize / partition .sector_size ;
+ partition .set_sector_usage( fs_size, fs_free ) ;
+ }
+ else
+ partition .messages .push_back( "statvfs (" + partition .get_mountpoint() + "): " +
+ Glib::strerror( errno ) ) ;
+ }
+}
+
#ifdef HAVE_LIBPARTED_FS_RESIZE
void GParted_Core::LP_set_used_sectors( Partition & partition )
{
diff --git a/src/btrfs.cc b/src/btrfs.cc
index 627d0a8..2db4b25 100644
--- a/src/btrfs.cc
+++ b/src/btrfs.cc
@@ -98,6 +98,8 @@ FS btrfs::get_filesystem_support()
fs .move = GParted::FS::GPARTED ;
}
+ fs .online_read = FS::GPARTED ;
+
fs .MIN = 256 * MEBIBYTE ;
//Linux before version 3.2 fails when resizing btrfs file system
diff --git a/src/exfat.cc b/src/exfat.cc
index 618b913..17ce5c2 100644
--- a/src/exfat.cc
+++ b/src/exfat.cc
@@ -29,6 +29,7 @@ FS exfat::get_filesystem_support()
fs .copy = FS::GPARTED ;
fs .move = FS::GPARTED ;
+ fs .online_read = FS::GPARTED ;
return fs ;
}
diff --git a/src/ext2.cc b/src/ext2.cc
index 6612eb0..722851a 100644
--- a/src/ext2.cc
+++ b/src/ext2.cc
@@ -58,7 +58,9 @@ FS ext2::get_filesystem_support()
fs .copy = FS::GPARTED ;
fs .move = FS::GPARTED ;
}
-
+
+ fs .online_read = FS::GPARTED ;
+
return fs ;
}
diff --git a/src/ext3.cc b/src/ext3.cc
index 07e740b..8698347 100644
--- a/src/ext3.cc
+++ b/src/ext3.cc
@@ -59,7 +59,9 @@ FS ext3::get_filesystem_support()
fs .copy = GParted::FS::GPARTED ;
fs .move = GParted::FS::GPARTED ;
}
-
+
+ fs .online_read = FS::GPARTED ;
+
return fs ;
}
diff --git a/src/ext4.cc b/src/ext4.cc
index 5fdc955..6a9d1a8 100644
--- a/src/ext4.cc
+++ b/src/ext4.cc
@@ -63,6 +63,8 @@ FS ext4::get_filesystem_support()
}
}
+ fs .online_read = FS::GPARTED ;
+
return fs ;
}
diff --git a/src/fat16.cc b/src/fat16.cc
index aed3fa1..47e2737 100644
--- a/src/fat16.cc
+++ b/src/fat16.cc
@@ -94,7 +94,8 @@ FS fat16::get_filesystem_support()
#endif
fs .copy = GParted::FS::GPARTED ;
-
+ fs .online_read = FS::GPARTED ;
+
fs .MIN = 16 * MEBIBYTE ;
fs .MAX = (4096 - 1) * MEBIBYTE ; //Maximum seems to be just less than 4096 MiB
diff --git a/src/fat32.cc b/src/fat32.cc
index e4f333e..686446e 100644
--- a/src/fat32.cc
+++ b/src/fat32.cc
@@ -82,7 +82,8 @@ FS fat32::get_filesystem_support()
#endif
fs .copy = GParted::FS::GPARTED ;
-
+ fs .online_read = FS::GPARTED ;
+
fs .MIN = 33 * MEBIBYTE ; //Smaller file systems will cause windows scandisk to fail.
return fs ;
diff --git a/src/hfs.cc b/src/hfs.cc
index 4486fdd..6a2b953 100644
--- a/src/hfs.cc
+++ b/src/hfs.cc
@@ -44,7 +44,8 @@ FS hfs::get_filesystem_support()
fs .copy = GParted::FS::GPARTED ;
fs .move = GParted::FS::GPARTED ;
-
+ fs .online_read = FS::GPARTED ;
+
fs .MAX = 2048 * MEBIBYTE ;
return fs ;
diff --git a/src/hfsplus.cc b/src/hfsplus.cc
index 5e378bc..24104e7 100644
--- a/src/hfsplus.cc
+++ b/src/hfsplus.cc
@@ -44,7 +44,8 @@ FS hfsplus::get_filesystem_support()
fs .copy = GParted::FS::GPARTED ;
fs .move = GParted::FS::GPARTED ;
-
+ fs .online_read = FS::GPARTED ;
+
return fs ;
}
diff --git a/src/jfs.cc b/src/jfs.cc
index 5d53187..c2e5006 100644
--- a/src/jfs.cc
+++ b/src/jfs.cc
@@ -60,7 +60,9 @@ FS jfs::get_filesystem_support()
fs .move = GParted::FS::GPARTED ;
fs .copy = GParted::FS::GPARTED ;
}
-
+
+ fs .online_read = FS::GPARTED ;
+
fs .MIN = 16 * MEBIBYTE ;
return fs ;
diff --git a/src/lvm2_pv.cc b/src/lvm2_pv.cc
index 4023aba..62f4670 100644
--- a/src/lvm2_pv.cc
+++ b/src/lvm2_pv.cc
@@ -60,6 +60,7 @@ FS lvm2_pv::get_filesystem_support()
fs .move = FS::GPARTED ;
fs .check = FS::EXTERNAL ;
fs .remove = FS::EXTERNAL ;
+ fs .online_read = FS::EXTERNAL ;
}
return fs ;
diff --git a/src/nilfs2.cc b/src/nilfs2.cc
index a72972c..d9bdb46 100644
--- a/src/nilfs2.cc
+++ b/src/nilfs2.cc
@@ -55,6 +55,7 @@ FS nilfs2::get_filesystem_support()
fs .copy = GParted::FS::GPARTED ;
fs .move = GParted::FS::GPARTED ;
+ fs .online_read = FS::GPARTED ;
//Minimum FS size is 128M+4K using mkfs.nilfs2 defaults
fs .MIN = 128 * MEBIBYTE + 4 * KIBIBYTE ;
diff --git a/src/ntfs.cc b/src/ntfs.cc
index 9ad7bca..1f6e228 100644
--- a/src/ntfs.cc
+++ b/src/ntfs.cc
@@ -102,7 +102,9 @@ FS ntfs::get_filesystem_support()
if ( fs .check )
fs .move = GParted::FS::GPARTED ;
-
+
+ fs .online_read = FS::GPARTED ;
+
return fs ;
}
diff --git a/src/reiser4.cc b/src/reiser4.cc
index e627b0c..459d664 100644
--- a/src/reiser4.cc
+++ b/src/reiser4.cc
@@ -45,7 +45,9 @@ FS reiser4::get_filesystem_support()
fs .copy = GParted::FS::GPARTED ;
fs .move = GParted::FS::GPARTED ;
}
-
+
+ fs .online_read = FS::GPARTED ;
+
/*
* IT SEEMS RESIZE AND COPY AREN'T IMPLEMENTED YET IN THE TOOLS...
* SEE http://marc.theaimsgroup.com/?t=109883161600003&r=1&w=2 for more information..
diff --git a/src/reiserfs.cc b/src/reiserfs.cc
index 8fd78f2..a6d5c5b 100644
--- a/src/reiserfs.cc
+++ b/src/reiserfs.cc
@@ -61,6 +61,8 @@ FS reiserfs::get_filesystem_support()
fs .move = GParted::FS::GPARTED ;
}
+ fs .online_read = FS::GPARTED ;
+
//Actual minimum is at least 18 blocks larger than 32 MiB for the journal offset
fs .MIN = 34 * MEBIBYTE ;
diff --git a/src/ufs.cc b/src/ufs.cc
index 0003929..84b2197 100644
--- a/src/ufs.cc
+++ b/src/ufs.cc
@@ -30,7 +30,8 @@ FS ufs::get_filesystem_support()
fs .copy = GParted::FS::GPARTED ;
fs .move = GParted::FS::GPARTED ;
-
+ fs .online_read = FS::GPARTED ;
+
return fs ;
}
diff --git a/src/xfs.cc b/src/xfs.cc
index ff098a7..7e00088 100644
--- a/src/xfs.cc
+++ b/src/xfs.cc
@@ -68,6 +68,8 @@ FS xfs::get_filesystem_support()
if ( fs .check )
fs .move = GParted::FS::GPARTED ;
+ fs .online_read = FS::GPARTED ;
+
fs .MIN = 32 * MEBIBYTE ;//official minsize = 16MB, but the smallest xfs_repair can handle is 32MB...
return fs ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]