[gparted] Resolve real path for symbolic link devices in mount files (#582687)
- From: Curtis Gedak <gedakc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gparted] Resolve real path for symbolic link devices in mount files (#582687)
- Date: Sun, 9 Aug 2009 20:34:09 +0000 (UTC)
commit 6d90d0fbcd75bec938d63bd4fb6ba585a51dcb05
Author: Curtis Gedak <gedakc gmail com>
Date: Sun Aug 9 14:26:07 2009 -0600
Resolve real path for symbolic link devices in mount files (#582687)
In order to find a match between the device paths in mount files and
partitions as found by libparted, the mount device must be a real path
and not a symbolic link.
Closes GParted bug #582687
src/GParted_Core.cc | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index e194fec..5799f8b 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -644,16 +644,21 @@ void GParted_Core::read_mountpoints_from_file(
{
node = Utils::regexp_label( line, "^(/[^ \t]+)[ \t]+[^ \t]+" ) ;
mountpoint = Utils::regexp_label( line, "^/[^ \t]+[ \t]+([^ \t]+)" ) ;
- if ( mountpoint .length() > 0 &&
- node .length() > 0 &&
- node != "/dev/root" )
+ if ( mountpoint .length() > 0 && node .length() > 0 )
{
+ //If node is a symbolic link (e.g., /dev/root), then find real path
+ if ( file_test( node, Glib::FILE_TEST_IS_SYMLINK ) )
+ {
+ char c_str[4096+1] ;
+ Glib::ustring tmp_node = node ;
+ //FIXME: it seems realpath is very unsafe to use (manpage)...
+ realpath( tmp_node .c_str(), c_str ) ;
+ if ( tmp_node .length() > 0 )
+ node = tmp_node ;
+ }
//only add this path if it exists
if ( file_test( mountpoint, Glib::FILE_TEST_EXISTS ) )
- {
map[ node ] .push_back( mountpoint ) ;
- //FIXME: Should check if file is a symbolic link. If so then find real path
- }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]