*/
#include <iostream>
+#include <sstream>
#include "zypp/base/Logger.h"
#include "zypp/base/String.h"
// CLASS NAME : MediaNFS
//
///////////////////////////////////////////////////////////////////
-
+
///////////////////////////////////////////////////////////////////
//
//
return;
}
- const char* const filesystem = "nfs";
- std::string mountpoint = attachPoint().asString();
- Mount mount;
+ if( !isUseableAttachPoint( attachPoint() ) )
+ {
+ setAttachPoint( createAttachPoint(), true );
+ }
+ std::string mountpoint( attachPoint().asString() );
- if( !isUseableAttachPoint(attachPoint()))
+ std::string filesystem( _url.getScheme() );
+ if ( filesystem != "nfs4" && _url.getQueryParam("type") == "nfs4" )
{
- mountpoint = createAttachPoint().asString();
- if( mountpoint.empty())
- ZYPP_THROW( MediaBadAttachPointException(url()));
- setAttachPoint( mountpoint, true);
+ filesystem = "nfs4";
}
string options = _url.getQueryParam("mountoptions");
{
options="ro";
}
-
- // Add option "nolock", unless option "lock" or "unlock" is already set.
- // This should prevent the mount command hanging when the portmapper isn't
- // running.
+
vector<string> optionList;
str::split( options, std::back_inserter(optionList), "," );
vector<string>::const_iterator it;
+ bool contains_lock = false, contains_soft = false,
+ contains_timeo = false, contains_hard = false;
+
for( it = optionList.begin(); it != optionList.end(); ++it ) {
- if ( *it == "lock" || *it == "nolock" ) break;
+ if ( *it == "lock" || *it == "nolock" ) contains_lock = true;
+ else if ( *it == "soft") contains_soft = true;
+ else if ( *it == "hard") contains_hard = true;
+ else if ( it->find("timeo") != string::npos ) contains_timeo = true;
}
- if ( it == optionList.end() ) {
- optionList.push_back( "nolock" );
- options = str::join( optionList, "," );
+
+ if ( !(contains_lock && contains_soft) ) {
+ // Add option "nolock", unless option "lock" or "unlock" is already set.
+ // This should prevent the mount command hanging when the portmapper isn't
+ // running.
+ if ( !contains_lock ) {
+ optionList.push_back( "nolock" );
+ }
+ // Add options "soft,timeo=NFS_MOUNT_TIMEOUT", unless they are set
+ // already or "hard" option is explicitly specified. This prevent
+ // the mount command from hanging when the nfs server is not responding
+ // and file transactions from an unresponsive to throw an error after
+ // a short time instead of hanging forever
+ if ( !(contains_soft || contains_hard) ) {
+ optionList.push_back( "soft" );
+ if ( !contains_timeo ) {
+ ostringstream s;
+ s << "timeo=" << NFS_MOUNT_TIMEOUT;
+ optionList.push_back( s.str() );
+ }
+ }
+ options = str::join( optionList, "," );
}
+ Mount mount;
mount.mount(path,mountpoint,filesystem,options);
setMediaSource(media);
bool
MediaNFS::isAttached() const
{
- return checkAttached(false, true);
+ return checkAttached(true);
}
///////////////////////////////////////////////////////////////////
//
//
- // METHOD NAME : MediaNFS::releaseFrom
- // METHOD TYPE : PMError
+ // METHOD NAME : MediaNFS::releaseFrom
+ // METHOD TYPE : void
//
- // DESCRIPTION : Asserted that media is attached.
+ // DESCRIPTION : Asserted that media is attached.
//
- void MediaNFS::releaseFrom( bool eject )
+ void MediaNFS::releaseFrom( const std::string & ejectDev )
{
Mount mount;
mount.umount(attachPoint().asString());
}
-
///////////////////////////////////////////////////////////////////
//
// METHOD NAME : MediaNFS::getFile
{
MediaHandler::getFile( filename );;
}
-
+
///////////////////////////////////////////////////////////////////
//
// METHOD NAME : MediaNFS::getDir
{
MediaHandler::getDir( dirname, recurse_r );
}
-
+
///////////////////////////////////////////////////////////////////
//
//
{
MediaHandler::getDirInfo( retlist, dirname, dots );
}
-
+
///////////////////////////////////////////////////////////////////
//
//
MediaHandler::getDirInfo( retlist, dirname, dots );
}
+ bool MediaNFS::getDoesFileExist( const Pathname & filename ) const
+ {
+ return MediaHandler::getDoesFileExist( filename );
+ }
+
+
} // namespace media
} // namespace zypp