- This code was not active but required libhal to detect auomounted media.
As libhal is dropped, it's time for cleanup.
#include <linux/cdrom.h>
-#define NO_HAL
-
-/*
-** try umount of foreign (user/automounter) media on eject
-** 0 = don't force, 1 = automounted only, 2 == all
-*/
-#define FORCE_RELEASE_FOREIGN 2
-
-/*
-** Reuse foreign (user/automounter) mount points.
-** 0 = don't use, 1 = automounted only, 2 = all
-*/
-#define REUSE_FOREIGN_MOUNTS 2
-
/*
** if to throw exception on eject errors or ignore them
*/
break;
}
-#if REUSE_FOREIGN_MOUNTS > 0
{
MediaManager manager;
MountEntries entries( manager.getMountEntries());
{
AttachPointRef ap( new AttachPoint(e->dir, false));
AttachedMedia am( media, ap);
- //
- // 1 = automounted only, 2 == all
- //
-#if REUSE_FOREIGN_MOUNTS == 1
- if( isAutoMountedMedia(am))
-#endif
{
DBG << "Using a system mounted media "
<< media->name
if( mountsucceeded)
break;
}
-#endif // REUSE_FOREIGN_MOUNTS
// close tray
closeTray( it->name );
ZYPP_CAUGHT(excpt_r);
if (!ejectDev.empty())
{
-#if FORCE_RELEASE_FOREIGN > 0
- /* 1 = automounted only, 2 = all */
- forceRelaseAllMedia(false, FORCE_RELEASE_FOREIGN == 1);
-#endif
+ forceRelaseAllMedia(false);
if(openTray( ejectDev ))
return;
}
// eject device
if (!ejectDev.empty())
{
-#if FORCE_RELEASE_FOREIGN > 0
- /* 1 = automounted only, 2 = all */
- forceRelaseAllMedia(false, FORCE_RELEASE_FOREIGN == 1);
-#endif
+ forceRelaseAllMedia(false);
if( !openTray( ejectDev ))
{
#if REPORT_EJECT_ERRORS
AttachedMedia ret( findAttachedMedia( media));
if( !ret.mediaSource)
{
-#if FORCE_RELEASE_FOREIGN > 0
- /* 1 = automounted only, 2 = all */
- forceRelaseAllMedia(media, false, FORCE_RELEASE_FOREIGN == 1);
-#endif
+ forceRelaseAllMedia(media, false);
if ( openTray( it->name ) )
{
ejected = true;
}
}
- bool MediaCD::isAutoMountedMedia(const AttachedMedia &media)
- {
- bool is_automounted = false;
- if( media.mediaSource && !media.mediaSource->name.empty())
- {
-#ifndef NO_HAL
- using namespace zypp::target::hal;
- try
- {
- HalContext hal(true);
-
- HalVolume vol = hal.getVolumeFromDeviceFile(media.mediaSource->name);
- if( vol)
- {
- std::string udi = vol.getUDI();
- std::string key;
- std::string mnt;
-
- try
- {
- key = "info.hal_mount.created_mount_point";
- mnt = hal.getDevicePropertyString(udi, key);
-
- if(media.attachPoint->path == mnt)
- is_automounted = true;
- }
- catch(const HalException &e1)
- {
- ZYPP_CAUGHT(e1);
-
- try
- {
- key = "volume.mount_point";
- mnt = hal.getDevicePropertyString(udi, key);
-
- if(media.attachPoint->path == mnt)
- is_automounted = true;
- }
- catch(const HalException &e2)
- {
- ZYPP_CAUGHT(e2);
- }
- }
- }
- }
- catch(const HalException &e)
- {
- ZYPP_CAUGHT(e);
- }
-#else // NO_HAL
-#warning Can not detect automounted media without HAL
- INT << "Can not detect automounted media without HAL!" << endl;
- // ma@: This codepath is probably unused due to 'REUSE_FOREIGN_MOUNTS == 2'
- // Maybe we should cleanup all this automount-specail-handling.
-#endif
- }
- DBG << "Media " << media.mediaSource->asString()
- << " attached on " << media.attachPoint->path
- << " is" << (is_automounted ? "" : " not")
- << " automounted" << std::endl;
- return is_automounted;
- }
-
///////////////////////////////////////////////////////////////////
//
// METHOD NAME : MediaCD::isAttached
virtual void forceEject(const std::string & ejectDev);
- virtual bool isAutoMountedMedia(const AttachedMedia &media);
-
virtual bool hasMoreDevices();
virtual void
#define DELAYED_VERIFY 1
/*
-** Reuse foreign (user/automounter) mount points.
-** 0 = don't use, 1 = automounted only, 2 = all
-*/
-#define REUSE_FOREIGN_MOUNTS 2
-
-/*
** Path to the vol_id tool (normal system, instsys)
*/
#define VOL_ID_TOOL_PATHS { "/sbin/vol_id", "/lib/udev/vol_id", NULL}
// mount /dev/<partition> /tmp_mount
// mount /tmp_mount/<dir> <to> --bind -o ro
// FIXME: try all filesystems
-
+
if(_device.empty())
ZYPP_THROW(MediaBadUrlEmptyDestinationException(url()));
-
+
PathInfo dev_info(_device);
if(!dev_info.isBlk())
ZYPP_THROW(MediaBadUrlEmptyDestinationException(url()));
if( is_device && media->maj_nr == dev_info.major() &&
media->min_nr == dev_info.minor())
{
-#if REUSE_FOREIGN_MOUNTS > 0
AttachPointRef ap( new AttachPoint(e->dir, false));
AttachedMedia am( media, ap);
- //
- // 1 = automounted only, 2 == all
- //
-#if REUSE_FOREIGN_MOUNTS == 1
- if( isAutoMountedMedia(am))
-#endif
{
DBG << "Using a system mounted media "
<< media->name
setAttachPoint(ap);
return;
}
-#else
- media->bdir = e->dir;
-#endif
}
}
{
MediaHandler::getFile( filename );
}
-
+
///////////////////////////////////////////////////////////////////
//
// METHOD NAME : MediaDISK::getDir
{
MediaHandler::getDir( dirname, recurse_r );
}
-
+
///////////////////////////////////////////////////////////////////
//
//
{
MediaHandler::getDirInfo( retlist, dirname, dots );
}
-
+
///////////////////////////////////////////////////////////////////
//
//
bool MediaDISK::getDoesFileExist( const Pathname & filename ) const
{
return MediaHandler::getDoesFileExist( filename );
- }
-
+ }
+
} // namespace media
} // namespace zypp
// vim: set ts=8 sts=2 sw=2 ai noet:
MIL << "Released: " << *this << endl;
}
-bool MediaHandler::isAutoMountedMedia(const AttachedMedia &media)
+void MediaHandler::forceRelaseAllMedia(bool matchMountFs)
{
- (void)media;
- return false;
-}
-
-void MediaHandler::forceRelaseAllMedia(bool matchMountFs, bool autoMountedOny)
-{
- forceRelaseAllMedia( attachedMedia().mediaSource, matchMountFs, autoMountedOny);
+ forceRelaseAllMedia( attachedMedia().mediaSource, matchMountFs);
}
void MediaHandler::forceRelaseAllMedia(const MediaSourceRef &ref,
- bool matchMountFs,
- bool autoMountedOny)
+ bool matchMountFs)
{
if( !ref)
return;
if( ref->equals( media) && e->type != "subfs")
{
- if(autoMountedOny)
- {
- try {
- AttachedMedia am(MediaSourceRef(new MediaSource(media)),
- AttachPointRef(new AttachPoint(e->dir)));
- if( !isAutoMountedMedia(am))
- continue;
- }
- catch(...)
- {
- continue;
- }
- }
DBG << "Forcing release of media device "
<< ref->asString()
<< " in the mount table as "
MediaSource media(mtype, e->src);
if( ref->equals( media))
{
- if(autoMountedOny)
- {
- try {
- AttachedMedia am(MediaSourceRef(new MediaSource(media)),
- AttachPointRef(new AttachPoint(e->dir)));
- if( !isAutoMountedMedia(am))
- continue;
- }
- catch(...)
- {
- continue;
- }
- }
DBG << "Forcing release of media name "
<< ref->asString()
<< " in the mount table as "
* mount table (nfs, smb and cifs) or from mediaSource
* while compare of a mount entry with mediaSource.
*/
- void forceRelaseAllMedia(bool matchMountFs,
- bool autoMountedOny=true);
+ void forceRelaseAllMedia(bool matchMountFs);
void forceRelaseAllMedia(const MediaSourceRef &ref,
- bool matchMountFs,
- bool autoMountedOnly=true);
- virtual bool isAutoMountedMedia(const AttachedMedia &media);
+ bool matchMountFs);
protected: