libzypp  17.35.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 <utility>
25 #include <zypp-core/KVMap>
26 
27 namespace zypp {
28  namespace media {
29 
30 
35  struct MountEntry
36  {
37  MountEntry(std::string source,
38  std::string target,
39  std::string fstype,
40  std::string options,
41  const int dumpfreq = 0,
42  const int passnum = 0)
43  : src(std::move(source))
44  , dir(std::move(target))
45  , type(std::move(fstype))
46  , opts(std::move(options))
47  , freq(dumpfreq)
48  , pass(passnum)
49  {}
50 
54  bool isBlockDevice () const;
55 
56  std::string src;
57  std::string dir;
58  std::string type;
59  std::string opts;
60  int freq;
61  int pass;
62  };
63 
67  using MountEntries = std::vector<MountEntry>;
68 
70  std::ostream & operator<<( std::ostream & str, const MountEntry & obj );
71 
75  class Mount
76  {
77  public:
78 
84 
89 
90  public:
91 
95  Mount();
96 
100  ~Mount();
101 
115  void mount ( const std::string& source,
116  const std::string& target,
117  const std::string& filesystem,
118  const std::string& options,
119  const Environment& environment = Environment() );
120 
128  void umount (const std::string& path);
129 
130  public:
131 
143  static MountEntries
144  getEntries(const std::string &mtab = "");
145 
150  static time_t getMTime();
151  };
152 
153 
154  } // namespace media
155 } // namespace zypp
156 
157 #endif
std::ostream & operator<<(std::ostream &str, const MediaHandler &obj)
Interface to the mount program.
Definition: mount.h:75
~Mount()
Clean up.
Definition: mount.cc:59
String related utilities and Regular expression matching.
Definition: Arch.h:363
std::map< std::string, std::string > Environment
For passing additional environment variables to set.
bool isBlockDevice() const
Returns true if the src part points to a block device in /dev.
Definition: mount.cc:50
ExternalProgram::Environment Environment
For passing additional environment variables to mount.
Definition: mount.h:83
std::vector< MountEntry > MountEntries
Definition: mount.h:67
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:58
int pass
pass number on parallel fsck
Definition: mount.h:61
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::string opts
mount options
Definition: mount.h:59
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:35
int freq
dump frequency in days
Definition: mount.h:60
A map of (key,value) strings.
Definition: kvmap.h:174
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
std::string src
name of mounted file system
Definition: mount.h:56
MountEntry(std::string source, std::string target, std::string fstype, std::string options, const int dumpfreq=0, const int passnum=0)
Definition: mount.h:37
void umount(const std::string &path)
umount device
Definition: mount.cc:117
std::string dir
file system path prefix
Definition: mount.h:57