libzypp  17.31.31
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-core/KVMap>
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 
53  bool isBlockDevice () const;
54 
55  std::string src;
56  std::string dir;
57  std::string type;
58  std::string opts;
59  int freq;
60  int pass;
61  };
62 
66  typedef std::vector<MountEntry> MountEntries;
67 
69  std::ostream & operator<<( std::ostream & str, const MountEntry & obj );
70 
74  class Mount
75  {
76  public:
77 
83 
88 
89  public:
90 
94  Mount();
95 
99  ~Mount();
100 
114  void mount ( const std::string& source,
115  const std::string& target,
116  const std::string& filesystem,
117  const std::string& options,
118  const Environment& environment = Environment() );
119 
127  void umount (const std::string& path);
128 
129  public:
130 
142  static MountEntries
143  getEntries(const std::string &mtab = "");
144 
149  static time_t getMTime();
150 
151  private:
152 #if LEGACY(1722)
153  ExternalProgram * _bincompat1;
154  int _bincompat2;
155 #endif
156  };
157 
158 
159  } // namespace media
160 } // namespace zypp
161 
162 #endif
std::ostream & operator<<(std::ostream &str, const MediaHandler &obj)
Interface to the mount program.
Definition: mount.h:74
~Mount()
Clean up.
Definition: mount.cc:59
ExternalProgram::Environment Environment
For passing additional environment variables to mount.
Definition: mount.h:82
String related utilities and Regular expression matching.
bool isBlockDevice() const
Returns true if the src part points to a block device in /dev.
Definition: mount.cc:50
std::vector< MountEntry > MountEntries
Definition: mount.h:66
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:62
std::string type
filesystem / mount type
Definition: mount.h:57
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
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:60
Mount()
Create an new instance.
Definition: mount.cc:56
static time_t getMTime()
Get the modification time of the /etc/mtab file.
Definition: mount.cc:264
std::map< std::string, std::string > Environment
For passing additional environment variables to set.
KVMap< kvmap::KVMapBase::CharSep<'=',','> > Options
Mount options.
Definition: mount.h:87
std::string opts
mount options
Definition: mount.h:58
static MountEntries getEntries(const std::string &mtab="")
Return mount entries from /etc/mtab or /etc/fstab file.
Definition: mount.cc:169
A "struct mntent" like mount entry structure, but using std::strings.
Definition: mount.h:34
int freq
dump frequency in days
Definition: mount.h:59
A map of (key,value) strings.
Definition: kvmap.h:173
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
std::string src
name of mounted file system
Definition: mount.h:55
void umount(const std::string &path)
umount device
Definition: mount.cc:117
std::string dir
file system path prefix
Definition: mount.h:56