From 9b02213d275f0e2d5a2cb8a07f54df7ea3c2a37e Mon Sep 17 00:00:00 2001 From: Bart Hakvoort Date: Mon, 30 Jan 2006 19:45:50 +0000 Subject: [PATCH] fixed error with mountpoints containing whitespaces. (#329247) * src/GParted_Core.cc: fixed error with mountpoints containing whitespaces. (#329247) --- ChangeLog | 5 +++++ src/GParted_Core.cc | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index df0e4006..524d9d84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-01-30 Bart Hakvoort + + * src/GParted_Core.cc: fixed error with mountpoints containing + whitespaces. (#329247) + 2006-01-30 Bart Hakvoort * configure.in: bump to gparted-0.2 diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 8e4839b6..a40370ca 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -166,14 +166,23 @@ void GParted_Core::init_maps() //initialize mountpoints.. char node[255], mountpoint[255] ; + unsigned int index ; std::ifstream proc_mounts( "/proc/mounts" ) ; if ( proc_mounts ) { while ( getline( proc_mounts, line ) ) if ( line .length() > 0 && line[ 0 ] == '/' && - sscanf( line .c_str(), "%s %s", node, mountpoint ) == 2 ) - mount_info[ node ] = mountpoint ; + sscanf( line .c_str(), "%255s %255s", node, mountpoint ) == 2 ) + { + //see if mountpoint contains spaces and deal with it + line = mountpoint ; + index = line .find( "\\040" ) ; + if ( index < line .length() ) + line .replace( index, 4, " " ) ; + + mount_info[ node ] = line ; + } proc_mounts .close() ; } @@ -185,10 +194,10 @@ void GParted_Core::init_maps() while ( getline( etc_mtab, line ) ) if ( line .length() > 0 && line[ 0 ] == '/' && - sscanf( line .c_str(), "%s %s", node, mountpoint ) == 2 && + sscanf( line .c_str(), "%255s %255s", node, mountpoint ) == 2 && static_cast( mountpoint ) == "/" ) { - mount_info[ node ] = mountpoint ; + mount_info[ node ] = "/" ; break ; }