Merge "Set underlying block device RO when enabling verity"
This commit is contained in:
commit
fbb3f8ca49
3 changed files with 14 additions and 6 deletions
|
|
@ -185,19 +185,22 @@ static void remove_trailing_slashes(char *n)
|
||||||
* Mark the given block device as read-only, using the BLKROSET ioctl.
|
* Mark the given block device as read-only, using the BLKROSET ioctl.
|
||||||
* Return 0 on success, and -1 on error.
|
* 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 fd;
|
||||||
|
int rc = -1;
|
||||||
int ON = 1;
|
int ON = 1;
|
||||||
|
|
||||||
fd = open(blockdev, O_RDONLY);
|
fd = TEMP_FAILURE_RETRY(open(blockdev, O_RDONLY | O_CLOEXEC));
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
// should never happen
|
// should never happen
|
||||||
return;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
ioctl(fd, BLKROSET, &ON);
|
rc = ioctl(fd, BLKROSET, &ON);
|
||||||
close(fd);
|
TEMP_FAILURE_RETRY(close(fd));
|
||||||
|
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -223,7 +226,7 @@ static int __mount(const char *source, const char *target, const struct fstab_re
|
||||||
save_errno = errno;
|
save_errno = errno;
|
||||||
INFO("%s(source=%s,target=%s,type=%s)=%d\n", __func__, source, target, rec->fs_type, ret);
|
INFO("%s(source=%s,target=%s,type=%s)=%d\n", __func__, source, target, rec->fs_type, ret);
|
||||||
if ((ret == 0) && (mountflags & MS_RDONLY) != 0) {
|
if ((ret == 0) && (mountflags & MS_RDONLY) != 0) {
|
||||||
fs_set_blk_ro(source);
|
fs_mgr_set_blk_ro(source);
|
||||||
}
|
}
|
||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
|
|
@ -79,5 +79,7 @@
|
||||||
|
|
||||||
#define DM_BUF_SIZE 4096
|
#define DM_BUF_SIZE 4096
|
||||||
|
|
||||||
|
int fs_mgr_set_blk_ro(const char *blockdev);
|
||||||
|
|
||||||
#endif /* __CORE_FS_MGR_PRIV_H */
|
#endif /* __CORE_FS_MGR_PRIV_H */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -442,6 +442,9 @@ int fs_mgr_setup_verity(struct fstab_rec *fstab) {
|
||||||
goto out;
|
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
|
// assign the new verity block device as the block device
|
||||||
free(fstab->blk_device);
|
free(fstab->blk_device);
|
||||||
fstab->blk_device = verity_blk_name;
|
fstab->blk_device = verity_blk_name;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue