Add f2fs file system support (#695396)

Only supports detection and creation of f2fs file systems.  Requires
f2fs-tools and a blkid with f2fs support, util-linux > 2.22.2.

f2fs-tools v1.1.0 only supports file system creation.
Currently requires util-linux directly from the git repository as f2fs
support was only committed on 5 Feb 2013 and it has not yet been
released.

Closes Bug #695396 - Please apply f2fs patch
This commit is contained in:
Patrick Verner 2013-03-16 15:56:02 -05:00 committed by Mike Fleetwood
parent 897c5b3008
commit 9b649ed445
9 changed files with 114 additions and 16 deletions

1
README
View File

@ -133,6 +133,7 @@ Optional packages include:
btrfs-tools
e2fsprogs
f2fs-tools
dosfstools
mtools - required to read and write FAT16/32 volume labels and UUIDs
hfsutils

View File

@ -40,6 +40,7 @@ EXTRA_DIST = \
btrfs.h \
exfat.h \
ext2.h \
f2fs.h \
fat16.h \
fat32.h \
hfs.h \

View File

@ -66,24 +66,25 @@ enum FILESYSTEM
FS_EXT2 = 6,
FS_EXT3 = 7,
FS_EXT4 = 8,
FS_FAT16 = 9,
FS_FAT32 = 10,
FS_HFS = 11,
FS_HFSPLUS = 12,
FS_JFS = 13,
FS_LINUX_SWAP = 14,
FS_LVM2_PV = 15,
FS_NILFS2 = 16,
FS_NTFS = 17,
FS_REISER4 = 18,
FS_REISERFS = 19,
FS_UFS = 20,
FS_XFS = 21,
FS_F2FS = 9,
FS_FAT16 = 10,
FS_FAT32 = 11,
FS_HFS = 12,
FS_HFSPLUS = 13,
FS_JFS = 14,
FS_LINUX_SWAP = 15,
FS_LVM2_PV = 16,
FS_NILFS2 = 17,
FS_NTFS = 18,
FS_REISER4 = 19,
FS_REISERFS = 20,
FS_UFS = 21,
FS_XFS = 22,
FS_USED = 22,
FS_UNUSED = 23,
FS_USED = 23,
FS_UNUSED = 24,
FS_LUKS = 24
FS_LUKS = 25
} ;
enum SIZE_UNIT

36
include/f2fs.h Normal file
View File

@ -0,0 +1,36 @@
/* Copyright (C) 2013 Patrick Verner <exodusrobot@yahoo.com>
*
* 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 F2FS_H_
#define F2FS_H_
#include "../include/FileSystem.h"
namespace GParted
{
class f2fs : public FileSystem
{
public:
FS get_filesystem_support() ;
bool create( const Partition & new_partition, OperationDetail & operationdetail ) ;
};
} //GParted
#endif /* F2FS_H_ */

View File

@ -34,6 +34,7 @@ src/Win_GParted.cc
src/btrfs.cc
src/exfat.cc
src/ext2.cc
src/f2fs.cc
src/fat16.cc
src/fat32.cc
src/hfs.cc

View File

@ -33,6 +33,7 @@
#include "../include/btrfs.h"
#include "../include/exfat.h"
#include "../include/ext2.h"
#include "../include/f2fs.h"
#include "../include/fat16.h"
#include "../include/fat32.h"
#include "../include/linux_swap.h"
@ -101,6 +102,7 @@ void GParted_Core::find_supported_filesystems()
FILESYSTEM_MAP[ FS_EXT2 ] = new ext2( FS_EXT2 ) ;
FILESYSTEM_MAP[ FS_EXT3 ] = new ext2( FS_EXT3 ) ;
FILESYSTEM_MAP[ FS_EXT4 ] = new ext2( FS_EXT4 ) ;
FILESYSTEM_MAP[ FS_F2FS ] = new f2fs() ;
FILESYSTEM_MAP[ FS_FAT16 ] = new fat16() ;
FILESYSTEM_MAP[ FS_FAT32 ] = new fat32() ;
FILESYSTEM_MAP[ FS_HFS ] = new hfs() ;
@ -1237,6 +1239,8 @@ GParted::FILESYSTEM GParted_Core::get_filesystem( PedDevice* lp_device, PedParti
return GParted::FS_LINUX_SWAP ;
else if ( fs_type == "LVM2_member" )
return GParted::FS_LVM2_PV ;
else if ( fs_type == "f2fs" )
return GParted::FS_F2FS ;
else if ( fs_type == "fat16" )
return GParted::FS_FAT16 ;
else if ( fs_type == "fat32" )

View File

@ -50,6 +50,7 @@ gpartedbin_SOURCES = \
btrfs.cc \
exfat.cc \
ext2.cc \
f2fs.cc \
fat16.cc \
fat32.cc \
hfs.cc \

View File

@ -84,6 +84,7 @@ Glib::ustring Utils::get_color( FILESYSTEM filesystem )
case FS_EXT3 : return "#7590AE" ; //blue medium
case FS_EXT4 : return "#4B6983" ; //blue dark
case FS_LINUX_SWAP : return "#C1665A" ; //red medium
case FS_F2FS : return "#DF421E" ; //accent red
case FS_FAT16 : return "#00FF00" ; //green
case FS_FAT32 : return "#18D918" ; // ~ medium green
case FS_EXFAT : return "#2E8B57" ; // ~ sea green
@ -132,6 +133,11 @@ int Utils::get_filesystem_label_maxlength( FILESYSTEM filesystem )
case FS_EXT2 : return 16 ;
case FS_EXT3 : return 16 ;
case FS_EXT4 : return 16 ;
//mkfs.f2fs says that it can create file systems with labels up to 512
// characters, but it core dumps with labels of 29 characters or larger!
// Also blkid only correctly displays labels up to 19 characters.
// (Suspect it is all part of a memory corruption bug in mkfs.f2fs).
case FS_F2FS : return 19 ;
case FS_FAT16 : return 11 ;
case FS_FAT32 : return 11 ;
//mkfs.hfsplus can create hfs and hfs+ file systems with labels up to 255
@ -199,6 +205,7 @@ Glib::ustring Utils::get_filesystem_string( FILESYSTEM filesystem )
case FS_EXT3 : return "ext3" ;
case FS_EXT4 : return "ext4" ;
case FS_LINUX_SWAP : return "linux-swap" ;
case FS_F2FS : return "f2fs" ;
case FS_FAT16 : return "fat16" ;
case FS_FAT32 : return "fat32" ;
case FS_EXFAT : return "exfat" ;
@ -228,6 +235,7 @@ Glib::ustring Utils::get_filesystem_software( FILESYSTEM filesystem )
case FS_EXT2 : return "e2fsprogs" ;
case FS_EXT3 : return "e2fsprogs" ;
case FS_EXT4 : return "e2fsprogs v1.41+" ;
case FS_F2FS : return "f2fs-tools" ;
case FS_FAT16 : return "dosfstools, mtools" ;
case FS_FAT32 : return "dosfstools, mtools" ;
case FS_HFS : return "hfsutils" ;

45
src/f2fs.cc Normal file
View File

@ -0,0 +1,45 @@
/* Copyright (C) 2013 Patrick Verner <exodusrobot@yahoo.com>
*
* 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/f2fs.h"
namespace GParted
{
FS f2fs::get_filesystem_support()
{
FS fs ;
fs .filesystem = FS_F2FS ;
if ( ! Glib::find_program_in_path( "mkfs.f2fs" ) .empty() )
fs .create = GParted::FS::EXTERNAL ;
fs .copy = FS::GPARTED ;
fs .move = FS::GPARTED ;
fs .online_read = FS::GPARTED ;
return fs ;
}
bool f2fs::create( const Partition & new_partition, OperationDetail & operationdetail )
{
return (! execute_command( "mkfs.f2fs -l \"" + new_partition .get_label() + "\" " + new_partition .get_path(), operationdetail ) );
}
} //GParted