libzypp 17.28.8
Mount.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
13// -*- C++ -*-
14
15#ifndef ZYPP_MEDIA_MOUNT_H
16#define ZYPP_MEDIA_MOUNT_H
17
18#include <set>
19#include <map>
20#include <string>
21#include <iosfwd>
22
23#include <zypp/ExternalProgram.h>
24#include <zypp/KVMap.h>
25
26namespace zypp {
27 namespace media {
28
29
35 {
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)
42 : src(source)
43 , dir(target)
44 , type(fstype)
45 , opts(options)
46 , freq(dumpfreq)
47 , pass(passnum)
48 {}
49
50 std::string src;
51 std::string dir;
52 std::string type;
53 std::string opts;
54 int freq;
55 int pass;
56 };
57
61 typedef std::vector<MountEntry> MountEntries;
62
64 std::ostream & operator<<( std::ostream & str, const MountEntry & obj );
65
69 class Mount
70 {
71 public:
72
78
83
84 public:
85
89 Mount();
90
94 ~Mount();
95
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() );
114
122 void umount (const std::string& path);
123
124 public:
125
137 static MountEntries
138 getEntries(const std::string &mtab = "");
139
140 private:
141
145
152 void run( const char *const *argv, const Environment& environment,
155
156 void run( const char *const *argv,
159 Environment notused;
160 run( argv, notused, stderr_disp );
161 }
162
166 int Status();
167
170 void Kill();
171
172
176 };
177
178
179 } // namespace media
180} // namespace zypp
181
182#endif
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
std::map< std::string, std::string > Environment
For passing additional environment variables to set.
Stderr_Disposition
Define symbols for different policies on the handling of stderr.
Interface to the mount program.
Definition: Mount.h:70
void umount(const std::string &path)
umount device
Definition: Mount.cc:163
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.
Definition: Mount.cc:234
void run(const char *const *argv, ExternalProgram::Stderr_Disposition stderr_disp=ExternalProgram::Stderr_To_Stdout)
Definition: Mount.h:156
static MountEntries getEntries(const std::string &mtab="")
Return mount entries from /etc/mtab or /etc/fstab file.
Definition: Mount.cc:276
KVMap< kvmap::KVMapBase::CharSep<'=',','> > Options
Mount options.
Definition: Mount.h:82
void Kill()
Forcably kill the process.
Definition: Mount.cc:269
int Status()
Return the exit status of the process, closing the connection if not already done.
Definition: Mount.cc:253
ExternalProgram * process
The connection to the mount process.
Definition: Mount.h:144
void mount(const std::string &source, const std::string &target, const std::string &filesystem, const std::string &options, const Environment &environment=Environment())
mount device
Definition: Mount.cc:67
int exit_code
The exit code of the process, or -1 if not yet known.
Definition: Mount.h:175
~Mount()
Clean up.
Definition: Mount.cc:55
ExternalProgram::Environment Environment
For passing additional environment variables to mount.
Definition: Mount.h:77
Mount()
Create an new instance.
Definition: Mount.cc:49
String related utilities and Regular expression matching.
std::ostream & operator<<(std::ostream &str, const MediaBlockList &bl)
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
A map of (key,value) strings.
Definition: KVMap.h:176
A "struct mntent" like mount entry structure, but using std::strings.
Definition: Mount.h:35
std::string dir
file system path prefix
Definition: Mount.h:51
std::vector< MountEntry > MountEntries
A vector of mount entries.
Definition: Mount.h:61
std::string src
name of mounted file system
Definition: Mount.h:50
std::string type
filesystem / mount type
Definition: Mount.h:52
int freq
dump frequency in days
Definition: Mount.h:54
int pass
pass number on parallel fsck
Definition: Mount.h:55
std::string opts
mount options
Definition: Mount.h:53
MountEntry(const std::string &source, const std::string &target, const std::string &fstype, const std::string &options, const int dumpfreq=0, const int passnum=0)
Definition: Mount.h:36