Bug #1570

HAMMER: you can newfs a mounted hammer device

Added by lentferj over 8 years ago. Updated over 8 years ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:


Retry the following:

# newfs_hammer -L pgsql /dev/ad7s2d
# mount_hammer /dev/ad7s2d /usr/pkg/pgsq
# newfs /dev/ad7s2d
# umount /usr/pkg/pgsql
# mount /dev/ad7s2d /usr/pkg/pgsql
# mount | grep pgsql
dev/ad7s2d on /usr/pkg/pgsql (ufs, local)

So, it actually newfs'd the mounted hammer fs, then you can unmount
the hammer and mount the device as UFS.

I think it works because newfs looks into the mounted devices, but
there is no /dev/xyz, but only the label... so it goes on happily and
newfs maybe does not check for existing superblocks (like newfs.xfs)
and if it checks maybe it doesn't know how a hammer one looks like.

Kind Regards,

Jan Lentfer


#3 Updated by tuxillo over 8 years ago

Previous submits are wrong, please don't commit. Sorry for the noise

#5 Updated by tuxillo over 8 years ago

Finally I did last changes by request:

I've tested it and it seems to work:

Writing to R/O is permitted.
vmware# mount -o ro /dev/da0s1d /mnt/test/
vmware# ./testwrite da0s1d
Opened /dev/da0s1d for writing: fd 3

Writing to R/W not allowed
vmware# umount /mnt/test/
vmware# mount -o rw /dev/da0s1d /mnt/test/
vmware# ./testwrite ad0s1a
/dev/ad0s1a opening failed
open: Device busy

When securelevel set >= 1, no writing allowed
vmware# umount /mnt/test/
vmware# mount -o ro /dev/da0s1d /mnt/test/
vmware# sysctl kern.securelevel=1
kern.securelevel: -1 -> 1
vmware# ./testwrite da0s1d
/dev/da0s1d opening failed
open: Operation not permitted

#6 Updated by tuxillo over 8 years ago

Fix committed in ddd7de8218ab45cb082d928d8573a7ca48b3c131

Also available in: Atom PDF