From 6bb830870f5329ef19a2635842063236123af050 Mon Sep 17 00:00:00 2001 From: Marius Tomaschewski Date: Thu, 23 Feb 2006 18:31:56 +0000 Subject: [PATCH] - Extended checkAttached() to allow to specify if fstype should match - Implemented support for nested media releases (dependsOnParent) --- zypp/media/MediaHandler.cc | 89 ++++++++++++++++++++++++++++++---------------- zypp/media/MediaHandler.h | 12 +++++-- 2 files changed, 68 insertions(+), 33 deletions(-) diff --git a/zypp/media/MediaHandler.cc b/zypp/media/MediaHandler.cc index e727380..c74cd27 100644 --- a/zypp/media/MediaHandler.cc +++ b/zypp/media/MediaHandler.cc @@ -53,6 +53,7 @@ MediaHandler::MediaHandler ( const Url & url_r, , _does_download( does_download_r ) , _attach_mtime(0) , _url( url_r ) + , _parentId(0) { if ( !attach_point_r.empty() ) { /////////////////////////////////////////////////////////////////// @@ -369,7 +370,7 @@ MediaHandler::isSharedMedia() const // DESCRIPTION : // bool -MediaHandler::checkAttached(bool aDevice) const +MediaHandler::checkAttached(bool isDevice, bool fsType) const { bool _isAttached = false; @@ -392,39 +393,39 @@ MediaHandler::checkAttached(bool aDevice) const MountEntries::const_iterator e; for( e = entries.begin(); e != entries.end(); ++e) { - bool isDevice = (Pathname(e->src).dirname() == "/dev"); - if( aDevice == isDevice) + bool is_device = (Pathname(e->src).dirname() == "/dev"); + if( is_device == isDevice) { PathInfo dinfo(e->src); - MediaSource media(ref.mediaSource->type, e->src, - dinfo.major(), dinfo.minor()); - - if( ref.mediaSource->equals( media) && - ref.attachPoint->path == Pathname(e->dir)) - { - DBG << "Found media " - << ref.mediaSource->asString() - << " in the mount table" << std::endl; - _isAttached = true; - break; - } - // differs + std::string mtype(fsType ? e->type : ref.mediaSource->type); + MediaSource media(mtype, e->src, dinfo.major(), dinfo.minor()); + + if( ref.mediaSource->equals( media) && + ref.attachPoint->path == Pathname(e->dir)) + { + DBG << "Found media " + << ref.mediaSource->asString() + << " in the mount table" << std::endl; + _isAttached = true; + break; + } + // differs + } + else + { + 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 " + << ref.mediaSource->asString() + << " in the mount table" << std::endl; + _isAttached = true; + break; + } + // differs } - else - { - MediaSource media(e->type, e->src); - - if( ref.mediaSource->equals( media) && - ref.attachPoint->path == Pathname(e->dir)) - { - DBG << "Found media " - << ref.mediaSource->asString() - << " in the mount table" << std::endl; - _isAttached = true; - break; - } - // differs - } } if( !_isAttached) @@ -554,6 +555,32 @@ void MediaHandler::release( bool eject ) /////////////////////////////////////////////////////////////////// // +// METHOD NAME : MediaHandler::dependsOnParent +// METHOD TYPE : bool +// +// DESCRIPTION : +// +bool +MediaHandler::dependsOnParent(MediaAccessId parentId) +{ + 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) + { + return am1.mediaSource->equals( *(am2.mediaSource)); + } + } + return false; +} + +/////////////////////////////////////////////////////////////////// +// // // METHOD NAME : MediaHandler::provideFile // METHOD TYPE : PMError diff --git a/zypp/media/MediaHandler.h b/zypp/media/MediaHandler.h index eaf9ccc..e19011a 100644 --- a/zypp/media/MediaHandler.h +++ b/zypp/media/MediaHandler.h @@ -88,7 +88,12 @@ class MediaHandler { /** * Url to handle **/ - const Url _url; + const Url _url; + + /** + * Access Id of media handler we depend on. + */ + MediaAccessId _parentId; /** * Return the currently used attach point. @@ -140,6 +145,8 @@ class MediaHandler { AttachedMedia findAttachedMedia(const MediaSourceRef &media) const; + bool dependsOnParent(MediaAccessId parentId); + /** * Returns the attached media. Used by MediaManager * to find other handlers using the same source. @@ -148,7 +155,8 @@ class MediaHandler { bool isSharedMedia() const; - bool checkAttached(bool aDevice) const; + bool checkAttached(bool aDevice, + bool fsType=false) const; protected: -- 2.7.4