1
/* Copyright (C) 2009,2010 Luca Bruno <lucab@debian.org>
2
* Copyright (C) 2010 Curtis Gedak
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU Library General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
#include "../include/btrfs.h"
25
FS btrfs::get_filesystem_support()
28
fs .filesystem = GParted::FS_BTRFS ;
30
if ( ! Glib::find_program_in_path( "btrfs-show" ) .empty() )
32
fs .read = GParted::FS::EXTERNAL ;
33
fs .read_label = FS::EXTERNAL ;
36
if ( ! Glib::find_program_in_path( "mkfs.btrfs" ) .empty() )
37
fs .create = GParted::FS::EXTERNAL ;
39
if ( ! Glib::find_program_in_path( "btrfsck" ) .empty() )
40
fs .check = GParted::FS::EXTERNAL ;
44
fs .copy = GParted::FS::GPARTED ;
45
fs .move = GParted::FS::GPARTED ;
48
fs .MIN = 256 * MEBIBYTE ;
53
bool btrfs::create( const Partition & new_partition, OperationDetail & operationdetail )
55
return (! execute_command( "mkfs.btrfs -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) );
58
bool btrfs::check_repair( const Partition & partition, OperationDetail & operationdetail )
60
return (! execute_command( "btrfsck " + partition .get_path(), operationdetail )) ;
63
void btrfs::set_used_sectors( Partition & partition )
65
if ( ! Utils::execute_command( "btrfs-show " + partition .get_path(), output, error, true ) )
67
Glib::ustring size_label;
68
if ( ((index = output .find( "FS bytes" )) < output .length()) &&
69
(size_label=Utils::regexp_label(output .substr( index ), "^FS bytes used (.*)B")) .length() > 0)
72
gdouble rawN = g_ascii_strtod (size_label.c_str(),&suffix);
73
unsigned long long mult=0;
91
partition .set_used( Utils::round( (rawN * mult)/ double(partition .sector_size) ) ) ;
96
if ( ! output .empty() )
97
partition .messages .push_back( output ) ;
99
if ( ! error .empty() )
100
partition .messages .push_back( error ) ;
104
bool btrfs::write_label( const Partition & partition, OperationDetail & operationdetail )
110
bool btrfs::move( const Partition & partition_new
111
, const Partition & partition_old
112
, OperationDetail & operationdetail
118
bool btrfs::copy( const Glib::ustring & src_part_path,
119
const Glib::ustring & dest_part_path,
120
OperationDetail & operationdetail )
126
bool btrfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
132
void btrfs::read_label( Partition & partition )
134
if ( ! Utils::execute_command( "btrfs-show " + partition .get_path(), output, error, true ) )
136
partition .label = Utils::regexp_label( output, "^Label ([^\n\t]*)" ) ;
140
if ( ! output .empty() )
141
partition .messages .push_back( output ) ;
143
if ( ! error .empty() )
144
partition .messages .push_back( error ) ;