1
1
/* Copyright (C) 2009,2010 Luca Bruno <lucab@debian.org>
2
* Copyright (C) 2010 Curtis Gedak
2
* Copyright (C) 2010, 2011 Curtis Gedak
4
4
* This program is free software; you can redistribute it and/or modify
5
5
* it under the terms of the GNU General Public License as published by
39
39
if ( ! Glib::find_program_in_path( "btrfsck" ) .empty() )
40
40
fs .check = GParted::FS::EXTERNAL ;
42
//resizing of btrfs requires btrfsctl, mount, and umount
43
if ( ! Glib::find_program_in_path( "btrfsctl" ) .empty()
44
&& ! Glib::find_program_in_path( "mount" ) .empty()
45
&& ! Glib::find_program_in_path( "umount" ) .empty()
49
fs .grow = FS::EXTERNAL ;
50
if ( fs .read ) //needed to determine a minimum file system size.
51
fs .shrink = FS::EXTERNAL ;
44
56
fs .copy = GParted::FS::GPARTED ;
126
138
bool btrfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
141
Glib::ustring str_temp = _( "create temporary directory" ) ;
142
operationdetail .add_child( OperationDetail( str_temp, STATUS_NONE, FONT_BOLD_ITALIC ) ) ;
143
char dtemplate[] = "/tmp/gparted-XXXXXXXX" ;
144
Glib::ustring dname = mkdtemp( dtemplate ) ;
147
//Failed to create temporary directory
148
str_temp = _( "Failed to create temporary directory." );
149
operationdetail .get_last_child() .add_child( OperationDetail( str_temp, STATUS_NONE, FONT_ITALIC ) ) ;
153
/*TO TRANSLATORS: looks like Created temporary directory /tmp/gparted-XXCOOO8U */
154
str_temp = String::ucompose ( _("Created temporary directory %1"), dname ) ;
155
operationdetail .get_last_child() .add_child( OperationDetail( str_temp, STATUS_NONE, FONT_ITALIC ) ) ;
157
//Mount file system. Needed to resize btrfs.
158
str_temp = "mount -v -t btrfs " + partition_new .get_path() + " " + dname ;
159
exit_status = ! execute_command( str_temp, operationdetail ) ;
163
//Build resize command
164
str_temp = "btrfsctl" ;
165
if ( ! fill_partition )
167
str_temp += " -r " + Utils::num_to_str( floor( Utils::sector_to_unit(
168
partition_new .get_sector_length(), partition_new .sector_size, UNIT_KIB ) ) ) + "K" ;
171
str_temp += " -r max" ;
172
str_temp += " " + dname ;
174
//Execute the command
175
exit_status = execute_command( str_temp, operationdetail ) ;
176
//Sometimes btrfsctl returns an exit status of 256 on successful resize.
177
exit_status = ( exit_status == 0 || exit_status == 256 ) ;
179
//Always unmount the file system
180
str_temp = "umount -v " + dname ;
181
execute_command( str_temp, operationdetail ) ;
184
//Always remove the temporary directory name
185
str_temp = "rmdir -v " + dname ;
186
execute_command( str_temp, operationdetail ) ;
132
191
void btrfs::read_label( Partition & partition )