summaryrefslogtreecommitdiffhomepage
path: root/test/util/verity_util.cc
diff options
context:
space:
mode:
authorChong Cai <chongc@google.com>2021-07-23 14:33:27 -0700
committergVisor bot <gvisor-bot@google.com>2021-07-23 14:35:42 -0700
commitd2479383639ab15301c4535a91cbbbeb22635a7e (patch)
treefecfead59cfc796d71d2c78ead824d381908342b /test/util/verity_util.cc
parent3d0a9300050ad9a72d452ec862827e35e3f38dcc (diff)
Add verity open benchmark test
PiperOrigin-RevId: 386533065
Diffstat (limited to 'test/util/verity_util.cc')
-rw-r--r--test/util/verity_util.cc13
1 files changed, 4 insertions, 9 deletions
diff --git a/test/util/verity_util.cc b/test/util/verity_util.cc
index 501d7c2cf..b7d1cb212 100644
--- a/test/util/verity_util.cc
+++ b/test/util/verity_util.cc
@@ -54,20 +54,14 @@ PosixError FlipRandomBit(int fd, int size) {
return NoError();
}
-PosixErrorOr<std::string> MountVerity(std::string tmpfs_dir,
- std::string filename,
+PosixErrorOr<std::string> MountVerity(std::string lower_dir,
std::vector<EnableTarget> targets) {
- // Mount a verity fs on the existing tmpfs mount.
- std::string mount_opts = "lower_path=" + tmpfs_dir;
+ // Mount a verity fs on the existing mount.
+ std::string mount_opts = "lower_path=" + lower_dir;
ASSIGN_OR_RETURN_ERRNO(TempPath verity_dir, TempPath::CreateDir());
RETURN_ERROR_IF_SYSCALL_FAIL(
mount("", verity_dir.path().c_str(), "verity", 0, mount_opts.c_str()));
- // Enable the file, symlink(if provided) and the directory.
- ASSIGN_OR_RETURN_ERRNO(
- auto fd, Open(JoinPath(verity_dir.path(), filename), O_RDONLY, 0777));
- RETURN_ERROR_IF_SYSCALL_FAIL(ioctl(fd.get(), FS_IOC_ENABLE_VERITY));
-
for (const EnableTarget& target : targets) {
ASSIGN_OR_RETURN_ERRNO(
auto target_fd,
@@ -92,6 +86,7 @@ PosixErrorOr<std::string> MountVerity(std::string tmpfs_dir,
ASSIGN_OR_RETURN_ERRNO(TempPath verity_with_hash_dir, TempPath::CreateDir());
RETURN_ERROR_IF_SYSCALL_FAIL(mount("", verity_with_hash_dir.path().c_str(),
"verity", 0, mount_opts.c_str()));
+
// Verity directories should not be deleted. Release the TempPath objects to
// prevent those directories from being deleted by the destructor.
verity_dir.release();