summaryrefslogtreecommitdiffstats
path: root/otautil/mounts.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--otautil/mounts.cpp (renamed from mounts.cpp)60
1 files changed, 30 insertions, 30 deletions
diff --git a/mounts.cpp b/otautil/mounts.cpp
index 76fa65739..951311bf3 100644
--- a/mounts.cpp
+++ b/otautil/mounts.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include "mounts.h"
+#include "otautil/mounts.h"
#include <errno.h>
#include <fcntl.h>
@@ -30,43 +30,43 @@
#include <android-base/logging.h>
struct MountedVolume {
- std::string device;
- std::string mount_point;
- std::string filesystem;
- std::string flags;
+ std::string device;
+ std::string mount_point;
+ std::string filesystem;
+ std::string flags;
};
-std::vector<MountedVolume*> g_mounts_state;
+static std::vector<MountedVolume*> g_mounts_state;
bool scan_mounted_volumes() {
- for (size_t i = 0; i < g_mounts_state.size(); ++i) {
- delete g_mounts_state[i];
- }
- g_mounts_state.clear();
+ for (size_t i = 0; i < g_mounts_state.size(); ++i) {
+ delete g_mounts_state[i];
+ }
+ g_mounts_state.clear();
- // Open and read mount table entries.
- FILE* fp = setmntent("/proc/mounts", "re");
- if (fp == NULL) {
- return false;
- }
- mntent* e;
- while ((e = getmntent(fp)) != NULL) {
- MountedVolume* v = new MountedVolume;
- v->device = e->mnt_fsname;
- v->mount_point = e->mnt_dir;
- v->filesystem = e->mnt_type;
- v->flags = e->mnt_opts;
- g_mounts_state.push_back(v);
- }
- endmntent(fp);
- return true;
+ // Open and read mount table entries.
+ FILE* fp = setmntent("/proc/mounts", "re");
+ if (fp == NULL) {
+ return false;
+ }
+ mntent* e;
+ while ((e = getmntent(fp)) != NULL) {
+ MountedVolume* v = new MountedVolume;
+ v->device = e->mnt_fsname;
+ v->mount_point = e->mnt_dir;
+ v->filesystem = e->mnt_type;
+ v->flags = e->mnt_opts;
+ g_mounts_state.push_back(v);
+ }
+ endmntent(fp);
+ return true;
}
MountedVolume* find_mounted_volume_by_mount_point(const char* mount_point) {
- for (size_t i = 0; i < g_mounts_state.size(); ++i) {
- if (g_mounts_state[i]->mount_point == mount_point) return g_mounts_state[i];
- }
- return nullptr;
+ for (size_t i = 0; i < g_mounts_state.size(); ++i) {
+ if (g_mounts_state[i]->mount_point == mount_point) return g_mounts_state[i];
+ }
+ return nullptr;
}
int unmount_mounted_volume(MountedVolume* volume) {