libzypp 17.31.23
zyppng::worker::DeviceDriver Class Referenceabstract

#include </home/abuild/rpmbuild/BUILD/libzypp-17.31.23/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< WorkerCapsinitialize (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::Configurationconfig () const
 

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)
 

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
 
zyppng::worker::Configuration _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
 

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 64 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 60 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 70 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 85 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 90 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 95 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 100 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 139 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 144 of file devicedriver.cc.

◆ attachRoot()

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

Returns the attachRoot as dictated by the controller

Definition at line 149 of file devicedriver.cc.

◆ immediateShutdown()

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

The system is shutting down, release all ressources

Definition at line 105 of file devicedriver.cc.

◆ parentWorker()

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

Returns the parent worker if set

Definition at line 119 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 158 of file devicedriver.cc.

◆ unmountDevice()

void zyppng::worker::DeviceDriver::unmountDevice ( Device dev)
protectedvirtual

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

Definition at line 124 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 163 of file devicedriver.cc.

◆ createAttachPoint()

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

Definition at line 210 of file devicedriver.cc.

◆ removeAttachPoint()

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

Definition at line 269 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 284 of file devicedriver.cc.

◆ devicePredicate()

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

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

Definition at line 316 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 
)
staticprotected

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

Definition at line 332 of file devicedriver.cc.

◆ bindMountPredicate()

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

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

Definition at line 348 of file devicedriver.cc.

Member Data Documentation

◆ _wType

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

Definition at line 187 of file devicedriver.h.

◆ _config

zyppng::worker::Configuration zyppng::worker::DeviceDriver::_config
private

Definition at line 188 of file devicedriver.h.

◆ _attach_mtime

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

Definition at line 189 of file devicedriver.h.

◆ _attachRoot

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

Definition at line 190 of file devicedriver.h.

◆ _sysDevs

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

Definition at line 191 of file devicedriver.h.

◆ _attachedMedia

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

Definition at line 192 of file devicedriver.h.

◆ _parentWorker

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

Definition at line 193 of file devicedriver.h.


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