~ubuntu-branches/ubuntu/precise/gparted/precise-security

« back to all changes in this revision

Viewing changes to src/btrfs.cc

  • Committer: Colin Watson
  • Date: 2010-07-15 12:06:59 UTC
  • Revision ID: cjwatson@canonical.com-20100715120659-2wynlx97k2tmiko2
add forgotten files from patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2009 Luca Bruno <lucab@debian.org>
 
2
 *
 
3
 *  This program is free software; you can redistribute it and/or modify
 
4
 *  it under the terms of the GNU General Public License as published by
 
5
 *  the Free Software Foundation; either version 2 of the License, or
 
6
 *  (at your option) any later version.
 
7
 *
 
8
 *  This program is distributed in the hope that it will be useful,
 
9
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 *  GNU Library General Public License for more details.
 
12
 *
 
13
 *  You should have received a copy of the GNU General Public License
 
14
 *  along with this program; if not, write to the Free Software
 
15
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
16
 */
 
17
 
 
18
 
 
19
#include "../include/btrfs.h"
 
20
 
 
21
namespace GParted
 
22
{
 
23
 
 
24
FS btrfs::get_filesystem_support()
 
25
{
 
26
        FS fs ;
 
27
        fs .filesystem = GParted::FS_BTRFS ;
 
28
        
 
29
        if ( ! Glib::find_program_in_path( "btrfs-show" ) .empty() )
 
30
        {
 
31
                fs .read = GParted::FS::EXTERNAL ;
 
32
                fs .read_label = FS::EXTERNAL ;
 
33
        }
 
34
 
 
35
        if ( ! Glib::find_program_in_path( "mkfs.btrfs" ) .empty() )
 
36
                fs .create = GParted::FS::EXTERNAL ;
 
37
        
 
38
        if ( ! Glib::find_program_in_path( "btrfsck" ) .empty() )
 
39
                fs .check = GParted::FS::EXTERNAL ;
 
40
                
 
41
        if ( fs .check )
 
42
        {
 
43
                fs .copy = GParted::FS::GPARTED ;
 
44
                fs .move = GParted::FS::GPARTED ;
 
45
        }
 
46
 
 
47
        fs .MIN = 256 * MEBIBYTE ;
 
48
        
 
49
        return fs ;
 
50
}
 
51
 
 
52
bool btrfs::create( const Partition & new_partition, OperationDetail & operationdetail )
 
53
{
 
54
        return (! execute_command( "mkfs.btrfs -L \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) );
 
55
}
 
56
 
 
57
bool btrfs::check_repair( const Partition & partition, OperationDetail & operationdetail )
 
58
{
 
59
        return (! execute_command( "btrfsck " + partition .get_path(), operationdetail )) ;
 
60
}
 
61
 
 
62
void btrfs::set_used_sectors( Partition & partition )
 
63
{
 
64
// TODO
 
65
    return;
 
66
}
 
67
 
 
68
bool btrfs::write_label( const Partition & partition, OperationDetail & operationdetail )
 
69
{
 
70
// TODO
 
71
        return true ;
 
72
}
 
73
 
 
74
bool btrfs::copy( const Glib::ustring & src_part_path,
 
75
                    const Glib::ustring & dest_part_path,
 
76
                    OperationDetail & operationdetail )
 
77
{
 
78
// TODO
 
79
        return true ;
 
80
}
 
81
 
 
82
bool btrfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
 
83
{
 
84
// TODO
 
85
        return true ;
 
86
}
 
87
 
 
88
void btrfs::read_label( Partition & partition )
 
89
{
 
90
        if ( ! Utils::execute_command( "btrfs-show " + partition .get_path(), output, error, true ) )
 
91
        {
 
92
                partition .label = Utils::regexp_label( output, "^Label ([^\n\t]*)" ) ;
 
93
        }
 
94
        else
 
95
        {
 
96
                if ( ! output .empty() )
 
97
                        partition .messages .push_back( output ) ;
 
98
 
 
99
                if ( ! error .empty() )
 
100
                        partition .messages .push_back( error ) ;
 
101
        }
 
102
 
 
103
}
 
104
 
 
105
} //GParted
 
106
 
 
107