libzypp: zypp/media/Mount.h Source File

libzypp 17.25.10

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
26 namespace zypp {
27 namespace media {
28
29
34 struct MountEntry
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
77 typedef ExternalProgram::Environment Environment;
78
82 typedef KVMap<kvmap::KVMapBase::CharSep<'=',','> > Options;
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
144 ExternalProgram *process;
145
152 void run( const char *const *argv, const Environment& environment,
153 ExternalProgram::Stderr_Disposition stderr_disp =
154 ExternalProgram::Stderr_To_Stdout);
155
156 void run( const char *const *argv,
157 ExternalProgram::Stderr_Disposition stderr_disp =
158 ExternalProgram::Stderr_To_Stdout) {
159 Environment notused;
160 run( argv, notused, stderr_disp );
161 }
162
166 int Status();
167
170 void Kill();
171
172
175 int exit_code;
176 };
177
178
179 } // namespace media
180 } // namespace zypp
181
182 #endif
ExternalProgram.h
KVMap.h
zypp::ExternalProgram
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
Definition: ExternalProgram.h:60
zypp::ExternalProgram::Environment
std::map< std::string, std::string > Environment
For passing additional environment variables to set.
Definition: ExternalProgram.h:81
zypp::ExternalProgram::Stderr_Disposition
Stderr_Disposition
Define symbols for different policies on the handling of stderr.
Definition: ExternalProgram.h:70
zypp::ExternalProgram::Stderr_To_Stdout
@ Stderr_To_Stdout
Definition: ExternalProgram.h:73
zypp::media::Mount
Interface to the mount program.
Definition: Mount.h:70
zypp::media::Mount::umount
void umount(const std::string &path)
umount device
Definition: Mount.cc:163
zypp::media::Mount::run
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
zypp::media::Mount::run
void run(const char *const *argv, ExternalProgram::Stderr_Disposition stderr_disp=ExternalProgram::Stderr_To_Stdout)
Definition: Mount.h:156
zypp::media::Mount::getEntries
static MountEntries getEntries(const std::string &mtab="")
Return mount entries from /etc/mtab or /etc/fstab file.
Definition: Mount.cc:276
zypp::media::Mount::Options
KVMap< kvmap::KVMapBase::CharSep<'=',','> > Options
Mount options.
Definition: Mount.h:82
zypp::media::Mount::Kill
void Kill()
Forcably kill the process.
Definition: Mount.cc:269
zypp::media::Mount::Status
int Status()
Return the exit status of the process, closing the connection if not already done.
Definition: Mount.cc:253
zypp::media::Mount::process
ExternalProgram * process
The connection to the mount process.
Definition: Mount.h:144
zypp::media::Mount::mount
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
zypp::media::Mount::exit_code
int exit_code
The exit code of the process, or -1 if not yet known.
Definition: Mount.h:175
zypp::media::Mount::~Mount
~Mount()
Clean up.
Definition: Mount.cc:55
zypp::media::Mount::Environment
ExternalProgram::Environment Environment
For passing additional environment variables to mount.
Definition: Mount.h:77
zypp::media::Mount::Mount
Mount()
Create an new instance.
Definition: Mount.cc:49
str
String related utilities and Regular expression matching.
zypp::media::operator<<
std::ostream & operator<<(std::ostream &str, const MediaAccess &obj)
Definition: MediaAccess.cc:481
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::KVMap
A map of (key,value) strings.
Definition: KVMap.h:176
zypp::media::MountEntry
A "struct mntent" like mount entry structure, but using std::strings.
Definition: Mount.h:35
zypp::media::MountEntry::dir
std::string dir
file system path prefix
Definition: Mount.h:51
zypp::media::MountEntry::MountEntries
std::vector< MountEntry > MountEntries
A vector of mount entries.
Definition: Mount.h:61
zypp::media::MountEntry::src
std::string src
name of mounted file system
Definition: Mount.h:50
zypp::media::MountEntry::type
std::string type
filesystem / mount type
Definition: Mount.h:52
zypp::media::MountEntry::freq
int freq
dump frequency in days
Definition: Mount.h:54
zypp::media::MountEntry::pass
int pass
pass number on parallel fsck
Definition: Mount.h:55
zypp::media::MountEntry::opts
std::string opts
mount options
Definition: Mount.h:53
zypp::media::MountEntry::MountEntry
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