summaryrefslogtreecommitdiffstats
path: root/otautil/mounts.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-01-04 22:19:11 +0100
committerTao Bao <tbao@google.com>2018-04-28 06:13:57 +0200
commit9a319f01f8768a1342c3f1c684f04c112a51f45c (patch)
tree78ab4e2c4138f54be8a2f112de0246b1dc0d8898 /otautil/mounts.cpp
parentMerge "recovery: Revoke (most of) short options." (diff)
downloadandroid_bootable_recovery-9a319f01f8768a1342c3f1c684f04c112a51f45c.tar
android_bootable_recovery-9a319f01f8768a1342c3f1c684f04c112a51f45c.tar.gz
android_bootable_recovery-9a319f01f8768a1342c3f1c684f04c112a51f45c.tar.bz2
android_bootable_recovery-9a319f01f8768a1342c3f1c684f04c112a51f45c.tar.lz
android_bootable_recovery-9a319f01f8768a1342c3f1c684f04c112a51f45c.tar.xz
android_bootable_recovery-9a319f01f8768a1342c3f1c684f04c112a51f45c.tar.zst
android_bootable_recovery-9a319f01f8768a1342c3f1c684f04c112a51f45c.zip
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) {