Assert that an msdosfs mount is not read-only when FAT modifications

are requested.

PR:	199152
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2015-04-05 21:08:04 +00:00
parent e1f0bb305b
commit 420d65d9e4

View File

@ -380,6 +380,8 @@ usemap_alloc(struct msdosfsmount *pmp, u_long cn)
MSDOSFS_ASSERT_MP_LOCKED(pmp);
KASSERT((pmp->pm_flags & MSDOSFSMNT_RONLY) == 0,
("usemap_alloc on ro msdosfs mount"));
KASSERT((pmp->pm_inusemap[cn / N_INUSEBITS] & (1 << (cn % N_INUSEBITS)))
== 0, ("Allocating used sector %ld %ld %x", cn, cn % N_INUSEBITS,
(unsigned)pmp->pm_inusemap[cn / N_INUSEBITS]));
@ -394,6 +396,8 @@ usemap_free(struct msdosfsmount *pmp, u_long cn)
{
MSDOSFS_ASSERT_MP_LOCKED(pmp);
KASSERT((pmp->pm_flags & MSDOSFSMNT_RONLY) == 0,
("usemap_free on ro msdosfs mount"));
pmp->pm_freeclustercount++;
pmp->pm_flags |= MSDOSFS_FSIMOD;
KASSERT((pmp->pm_inusemap[cn / N_INUSEBITS] & (1 << (cn % N_INUSEBITS)))
@ -675,6 +679,8 @@ chainalloc(struct msdosfsmount *pmp, u_long start, u_long count,
u_long cl, n;
MSDOSFS_ASSERT_MP_LOCKED(pmp);
KASSERT((pmp->pm_flags & MSDOSFSMNT_RONLY) == 0,
("chainalloc on ro msdosfs mount"));
for (cl = start, n = count; n-- > 0;)
usemap_alloc(pmp, cl++);