diff options
author | Rahat Mahmood <rahat@google.com> | 2021-04-22 15:50:01 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-04-22 15:52:24 -0700 |
commit | d93907110eebdfb1e51dacd9ccffd0f0c2633a81 (patch) | |
tree | 5941c19d879269244b71031bffa437af895728a6 /test/util/mount_util.h | |
parent | dbfdb31e8a014e5e11092de121e825b21c2804c3 (diff) |
Also report mount options through /proc/<pid>/mounts.
PiperOrigin-RevId: 369967629
Diffstat (limited to 'test/util/mount_util.h')
-rw-r--r-- | test/util/mount_util.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/util/mount_util.h b/test/util/mount_util.h index 09e2281eb..b75a490fb 100644 --- a/test/util/mount_util.h +++ b/test/util/mount_util.h @@ -22,6 +22,7 @@ #include <string> #include "gmock/gmock.h" +#include "absl/container/flat_hash_map.h" #include "test/util/cleanup.h" #include "test/util/posix_error.h" #include "test/util/test_util.h" @@ -45,6 +46,43 @@ inline PosixErrorOr<Cleanup> Mount(const std::string& source, }); } +struct ProcMountsEntry { + std::string spec; + std::string mount_point; + std::string fstype; + std::string mount_opts; + uint32_t dump; + uint32_t fsck; +}; + +// ProcSelfMountsEntries returns a parsed representation of /proc/self/mounts. +PosixErrorOr<std::vector<ProcMountsEntry>> ProcSelfMountsEntries(); + +struct ProcMountInfoEntry { + uint64_t id; + uint64_t parent_id; + dev_t major; + dev_t minor; + std::string root; + std::string mount_point; + std::string mount_opts; + std::string optional; + std::string fstype; + std::string mount_source; + std::string super_opts; +}; + +// ProcSelfMountInfoEntries returns a parsed representation of +// /proc/self/mountinfo. +PosixErrorOr<std::vector<ProcMountInfoEntry>> ProcSelfMountInfoEntries(); + +// Interprets the input string mopts as a comma separated list of mount +// options. A mount option can either be just a value, or a key=value pair. For +// example, the string "rw,relatime,fd=7" will be parsed into a map like { "rw": +// "", "relatime": "", "fd": "7" }. +absl::flat_hash_map<std::string, std::string> ParseMountOptions( + std::string mopts); + } // namespace testing } // namespace gvisor |