adbncfs  0.9.1
mountInfo.h
Go to the documentation of this file.
1 /*
2  * $Id: mountInfo.h 2 2015-12-03 19:46:25Z wejaeger $
3  *
4  * File: mountInfo.h
5  * Author: Werner Jaeger
6  *
7  * Created on November 28, 2015, 10:38 AM
8  *
9  * Copyright 2015 Werner Jaeger.
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <http://www.gnu.org/licenses/>.
23  */
24 
25 #ifndef MOUNTINFO_H
26 #define MOUNTINFO_H
27 
28 #include <deque>
29 #include <set>
30 #include <map>
31 
32 using namespace std;
33 
41 class MountInfo
42 {
43 private:
48  class Entry
49  {
50  public:
51  Entry(const char* pcMountLine);
52  virtual ~Entry() {}
53 
59  const string& fileSystem() const { return(m_strFileSystem); }
60 
66  const string& mountPoint() const { return(m_strMountPoint); }
67 
73  const string& deviceType() const { return(m_strDevType); }
74 
80  const set<string>& mountOptions() const { return(m_mountOptions); }
81 
82  bool isMountedRo() const;
83  bool isMountedNoexec() const;
84 
85  private:
86  // Prevent default construction
87  Entry();
88 
89  void parseMountInfo(const char* pcMountLine);
90 
93  string m_strDevType;
94  set<string> m_mountOptions;
95  };
96 
97  // Prevent default construction
98  MountInfo();
99 
100  const Entry* findMountPointEntry(const string& strPath) const;
101  static const string parent(const string& strPath);
102 
103  // key is the mount point
104  map<string, Entry> m_Entries;
105 public:
106  MountInfo(const deque<string>& mountInfo);
107  virtual ~MountInfo() {}
108 
109  const Entry* mountPoint(const char* pcPath) const;
110  bool isMountedRo(const char* pcPath) const;
111  bool isMountedNoexec(const char* pcPath) const ;
112 };
113 
114 #endif /* MOUNTINFO_H */
115 
A class to manage informations obtained from the output of the busybox applet mount command...
Definition: mountInfo.h:41
const set< string > & mountOptions() const
Retrieve the set of mount options.
Definition: mountInfo.h:80
set< string > m_mountOptions
Definition: mountInfo.h:94
A class to manage a line obtained from the output of the busybox applet mount command.
Definition: mountInfo.h:48
virtual ~MountInfo()
Definition: mountInfo.h:107
const string & fileSystem() const
Retrieve the file system name.
Definition: mountInfo.h:59
string m_strDevType
Definition: mountInfo.h:93
virtual ~Entry()
Definition: mountInfo.h:52
static string parent(const string &strPath)
Returns the parent pathname string of the given strPath.
Definition: adbncfs.cpp:229
const string & mountPoint() const
Retrieve the mount point path.
Definition: mountInfo.h:66
const string & deviceType() const
Retrieve the device type.
Definition: mountInfo.h:73
string m_strMountPoint
Definition: mountInfo.h:92
string m_strFileSystem
Definition: mountInfo.h:91
map< string, Entry > m_Entries
Definition: mountInfo.h:104