61 return(m_mountOptions.find(
"ro") != m_mountOptions.cend());
71 return(m_mountOptions.find(
"noexec") != m_mountOptions.cend());
98 const int iLen(::strlen(pcMountLine) + 1);
101 ::strncpy(acTokens, pcMountLine, iLen);
104 char* pch = ::strtok_r(acTokens,
" ", &pcSave);
106 m_strFileSystem = pch;
108 pch = ::strtok_r(NULL,
" ", &pcSave);
109 if (pch && ::strcmp(pch,
"on") == 0)
111 pch = ::strtok_r(NULL,
" ", &pcSave);
114 m_strMountPoint = pch;
115 pch = ::strtok_r(NULL,
" ", &pcSave);
116 if (pch && ::strcmp(pch,
"type") == 0)
118 pch = ::strtok_r(NULL,
" ", &pcSave);
122 pch = ::strtok_r(NULL,
"(", &pcSave);
130 pch = ::strtok_r(pch,
",)", &pcSave);
133 m_mountOptions.insert(pch);
134 pch = ::strtok_r(NULL,
",)", &pcSave);
165 for(
auto it = mountInfo.begin(); it != mountInfo.end(); ++it)
167 Entry entry(it->c_str());
168 m_Entries.insert(make_pair(entry.mountPoint(), entry));
182 string strParent(pcPath);
185 while (!pMountPointEntry && strParent !=
"/")
187 strParent =
parent(strParent);
191 return(pMountPointEntry);
235 const Entry* pMountPointEntry(NULL);
239 if (it->first == strPath)
240 pMountPointEntry = &it->second;
243 return(pMountPointEntry);
258 string strParent(strPath);
259 const size_t uiLen(strParent.length());
262 if (uiLen != 1 || strParent[0] !=
'/')
267 if (strParent[uiLen - 1] ==
'/')
268 strParent = strParent.substr(0, uiLen - 1);
270 const std::size_t uiPos(strParent.rfind(
'/'));
271 if (uiPos != string::npos)
272 strParent = strParent.substr(0, uiPos == 0 ? 1 : uiPos);
274 if (strParent == strPath)
const Entry * mountPoint(const char *pcPath) const
Returns the mount point of a given path.
bool isMountedNoexec(const char *pcPath) const
Test if the given path is located on a mount point that is mounted with the noexec option...
void parseMountInfo(const char *pcMountLine)
Parse the given mount line and store the results in the corresponding member variables.
A class to manage a line obtained from the output of the busybox applet mount command.
static const string parent(const string &strPath)
Returns the parent pathname string of the given strPath.
bool isMountedNoexec() const
Test this mount point is mounted wit no execution option.
bool isMountedRo() const
Test this mount point is mounted read only.
bool isMountedRo(const char *pcPath) const
Test if the given path is located on a mount point that is mounted read only.
const Entry * findMountPointEntry(const string &strPath) const
Lookup if there is a mount point entry with the given path.
map< string, Entry > m_Entries