1
/*---------------------------------------------------------------------\
3
| |__ / \ / / . \ . \ |
8
\---------------------------------------------------------------------*/
9
/** \file zypp/media/Mount.h
15
#ifndef ZYPP_MEDIA_MOUNT_H
16
#define ZYPP_MEDIA_MOUNT_H
23
#include "zypp/ExternalProgram.h"
24
#include "zypp/KVMap.h"
31
* A "struct mntent" like mount entry structure,
32
* but using std::strings.
36
MountEntry(const std::string &source,
37
const std::string &target,
38
const std::string &fstype,
39
const std::string &options,
40
const int dumpfreq = 0,
41
const int passnum = 0)
50
std::string src; //!< name of mounted file system
51
std::string dir; //!< file system path prefix
52
std::string type; //!< filesystem / mount type
53
std::string opts; //!< mount options
54
int freq; //!< dump frequency in days
55
int pass; //!< pass number on parallel fsck
58
/** \relates MountEntry
59
* A vector of mount entries.
61
typedef std::vector<MountEntry> MountEntries;
63
/** \relates MountEntry Stream output */
64
std::ostream & operator<<( std::ostream & str, const MountEntry & obj );
67
* @short Interface to the mount program
74
* For passing additional environment variables
77
typedef ExternalProgram::Environment Environment;
80
* Mount options. 'key' or 'key=value' pairs, separated by ','
82
typedef KVMap<kvmap::KVMapBase::CharSep<'=',','> > Options;
87
* Create an new instance.
99
* @param source what to mount (e.g. /dev/hda3)
100
* @param target where to mount (e.g. /mnt)
101
* @param filesystem which filesystem to use (e.g. reiserfs) (-t parameter)
102
* @param options mount options (e.g. ro) (-o parameter)
103
* @param environment optinal environment to pass (e.g. PASSWD="sennah")
105
* \throws MediaException
109
void mount ( const std::string& source,
110
const std::string& target,
111
const std::string& filesystem,
112
const std::string& options,
113
const Environment& environment = Environment() );
117
* @param path device or mountpoint to umount
119
* \throws MediaException
122
void umount (const std::string& path);
127
* Return mount entries from /etc/mtab or /etc/fstab file.
129
* @param mtab The name of the (mounted) file system description
130
* file to read from. This file should be one /etc/mtab,
131
* /etc/fstab or /proc/mounts. Default is to read
132
* /proc/mounts and /etc/mtab in case is not a symlink
134
* @returns A vector with mount entries or empty vector if reading
135
* or parsing of the mtab file(s) failed.
138
getEntries(const std::string &mtab = "");
142
/** The connection to the mount process.
144
ExternalProgram *process;
147
* Run mount with the specified arguments and handle stderr.
148
* @param argv Mount arguments
149
* @param environment Addittional environment to set
150
* @param stderr_disp How to handle stderr, merged with stdout by default
152
void run( const char *const *argv, const Environment& environment,
153
ExternalProgram::Stderr_Disposition stderr_disp =
154
ExternalProgram::Stderr_To_Stdout);
156
void run( const char *const *argv,
157
ExternalProgram::Stderr_Disposition stderr_disp =
158
ExternalProgram::Stderr_To_Stdout) {
160
run( argv, notused, stderr_disp );
163
/** Return the exit status of the process, closing the connection if
168
/** Forcably kill the process
173
/** The exit code of the process, or -1 if not yet known.