summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Tolvanen <samitolvanen@google.com>2015-02-28 00:57:04 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-02-28 00:57:04 +0000
commit73bb196e35c13f0ce952d6bc91f2735433d1daf8 (patch)
tree435331c301bd95b2bcb50e4a1f4ad8521b60a68b
parent8e6aea5c720f944e3b991c8078341e46a9d8f358 (diff)
parent3aa700e6857566290fdf42265091de9eb872ce35 (diff)
downloadsystem_core-73bb196e35c13f0ce952d6bc91f2735433d1daf8.zip
system_core-73bb196e35c13f0ce952d6bc91f2735433d1daf8.tar.gz
system_core-73bb196e35c13f0ce952d6bc91f2735433d1daf8.tar.bz2
am 3aa700e6: am 622d44d8: am fbb3f8ca: Merge "Set underlying block device RO when enabling verity"
* commit '3aa700e6857566290fdf42265091de9eb872ce35': Set underlying block device RO when enabling verity
-rw-r--r--fs_mgr/fs_mgr.c15
-rw-r--r--fs_mgr/fs_mgr_priv.h2
-rw-r--r--fs_mgr/fs_mgr_verity.c3
3 files changed, 14 insertions, 6 deletions
diff --git a/fs_mgr/fs_mgr.c b/fs_mgr/fs_mgr.c
index 8b2d439..d4daed6 100644
--- a/fs_mgr/fs_mgr.c
+++ b/fs_mgr/fs_mgr.c
@@ -186,19 +186,22 @@ static void remove_trailing_slashes(char *n)
* Mark the given block device as read-only, using the BLKROSET ioctl.
* Return 0 on success, and -1 on error.
*/
-static void fs_set_blk_ro(const char *blockdev)
+int fs_mgr_set_blk_ro(const char *blockdev)
{
int fd;
+ int rc = -1;
int ON = 1;
- fd = open(blockdev, O_RDONLY);
+ fd = TEMP_FAILURE_RETRY(open(blockdev, O_RDONLY | O_CLOEXEC));
if (fd < 0) {
// should never happen
- return;
+ return rc;
}
- ioctl(fd, BLKROSET, &ON);
- close(fd);
+ rc = ioctl(fd, BLKROSET, &ON);
+ TEMP_FAILURE_RETRY(close(fd));
+
+ return rc;
}
/*
@@ -224,7 +227,7 @@ static int __mount(const char *source, const char *target, const struct fstab_re
save_errno = errno;
INFO("%s(source=%s,target=%s,type=%s)=%d\n", __func__, source, target, rec->fs_type, ret);
if ((ret == 0) && (mountflags & MS_RDONLY) != 0) {
- fs_set_blk_ro(source);
+ fs_mgr_set_blk_ro(source);
}
errno = save_errno;
return ret;
diff --git a/fs_mgr/fs_mgr_priv.h b/fs_mgr/fs_mgr_priv.h
index 4ba6f92..88a1040 100644
--- a/fs_mgr/fs_mgr_priv.h
+++ b/fs_mgr/fs_mgr_priv.h
@@ -79,5 +79,7 @@
#define DM_BUF_SIZE 4096
+int fs_mgr_set_blk_ro(const char *blockdev);
+
#endif /* __CORE_FS_MGR_PRIV_H */
diff --git a/fs_mgr/fs_mgr_verity.c b/fs_mgr/fs_mgr_verity.c
index ece0b5b..1000e7f 100644
--- a/fs_mgr/fs_mgr_verity.c
+++ b/fs_mgr/fs_mgr_verity.c
@@ -442,6 +442,9 @@ int fs_mgr_setup_verity(struct fstab_rec *fstab) {
goto out;
}
+ // mark the underlying block device as read-only
+ fs_mgr_set_blk_ro(fstab->blk_device);
+
// assign the new verity block device as the block device
free(fstab->blk_device);
fstab->blk_device = verity_blk_name;