libzypp 17.37.10

zyppng::worker::DeviceDriver Class Referenceabstract

`#include <zypp-media/ng/worker/devicedriver.h>`

Inheritance diagram for zyppng::worker::DeviceDriver:

## Public Member Functions
| DeviceDriver (WorkerCaps::WorkerType wType)
void | setProvider (ProvideWorkerWeakRef workerRef)
virtual AttachResult | mountDevice (const uint32_t id, const zypp::Url &mediaUrl, const std::string &attachId, const std::string &label, const HeaderValueMap &extras)=0
virtual zyppng::expected< WorkerCaps > | initialize (const zyppng::worker::Configuration &conf)
bool | detachMedia (const std::string &attachId)
void | releaseIdleDevices ()
virtual void | detectDevices ()
std::vector< std::shared_ptr< Device > > & | knownDevices ()
const std::vector< std::shared_ptr< Device > > & | knownDevices () const
std::unordered_map< std::string, AttachedMedia > & | attachedMedia ()
virtual bool | isVolatile () const
void | setAttachRoot (const zypp::Pathname &root)
zypp::Pathname | attachRoot () const
virtual void | immediateShutdown ()
ProvideWorkerRef | parentWorker () const
const zyppng::worker::Configuration & | config () const
Public Member Functions inherited from zyppng::Base
| Base ()
virtual | ~Base ()
WeakPtr | parent () const
void | addChild (const Base::Ptr &child)
void | removeChild (const Ptr &child)
const std::unordered_set< Ptr > & | children () const
std::thread::id | threadId () const
template<typename T>
std::vector< std::weak_ptr< T > > | findChildren () const
template<typename T>
std::shared_ptr< T > | shared_this () const
template<typename T>
std::shared_ptr< T > | shared_this ()
template<typename T>
std::weak_ptr< T > | weak_this () const
template<typename T>
std::weak_ptr< T > | weak_this ()
template<typename SenderFunc, typename ReceiverFunc>
auto | connect (SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc)
template<typename SenderFunc, typename ReceiverFunc, typename ... Tracker>
std::enable_if_t< std::is_member_function_pointer_v< SenderFunc >, connection > | connectFunc (SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers)

## Protected Member Functions
virtual void | unmountDevice (Device &dev)
zyppng::expected< void > | isDesiredMedium (const zypp::Url &deviceUrl, const zypp::Pathname &mountPoint, const zyppng::MediaDataVerifierRef &verifier, uint mediaNr=1)
zypp::Pathname | createAttachPoint (const zypp::Pathname &attach_root) const
void | removeAttachPoint (const zypp::Pathname &attach_pt) const
bool | checkAttached (const zypp::Pathname &mountPoint, const std::function< bool(const zypp::media::MountEntry &)> predicate)
Protected Member Functions inherited from zyppng::Base
| Base (BasePrivate &dd)

## Static Protected Member Functions
static const std::function< bool(const zypp::media::MountEntry &)> | devicePredicate (unsigned int majNr, unsigned int minNr)
static const std::function< bool(const zypp::media::MountEntry &)> | fstypePredicate (const std::string &src, const std::vector< std::string > &fstypes)
static const std::function< bool(const zypp::media::MountEntry &)> | bindMountPredicate (const std::string &src)

## Private Attributes
WorkerCaps::WorkerType | _wType
ProviderConfiguration | _config
time_t | _attach_mtime = 0
zypp::Pathname | _attachRoot
std::vector< std::shared_ptr< Device > > | _sysDevs
std::unordered_map< std::string, AttachedMedia > | _attachedMedia
ProvideWorkerWeakRef | _parentWorker

## Additional Inherited Members
Public Types inherited from zyppng::Base
using | Ptr = std::shared_ptr<Base>
using | WeakPtr = std::weak_ptr<Base>
Static Public Member Functions inherited from zyppng::Base
template<typename Obj, typename Functor>
static decltype(auto) | make_base_slot (Obj *o, Functor &&f)
template<typename SenderFunc, typename ReceiverFunc>
static auto | connect (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc)
template<typename SenderFunc, typename ReceiverFunc, typename ... Tracker>
static auto | connectFunc (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers)
Protected Attributes inherited from zyppng::Base
std::unique_ptr< BasePrivate > | d_ptr

## Detailed Description

Abstract base class to be used together with the

See also
  MountingWorker class to control attaching and detaching of a multitude of different media types via a unified interface. Reimplement this class to easily support a new backend that utilizes the "mount" command to attach real filesystems to the system.

Definition at line 65 of file devicedriver.h.

## Constructor & Destructor Documentation

## ◆ DeviceDriver()

zyppng::worker::DeviceDriver::DeviceDriver | ( | WorkerCaps::WorkerType | wType | ) |

Definition at line 25 of file devicedriver.cc.

## Member Function Documentation

## ◆ setProvider()

void zyppng::worker::DeviceDriver::setProvider | ( | ProvideWorkerWeakRef | workerRef | ) |

Tells the driver which provide worker to use when requiring auth data or media changes

Definition at line 29 of file devicedriver.cc.

## ◆ mountDevice()

virtual AttachResult zyppng::worker::DeviceDriver::mountDevice | ( | const uint32_t | id,
|  | const zypp::Url & | mediaUrl,
|  | const std::string & | attachId,
|  | const std::string & | label,
|  | const HeaderValueMap & | extras )
| pure virtual

Called by the provide loop whenever a attach request is received.

## ◆ initialize()

zyppng::expected< WorkerCaps > zyppng::worker::DeviceDriver::initialize | ( | const zyppng::worker::Configuration & | conf | ) |
| virtual

Definition at line 34 of file devicedriver.cc.

## ◆ detachMedia()

bool zyppng::worker::DeviceDriver::detachMedia | ( | const std::string & | attachId | ) |

Detaches the medium referenced by attachId. Returns false if the medium could not be found

Note
  this will not unmount the physical devices. Call releaseIdleDevices to force this.

Definition at line 59 of file devicedriver.cc.

## ◆ releaseIdleDevices()

void zyppng::worker::DeviceDriver::releaseIdleDevices | ( |  | ) |

Physically detaches all devices that are not referenced by a attachment anymore

Definition at line 69 of file devicedriver.cc.

## ◆ detectDevices()

void zyppng::worker::DeviceDriver::detectDevices | ( |  | ) |
| virtual

Called by the parent to populate the device array every time a provide request arrives, only relevant for workers that operate on detectable devices. The base implementation does nothing

Definition at line 84 of file devicedriver.cc.

## ◆ knownDevices() [1/2]

std::vector< std::shared_ptr< Device > > & zyppng::worker::DeviceDriver::knownDevices | ( |  | ) |

Returns a list of all currently known devices, a subclass should always make sure that all currently mounted devices are present in that list.

Definition at line 89 of file devicedriver.cc.

## ◆ knownDevices() [2/2]

const std::vector< std::shared_ptr< Device > > & zyppng::worker::DeviceDriver::knownDevices | ( |  | ) | const

Returns a list of all currently known devices, a subclass should always make sure that all currently mounted devices are present in that list.

Definition at line 94 of file devicedriver.cc.

## ◆ attachedMedia()

std::unordered_map< std::string, AttachedMedia > & zyppng::worker::DeviceDriver::attachedMedia | ( |  | ) |

Returns the list of currently attached medias

Definition at line 99 of file devicedriver.cc.

## ◆ isVolatile()

bool zyppng::worker::DeviceDriver::isVolatile | ( |  | ) | const
| virtual

Returns true if the worker handles volatile devices ( e.g. DVDs ). The default impl returns false.

Definition at line 138 of file devicedriver.cc.

## ◆ setAttachRoot()

void zyppng::worker::DeviceDriver::setAttachRoot | ( | const zypp::Pathname & | root | ) |

Changes the attach root to a specific path, otherwise realpath(".") is used.

Definition at line 143 of file devicedriver.cc.

## ◆ attachRoot()

zypp::Pathname zyppng::worker::DeviceDriver::attachRoot | ( |  | ) | const

Returns the attachRoot as dictated by the controller

Definition at line 148 of file devicedriver.cc.

## ◆ immediateShutdown()

void zyppng::worker::DeviceDriver::immediateShutdown | ( |  | ) |
| virtual

The system is shutting down, release all ressources

Definition at line 104 of file devicedriver.cc.

## ◆ parentWorker()

ProvideWorkerRef zyppng::worker::DeviceDriver::parentWorker | ( |  | ) | const

Returns the parent worker if set

Definition at line 118 of file devicedriver.cc.

## ◆ config()

const zyppng::worker::Configuration & zyppng::worker::DeviceDriver::config | ( |  | ) | const

Returns the configuration that was sent by the controller

Definition at line 157 of file devicedriver.cc.

## ◆ unmountDevice()

void zyppng::worker::DeviceDriver::unmountDevice | ( | Device & | dev | ) |
| protected virtual

Forcefully unmounts the device, this does not check if there any attached medias still relying on it

Definition at line 123 of file devicedriver.cc.

## ◆ isDesiredMedium()

zyppng::expected< void > zyppng::worker::DeviceDriver::isDesiredMedium | ( | const zypp::Url & | deviceUrl,
|  | const zypp::Pathname & | mountPoint,
|  | const zyppng::MediaDataVerifierRef & | verifier,
|  | uint | mediaNr = 1 )
| protected

Checks if the medium deviceUrl mounted on path matches the verifier and mediaNr

Definition at line 162 of file devicedriver.cc.

## ◆ createAttachPoint()

zypp::Pathname zyppng::worker::DeviceDriver::createAttachPoint | ( | const zypp::Pathname & | attach_root | ) | const
| protected

Definition at line 209 of file devicedriver.cc.

## ◆ removeAttachPoint()

void zyppng::worker::DeviceDriver::removeAttachPoint | ( | const zypp::Pathname & | attach_pt | ) | const
| protected

Definition at line 268 of file devicedriver.cc.

## ◆ checkAttached()

bool zyppng::worker::DeviceDriver::checkAttached | ( | const zypp::Pathname & | mountPoint,
|  | const std::function< bool(const zypp::media::MountEntry &)> | predicate )
| protected

Definition at line 283 of file devicedriver.cc.

## ◆ devicePredicate()

const std::function< bool(const zypp::media::MountEntry &)> zyppng::worker::DeviceDriver::devicePredicate | ( | unsigned int | majNr,
|  | unsigned int | minNr )
| static protected

Returns a predicate for the checkAttached function that looks for a real device in the mount table

Definition at line 315 of file devicedriver.cc.

## ◆ fstypePredicate()

const std::function< bool(const zypp::media::MountEntry &)> zyppng::worker::DeviceDriver::fstypePredicate | ( | const std::string & | src,
|  | const std::vector< std::string > & | fstypes )
| static protected

Returns a predicate for the checkAttached function that looks for a virtual mount ( like smb or nfs ) in the mount table

Definition at line 331 of file devicedriver.cc.

## ◆ bindMountPredicate()

const std::function< bool(const zypp::media::MountEntry &)> zyppng::worker::DeviceDriver::bindMountPredicate | ( | const std::string & | src | ) |
| static protected

Returns a predicate for the checkAttached function that looks for a bind mount in the mount table

Definition at line 347 of file devicedriver.cc.

## Member Data Documentation

## ◆ _wType

WorkerCaps::WorkerType zyppng::worker::DeviceDriver::_wType
| private

Definition at line 188 of file devicedriver.h.

## ◆ _config

ProviderConfiguration zyppng::worker::DeviceDriver::_config
| private

Definition at line 189 of file devicedriver.h.

## ◆ _attach_mtime

time_t zyppng::worker::DeviceDriver::_attach_mtime = 0
| private

Definition at line 190 of file devicedriver.h.

## ◆ _attachRoot

zypp::Pathname zyppng::worker::DeviceDriver::_attachRoot
| private

Definition at line 191 of file devicedriver.h.

## ◆ _sysDevs

std::vector<std::shared_ptr<Device> > zyppng::worker::DeviceDriver::_sysDevs
| private

Definition at line 192 of file devicedriver.h.

## ◆ _attachedMedia

std::unordered_map<std::string, AttachedMedia> zyppng::worker::DeviceDriver::_attachedMedia
| private

Definition at line 193 of file devicedriver.h.

## ◆ _parentWorker

ProvideWorkerWeakRef zyppng::worker::DeviceDriver::_parentWorker
| private

Definition at line 194 of file devicedriver.h.

The documentation for this class was generated from the following files:

- zypp-media/ng/worker/devicedriver.h
- zypp-media/ng/worker/devicedriver.cc