fixed small issue with mounting. (discovered on the livecd)

* include/Utils.h,
  src/Utils.cc,
  src/jfs.cc,
  src/xfs.cc: fixed small issue with mounting. (discovered on the
  livecd)
This commit is contained in:
Bart Hakvoort 2006-01-25 14:50:26 +00:00
parent 409096f739
commit 06cab31e44
5 changed files with 20 additions and 16 deletions

View File

@ -1,3 +1,11 @@
2006-01-25 Bart Hakvoort <hakvoort@cvs.gnome.org>
* include/Utils.h,
src/Utils.cc,
src/jfs.cc,
src/xfs.cc: fixed small issue with mounting. (discovered on the
livecd)
2006-01-25 Bart Hakvoort <hakvoort@cvs.gnome.org>
* src/GParted_Core.cc: improved scanning for root mountpoint (/)

View File

@ -30,7 +30,6 @@
#include <glibmm/ustring.h>
#include <iostream>
#include <sys/mount.h>
namespace GParted
{

View File

@ -21,6 +21,7 @@
#include <fstream>
#include <cerrno>
#include <iomanip>
#include <sys/mount.h>
namespace GParted
{
@ -145,16 +146,15 @@ bool Utils::mount( const Glib::ustring & node,
if ( proc_mounts )
{
bool hit = false ;
char c_node[255], c_mountpoint[255] ;
char c_node[255] ;
std::string line ;
//search for relevant line in /proc/mounts
while ( getline( proc_mounts, line ) )
{
if ( line .length() > 0 && line[ 0 ] == '/' &&
sscanf( line .c_str(),"%s %s", c_node, c_mountpoint ) == 2 &&
c_node == node && c_mountpoint == mountpoint
)
sscanf( line .c_str(),"%255s", c_node ) == 1 &&
c_node == node )
{
hit = true ;
break ;
@ -166,19 +166,14 @@ bool Utils::mount( const Glib::ustring & node,
//append 'line' to /etc/mtab
if ( hit )
{
//in some situations (some livecd's e.g.) /etc/mtab is a (sym)link.
char real_path[255] ;
if ( realpath( "/etc/mtab", real_path ) )
{
std::ofstream mtab( real_path, std::ios::app ) ;
std::ofstream mtab( "/etc/mtab", std::ios::app ) ;
if ( mtab )
{
mtab << line << '\n' ;
mtab .close() ;
if ( mtab )
{
mtab << line << '\n' ;
mtab .close() ;
return true ;
}
return true ;
}
}

View File

@ -19,6 +19,7 @@
#include "../include/jfs.h"
#include <cerrno>
#include <sys/mount.h>
namespace GParted
{

View File

@ -19,6 +19,7 @@
#include "../include/xfs.h"
#include <cerrno>
#include <sys/mount.h>
namespace GParted
{