Other file systems can be changed later. diff --git sys/msdosfs/msdosfs_vfsops.c sys/msdosfs/msdosfs_vfsops.c index e13b0b1ea0b..5cd273c4087 100644 --- sys/msdosfs/msdosfs_vfsops.c +++ sys/msdosfs/msdosfs_vfsops.c @@ -64,6 +64,7 @@ #include <sys/malloc.h> #include <sys/dirent.h> #include <sys/disk.h> +#include <sys/dkio.h> #include <sys/stdint.h> #include <msdosfs/bpb.h> @@ -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 sys/ufs/ffs/ffs_vfsops.c sys/ufs/ffs/ffs_vfsops.c index 0770e9aa45d..3714c0c09cc 100644 --- sys/ufs/ffs/ffs_vfsops.c +++ sys/ufs/ffs/ffs_vfsops.c @@ -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);