libzypp  13.10.6
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 
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
Interface to the mount program.
Definition: Mount.h:69
~Mount()
Clean up.
Definition: Mount.cc:54
ExternalProgram::Environment Environment
For passing additional environment variables to mount.
Definition: Mount.h:77
std::vector< MountEntry > MountEntries
Definition: Mount.h:61
std::ostream & operator<<(std::ostream &str, const MediaAccess &obj)
Definition: MediaAccess.cc:482
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:66
std::string type
filesystem / mount type
Definition: Mount.h:52
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
int Status()
Return the exit status of the process, closing the connection if not already done.
Definition: Mount.cc:252
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:233
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
int pass
pass number on parallel fsck
Definition: Mount.h:55
Mount()
Create an new instance.
Definition: Mount.cc:48
Stderr_Disposition
Define symbols for different policies on the handling of stderr.
std::map< std::string, std::string > Environment
For passing additional environment variables to set.
KVMap< kvmap::KVMapBase::CharSep<'=',','> > Options
Mount options.
Definition: Mount.h:82
ExternalProgram * process
The connection to the mount process.
Definition: Mount.h:144
int exit_code
The exit code of the process, or -1 if not yet known.
Definition: Mount.h:175
std::string opts
mount options
Definition: Mount.h:53
static MountEntries getEntries(const std::string &mtab="")
Return mount entries from /etc/mtab or /etc/fstab file.
Definition: Mount.cc:275
A &quot;struct mntent&quot; like mount entry structure, but using std::strings.
Definition: Mount.h:34
int freq
dump frequency in days
Definition: Mount.h:54
void Kill()
Forcably kill the process.
Definition: Mount.cc:268
A map of (key,value) strings.
Definition: KVMap.h:176
void run(const char *const *argv, ExternalProgram::Stderr_Disposition stderr_disp=ExternalProgram::Stderr_To_Stdout)
Definition: Mount.h:156
std::string src
name of mounted file system
Definition: Mount.h:50
void umount(const std::string &path)
umount device
Definition: Mount.cc:162
std::string dir
file system path prefix
Definition: Mount.h:51