Imported Upstream version 17.0.0
[platform/upstream/libzypp.git] / zypp / media / MediaHandler.cc
index 9c8ef67..2e20218 100644 (file)
 #include <fstream>
 #include <sstream>
 
-#include "zypp/base/Logger.h"
+#include "zypp/ZConfig.h"
+#include "zypp/TmpPath.h"
+#include "zypp/Date.h"
+#include "zypp/base/LogTools.h"
+#include "zypp/base/Gettext.h"
 #include "zypp/base/String.h"
 #include "zypp/media/MediaHandler.h"
 #include "zypp/media/MediaManager.h"
 #include "zypp/media/Mount.h"
+#include <limits.h>
+#include <stdlib.h>
+#include <errno.h>
+
 
 using namespace std;
 
@@ -50,27 +58,39 @@ MediaHandler::MediaHandler ( const Url &      url_r,
                             const bool       does_download_r )
     : _mediaSource()
     , _attachPoint( new AttachPoint())
-    , _AttachPointHint()
+    , _attachPointHint()
     , _relativeRoot( urlpath_below_attachpoint_r)
     , _does_download( does_download_r )
     , _attach_mtime(0)
     , _url( url_r )
     , _parentId(0)
 {
-  if ( !attach_point_r.empty() ) {
+  Pathname real_attach_point( getRealPath(attach_point_r.asString()));
+
+  if ( !real_attach_point.empty() ) {
     ///////////////////////////////////////////////////////////////////
     // check if provided attachpoint is usable.
     ///////////////////////////////////////////////////////////////////
 
-    PathInfo adir( attach_point_r );
-    // FIXME: verify if attach_point_r isn't a mountpoint of other device
-    if ( !adir.isDir() || !attach_point_r.absolute()) {
+    PathInfo adir( real_attach_point );
+    //
+    // The verify if attach_point_r isn't a mountpoint of another
+    // device is done in the particular media handler (if needed).
+    //
+    // We just verify, if attach_point_r is a directory and for
+    // schemes other than "file" and "dir", if it is absolute.
+    //
+    if ( !adir.isDir()
+        || (_url.getScheme() != "file"
+            && _url.getScheme() != "dir"
+            && !real_attach_point.absolute()) )
+    {
       ERR << "Provided attach point is not a absolute directory: "
           << adir << endl;
     }
     else {
-      attachPointHint( attach_point_r, false);
-      setAttachPoint( attach_point_r, false);
+      attachPointHint( real_attach_point, false);
+      setAttachPoint( real_attach_point, false);
     }
   }
 }
@@ -92,6 +112,56 @@ MediaHandler::~MediaHandler()
   catch(...) {}
 }
 
+void
+MediaHandler::resetParentId()
+{
+  _parentId = 0;
+}
+
+std::string
+MediaHandler::getRealPath(const std::string &path)
+{
+  std::string real;
+  if( !path.empty())
+  {
+#if __GNUC__ > 2
+    /** GNU extension */
+    char *ptr = ::realpath(path.c_str(), NULL);
+    if( ptr != NULL)
+    {
+      real = ptr;
+      free( ptr);
+    }
+    else
+    /** the SUSv2 way */
+    if( EINVAL == errno)
+    {
+      char buff[PATH_MAX + 2];
+      memset(buff, '\0', sizeof(buff));
+      if( ::realpath(path.c_str(), buff) != NULL)
+      {
+       real = buff;
+      }
+    }
+#else
+    char buff[PATH_MAX + 2];
+    memset(buff, '\0', sizeof(buff));
+    if( ::realpath(path.c_str(), buff) != NULL)
+    {
+      real = buff;
+    }
+#endif
+  }
+  return real;
+}
+
+zypp::Pathname
+MediaHandler::getRealPath(const Pathname &path)
+{
+  return zypp::Pathname(getRealPath(path.asString()));
+}
+
+
 ///////////////////////////////////////////////////////////////////
 //
 //
@@ -128,7 +198,7 @@ MediaHandler::removeAttachPoint()
   }
   else
   {
-    if( !_attachPoint->temp)
+    if( !_attachPoint->path.empty() && !_attachPoint->temp)
       DBG << "MediaHandler - attachpoint is not temporary" << endl;
   }
 }
@@ -200,8 +270,8 @@ MediaHandler::setAttachPoint(const AttachPointRef &ref)
 void
 MediaHandler::attachPointHint(const Pathname &path, bool temporary)
 {
-  _AttachPointHint.path = path;
-  _AttachPointHint.temp = temporary;
+  _attachPointHint.path = path;
+  _attachPointHint.temp = temporary;
 }
 
 ///////////////////////////////////////////////////////////////////
@@ -215,7 +285,7 @@ MediaHandler::attachPointHint(const Pathname &path, bool temporary)
 AttachPoint
 MediaHandler::attachPointHint() const
 {
-  return _AttachPointHint;
+  return _attachPointHint;
 }
 
 ///////////////////////////////////////////////////////////////////
@@ -272,36 +342,36 @@ MediaHandler::setAttachPrefix(const Pathname &attach_prefix)
 Pathname
 MediaHandler::createAttachPoint() const
 {
-  /////////////////////////////////////////////////////////////////
-  // provide a default (temporary) attachpoint
-  /////////////////////////////////////////////////////////////////
-  const char * defmounts[] = {
-      "/var/adm/mount", "/var/tmp", /**/NULL/**/
-  };
-
+  Pathname aroot;
   Pathname apoint;
-  Pathname aroot( MediaHandler::_attachPrefix);
-
-  if( !aroot.empty())
   {
-    apoint = createAttachPoint(aroot);
+    aroot = MediaHandler::_attachPrefix;       // explicit request
+    if ( ! aroot.empty() )
+      apoint = createAttachPoint( aroot );
   }
-  for ( const char ** def = defmounts; *def && apoint.empty(); ++def ) {
-    aroot = *def;
-    if( aroot.empty())
-      continue;
 
-    apoint = createAttachPoint(aroot);
+  if ( apoint.empty() )                                // fallback to config value
+  {
+    aroot = ZConfig::instance().download_mediaMountdir();
+    if ( ! aroot.empty() )
+      apoint = createAttachPoint( aroot );
   }
 
-  if ( aroot.empty() ) {
-    ERR << "Create attach point: Can't find a writable directory to create an attach point" << std::endl;
-    return aroot;
+  if ( apoint.empty() )                                // fall back to temp space
+  {
+    aroot = filesystem::TmpPath::defaultLocation();
+    if ( ! aroot.empty() )
+      apoint = createAttachPoint( aroot );
   }
 
-  if ( !apoint.empty() ) {
-    MIL << "Created default attach point " << apoint << std::endl;
+  if ( apoint.empty() )
+  {
+    auto except = MediaBadAttachPointException( url() );
+    except.addHistory( _("Create attach point: Can't find a writable directory to create an attach point") );
+    ZYPP_THROW( std::move(except) );
   }
+
+  MIL << "Created default attach point " << apoint << std::endl;
   return apoint;
 }
 
@@ -316,38 +386,51 @@ MediaHandler::createAttachPoint(const Pathname &attach_root) const
     return apoint;
   }
 
-  PathInfo adir( attach_root);
-  if( !adir.isDir() || !adir.userMayRWX()) {
+  PathInfo adir( attach_root );
+  if( !adir.isDir() || (geteuid() != 0 && !adir.userMayRWX())) {
     DBG << "Create attach point: attach root is not a writable directory: '"
         << attach_root << "'" << std::endl;
     return apoint;
   }
 
-  DBG << "Trying to create attach point in " << attach_root << std::endl;
-
-  //
-  // FIXME: use mkdtemp?
-  //
-  Pathname abase( attach_root + "AP_" );
-  //        ma and sh need more than 42 for debugging :-)
-  //        since the readonly fs are handled now, ...
-  for ( unsigned i = 1; i < 1000; ++i ) {
-    adir( Pathname::extend( abase, str::hexstring( i ) ) );
-    if ( ! adir.isExist() ) {
-      int err = mkdir( adir.path() );
-      if (err == 0 ) {
-        apoint = adir.path();
-        break;
+  static bool cleanup_once( true );
+  if ( cleanup_once )
+  {
+    cleanup_once = false;
+    DBG << "Look for orphaned attach points in " << adir << std::endl;
+    std::list<std::string> entries;
+    filesystem::readdir( entries, attach_root, false );
+    for ( const std::string & entry : entries )
+    {
+      if ( ! str::hasPrefix( entry, "AP_0x" ) )
+       continue;
+      PathInfo sdir( attach_root + entry );
+      if ( sdir.isDir()
+       && sdir.dev() == adir.dev()
+       && ( Date::now()-sdir.mtime() > Date::month ) )
+      {
+       DBG << "Remove orphaned attach point " << sdir << std::endl;
+       filesystem::recursive_rmdir( sdir.path() );
       }
-      else
-      if (err != EEXIST)       // readonly fs or other, dont try further
-        break;
     }
   }
 
-  if ( apoint.empty()) {
-    ERR << "Unable to create an attach point below of "
-        << attach_root << std::endl;
+  filesystem::TmpDir tmpdir( attach_root, "AP_0x" );
+  if ( tmpdir )
+  {
+    apoint = getRealPath( tmpdir.path().asString() );
+    if ( ! apoint.empty() )
+    {
+      tmpdir.autoCleanup( false );     // Take responsibility for cleanup.
+    }
+    else
+    {
+      ERR << "Unable to resolve real path for attach point " << tmpdir << std::endl;
+    }
+  }
+  else
+  {
+    ERR << "Unable to create attach point below " << attach_root << std::endl;
   }
   return apoint;
 }
@@ -361,10 +444,10 @@ MediaHandler::createAttachPoint(const Pathname &attach_root) const
 //     DESCRIPTION :
 //
 bool
-MediaHandler::isUseableAttachPoint(const Pathname &path) const
+MediaHandler::isUseableAttachPoint(const Pathname &path, bool mtab) const
 {
   MediaManager  manager;
-  return manager.isUseableAttachPoint(path);
+  return manager.isUseableAttachPoint(path, mtab);
 }
 
 
@@ -424,18 +507,16 @@ MediaHandler::isSharedMedia() const
 //     DESCRIPTION :
 //
 bool
-MediaHandler::checkAttached(bool isDevice,  bool fsType) const
+MediaHandler::checkAttached(bool matchMountFs) const
 {
   bool _isAttached = false;
 
-  AttachedMedia ref( attachedMedia());
-  if( ref.mediaSource)
+  AttachedMedia ref( attachedMedia() );
+  if( ref.mediaSource )
   {
-    MediaManager  manager;
-
     time_t old_mtime = _attach_mtime;
-    _attach_mtime = manager.getMountTableMTime();
-    if( !(old_mtime <= 0 || _attach_mtime != old_mtime))
+    _attach_mtime = MediaManager::getMountTableMTime();
+    if( !(old_mtime <= 0 || _attach_mtime != old_mtime) )
     {
       // OK, skip the check (we've seen it at least once)
       _isAttached = true;
@@ -447,27 +528,27 @@ MediaHandler::checkAttached(bool isDevice,  bool fsType) const
       else
         DBG << "Forced check of the mount table" << std::endl;
 
-      MountEntries  entries( manager.getMountEntries());
-      MountEntries::const_iterator e;
-      for( e = entries.begin(); e != entries.end(); ++e)
+      MountEntries entries( MediaManager::getMountEntries());
+      for_( e, entries.begin(), entries.end() )
       {
+       if ( ref.attachPoint->path != Pathname(e->dir) )
+         continue;     // at least the mount points must match
+
         bool        is_device = false;
-        std::string dev_path(Pathname(e->src).asString());
         PathInfo    dev_info;
-
-        if( dev_path.compare(0, sizeof("/dev/")-1, "/dev/") == 0 &&
-            dev_info(e->src) && dev_info.isBlk())
+        if( str::hasPrefix( Pathname(e->src).asString(), "/dev/" ) &&
+            dev_info(e->src) && dev_info.isBlk() )
         {
           is_device = true;
         }
 
-        if( isDevice && is_device)
+        if( is_device &&  (ref.mediaSource->maj_nr &&
+                          ref.mediaSource->bdir.empty()))
         {
-          std::string mtype(fsType ? e->type : ref.mediaSource->type);
-          MediaSource media(mtype, e->src, dev_info.major(), dev_info.minor());
+          std::string mtype(matchMountFs ? e->type : ref.mediaSource->type);
+          MediaSource media(mtype, e->src, dev_info.devMajor(), dev_info.devMinor());
 
-          if( ref.mediaSource->equals( media) &&
-              ref.attachPoint->path == Pathname(e->dir))
+          if( ref.mediaSource->equals( media ) )
           {
             DBG << "Found media device "
                 << ref.mediaSource->asString()
@@ -478,27 +559,86 @@ MediaHandler::checkAttached(bool isDevice,  bool fsType) const
           // differs
         }
         else
-        if( !isDevice && !is_device)
+        if(!is_device && (!ref.mediaSource->maj_nr ||
+                         !ref.mediaSource->bdir.empty()))
         {
-          std::string mtype(fsType ? e->type : ref.mediaSource->type);
-          MediaSource media(mtype, e->src);
-
-          if( ref.mediaSource->equals( media) &&
-              ref.attachPoint->path == Pathname(e->dir))
-          {
-            DBG << "Found media name "
-                << ref.mediaSource->asString()
-                << " in the mount table as " << e->src << std::endl;
-            _isAttached = true;
-            break;
-          }
+         if( ref.mediaSource->bdir.empty())
+         {
+           // bnc#710269: Type nfs may appear as nfs4 in in the mount table
+           // and maybe vice versa. Similar cifs/smb. Need to unify these types:
+           if ( matchMountFs && e->type != ref.mediaSource->type )
+           {
+             if ( str::hasPrefix( e->type, "nfs" ) && str::hasPrefix( ref.mediaSource->type, "nfs" ) )
+               matchMountFs = false;
+             else if ( ( e->type == "cifs" || e->type == "smb" ) && ( ref.mediaSource->type == "cifs" || ref.mediaSource->type == "smb" ) )
+               matchMountFs = false;
+             else
+               continue;       // different types cannot match
+           }
+           // Here: Types are ok or not to check.
+           // Check the name except for nfs (bnc#804544; symlink resolution in mount path)
+           //
+           //   [fibonacci]$ ls -l /Local/ma/c12.1
+           //   lrwxrwxrwx  /Local/ma/c12.1 -> zypp-SuSE-Code-12_1-Branch/
+           //
+           //   [localhost]$ mount -t nfs4 fibonacci:/Local/ma/c12.1 /mnt
+           //   [localhost]$ mount
+           //   fibonacci:/Local/ma/zypp-SuSE-Code-12_1-Branch on /mnt
+
+           // std::string mtype(matchMountFs ? e->type : ref.mediaSource->type);
+           // MediaSource media(mtype, e->src);
+
+           if( ref.mediaSource->name == e->src || str::hasPrefix( ref.mediaSource->type, "nfs" ) )
+           {
+             DBG << "Found media name "
+             << ref.mediaSource->asString()
+             << " in the mount table as " << e->src << std::endl;
+             _isAttached = true;
+             break;
+           }
+         }
+         else
+         {
+           if ( ref.mediaSource->bdir == e->src )
+           {
+             DBG << "Found bound media "
+                 << ref.mediaSource->asString()
+                 << " in the mount table as " << e->src << std::endl;
+             _isAttached = true;
+             break;
+           }
+         }
           // differs
         }
+        else // mixed cases:
+       {
+         // Type ISO: Since 11.1 mtab might contain the name of
+         // the loop device instead of the iso file:
+         if ( ref.mediaSource->type == "iso"
+           && str::hasPrefix( Pathname(e->src).asString(), "/dev/loop" )
+           && ref.attachPoint->path == Pathname(e->dir) )
+         {
+           DBG << "Found bound media "
+           << ref.mediaSource->asString()
+           << " in the mount table as " << e->src << std::endl;
+           _isAttached = true;
+           break;
+         }
+       }
       }
 
       if( !_isAttached)
       {
-       if( old_mtime > 0)
+        MIL << "Looking for " << ref << endl;
+       if( entries.empty() )
+       {
+         ERR << "Unable to find any entry in the /etc/mtab file" << std::endl;
+       }
+       else
+       {
+          dumpRange( DBG << "MountEntries: ", entries.begin(), entries.end() ) << endl;
+       }
+       if( old_mtime > 0 )
        {
           ERR << "Attached media not in mount table any more - forcing reset!"
               << std::endl;
@@ -598,12 +738,13 @@ void MediaHandler::disconnect()
 //
 //     DESCRIPTION :
 //
-void MediaHandler::release( bool eject )
+void MediaHandler::release( const std::string & ejectDev )
 {
   if ( !isAttached() ) {
-    DBG << "Request to release media - not attached; eject " << eject << std::endl;
-    if ( eject )
-      forceEject();
+    DBG << "Request to release media - not attached; eject '" << ejectDev << "'"
+        << std::endl;
+    if ( !ejectDev.empty() )
+      forceEject(ejectDev);
     return;
   }
 
@@ -615,11 +756,24 @@ void MediaHandler::release( bool eject )
   if( _mediaSource.unique())
   {
     DBG << "Releasing media " << _mediaSource->asString() << std::endl;
-    releaseFrom( eject ); // pass to concrete handler
+    try {
+      releaseFrom( ejectDev ); // pass to concrete handler
+    }
+    catch(const MediaNotEjectedException &e)
+    {
+      // not ejected because the media
+      // is mounted by somebody else
+      // (if our attach point is busy,
+      //  we get an umount exception)
+      _mediaSource.reset(NULL);
+      removeAttachPoint();
+      // OK, retrow now
+      ZYPP_RETHROW(e);
+    }
     _mediaSource.reset(NULL);
     removeAttachPoint();
   }
-  else if( eject) {
+  else if( !ejectDev.empty() ) {
     //
     // Can't eject a shared media
     //
@@ -629,11 +783,24 @@ void MediaHandler::release( bool eject )
     _mediaSource.reset(NULL);
 
     MediaManager manager;
-    manager.forceMediaRelease(media);
+    manager.forceReleaseShared(media);
 
     setMediaSource(media);
     DBG << "Releasing media (forced) " << _mediaSource->asString() << std::endl;
-    releaseFrom( eject ); // pass to concrete handler
+    try {
+      releaseFrom( ejectDev ); // pass to concrete handler
+    }
+    catch(const MediaNotEjectedException &e)
+    {
+      // not ejected because the media
+      // is mounted by somebody else
+      // (if our attach point is busy,
+      //  we get an umount exception)
+      _mediaSource.reset(NULL);
+      removeAttachPoint();
+      // OK, retrow now
+      ZYPP_RETHROW(e);
+    }
     _mediaSource.reset(NULL);
     removeAttachPoint();
   }
@@ -645,6 +812,75 @@ void MediaHandler::release( bool eject )
   MIL << "Released: " << *this << endl;
 }
 
+void MediaHandler::forceRelaseAllMedia(bool matchMountFs)
+{
+  forceRelaseAllMedia( attachedMedia().mediaSource, matchMountFs);
+}
+
+void MediaHandler::forceRelaseAllMedia(const MediaSourceRef &ref,
+                                       bool                  matchMountFs)
+{
+  if( !ref)
+    return;
+
+  MountEntries  entries( MediaManager::getMountEntries());
+  MountEntries::const_iterator e;
+  for( e = entries.begin(); e != entries.end(); ++e)
+  {
+    bool        is_device = false;
+    PathInfo    dev_info;
+
+    if( str::hasPrefix( Pathname(e->src).asString(), "/dev/" ) &&
+        dev_info(e->src) && dev_info.isBlk())
+    {
+      is_device = true;
+    }
+
+    if( is_device &&  ref->maj_nr)
+    {
+      std::string mtype(matchMountFs ? e->type : ref->type);
+      MediaSource media(mtype, e->src, dev_info.devMajor(), dev_info.devMinor());
+
+      if( ref->equals( media) && e->type != "subfs")
+      {
+        DBG << "Forcing release of media device "
+            << ref->asString()
+            << " in the mount table as "
+           << e->src << std::endl;
+       try {
+         Mount mount;
+         mount.umount(e->dir);
+       }
+       catch (const Exception &e)
+       {
+         ZYPP_CAUGHT(e);
+       }
+      }
+    }
+    else
+    if(!is_device && !ref->maj_nr)
+    {
+      std::string mtype(matchMountFs ? e->type : ref->type);
+      MediaSource media(mtype, e->src);
+      if( ref->equals( media))
+      {
+       DBG << "Forcing release of media name "
+           << ref->asString()
+           << " in the mount table as "
+           << e->src << std::endl;
+       try {
+         Mount mount;
+         mount.umount(e->dir);
+       }
+       catch (const Exception &e)
+       {
+         ZYPP_CAUGHT(e);
+       }
+      }
+    }
+  }
+}
+
 bool
 MediaHandler::checkAttachPoint(const Pathname &apoint) const
 {
@@ -720,19 +956,28 @@ MediaHandler::checkAttachPoint(const Pathname &apoint,
 //     DESCRIPTION :
 //
 bool
-MediaHandler::dependsOnParent(MediaAccessId parentId)
+MediaHandler::dependsOnParent()
+{
+  return _parentId != 0;
+}
+
+bool
+MediaHandler::dependsOnParent(MediaAccessId parentId, bool exactIdMatch)
 {
   if( _parentId != 0)
   {
     if(parentId == _parentId)
       return true;
-    MediaManager mm;
-    AttachedMedia am1 = mm.getAttachedMedia(_parentId);
-    AttachedMedia am2 = mm.getAttachedMedia(parentId);
-    if( am1.mediaSource && am2.mediaSource)
+
+    if( !exactIdMatch)
     {
-      return am1.mediaSource->equals( *(am2.mediaSource));
+      MediaManager mm;
+      AttachedMedia am1 = mm.getAttachedMedia(_parentId);
+      AttachedMedia am2 = mm.getAttachedMedia(parentId);
+      if( am1.mediaSource && am2.mediaSource)
+      {
+       return am1.mediaSource->equals( *(am2.mediaSource));
+      }
     }
   }
   return false;
@@ -843,8 +1088,8 @@ void MediaHandler::releasePath( Pathname pathname ) const
 //
 //     DESCRIPTION :
 //
-void MediaHandler::dirInfo( list<string> & retlist,
-                              const Pathname & dirname, bool dots ) const
+void MediaHandler::dirInfo( std::list<std::string> & retlist,
+                            const Pathname & dirname, bool dots ) const
 {
   retlist.clear();
 
@@ -882,6 +1127,25 @@ void MediaHandler::dirInfo( filesystem::DirContent & retlist,
 ///////////////////////////////////////////////////////////////////
 //
 //
+//      METHOD NAME : MediaHandler::doesFileExist
+//      METHOD TYPE : PMError
+//
+//      DESCRIPTION :
+//
+bool MediaHandler::doesFileExist( const Pathname & filename ) const
+{
+  // TODO do some logging
+  if ( !isAttached() ) {
+    INT << "Error Not attached on doesFileExist(" << filename << ")" << endl;
+    ZYPP_THROW(MediaNotAttachedException(url()));
+  }
+  return getDoesFileExist( filename );
+  MIL << "doesFileExist(" << filename << ")" << endl;
+}
+
+///////////////////////////////////////////////////////////////////
+//
+//
 //     METHOD NAME : MediaHandler::getDirectoryYast
 //     METHOD TYPE : PMError
 //
@@ -1041,10 +1305,16 @@ void MediaHandler::getDirInfo( std::list<std::string> & retlist,
   {
 #endif
 
-  // readdir
+    // readdir
     int res = readdir( retlist, info.path(), dots );
-  if ( res )
-    ZYPP_THROW(MediaSystemException(url(), "readdir failed"));
+    if ( res )
+    {
+      MediaSystemException nexcpt(url(), "readdir failed");
+#if NONREMOTE_DIRECTORY_YAST
+      nexcpt.remember(excpt_r);
+#endif
+      ZYPP_THROW(nexcpt);
+    }
 
 #if NONREMOTE_DIRECTORY_YAST
   }
@@ -1079,15 +1349,64 @@ void MediaHandler::getDirInfo( filesystem::DirContent & retlist,
   {
 #endif
 
-  // readdir
-  int res = readdir( retlist, info.path(), dots );
-  if ( res )
-    ZYPP_THROW(MediaSystemException(url(), "readdir failed"));
+    // readdir
+    int res = readdir( retlist, info.path(), dots );
+    if ( res )
+    {
+       MediaSystemException nexcpt(url(), "readdir failed");
+#if NONREMOTE_DIRECTORY_YAST
+       nexcpt.remember(excpt_r);
+#endif
+       ZYPP_THROW(nexcpt);
+    }
 #if NONREMOTE_DIRECTORY_YAST
   }
 #endif
 }
 
+///////////////////////////////////////////////////////////////////
+//
+//
+//      METHOD NAME : MediaHandler::getDoesFileExist
+//      METHOD TYPE : PMError
+//
+//      DESCRIPTION : Asserted that file is not a directory
+//                    Default implementation of pure virtual.
+//
+bool MediaHandler::getDoesFileExist( const Pathname & filename ) const
+{
+  PathInfo info( localPath( filename ) );
+  if( info.isDir() ) {
+    ZYPP_THROW(MediaNotAFileException(url(), localPath(filename)));
+  }
+  return info.isExist();
+}
+
+bool MediaHandler::hasMoreDevices()
+{
+  return false;
+}
+
+void MediaHandler::getDetectedDevices(std::vector<std::string> & devices,
+                                      unsigned int & index) const
+{
+  // clear the vector by default
+  if (!devices.empty())
+    devices.clear();
+  index = 0;
+
+  DBG << "No devices for this medium" << endl;
+}
+
+void MediaHandler::setDeltafile( const Pathname & filename ) const
+{
+  _deltafile = filename;
+}
+
+Pathname MediaHandler::deltafile() const {
+  return _deltafile;
+}
+
   } // namespace media
 } // namespace zypp
 // vim: set ts=8 sts=2 sw=2 ai noet: