libzypp 17.37.10

zypp::media::MediaCIFS Class Reference

Implementation class for CIFS MediaHandler. More...

`#include <zypp/media/MediaCIFS.h>`

Inheritance diagram for zypp::media::MediaCIFS:

## Public Member Functions
| MediaCIFS (const MirroredOrigin &origin_r, const Pathname &attach_point_hint_r)
| ~MediaCIFS () override
bool | isAttached () const override
| True if media is attached.
Public Member Functions inherited from zypp::media::MediaHandler
bool | dependsOnParent (MediaAccessId parentId, bool exactIdMatch)
| Check if the current media handler depends on an another handler specified by media access id.
bool | dependsOnParent ()
void | resetParentId ()
| Called in case, where the media manager takes over the destruction of the parent id (e.g.
Pathname | attachPoint () const
| Return the currently used attach point.
void | setAttachPoint (const Pathname &path, bool temp)
| Set a new attach point.
void | setAttachPoint (const AttachPointRef &ref)
| Set a (shared) attach point.
AttachPoint | attachPointHint () const
| Get the actual attach point hint.
void | attachPointHint (const Pathname &path, bool temp)
| Set the attach point hint as specified by the user.
Pathname | createAttachPoint () const
| Try to create a default / temporary attach point.
Pathname | createAttachPoint (const Pathname &attach_root) const
| Try to create a temporary attach point in specified root.
void | removeAttachPoint ()
| Remove unused attach point.
virtual bool | checkAttachPoint (const Pathname &apoint) const
| Verify if the specified directory as attach point (root) as requires by the particular media handler implementation.
bool | isUseableAttachPoint (const Pathname &path, bool mtab=true) const
| Ask media manager, if the specified path is already used as attach point or if there are another attach points bellow of it.
std::string | mediaSourceName () const
| Get the media source name or an empty string.
void | setMediaSource (const MediaSourceRef &ref)
| Set new media source reference.
AttachedMedia | findAttachedMedia (const MediaSourceRef &media) const
| Ask the media manager if specified media source is already attached.
AttachedMedia | attachedMedia () const
| Returns the attached media.
bool | isSharedMedia () const
| Returns a hint if the media is shared or not.
bool | checkAttached (bool matchMountFs) const
| Check actual mediaSource attachment against the current mount table of the system.
void | forceRelaseAllMedia (bool matchMountFs)
| Call to this function will try to release all media matching the currenlty attached media source, that it is able to find in the mount table.
void | forceRelaseAllMedia (const MediaSourceRef &ref, bool matchMountFs)
| MediaHandler (MirroredOrigin origin_r, const Pathname &attach_point_r, Pathname urlpath_below_attachpoint_r, const bool does_download_r)
| If the concrete media handler provides a nonempty attach_point, it must be an existing directory.
virtual | ~MediaHandler ()
| Contolling MediaAccess takes care, that attached media is released prior to deleting this.
bool | downloads () const
| Hint if files are downloaded or not.
std::string | protocol () const
| Protocol hint for MediaAccess.
Url | url () const
| Primary Url used.
OriginEndpoint | originEndpoint () const
| Primary OriginEndpoint used.
void | attach (bool next)
| Use concrete handler to attach the media.
Pathname | localRoot () const
| Return the local directory that corresponds to medias url, no matter if media isAttached or not.
Pathname | localPath (const Pathname &pathname) const
| Files provided will be available at 'localPath(filename)'.
void | disconnect ()
| Use concrete handler to isconnect media.
void | release (const std::string &ejectDev="")
| Use concrete handler to release the media.
void | provideFile (const OnMediaLocation &file) const
| Use concrete handler to provide file denoted by path below 'localRoot'.
void | provideFileCopy (const OnMediaLocation &srcFile, const Pathname &targetFilename) const
| Call concrete handler to provide a copy of a file under a different place in the file system (usually not under attach point) as a copy.
void | provideDir (const Pathname &dirname) const
| Use concrete handler to provide directory denoted by path below 'localRoot' (not recursive!).
void | provideDirTree (const Pathname &dirname) const
| Use concrete handler to provide directory tree denoted by path below 'localRoot' (recursive!
void | releaseFile (const Pathname &filename) const
| Remove filename below localRoot IFF handler downloads files to the local filesystem.
void | releaseDir (const Pathname &dirname) const
| Remove directory tree below localRoot IFF handler downloads files to the local filesystem.
void | releasePath (const Pathname &pathname) const
| Remove pathname below localRoot IFF handler downloads files to the local filesystem.
void | dirInfo (std::list< std::string > &retlist, const Pathname &dirname, bool dots=true) const
| Return content of directory on media via retlist.
void | dirInfo (filesystem::DirContent &retlist, const Pathname &dirname, bool dots=true) const
| Basically the same as dirInfo above.
bool | doesFileExist (const Pathname &filename) const
| check if a file exists
virtual bool | hasMoreDevices ()
| Check if the media has one more device available for attach(true).
virtual void | getDetectedDevices (std::vector< std::string > &devices, unsigned int &index) const
| Fill in a vector of detected ejectable devices and the index of the currently attached device within the vector.
virtual void | precacheFiles (const std::vector< OnMediaLocation > &files)
| Tries to fetch the given files and precaches them.

## Protected Member Functions
void | attachTo (bool next=false) override
| Asserted that not already attached, and attachPoint is a directory.
void | releaseFrom (const std::string &ejectDev) override
| Call concrete handler to release the media.
void | getFile (const OnMediaLocation &file) const override
| Call concrete handler to provide file below attach point.
void | getDir (const Pathname &dirname, bool recurse_r) const override
| Call concrete handler to provide directory content (not recursive!) below attach point.
void | getDirInfo (std::list< std::string > &retlist, const Pathname &dirname, bool dots=true) const override
| Call concrete handler to provide a content list of directory on media via retlist.
void | getDirInfo (filesystem::DirContent &retlist, const Pathname &dirname, bool dots=true) const override
| Basically the same as getDirInfo above.
bool | getDoesFileExist (const Pathname &filename) const override
| check if a file exists
Protected Member Functions inherited from zypp::media::MediaHandler
virtual void | disconnectFrom ()
| Call concrete handler to disconnect media.
virtual void | forceEject (const std::string &device)
| Call concrete handler to physically eject the media (i.e.
virtual void | getFileCopy (const OnMediaLocation &file, const Pathname &targetFilename) const
| Call concrete handler to provide a file under a different place in the file system (usually not under attach point) as a copy.
void | getDirectoryYast (std::list< std::string > &retlist, const Pathname &dirname, bool dots=true) const
| Retrieve and if available scan dirname/directory.yast.
void | getDirectoryYast (filesystem::DirContent &retlist, const Pathname &dirname, bool dots=true) const
| Retrieve and if available scan dirname/directory.yast.

## Private Member Functions
bool | authenticate (AuthData &authdata, bool firstTry) const

## Additional Inherited Members
Public Types inherited from zypp::media::MediaHandler
using | Ptr = shared_ptr<MediaHandler>
using | constPtr = shared_ptr<const MediaHandler>
Static Public Member Functions inherited from zypp::media::MediaHandler
static bool | setAttachPrefix (const Pathname &attach_prefix)
static std::string | getRealPath (const std::string &path)
static Pathname | getRealPath (const Pathname &path)
static bool | checkAttachPoint (const Pathname &apoint, bool empty_dir, bool writeable)
| Verify if the specified directory as attach point (root) using requested checks.
Protected Attributes inherited from zypp::media::MediaHandler
MirroredOrigin | _origin
| Contains the authority URL and mirrors.
MediaAccessId | _parentId
| Access Id of media handler we depend on.

## Detailed Description

Implementation class for CIFS MediaHandler.

NOTE: The implementation serves both, "smb" and "cifs" URLs, but passes "cifs" to the mount command in any case.

See also
  MediaHandler

Definition at line 32 of file MediaCIFS.h.

## Constructor & Destructor Documentation

## ◆ MediaCIFS()

zypp::media::MediaCIFS::MediaCIFS | ( | const MirroredOrigin & | origin_r,
|  | const Pathname & | attach_point_hint_r )

Definition at line 101 of file MediaCIFS.cc.

## ◆ ~MediaCIFS()

zypp::media::MediaCIFS::~MediaCIFS | ( |  | ) |
| inline override

Definition at line 50 of file MediaCIFS.h.

## Member Function Documentation

## ◆ attachTo()

void zypp::media::MediaCIFS::attachTo | ( | bool | next = false | ) |
| override protected virtual

Asserted that not already attached, and attachPoint is a directory.

Authentication: credentials can be specified in the following few ways (the first has the highest preference).

- URL username:password
- mountoptions URL query parameter (see man mount.cifs)
- CredentialManager - either previously saved credentials will be used or the user will be promted for them via AuthenticationReport callback.

Note
  The implementation currently serves both, "smb" and and "cifs" URLs, but passes "cifs" to the mount command in any case.

Implements zypp::media::MediaHandler.

Definition at line 129 of file MediaCIFS.cc.

## ◆ releaseFrom()

void zypp::media::MediaCIFS::releaseFrom | ( | const std::string & | ejectDev | ) |
| override protected virtual

Call concrete handler to release the media.

If eject is true, and the media is used in one handler instance only, physically eject the media (i.e. CD-ROM).

Asserted that media is attached.

Parameters

  ejectDev | Device to eject. None if empty.

Exceptions

  MediaException |

Implements zypp::media::MediaHandler.

Definition at line 340 of file MediaCIFS.cc.

## ◆ getFile()

void zypp::media::MediaCIFS::getFile | ( | const OnMediaLocation & | file | ) | const
| override protected virtual

Call concrete handler to provide file below attach point.

Default implementation provided, that returns whether a file is located at 'localRoot + filename'.

Asserted that media is attached.

Exceptions

  MediaException |

Reimplemented from zypp::media::MediaHandler.

Definition at line 353 of file MediaCIFS.cc.

## ◆ getDir()

void zypp::media::MediaCIFS::getDir | ( | const Pathname & | dirname,
|  | bool | recurse_r ) const
| override protected virtual

Call concrete handler to provide directory content (not recursive!) below attach point.

Return E_not_supported_by_media if media does not support retrieval of directory content.

Default implementation provided, that returns whether a directory is located at 'localRoot + dirname'.

Asserted that media is attached.

Exceptions

  MediaException |

Implements zypp::media::MediaHandler.

Definition at line 365 of file MediaCIFS.cc.

## ◆ getDirInfo() [1/2]

void zypp::media::MediaCIFS::getDirInfo | ( | std::list< std::string > & | retlist,
|  | const Pathname & | dirname,
|  | bool | dots = true ) const
| override protected virtual

Call concrete handler to provide a content list of directory on media via retlist.

If dots is false entries starting with '.' are not reported.

Return E_not_supported_by_media if media does not support retrieval of directory content.

Default implementation provided, that returns the content of a directory at 'localRoot + dirnname' retrieved via 'readdir'.

Asserted that media is attached and retlist is empty.

Exceptions

  MediaException |

Implements zypp::media::MediaHandler.

Definition at line 378 of file MediaCIFS.cc.

## ◆ getDirInfo() [2/2]

void zypp::media::MediaCIFS::getDirInfo | ( | filesystem::DirContent & | retlist,
|  | const Pathname & | dirname,
|  | bool | dots = true ) const
| override protected virtual

Basically the same as getDirInfo above.

The content list is returned as filesystem::DirContent, which includes name and filetype of each directory entry. Retrieving the filetype usg. requires an additional ::stat call for each entry, thus it's more expensive than a simple readdir.

Asserted that media is attached and retlist is empty.

Exceptions

  MediaException |

Implements zypp::media::MediaHandler.

Definition at line 392 of file MediaCIFS.cc.

## ◆ getDoesFileExist()

bool zypp::media::MediaCIFS::getDoesFileExist | ( | const Pathname & | filename | ) | const
| override protected virtual

check if a file exists

Asserted that url is a file and not a dir.

Exceptions

  MediaException |

Implements zypp::media::MediaHandler.

Definition at line 398 of file MediaCIFS.cc.

## ◆ isAttached()

bool zypp::media::MediaCIFS::isAttached | ( |  | ) | const
| override virtual

True if media is attached.

Reimplemented from zypp::media::MediaHandler.

Definition at line 327 of file MediaCIFS.cc.

## ◆ authenticate()

bool zypp::media::MediaCIFS::authenticate | ( | AuthData & | authdata,
|  | bool | firstTry ) const
| private

Todo
  need a way to pass different CredManagerOptions here

Todo
  add comma to the message for the next release

Todo
  find a way to save the url with changed username back to repoinfo or dont store urls with username (and either forbid more repos with the same url and different user, or return a set of credentials from CM and try them one by one)

Definition at line 403 of file MediaCIFS.cc.

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

- zypp/media/MediaCIFS.h
- zypp/media/MediaCIFS.cc