libzypp  17.23.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 
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
ExternalProgram.h
zypp::ExternalProgram::Stderr_To_Stdout
Definition: ExternalProgram.h:73
zypp::media::Mount::~Mount
~Mount()
Clean up.
Definition: Mount.cc:55
zypp::media::Mount
Interface to the mount program.
Definition: Mount.h:69
zypp::media::MountEntry::opts
std::string opts
mount options
Definition: Mount.h:53
zypp::ExternalProgram
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
Definition: ExternalProgram.h:59
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::Status
int Status()
Return the exit status of the process, closing the connection if not already done.
Definition: Mount.cc:253
zypp::media::Mount::Options
KVMap< kvmap::KVMapBase::CharSep<'=',','> > Options
Mount options.
Definition: Mount.h:82
zypp::media::operator<<
std::ostream & operator<<(std::ostream &str, const MediaAccess &obj)
Definition: MediaAccess.cc:481
zypp::media::MountEntry::type
std::string type
filesystem / mount type
Definition: Mount.h:52
zypp::media::Mount::Environment
ExternalProgram::Environment Environment
For passing additional environment variables to mount.
Definition: Mount.h:77
zypp::media::MountEntry::pass
int pass
pass number on parallel fsck
Definition: Mount.h:55
zypp::media::MountEntry::src
std::string src
name of mounted file system
Definition: Mount.h:50
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
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
zypp::media::Mount::Mount
Mount()
Create an new instance.
Definition: Mount.cc:49
zypp::ExternalProgram::Stderr_Disposition
Stderr_Disposition
Define symbols for different policies on the handling of stderr.
Definition: ExternalProgram.h:70
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
zypp::ExternalProgram::Environment
std::map< std::string, std::string > Environment
For passing additional environment variables to set.
Definition: ExternalProgram.h:81
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::exit_code
int exit_code
The exit code of the process, or -1 if not yet known.
Definition: Mount.h:175
zypp::KVMap
A map of (key,value) strings.
Definition: KVMap.h:176
KVMap.h
zypp::media::MountEntry::freq
int freq
dump frequency in days
Definition: Mount.h:54
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::process
ExternalProgram * process
The connection to the mount process.
Definition: Mount.h:144
zypp::media::MountEntry
A "struct mntent" like mount entry structure, but using std::strings.
Definition: Mount.h:34
zypp::media::Mount::umount
void umount(const std::string &path)
umount device
Definition: Mount.cc:163
zypp::media::Mount::Kill
void Kill()
Forcably kill the process.
Definition: Mount.cc:269
zypp::media::MountEntry::MountEntries
std::vector< MountEntry > MountEntries
Definition: Mount.h:61
str
String related utilities and Regular expression matching.
zypp::media::MountEntry::dir
std::string dir
file system path prefix
Definition: Mount.h:51