--- ../busybox-1.23.2.orig/util-linux/mount.c 2015-03-23 06:07:19.000000000 +0300 +++ ./util-linux/mount.c 2015-11-06 01:52:04.522480751 +0300 @@ -567,6 +567,23 @@ void delete_block_backed_filesystems(void); #endif +// Mark the given block device as read-write, using the BLKROSET ioctl. +// https://github.com/CyanogenMod/android_system_core/blob/cm-12.1/toolbox/mount.c +static void fs_set_blk_rw(const char *blockdev) +{ + int fd; + int OFF = 0; + + fd = open(blockdev, O_RDONLY); + if (fd < 0) { + // should never happen + return; + } + + ioctl(fd, BLKROSET, &OFF); + close(fd); +} + // Perform actual mount of specific filesystem at specific location. // NB: mp->xxx fields may be trashed on exit static int mount_it_now(struct mntent *mp, unsigned long vfsflags, char *filteropts) @@ -581,6 +598,9 @@ goto mtab; } + if ((vfsflags & MS_RDONLY) == 0) + fs_set_blk_rw(mp->mnt_fsname); + // Mount, with fallback to read-only if necessary. for (;;) { errno = 0;