From: sf Date: Mon, 29 May 2017 14:07:16 +0000 (+0000) Subject: msdosfs & ffs: flush cache if updating mount from r/w to r/o X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a34a8c9c6a452cfd716b8f8bd96df8edb08fa1fe;p=openbsd msdosfs & ffs: flush cache if updating mount from r/w to r/o ok deraadt@ --- diff --git a/sys/msdosfs/msdosfs_vfsops.c b/sys/msdosfs/msdosfs_vfsops.c index e13b0b1ea0b..5c426a2c37e 100644 --- a/sys/msdosfs/msdosfs_vfsops.c +++ b/sys/msdosfs/msdosfs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msdosfs_vfsops.c,v 1.83 2016/10/10 00:34:50 bluhm Exp $ */ +/* $OpenBSD: msdosfs_vfsops.c,v 1.84 2017/05/29 14:07:16 sf Exp $ */ /* $NetBSD: msdosfs_vfsops.c,v 1.48 1997/10/18 02:54:57 briggs Exp $ */ /*- @@ -64,6 +64,7 @@ #include #include #include +#include #include #include @@ -128,8 +129,14 @@ msdosfs_mount(struct mount *mp, const char *path, void *data, if (mp->mnt_flag & MNT_FORCE) flags |= FORCECLOSE; error = vflush(mp, NULLVP, flags); - if (!error) + if (!error) { + int force = 0; + pmp->pm_flags |= MSDOSFSMNT_RONLY; + /* may be not supported, ignore error */ + VOP_IOCTL(pmp->pm_devvp, DIOCCACHESYNC, + &force, FWRITE, FSCRED, p); + } } if (!error && (mp->mnt_flag & MNT_RELOAD)) /* not yet implemented */ diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 0770e9aa45d..d0894ffb408 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_vfsops.c,v 1.165 2017/04/20 14:13:00 visa Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.166 2017/05/29 14:07:16 sf Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -456,6 +456,16 @@ success: fs->fs_flags &= ~FS_DOSOFTDEP; } ffs_sbupdate(ump, MNT_WAIT); + if (ronly) { + int force = 0; + + /* + * Updating mount to readonly. Try a cache flush. + * Ignore error because the ioctl may not be supported. + */ + VOP_IOCTL(ump->um_devvp, DIOCCACHESYNC, &force, + FWRITE, FSCRED, p); + } } return (0);