86
93
partition .Set_Unused( Utils::round( N * ( S / 512.0 ) ) ) ;
89
partition .error = error ;
92
bool jfs::Create( const Partition & new_partition, std::vector<OperationDetails> & operation_details )
94
operation_details .push_back( OperationDetails( String::ucompose(
95
_("create new %1 filesystem"),
96
Utils::get_filesystem_string( GParted::FS_JFS ) ) ) ) ;
98
if ( ! execute_command( "mkfs.jfs -q " + new_partition .get_path(), operation_details .back() .sub_details ) )
100
operation_details .back() .status = OperationDetails::SUCCES ;
105
operation_details .back() .status = OperationDetails::ERROR ;
110
bool jfs::Resize( const Partition & partition_new,
111
std::vector<OperationDetails> & operation_details,
112
bool fill_partition )
114
if ( fill_partition )
115
operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ;
117
operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ;
97
if ( ! output .empty() )
98
partition .messages .push_back( output ) ;
100
if ( ! error .empty() )
101
partition .messages .push_back( error ) ;
105
void jfs::get_label( Partition & partition )
107
if ( ! Utils::execute_command( "jfs_tune -l " + partition .get_path(), output, error, true ) )
110
index = output .find( "Volume label:" ) ;
112
if ( index < output .length() && sscanf( output .substr( index ) .c_str(), "Volume label: %512s", buf ) == 1 )
114
partition .label = buf ;
116
//remove '' from the label..
117
if ( partition .label .size() > 0 && partition .label[0] == '\'' )
118
partition .label = partition .label .substr( 1 ) ;
120
if ( partition .label .size() > 0 && partition .label[ partition .label .size() -1 ] == '\'' )
121
partition .label = partition .label .substr( 0, partition .label .size() -1 ) ;
126
if ( ! output .empty() )
127
partition .messages .push_back( output ) ;
129
if ( ! error .empty() )
130
partition .messages .push_back( error ) ;
134
bool jfs::create( const Partition & new_partition, OperationDetail & operationdetail )
136
return ! execute_command( "mkfs.jfs -q " + new_partition .get_path(), operationdetail ) ;
139
bool jfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
119
141
bool return_value = false ;
120
142
Glib::ustring error ;
121
143
Glib::ustring TEMP_MP = Glib::get_tmp_dir() + "/gparted_tmp_jfs_mountpoint" ;
123
145
//create mountpoint...
124
operation_details .back() .sub_details .push_back(
125
OperationDetails( String::ucompose( _("create temporary mountpoint (%1)"), TEMP_MP ) ) ) ;
146
operationdetail .add_child( OperationDetail( String::ucompose( _("create temporary mountpoint (%1)"), TEMP_MP ) ) ) ;
126
147
if ( ! mkdir( TEMP_MP .c_str(), 0 ) )
128
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
149
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
130
151
//mount partition
131
operation_details .back() .sub_details .push_back(
132
OperationDetails( String::ucompose( _("mount %1 on %2"), partition_new .get_path(), TEMP_MP ) ) ) ;
152
operationdetail .add_child(
153
OperationDetail( String::ucompose( _("mount %1 on %2"), partition_new .get_path(), TEMP_MP ) ) ) ;
134
155
if ( ! execute_command( "mount -v -t jfs " + partition_new .get_path() + " " + TEMP_MP,
135
operation_details .back() .sub_details .back() .sub_details ) )
156
operationdetail .get_last_child() ) )
137
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
158
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
139
160
//remount the partition to resize the filesystem
140
operation_details .back() .sub_details .push_back(
141
OperationDetails( String::ucompose( _("remount %1 on %2 with the 'resize' flag enabled"),
142
partition_new .get_path(), TEMP_MP ) ) ) ;
161
operationdetail .add_child(
162
OperationDetail( String::ucompose( _("remount %1 on %2 with the 'resize' flag enabled"),
163
partition_new .get_path(),
144
if ( ! execute_command( "mount -v -t jfs -o remount,resize " + partition_new .get_path() + " " + TEMP_MP,
145
operation_details .back() .sub_details .back() .sub_details ) )
166
if ( ! execute_command(
167
"mount -v -t jfs -o remount,resize " + partition_new .get_path() + " " + TEMP_MP,
168
operationdetail .get_last_child() ) )
147
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
170
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
148
171
return_value = true ;
152
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
175
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
155
178
//and unmount it...
156
operation_details .back() .sub_details .push_back(
157
OperationDetails( String::ucompose( _("unmount %1"), partition_new .get_path() ) ) ) ;
179
operationdetail .add_child(
180
OperationDetail( String::ucompose( _("unmount %1"), partition_new .get_path() ) ) ) ;
159
182
if ( ! execute_command( "umount -v " + partition_new .get_path(),
160
operation_details .back() .sub_details .back() .sub_details ) )
183
operationdetail .get_last_child() ) )
162
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
185
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
166
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
189
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
167
190
return_value = false ;
172
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
195
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
175
198
//remove the mountpoint..
176
operation_details .back() .sub_details .push_back(
177
OperationDetails( String::ucompose( _("remove temporary mountpoint (%1)"), TEMP_MP ) ) ) ;
199
operationdetail .add_child(
200
OperationDetail( String::ucompose( _("remove temporary mountpoint (%1)"), TEMP_MP ) ) ) ;
178
201
if ( ! rmdir( TEMP_MP .c_str() ) )
180
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
203
operationdetail .get_last_child() .set_status( STATUS_SUCCES ) ;
184
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
185
operation_details .back() .sub_details .back() .sub_details .push_back(
186
OperationDetails( Glib::strerror( errno ), OperationDetails::NONE ) ) ;
207
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
208
operationdetail .get_last_child() .add_child(
209
OperationDetail( Glib::strerror( errno ), STATUS_NONE ) ) ;
188
211
return_value = false ;
193
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
194
operation_details .back() .sub_details .back() .sub_details .push_back(
195
OperationDetails( Glib::strerror( errno ), OperationDetails::NONE ) ) ;
216
operationdetail .get_last_child() .set_status( STATUS_ERROR ) ;
217
operationdetail .get_last_child() .add_child(
218
OperationDetail( Glib::strerror( errno ), STATUS_NONE ) ) ;
198
operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ;
199
221
return return_value ;
202
bool jfs::Copy( const Glib::ustring & src_part_path,
224
bool jfs::copy( const Glib::ustring & src_part_path,
203
225
const Glib::ustring & dest_part_path,
204
std::vector<OperationDetails> & operation_details )
226
OperationDetail & operationdetail )
206
operation_details .push_back( OperationDetails(
207
String::ucompose( _("copy contents of %1 to %2"), src_part_path, dest_part_path ) ) ) ;
209
if ( ! execute_command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path,
210
operation_details .back() .sub_details ) )
212
operation_details .back() .status = OperationDetails::SUCCES ;
218
operation_details .back() .status = OperationDetails::ERROR ;
223
bool jfs::Check_Repair( const Partition & partition, std::vector<OperationDetails> & operation_details )
231
bool jfs::check_repair( const Partition & partition, OperationDetail & operationdetail )
225
operation_details .push_back( OperationDetails(
226
String::ucompose( _("check filesystem on %1 for errors and (if possible) fix them"),
227
partition .get_path() ) ) ) ;
233
exit_status = execute_command( "jfs_fsck -f " + partition .get_path(), operationdetail ) ;
229
exit_status = execute_command( "jfs_fsck -f " + partition .get_path(), operation_details .back() .sub_details ) ;
230
if ( exit_status == 0 || exit_status == 1 )
232
operation_details .back() .status = OperationDetails::SUCCES ;
237
operation_details .back() .status = OperationDetails::ERROR ;
235
return ( exit_status == 0 || exit_status == 1 ) ;