* limitations under the License
*/
#include <iomanip>
+#include <fstream>
#include <unistd.h>
#include <sys/vfs.h>
} // namespace
EcryptfsEngine::EcryptfsEngine(const std::string &src, const std::string &dest, const ProgressBar &prg) :
- source(src), destination(dest), progress(prg), mounted(false)
+ source(src), destination(dest), progress(prg)
{
}
void EcryptfsEngine::mount(const data &key, unsigned int options)
{
ecryptfsMount(source, destination, key, options);
-
- mounted = true;
}
void EcryptfsEngine::umount()
{
ecryptfsUmount(destination);
-
- mounted = false;
}
bool EcryptfsEngine::isMounted()
{
- return mounted;
+ std::ifstream file("/proc/mounts");
+ std::string line;
+
+ while (std::getline(file, line)) {
+ std::stringstream info(line);
+ std::string src, dest, type;
+
+ info >> src >> dest >> type;
+ if (type == "ecryptfs" && src == source && dest == destination) {
+ return true;
+ }
+ }
+
+ return false;
}
void EcryptfsEngine::encrypt(const data &key, unsigned int options)