* Added support for xfs. this means creating and growing xfs filesystems. Shrinking requires some hacking with dump_xfs etc..
  i'll add that at a later point. :)
This commit is contained in:
Bart Hakvoort 2004-12-13 21:24:12 +00:00
parent 789daf9b4f
commit d44aa2cf45
7 changed files with 191 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2004-12-13 Bart Hakvoort <gparted@users.sf.net>
* Added support for xfs. this means creating and growing xfs filesystems. Shrinking requires some hacking with dump_xfs etc..
i'll add that at a later point. :)
2004-12-13 Bart Hakvoort <gparted@users.sf.net> 2004-12-13 Bart Hakvoort <gparted@users.sf.net>
* Replaced boolean 'resize' with 'shrink' and 'grow'. It seems some filesystems only support growing (e.g. xfs) so i need * Replaced boolean 'resize' with 'shrink' and 'grow'. It seems some filesystems only support growing (e.g. xfs) so i need

View File

@ -26,6 +26,7 @@
#include "../include/linux_swap.h" #include "../include/linux_swap.h"
#include "../include/reiserfs.h" #include "../include/reiserfs.h"
#include "../include/ntfs.h" #include "../include/ntfs.h"
#include "../include/xfs.h"
#include <glibmm/ustring.h> #include <glibmm/ustring.h>

View File

@ -117,6 +117,7 @@ inline FS Get_FS( const Glib::ustring & filesystem, const std::vector<FS> & FILE
return FILESYSTEMS .back( ) ; return FILESYSTEMS .back( ) ;
} }
//use http://developer.gnome.org/projects/gup/hig/2.0/design.html#Palette as a starting point..
inline Glib::ustring Get_Color( const Glib::ustring & filesystem ) inline Glib::ustring Get_Color( const Glib::ustring & filesystem )
{ {
//blue teints //blue teints
@ -133,18 +134,19 @@ inline Glib::ustring Get_Color( const Glib::ustring & filesystem )
//purple something.. //purple something..
else if ( filesystem == "reiserfs" ) return "#ADA7C8" ; else if ( filesystem == "reiserfs" ) return "#ADA7C8" ;
else if ( filesystem == "xfs" ) return "#EED680" ;
//libparted can only detect these, i decided to "yellow them" :^) //libparted can only detect these, i decided to "yellow them" :^)
else if ( filesystem == "HFS" ) return "yellow" ; else if ( filesystem == "HFS" ) return "yellow" ;
else if ( filesystem == "JFS" ) return "yellow" ; else if ( filesystem == "JFS" ) return "yellow" ;
else if ( filesystem == "UFS" ) return "yellow" ; else if ( filesystem == "UFS" ) return "yellow" ;
else if ( filesystem == "XFS" ) return "yellow" ;
//darkgrey and ligthblue //darkgrey and ligthblue
else if ( filesystem == "---" ) return "darkgrey"; else if ( filesystem == "---" ) return "darkgrey";
else if ( filesystem == "extended" ) return "#7DFCFE" ; else if ( filesystem == "extended" ) return "#7DFCFE" ;
//unknown filesystem ( damaged, unknown or simply no filesystem ) //unknown filesystem ( damaged, unknown or simply no filesystem )
else return "black"; else return "black";
} }

43
include/xfs.h Normal file
View File

@ -0,0 +1,43 @@
/* Copyright (C) 2004 Bart
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef XFS
#define XFS
#include "../include/FileSystem.h"
#include <fstream>
namespace GParted
{
class xfs : public FileSystem
{
public:
FS get_filesystem_support( ) ;
void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Glib::ustring device_path, const Partition & new_partition ) ;
bool Resize( const Partition & partition_new, bool fill_partition = false ) ;
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ;
bool Check_Repair( const Partition & partition ) ;
int get_estimated_time( long MB_to_Consider ) ;
};
} //GParted
#endif //XFS

View File

@ -42,6 +42,9 @@ void GParted_Core::find_supported_filesystems( )
ntfs fs_ntfs; ntfs fs_ntfs;
FILESYSTEMS .push_back( fs_ntfs .get_filesystem_support( ) ) ; FILESYSTEMS .push_back( fs_ntfs .get_filesystem_support( ) ) ;
xfs fs_xfs;
FILESYSTEMS .push_back( fs_xfs .get_filesystem_support( ) ) ;
//unknown filesystem (default when no match is found) //unknown filesystem (default when no match is found)
FS fs ; fs .filesystem = "unknown" ; FS fs ; fs .filesystem = "unknown" ;
FILESYSTEMS .push_back( fs ) ; FILESYSTEMS .push_back( fs ) ;
@ -707,6 +710,8 @@ void GParted_Core::set_proper_filesystem( const Glib::ustring & filesystem )
p_filesystem = new reiserfs( ) ; p_filesystem = new reiserfs( ) ;
else if ( filesystem == "ntfs" ) else if ( filesystem == "ntfs" )
p_filesystem = new ntfs( ) ; p_filesystem = new ntfs( ) ;
else if ( filesystem == "xfs" )
p_filesystem = new xfs( ) ;
else else
p_filesystem = NULL ; p_filesystem = NULL ;

View File

@ -38,7 +38,8 @@ gparted_SOURCES = \
linux_swap.cc\ linux_swap.cc\
main.cc\ main.cc\
ntfs.cc\ ntfs.cc\
reiserfs.cc reiserfs.cc\
xfs.cc
gparted_LDFLAGS = -lparted -lgthread-2.0 gparted_LDFLAGS = -lparted -lgthread-2.0

129
src/xfs.cc Normal file
View File

@ -0,0 +1,129 @@
/* Copyright (C) 2004 Bart
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "../include/xfs.h"
namespace GParted
{
FS xfs::get_filesystem_support( )
{
FS fs ;
fs .filesystem = "xfs" ;
if ( ! system( "which xfs_db 1>/dev/null 2>/dev/null" ) )
fs .read = true ;
if ( ! system( "which mkfs.xfs 1>/dev/null 2>/dev/null" ) )
fs .create = true ;
if ( ! system( "which xfs_repair 1>/dev/null 2>/dev/null" ) )
fs .check = true ;
//resizing of xfs requires xfs_db, xfs_growfs, xfs_repair, mount, umount and xfs support in the kernel
if ( ! system( "which xfs_growfs mount umount 1>/dev/null 2>/dev/null" ) && fs .read && fs .check )
{
Glib::ustring line ;
std::ifstream input( "/proc/filesystems" ) ;
while ( input >> line )
if ( line == "xfs" )
{
fs .grow = true ;
break ;
}
input .close( ) ;
}
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
fs .copy = true ;
fs .MIN = 32 ;//official minsize = 16MB, but the smallest xfs_repair can handle is 32MB...
return fs ;
}
void xfs::Set_Used_Sectors( Partition & partition )
{
char c_buf[ 512 ] ;
FILE *f ;
Glib::ustring output ;
Sector free_blocks = -1, blocksize = -1 ;
//get free blocks..
f = popen( ( "LANG=C xfs_db -c 'sb 0' -c print -r " + partition .partition ) .c_str( ), "r" ) ;
while ( fgets( c_buf, 512, f ) )
{
output = Glib::locale_to_utf8( c_buf ) ;
//free blocks
if ( output .find( "fdblocks" ) < output .length( ) )
free_blocks = atoi( (output .substr( output .find( "=" ) +1, output .length( ) ) ) .c_str( ) ) ;
//blocksize
if ( output .find( "blocksize" ) < output .length( ) )
blocksize = atoi( (output .substr( output .find( "=" ) +1, output .length( ) ) ) .c_str( ) ) ;
}
pclose( f ) ;
if ( free_blocks > -1 && blocksize > -1 )
partition .Set_Unused( free_blocks * blocksize / 512 ) ;
}
bool xfs::Create( const Glib::ustring device_path, const Partition & new_partition )
{
return ! Execute_Command( "mkfs.xfs " + new_partition .partition ) ;
}
bool xfs::Resize( const Partition & partition_new, bool fill_partition )
{
bool return_value = false ;
//xfs kan only grow if the partition is mounted..
system( "mkdir /tmp/gparted_tmp_xfs_mountpoint" ) ;
if ( ! Execute_Command( "mount " + partition_new .partition + " /tmp/gparted_tmp_xfs_mountpoint" ) )
{
return_value = ! Execute_Command( "xfs_growfs /tmp/gparted_tmp_xfs_mountpoint" ) ;
Execute_Command( "umount " + partition_new .partition ) ;
}
system( "rmdir /tmp/gparted_tmp_xfs_mountpoint" ) ;
return return_value ;
}
bool xfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
{
return ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ;
}
bool xfs::Check_Repair( const Partition & partition )
{
return ! Execute_Command( "xfs_repair " + partition .partition ) ;
}
int xfs::get_estimated_time( long MB_to_Consider )
{
return -1 ;
}
} //GParted