2011-12-08 05:45:12 -07:00
|
|
|
/* Copyright (C) 2011 Mike Fleetwood
|
|
|
|
*
|
|
|
|
* 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
|
2014-01-23 03:59:48 -07:00
|
|
|
* GNU General Public License for more details.
|
2011-12-08 05:45:12 -07:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-23 03:59:48 -07:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2011-12-08 05:45:12 -07:00
|
|
|
*/
|
|
|
|
|
2016-10-18 16:45:28 -06:00
|
|
|
#include "nilfs2.h"
|
2018-01-18 09:26:20 -07:00
|
|
|
#include "FileSystem.h"
|
2016-10-18 16:45:28 -06:00
|
|
|
#include "Partition.h"
|
2011-12-08 05:45:12 -07:00
|
|
|
|
2018-12-04 09:46:27 -07:00
|
|
|
#include <glibmm/miscutils.h>
|
|
|
|
#include <glibmm/shell.h>
|
|
|
|
|
|
|
|
|
2011-12-08 05:45:12 -07:00
|
|
|
namespace GParted
|
|
|
|
{
|
|
|
|
|
|
|
|
FS nilfs2::get_filesystem_support()
|
|
|
|
{
|
2015-11-13 14:46:57 -07:00
|
|
|
FS fs( FS_NILFS2 );
|
2011-12-08 05:45:12 -07:00
|
|
|
|
2014-02-14 18:26:32 -07:00
|
|
|
fs .busy = FS::GPARTED ;
|
|
|
|
|
2011-12-08 05:45:12 -07:00
|
|
|
if ( ! Glib::find_program_in_path( "mkfs.nilfs2" ) .empty() )
|
|
|
|
{
|
2018-10-13 05:59:31 -06:00
|
|
|
fs.create = FS::EXTERNAL;
|
|
|
|
fs.create_with_label = FS::EXTERNAL;
|
2011-12-08 05:45:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! Glib::find_program_in_path( "nilfs-tune" ) .empty() )
|
|
|
|
{
|
2018-10-13 05:59:31 -06:00
|
|
|
fs.read = FS::EXTERNAL;
|
|
|
|
fs.read_label = FS::EXTERNAL;
|
|
|
|
fs.write_label = FS::EXTERNAL;
|
|
|
|
fs.read_uuid = FS::EXTERNAL;
|
|
|
|
fs.write_uuid = FS::EXTERNAL;
|
2011-12-08 05:45:12 -07:00
|
|
|
}
|
|
|
|
|
2012-02-05 02:06:44 -07:00
|
|
|
//Nilfs2 resizing is an online only operation and needs:
|
|
|
|
// mount, umount, nilfs-resize and linux >= 3.0 with nilfs2 support.
|
|
|
|
if ( ! Glib::find_program_in_path( "mount" ) .empty() &&
|
|
|
|
! Glib::find_program_in_path( "umount" ) .empty() &&
|
|
|
|
! Glib::find_program_in_path( "nilfs-resize" ) .empty() &&
|
|
|
|
Utils::kernel_supports_fs( "nilfs2" ) &&
|
|
|
|
Utils::kernel_version_at_least( 3, 0, 0 ) )
|
|
|
|
{
|
2018-10-13 05:59:31 -06:00
|
|
|
fs.grow = FS::EXTERNAL;
|
2012-02-05 02:06:44 -07:00
|
|
|
if ( fs .read ) //needed to determine a minimum file system size.
|
2018-10-13 05:59:31 -06:00
|
|
|
fs.shrink = FS::EXTERNAL;
|
2012-02-05 02:06:44 -07:00
|
|
|
}
|
2011-12-27 11:31:10 -07:00
|
|
|
|
2018-10-13 05:59:31 -06:00
|
|
|
fs.copy = FS::GPARTED;
|
|
|
|
fs.move = FS::GPARTED;
|
2012-09-10 09:41:58 -06:00
|
|
|
fs .online_read = FS::GPARTED ;
|
2013-11-15 09:27:12 -07:00
|
|
|
#ifdef ENABLE_ONLINE_RESIZE
|
|
|
|
if ( Utils::kernel_version_at_least( 3, 6, 0 ) )
|
|
|
|
{
|
|
|
|
fs .online_grow = fs .grow ;
|
|
|
|
fs .online_shrink = fs .shrink ;
|
|
|
|
}
|
|
|
|
#endif
|
2011-12-08 05:45:12 -07:00
|
|
|
|
2011-12-27 11:31:10 -07:00
|
|
|
//Minimum FS size is 128M+4K using mkfs.nilfs2 defaults
|
2018-01-11 16:21:56 -07:00
|
|
|
fs_limits.min_size = 128 * MEBIBYTE + 4 * KIBIBYTE;
|
2011-12-27 11:31:10 -07:00
|
|
|
|
2011-12-08 05:45:12 -07:00
|
|
|
return fs ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nilfs2::set_used_sectors( Partition & partition )
|
|
|
|
{
|
2017-09-03 01:52:54 -06:00
|
|
|
if ( ! Utils::execute_command( "nilfs-tune -l " + Glib::shell_quote( partition.get_path() ),
|
|
|
|
output, error, true ) )
|
2011-12-08 05:45:12 -07:00
|
|
|
{
|
Query unallocated space for unmounted file systems (#499202)
Update file system specific implementations to set the size and free
space, thus allowing the unallocated space in the partition to be
calculated, for the following unmounted file systems:
btrfs, ext2, ext3, ext4, fat16, fat32, jfs, nilfs2, ntfs, reiserfs,
reiser4, xfs
Bug #499202 - gparted does not see the difference if partition size
differs from filesystem size
2012-01-10 08:19:01 -07:00
|
|
|
//File system size in bytes
|
|
|
|
Glib::ustring::size_type index = output .find( "Device size:" ) ;
|
|
|
|
if ( index == Glib::ustring::npos
|
2016-06-30 04:56:10 -06:00
|
|
|
|| sscanf( output.substr( index ).c_str(), "Device size: %lld", &T ) != 1
|
Query unallocated space for unmounted file systems (#499202)
Update file system specific implementations to set the size and free
space, thus allowing the unallocated space in the partition to be
calculated, for the following unmounted file systems:
btrfs, ext2, ext3, ext4, fat16, fat32, jfs, nilfs2, ntfs, reiserfs,
reiser4, xfs
Bug #499202 - gparted does not see the difference if partition size
differs from filesystem size
2012-01-10 08:19:01 -07:00
|
|
|
)
|
|
|
|
T = -1 ;
|
|
|
|
|
|
|
|
//Free space in blocks
|
|
|
|
index = output .find( "Free blocks count:" ) ;
|
2011-12-08 05:45:12 -07:00
|
|
|
if ( index == Glib::ustring::npos
|
2016-06-30 04:56:10 -06:00
|
|
|
|| sscanf( output.substr( index ).c_str(), "Free blocks count: %lld", &N ) != 1
|
2011-12-08 05:45:12 -07:00
|
|
|
)
|
|
|
|
N = -1 ;
|
|
|
|
|
|
|
|
index = output .find( "Block size:" ) ;
|
|
|
|
if ( index == Glib::ustring::npos
|
2016-06-30 04:56:10 -06:00
|
|
|
|| sscanf( output.substr( index ).c_str(), "Block size: %lld", &S ) != 1
|
2011-12-08 05:45:12 -07:00
|
|
|
)
|
|
|
|
S = -1 ;
|
|
|
|
|
Query unallocated space for unmounted file systems (#499202)
Update file system specific implementations to set the size and free
space, thus allowing the unallocated space in the partition to be
calculated, for the following unmounted file systems:
btrfs, ext2, ext3, ext4, fat16, fat32, jfs, nilfs2, ntfs, reiserfs,
reiser4, xfs
Bug #499202 - gparted does not see the difference if partition size
differs from filesystem size
2012-01-10 08:19:01 -07:00
|
|
|
if ( T > -1 && N > -1 && S > -1 )
|
|
|
|
{
|
|
|
|
T = Utils::round( T / double(partition .sector_size) ) ;
|
|
|
|
N = Utils::round( N * ( S / double(partition .sector_size) ) ) ;
|
|
|
|
partition .set_sector_usage( T, N ) ;
|
2016-01-16 03:40:58 -07:00
|
|
|
partition.fs_block_size = S;
|
Query unallocated space for unmounted file systems (#499202)
Update file system specific implementations to set the size and free
space, thus allowing the unallocated space in the partition to be
calculated, for the following unmounted file systems:
btrfs, ext2, ext3, ext4, fat16, fat32, jfs, nilfs2, ntfs, reiserfs,
reiser4, xfs
Bug #499202 - gparted does not see the difference if partition size
differs from filesystem size
2012-01-10 08:19:01 -07:00
|
|
|
}
|
2011-12-08 05:45:12 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( ! output .empty() )
|
2015-12-31 09:32:08 -07:00
|
|
|
partition.push_back_message( output );
|
2011-12-08 05:45:12 -07:00
|
|
|
|
|
|
|
if ( ! error .empty() )
|
2015-12-31 09:32:08 -07:00
|
|
|
partition.push_back_message( error );
|
2011-12-08 05:45:12 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nilfs2::read_label( Partition & partition )
|
|
|
|
{
|
2017-09-03 01:52:54 -06:00
|
|
|
if ( ! Utils::execute_command( "nilfs-tune -l " + Glib::shell_quote( partition.get_path() ),
|
|
|
|
output, error, true ) )
|
2011-12-08 05:45:12 -07:00
|
|
|
{
|
|
|
|
Glib::ustring label = Utils::regexp_label( output, "^Filesystem volume name:[\t ]*(.*)$" ) ;
|
|
|
|
if ( label != "(none)" )
|
2014-12-16 15:04:34 -07:00
|
|
|
partition.set_filesystem_label( label );
|
2012-10-08 07:23:17 -06:00
|
|
|
else
|
2014-12-16 15:04:34 -07:00
|
|
|
partition.set_filesystem_label( "" );
|
2011-12-08 05:45:12 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( ! output .empty() )
|
2015-12-31 09:32:08 -07:00
|
|
|
partition.push_back_message( output );
|
2011-12-08 05:45:12 -07:00
|
|
|
|
|
|
|
if ( ! error .empty() )
|
2015-12-31 09:32:08 -07:00
|
|
|
partition.push_back_message( error );
|
2011-12-08 05:45:12 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool nilfs2::write_label( const Partition & partition, OperationDetail & operationdetail )
|
|
|
|
{
|
2017-09-03 01:52:54 -06:00
|
|
|
return ! execute_command( "nilfs-tune -L " + Glib::shell_quote( partition.get_filesystem_label() ) +
|
|
|
|
" " + Glib::shell_quote( partition.get_path() ),
|
Time and check nearly all file system action commands (#754684)
There has been an undocumented rule that external commands displayed in
the operation details, as part of file system manipulations, only get a
time and check mark displayed when multiple commands are needed, and not
otherwise. (GParted checks whether all commands are successful or not
regardless of whether a check mark is displayed in the operation details
or not).
EXCEPTION 1: btrfs resize
Since the following commit [1] from 2013-02-22, GParted stopped
displaying the timing for the btrfs resize command in the operation
details. It being part of a multi-command sequence to perform the step.
This is because FileSystem::execute_command() since the commit can only
check the exit status for zero / non-zero while timing and checking the
command status but btrfs resize needs to consider some non-zero statuses
as successful.
[1] 52a2a9b00a32996921ace055e71d0e09fb33c5fe
Reduce threading (#685740)
EXCEPTION 2: ext2/3/4 move and copy using e2image
When use of e2image was added [2] the single command steps were timed
and check.
[2] 86111fe12a26d23d9fc2a9e2d19281290ecaf985
Use e2image to move/copy ext[234] file systems (#721516)
EXCEPTION 3: fat16/32 write label and UUID
Uses Utils::execute_command() rather than FileSystem::execute_command()
so can be separately changed. See the following commit for resolution
of the final commands not yet timed and check mark displayed.
CHANGE:
Lets make a simpler rule of always displaying the time and a check mark
for all external commands displayed in the operation details. However
this makes several of the other single command actions need special exit
status handling because zero success, non-zero failure is not correct
for every case. Specifically affects resizing of reiserfs and check
repair of ext2/3/4, fat16/32, jfs and reiserfs.
After this change all external commands run as file system actions must
follow one of these two patterns of using the EXEC_CHECK_STATUS flag or
separately calling FileSystem::set_status() to register success or
failure of the command:
exit_status = execute_command(cmd, od, EXEC_CHECK_STATUS...);
or:
exit_status = execute_command(cmd, od, ...);
bool success = (exit_status == 0 || exit_status == OTHER_SUCCESS_VALUE...);
set_status(od, success );
Bug 754684 - Updates to FileSystem:: and Utils::execute_command()
functions
2015-09-05 02:31:16 -06:00
|
|
|
operationdetail, EXEC_CHECK_STATUS );
|
2011-12-08 05:45:12 -07:00
|
|
|
}
|
|
|
|
|
2012-01-22 13:49:52 -07:00
|
|
|
void nilfs2::read_uuid( Partition & partition )
|
|
|
|
{
|
2017-09-03 01:52:54 -06:00
|
|
|
if ( ! Utils::execute_command( "nilfs-tune -l " + Glib::shell_quote( partition.get_path() ),
|
|
|
|
output, error, true ) )
|
2012-01-22 13:49:52 -07:00
|
|
|
{
|
2012-09-23 08:44:40 -06:00
|
|
|
partition .uuid = Utils::regexp_label( output, "^Filesystem UUID:[[:blank:]]*(" RFC4122_NONE_NIL_UUID_REGEXP ")" ) ;
|
2012-01-22 13:49:52 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( ! output .empty() )
|
2015-12-31 09:32:08 -07:00
|
|
|
partition.push_back_message( output );
|
2012-01-22 13:49:52 -07:00
|
|
|
|
|
|
|
if ( ! error .empty() )
|
2015-12-31 09:32:08 -07:00
|
|
|
partition.push_back_message( error );
|
2012-01-22 13:49:52 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool nilfs2::write_uuid( const Partition & partition, OperationDetail & operationdetail )
|
|
|
|
{
|
2017-09-03 01:52:54 -06:00
|
|
|
return ! execute_command( "nilfs-tune -U " + Glib::shell_quote( Utils::generate_uuid() ) +
|
|
|
|
" " + Glib::shell_quote( partition .get_path() ),
|
Time and check nearly all file system action commands (#754684)
There has been an undocumented rule that external commands displayed in
the operation details, as part of file system manipulations, only get a
time and check mark displayed when multiple commands are needed, and not
otherwise. (GParted checks whether all commands are successful or not
regardless of whether a check mark is displayed in the operation details
or not).
EXCEPTION 1: btrfs resize
Since the following commit [1] from 2013-02-22, GParted stopped
displaying the timing for the btrfs resize command in the operation
details. It being part of a multi-command sequence to perform the step.
This is because FileSystem::execute_command() since the commit can only
check the exit status for zero / non-zero while timing and checking the
command status but btrfs resize needs to consider some non-zero statuses
as successful.
[1] 52a2a9b00a32996921ace055e71d0e09fb33c5fe
Reduce threading (#685740)
EXCEPTION 2: ext2/3/4 move and copy using e2image
When use of e2image was added [2] the single command steps were timed
and check.
[2] 86111fe12a26d23d9fc2a9e2d19281290ecaf985
Use e2image to move/copy ext[234] file systems (#721516)
EXCEPTION 3: fat16/32 write label and UUID
Uses Utils::execute_command() rather than FileSystem::execute_command()
so can be separately changed. See the following commit for resolution
of the final commands not yet timed and check mark displayed.
CHANGE:
Lets make a simpler rule of always displaying the time and a check mark
for all external commands displayed in the operation details. However
this makes several of the other single command actions need special exit
status handling because zero success, non-zero failure is not correct
for every case. Specifically affects resizing of reiserfs and check
repair of ext2/3/4, fat16/32, jfs and reiserfs.
After this change all external commands run as file system actions must
follow one of these two patterns of using the EXEC_CHECK_STATUS flag or
separately calling FileSystem::set_status() to register success or
failure of the command:
exit_status = execute_command(cmd, od, EXEC_CHECK_STATUS...);
or:
exit_status = execute_command(cmd, od, ...);
bool success = (exit_status == 0 || exit_status == OTHER_SUCCESS_VALUE...);
set_status(od, success );
Bug 754684 - Updates to FileSystem:: and Utils::execute_command()
functions
2015-09-05 02:31:16 -06:00
|
|
|
operationdetail, EXEC_CHECK_STATUS );
|
2012-01-22 13:49:52 -07:00
|
|
|
}
|
|
|
|
|
2011-12-08 05:45:12 -07:00
|
|
|
bool nilfs2::create( const Partition & new_partition, OperationDetail & operationdetail )
|
|
|
|
{
|
2017-09-03 01:52:54 -06:00
|
|
|
return ! execute_command( "mkfs.nilfs2 -L " + Glib::shell_quote( new_partition.get_filesystem_label() ) +
|
|
|
|
" " + Glib::shell_quote( new_partition.get_path() ),
|
Time and check nearly all file system action commands (#754684)
There has been an undocumented rule that external commands displayed in
the operation details, as part of file system manipulations, only get a
time and check mark displayed when multiple commands are needed, and not
otherwise. (GParted checks whether all commands are successful or not
regardless of whether a check mark is displayed in the operation details
or not).
EXCEPTION 1: btrfs resize
Since the following commit [1] from 2013-02-22, GParted stopped
displaying the timing for the btrfs resize command in the operation
details. It being part of a multi-command sequence to perform the step.
This is because FileSystem::execute_command() since the commit can only
check the exit status for zero / non-zero while timing and checking the
command status but btrfs resize needs to consider some non-zero statuses
as successful.
[1] 52a2a9b00a32996921ace055e71d0e09fb33c5fe
Reduce threading (#685740)
EXCEPTION 2: ext2/3/4 move and copy using e2image
When use of e2image was added [2] the single command steps were timed
and check.
[2] 86111fe12a26d23d9fc2a9e2d19281290ecaf985
Use e2image to move/copy ext[234] file systems (#721516)
EXCEPTION 3: fat16/32 write label and UUID
Uses Utils::execute_command() rather than FileSystem::execute_command()
so can be separately changed. See the following commit for resolution
of the final commands not yet timed and check mark displayed.
CHANGE:
Lets make a simpler rule of always displaying the time and a check mark
for all external commands displayed in the operation details. However
this makes several of the other single command actions need special exit
status handling because zero success, non-zero failure is not correct
for every case. Specifically affects resizing of reiserfs and check
repair of ext2/3/4, fat16/32, jfs and reiserfs.
After this change all external commands run as file system actions must
follow one of these two patterns of using the EXEC_CHECK_STATUS flag or
separately calling FileSystem::set_status() to register success or
failure of the command:
exit_status = execute_command(cmd, od, EXEC_CHECK_STATUS...);
or:
exit_status = execute_command(cmd, od, ...);
bool success = (exit_status == 0 || exit_status == OTHER_SUCCESS_VALUE...);
set_status(od, success );
Bug 754684 - Updates to FileSystem:: and Utils::execute_command()
functions
2015-09-05 02:31:16 -06:00
|
|
|
operationdetail, EXEC_CHECK_STATUS );
|
2011-12-08 05:45:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool nilfs2::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
|
|
|
|
{
|
2011-12-27 11:31:10 -07:00
|
|
|
bool success = true ;
|
|
|
|
|
2013-11-15 09:27:12 -07:00
|
|
|
Glib::ustring mount_point ;
|
|
|
|
if ( ! partition_new .busy )
|
|
|
|
{
|
|
|
|
mount_point = mk_temp_dir( "", operationdetail ) ;
|
|
|
|
if ( mount_point .empty() )
|
|
|
|
return false ;
|
2011-12-27 11:31:10 -07:00
|
|
|
|
2017-09-03 01:52:54 -06:00
|
|
|
success &= ! execute_command( "mount -v -t nilfs2 " + Glib::shell_quote( partition_new.get_path() ) +
|
|
|
|
" " + Glib::shell_quote( mount_point ),
|
Refactor flags in method FileSystem::execute_command() (#754684)
Change the two optional boolean parameters into a single optional flags
parameter which uses symbolically defined names. Makes reading the
execute_command() calls much easier to understand. (Implemented as bit
field using the same technique as used for Glib::SpawnFlags [1]).
This changes the calls thus:
execute_command(cmd, od) -> (cmd, od)
execute_command(cmd, od, false) -> (cmd, od, EXEC_NONE) // [2]
execute_command(cmd, od, true ) -> (cmd, od, EXEC_CHECK_STATUS)
execute_command(cmd, od, false, true) -> (cmd, od, EXEC_CANCEL_SAFE)
execute_command(cmd, od, true , true) ->
(cmd, od, EXEC_CHECK_STATUS|EXEC_CANCEL_SAFE)
[1] SpawnFlags bitwise operators in
/usr/include/glibmm-2.4/glibmm/spawn.h.
[2] False and EXEC_NONE are the default values for the optional third
parameter before and after this change respectively and both mean
the same. This is being used in btrfs::resize() and being kept for
now despite it being the default.
Bug 754684 - Updates to FileSystem:: and Utils::execute_command()
functions
2015-08-29 08:15:24 -06:00
|
|
|
operationdetail, EXEC_CHECK_STATUS );
|
2013-11-15 09:27:12 -07:00
|
|
|
}
|
2011-12-27 11:31:10 -07:00
|
|
|
|
|
|
|
if ( success )
|
|
|
|
{
|
2017-09-03 01:52:54 -06:00
|
|
|
Glib::ustring cmd = "nilfs-resize -v -y " + Glib::shell_quote( partition_new.get_path() );
|
2011-12-27 11:31:10 -07:00
|
|
|
if ( ! fill_partition )
|
|
|
|
{
|
|
|
|
Glib::ustring size = Utils::num_to_str( floor( Utils::sector_to_unit(
|
|
|
|
partition_new .get_sector_length(), partition_new .sector_size, UNIT_KIB ) ) ) + "K" ;
|
|
|
|
cmd += " " + size ;
|
|
|
|
}
|
Refactor flags in method FileSystem::execute_command() (#754684)
Change the two optional boolean parameters into a single optional flags
parameter which uses symbolically defined names. Makes reading the
execute_command() calls much easier to understand. (Implemented as bit
field using the same technique as used for Glib::SpawnFlags [1]).
This changes the calls thus:
execute_command(cmd, od) -> (cmd, od)
execute_command(cmd, od, false) -> (cmd, od, EXEC_NONE) // [2]
execute_command(cmd, od, true ) -> (cmd, od, EXEC_CHECK_STATUS)
execute_command(cmd, od, false, true) -> (cmd, od, EXEC_CANCEL_SAFE)
execute_command(cmd, od, true , true) ->
(cmd, od, EXEC_CHECK_STATUS|EXEC_CANCEL_SAFE)
[1] SpawnFlags bitwise operators in
/usr/include/glibmm-2.4/glibmm/spawn.h.
[2] False and EXEC_NONE are the default values for the optional third
parameter before and after this change respectively and both mean
the same. This is being used in btrfs::resize() and being kept for
now despite it being the default.
Bug 754684 - Updates to FileSystem:: and Utils::execute_command()
functions
2015-08-29 08:15:24 -06:00
|
|
|
success &= ! execute_command( cmd, operationdetail, EXEC_CHECK_STATUS );
|
2011-12-27 11:31:10 -07:00
|
|
|
|
2013-11-15 09:27:12 -07:00
|
|
|
if ( ! partition_new. busy )
|
2017-09-03 01:52:54 -06:00
|
|
|
success &= ! execute_command( "umount -v " + Glib::shell_quote( mount_point ),
|
Quote mount point when resizing nilfs2 (#782681)
The current nilfs2 resizing code is safe because it never passes a user
influenced mount point into a command line. Regardless, apply the same
simple rule to always quote mount points when used in command lines.
WARNING:
Nilfs-resize is broken and can't actually resize a file system mounted
with spaces in the mount point anyway!
# mkdir "/tmp/File System Label"
# mount -v -t nilfs2 /dev/sdb3 "/tmp/File System Label"
mount.nilfs2: started nilfs_cleanerd
# nilfs-resize -v -y /dev/sdb3
Error: cannot open NILFS on /dev/sdb3.
# echo $?
1
# strace nilfs-resize -v -y /dev/sdb3
...
stat("/dev/sdb3", {st_mode=S_IFBLK|0660, st_rdev=makedev(8, 19), ...}) = 0
open("/dev/sdb3", O_RDONLY) = 3
...
open("/proc/mounts", O_RDONLY) = 4
read(4, "sysfs /sys sysfs rw,seclabel,nos"..., 1024) = 1024
...
close(4) = 0
open("/tmp/File\\040System\\040Label", O_RDONLY) = -1 ENOENT (No such file or directory)
...
# fgrep /dev/sd /proc/mounts
/dev/sda3 / ext4 rw,seclabel,relatime,data=ordered 0 0
/dev/sda1 /boot ext4 rw,seclabel,relatime,data=ordered 0 0
/dev/sdb3 /tmp/File\040System\040Label nilfs2 rw,relatime 0 0
So it looks like nilfs-resize (or a library it uses) can't decode the
octal characters '\040' used to encode spaces in the mount point as
reported in /proc/mounts.
Bug 782681 - btrfs partitions mounted with whitespace cannot be resized
2017-05-19 08:27:49 -06:00
|
|
|
operationdetail, EXEC_CHECK_STATUS );
|
2011-12-27 11:31:10 -07:00
|
|
|
}
|
|
|
|
|
2013-11-15 09:27:12 -07:00
|
|
|
if ( ! partition_new .busy )
|
|
|
|
rm_temp_dir( mount_point, operationdetail ) ;
|
2011-12-27 11:31:10 -07:00
|
|
|
|
|
|
|
return success ;
|
2011-12-08 05:45:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
} //GParted
|