Add nilfs2 support (#642842)
Requires libparted 2.4 or higher, or blkid from utils-linux 2.20 or higher for nilfs2 file system detection. Requires nilfs-utils for nilfs2 file system support. Closes Bug #642842 - nilfs is not detected
This commit is contained in:
parent
46973f8721
commit
df20b54d00
6
README
6
README
|
@ -133,6 +133,7 @@ Optional packages include:
|
|||
hfsutils
|
||||
hfsprogs
|
||||
jfsutils
|
||||
nilfs-utils
|
||||
ntfsprogs
|
||||
reiser4progs
|
||||
reiserfsprogs
|
||||
|
@ -143,8 +144,9 @@ Optional packages include:
|
|||
volume labels.
|
||||
* If the blkid command is in the search path, it will be used
|
||||
to read file system UUIDs and labels. It is also used for
|
||||
ext4 file detection.
|
||||
blkid is part of the e2fsprogs package.
|
||||
ext4 file system detection.
|
||||
blkid is part of the util-linux package and e2fsprogs
|
||||
package before that.
|
||||
|
||||
|
||||
For Linux software RAID support, the following package is required:
|
||||
|
|
|
@ -48,6 +48,7 @@ EXTRA_DIST = \
|
|||
i18n.h \
|
||||
jfs.h \
|
||||
linux_swap.h \
|
||||
nilfs2.h \
|
||||
ntfs.h \
|
||||
reiser4.h \
|
||||
reiserfs.h \
|
||||
|
|
|
@ -69,12 +69,13 @@ enum FILESYSTEM
|
|||
FS_HFS = 17,
|
||||
FS_HFSPLUS = 18,
|
||||
FS_UFS = 19,
|
||||
FS_NILFS2 = 20,
|
||||
|
||||
FS_USED = 20,
|
||||
FS_UNUSED = 21,
|
||||
FS_USED = 21,
|
||||
FS_UNUSED = 22,
|
||||
|
||||
FS_LVM2 = 22,
|
||||
FS_LUKS = 23
|
||||
FS_LVM2 = 23,
|
||||
FS_LUKS = 24
|
||||
} ;
|
||||
|
||||
enum SIZE_UNIT
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/* Copyright (C) 2011 Mike Fleetwood
|
||||
*
|
||||
* 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 NILFS2_H_
|
||||
#define NILFS2_H_
|
||||
|
||||
#include "../include/FileSystem.h"
|
||||
|
||||
namespace GParted
|
||||
{
|
||||
|
||||
class nilfs2 : public FileSystem
|
||||
{
|
||||
public:
|
||||
FS get_filesystem_support() ;
|
||||
void set_used_sectors( Partition & partition ) ;
|
||||
void read_label( Partition & partition ) ;
|
||||
bool write_label( const Partition & partition, OperationDetail & operationdetail ) ;
|
||||
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
|
||||
bool resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition = false ) ;
|
||||
bool move( const Partition & partition_new
|
||||
, const Partition & partition_old
|
||||
, OperationDetail & operationdetail
|
||||
) ;
|
||||
bool copy( const Glib::ustring & src_part_path
|
||||
, const Glib::ustring & dest_part_path
|
||||
, OperationDetail & operationdetail
|
||||
) ;
|
||||
bool check_repair( const Partition & partition, OperationDetail & operationdetail ) ;
|
||||
};
|
||||
|
||||
} //GParted
|
||||
|
||||
#endif /*NILFS2_H_*/
|
|
@ -38,6 +38,7 @@
|
|||
#include "../include/fat32.h"
|
||||
#include "../include/linux_swap.h"
|
||||
#include "../include/reiserfs.h"
|
||||
#include "../include/nilfs2.h"
|
||||
#include "../include/ntfs.h"
|
||||
#include "../include/xfs.h"
|
||||
#include "../include/jfs.h"
|
||||
|
@ -124,6 +125,9 @@ void GParted_Core::find_supported_filesystems()
|
|||
linux_swap fs_linux_swap;
|
||||
FILESYSTEMS .push_back( fs_linux_swap .get_filesystem_support() ) ;
|
||||
|
||||
nilfs2 fs_nilfs2;
|
||||
FILESYSTEMS .push_back( fs_nilfs2 .get_filesystem_support() ) ;
|
||||
|
||||
ntfs fs_ntfs;
|
||||
FILESYSTEMS .push_back( fs_ntfs .get_filesystem_support() ) ;
|
||||
|
||||
|
@ -1113,6 +1117,8 @@ GParted::FILESYSTEM GParted_Core::get_filesystem()
|
|||
return GParted::FS_FAT16 ;
|
||||
else if ( fs_type == "fat32" )
|
||||
return GParted::FS_FAT32 ;
|
||||
else if ( fs_type == "nilfs2" )
|
||||
return GParted::FS_NILFS2 ;
|
||||
else if ( fs_type == "ntfs" )
|
||||
return GParted::FS_NTFS ;
|
||||
else if ( fs_type == "reiserfs" )
|
||||
|
@ -2948,6 +2954,7 @@ bool GParted_Core::set_proper_filesystem( const FILESYSTEM & filesystem )
|
|||
case FS_LINUX_SWAP : p_filesystem = new linux_swap() ; break ;
|
||||
case FS_FAT16 : p_filesystem = new fat16() ; break ;
|
||||
case FS_FAT32 : p_filesystem = new fat32() ; break ;
|
||||
case FS_NILFS2 : p_filesystem = new nilfs2() ; break ;
|
||||
case FS_NTFS : p_filesystem = new ntfs() ; break ;
|
||||
case FS_REISERFS : p_filesystem = new reiserfs() ; break ;
|
||||
case FS_REISER4 : p_filesystem = new reiser4() ; break ;
|
||||
|
|
|
@ -57,6 +57,7 @@ gpartedbin_SOURCES = \
|
|||
jfs.cc \
|
||||
linux_swap.cc \
|
||||
main.cc \
|
||||
nilfs2.cc \
|
||||
ntfs.cc \
|
||||
reiser4.cc \
|
||||
reiserfs.cc \
|
||||
|
|
|
@ -63,7 +63,7 @@ Glib::ustring Utils::num_to_str( Sector number )
|
|||
return ss .str() ;
|
||||
}
|
||||
|
||||
//use http://developer.gnome.org/projects/gup/hig/2.0/design.html#Palette as a starting point..
|
||||
//use palette from http://developer.gnome.org/hig-book/2.32/design-color.html.en as a starting point.
|
||||
Glib::ustring Utils::get_color( FILESYSTEM filesystem )
|
||||
{
|
||||
switch( filesystem )
|
||||
|
@ -80,6 +80,7 @@ Glib::ustring Utils::get_color( FILESYSTEM filesystem )
|
|||
case FS_FAT16 : return "#00FF00" ; //green
|
||||
case FS_FAT32 : return "#18D918" ; // ~ medium green
|
||||
case FS_EXFAT : return "#2E8B57" ; // ~ sea green
|
||||
case FS_NILFS2 : return "#826647" ; //face skin dark
|
||||
case FS_NTFS : return "#42E5AC" ; // ~ light turquoise
|
||||
case FS_REISERFS : return "#ADA7C8" ; //purple hilight
|
||||
case FS_REISER4 : return "#887FA3" ; //purple medium
|
||||
|
@ -146,6 +147,7 @@ Glib::ustring Utils::get_filesystem_string( FILESYSTEM filesystem )
|
|||
case FS_FAT16 : return "fat16" ;
|
||||
case FS_FAT32 : return "fat32" ;
|
||||
case FS_EXFAT : return "exfat" ;
|
||||
case FS_NILFS2 : return "nilfs2" ;
|
||||
case FS_NTFS : return "ntfs" ;
|
||||
case FS_REISERFS : return "reiserfs" ;
|
||||
case FS_REISER4 : return "reiser4" ;
|
||||
|
@ -177,6 +179,7 @@ Glib::ustring Utils::get_filesystem_software( FILESYSTEM filesystem )
|
|||
case FS_HFSPLUS : return "hfsprogs" ;
|
||||
case FS_JFS : return "jfsutils" ;
|
||||
case FS_LINUX_SWAP : return "util-linux" ;
|
||||
case FS_NILFS2 : return "nilfs-utils" ;
|
||||
case FS_NTFS : return "ntfsprogs" ;
|
||||
case FS_REISER4 : return "reiser4progs" ;
|
||||
case FS_REISERFS : return "reiserfsprogs" ;
|
||||
|
|
|
@ -0,0 +1,132 @@
|
|||
/* Copyright (C) 2011 Mike Fleetwood
|
||||
*
|
||||
* 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/nilfs2.h"
|
||||
|
||||
namespace GParted
|
||||
{
|
||||
|
||||
FS nilfs2::get_filesystem_support()
|
||||
{
|
||||
FS fs ;
|
||||
fs .filesystem = GParted::FS_NILFS2 ;
|
||||
|
||||
if ( ! Glib::find_program_in_path( "mkfs.nilfs2" ) .empty() )
|
||||
{
|
||||
fs .create = GParted::FS::EXTERNAL ;
|
||||
}
|
||||
|
||||
if ( ! Glib::find_program_in_path( "nilfs-tune" ) .empty() )
|
||||
{
|
||||
fs .read = GParted::FS::EXTERNAL ;
|
||||
fs .read_label = GParted::FS::EXTERNAL ;
|
||||
fs .write_label = GParted::FS::EXTERNAL ;
|
||||
}
|
||||
|
||||
fs .copy = GParted::FS::GPARTED ;
|
||||
fs .move = GParted::FS::GPARTED ;
|
||||
|
||||
return fs ;
|
||||
}
|
||||
|
||||
void nilfs2::set_used_sectors( Partition & partition )
|
||||
{
|
||||
if ( ! Utils::execute_command( "nilfs-tune -l " + partition .get_path(), output, error, true ) )
|
||||
{
|
||||
Glib::ustring::size_type index = output .find( "Free blocks count:" ) ;
|
||||
if ( index == Glib::ustring::npos
|
||||
|| sscanf( output.substr( index ) .c_str(), "Free blocks count: %Ld", &N ) != 1
|
||||
)
|
||||
N = -1 ;
|
||||
|
||||
index = output .find( "Block size:" ) ;
|
||||
if ( index == Glib::ustring::npos
|
||||
|| sscanf( output.substr( index ) .c_str(), "Block size: %Ld", &S ) != 1
|
||||
)
|
||||
S = -1 ;
|
||||
|
||||
if ( N > -1 && S > -1 )
|
||||
partition .Set_Unused( Utils::round( N * ( S / double( partition .sector_size) ) ) ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! output .empty() )
|
||||
partition .messages .push_back( output ) ;
|
||||
|
||||
if ( ! error .empty() )
|
||||
partition .messages .push_back( error ) ;
|
||||
}
|
||||
}
|
||||
|
||||
void nilfs2::read_label( Partition & partition )
|
||||
{
|
||||
if ( ! Utils::execute_command( "nilfs-tune -l " + partition .get_path(), output, error, true ) )
|
||||
{
|
||||
Glib::ustring label = Utils::regexp_label( output, "^Filesystem volume name:[\t ]*(.*)$" ) ;
|
||||
if ( label != "(none)" )
|
||||
partition .label = label;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! output .empty() )
|
||||
partition .messages .push_back( output ) ;
|
||||
|
||||
if ( ! error .empty() )
|
||||
partition .messages .push_back( error ) ;
|
||||
}
|
||||
}
|
||||
|
||||
bool nilfs2::write_label( const Partition & partition, OperationDetail & operationdetail )
|
||||
{
|
||||
return ! execute_command( "nilfs-tune -L \"" + partition .label + "\" " + partition .get_path(), operationdetail ) ;
|
||||
}
|
||||
|
||||
bool nilfs2::create( const Partition & new_partition, OperationDetail & operationdetail )
|
||||
{
|
||||
return ! execute_command( "mkfs.nilfs2 -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
|
||||
}
|
||||
|
||||
bool nilfs2::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
|
||||
{
|
||||
//FIXME: Implement file system resizing. Must be mounted like
|
||||
// xfs, jfs and btrfs.
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool nilfs2::move( const Partition & partition_new
|
||||
, const Partition & partition_old
|
||||
, OperationDetail & operationdetail
|
||||
)
|
||||
{
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool nilfs2::copy( const Glib::ustring & src_part_path
|
||||
, const Glib::ustring & dest_part_path
|
||||
, OperationDetail & operationdetail
|
||||
)
|
||||
{
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool nilfs2::check_repair( const Partition & partition, OperationDetail & operationdetail )
|
||||
{
|
||||
return true ;
|
||||
}
|
||||
|
||||
} //GParted
|
Loading…
Reference in New Issue