libzypp  17.14.0
zypp::media::Mount Class Reference

Interface to the mount program. More...

#include <Mount.h>

Public Types

typedef ExternalProgram::Environment Environment
 For passing additional environment variables to mount. More...
 
typedef KVMap< kvmap::KVMapBase::CharSep<'=',','> > Options
 Mount options. More...
 

Public Member Functions

 Mount ()
 Create an new instance. More...
 
 ~Mount ()
 Clean up. More...
 
void mount (const std::string &source, const std::string &target, const std::string &filesystem, const std::string &options, const Environment &environment=Environment())
 mount device More...
 
void umount (const std::string &path)
 umount device More...
 

Static Public Member Functions

static MountEntries getEntries (const std::string &mtab="")
 Return mount entries from /etc/mtab or /etc/fstab file. More...
 

Private Member Functions

void run (const char *const *argv, const Environment &environment, ExternalProgram::Stderr_Disposition stderr_disp=ExternalProgram::Stderr_To_Stdout)
 Run mount with the specified arguments and handle stderr. More...
 
void run (const char *const *argv, ExternalProgram::Stderr_Disposition stderr_disp=ExternalProgram::Stderr_To_Stdout)
 
int Status ()
 Return the exit status of the process, closing the connection if not already done. More...
 
void Kill ()
 Forcably kill the process. More...
 

Private Attributes

ExternalProgramprocess
 The connection to the mount process. More...
 
int exit_code
 The exit code of the process, or -1 if not yet known. More...
 

Detailed Description

Interface to the mount program.

Definition at line 69 of file Mount.h.

Member Typedef Documentation

◆ Environment

For passing additional environment variables to mount.

Definition at line 77 of file Mount.h.

◆ Options

Mount options.

'key' or 'key=value' pairs, separated by ','

Definition at line 82 of file Mount.h.

Constructor & Destructor Documentation

◆ Mount()

zypp::media::Mount::Mount ( )

Create an new instance.

Definition at line 48 of file Mount.cc.

◆ ~Mount()

zypp::media::Mount::~Mount ( )

Clean up.

Definition at line 54 of file Mount.cc.

Member Function Documentation

◆ mount()

void zypp::media::Mount::mount ( const std::string &  source,
const std::string &  target,
const std::string &  filesystem,
const std::string &  options,
const Environment environment = Environment() 
)

mount device

Parameters
sourcewhat to mount (e.g. /dev/hda3)
targetwhere to mount (e.g. /mnt)
filesystemwhich filesystem to use (e.g. reiserfs) (-t parameter)
optionsmount options (e.g. ro) (-o parameter)
environmentoptinal environment to pass (e.g. PASSWD="sennah")
Exceptions
MediaException

Definition at line 66 of file Mount.cc.

◆ umount()

void zypp::media::Mount::umount ( const std::string &  path)

umount device

Parameters
pathdevice or mountpoint to umount
Exceptions
MediaException

Definition at line 162 of file Mount.cc.

◆ getEntries()

MountEntries zypp::media::Mount::getEntries ( const std::string &  mtab = "")
static

Return mount entries from /etc/mtab or /etc/fstab file.

Parameters
mtabThe name of the (mounted) file system description file to read from. This file should be one /etc/mtab, /etc/fstab or /proc/mounts. Default is to read /proc/mounts and /etc/mtab in case is not a symlink to /proc/mounts.
Returns
A vector with mount entries or empty vector if reading or parsing of the mtab file(s) failed.

Definition at line 275 of file Mount.cc.

◆ run() [1/2]

void zypp::media::Mount::run ( const char *const *  argv,
const Environment environment,
ExternalProgram::Stderr_Disposition  stderr_disp = ExternalProgram::Stderr_To_Stdout 
)
private

Run mount with the specified arguments and handle stderr.

Parameters
argvMount arguments
environmentAddittional environment to set
stderr_dispHow to handle stderr, merged with stdout by default

Definition at line 233 of file Mount.cc.

◆ run() [2/2]

void zypp::media::Mount::run ( const char *const *  argv,
ExternalProgram::Stderr_Disposition  stderr_disp = ExternalProgram::Stderr_To_Stdout 
)
inlineprivate

Definition at line 156 of file Mount.h.

◆ Status()

int zypp::media::Mount::Status ( )
private

Return the exit status of the process, closing the connection if not already done.

Definition at line 252 of file Mount.cc.

◆ Kill()

void zypp::media::Mount::Kill ( )
private

Forcably kill the process.

Definition at line 268 of file Mount.cc.

Member Data Documentation

◆ process

ExternalProgram* zypp::media::Mount::process
private

The connection to the mount process.

Definition at line 144 of file Mount.h.

◆ exit_code

int zypp::media::Mount::exit_code
private

The exit code of the process, or -1 if not yet known.

Definition at line 175 of file Mount.h.


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