sbin/hammer: Add hammer strip command
commit2eccaef52dab614a753aba8029714fe5424c26e1
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sun, 4 Dec 2016 09:57:15 +0000 (4 18:57 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Mon, 5 Dec 2016 17:50:34 +0000 (6 02:50 +0900)
treeecf55879d31b6a335d03566fae71c25d8831c62b
parent4a2f63485dfb6fa133b44054e32f4ed08a93bd8d
sbin/hammer: Add hammer strip command

This command is inspired by hammer recover command, and does
opposite of what recover command does.

This command zero clears zone-8(B-Tree) big-blocks, zone-9(meta)
big-blocks, and then the whole volume header, except that volume
signature field is overwritten with "STRIPPED" instead of zeros.
After running, a filesystem is no longer mountable or recoverable
with hammer recover command. This command is also fast as it only
zero clears good enough ondisk data to make it unmountable and
unrecoverable.

Keep in mind that this command does _not_ zero clear user data.
Users would normally use a software designed to completely shred
a filesystem. This command is not designed to shred a filesystem.
The name "strip" gives better idea of what it really does than
using "shred"/etc.

-- example
 # newfs_hammer -L TEST /dev/da1 /dev/da2 /dev/da3 > /dev/null
 # mount_hammer /dev/da1:/dev/da2:/dev/da3 /HAMMER
 # cd /HAMMER
 # dd if=/dev/urandom of=./out bs=1M count=120000
 120000+0 records in
 120000+0 records out
 125829120000 bytes transferred in 1766.417077 secs (71234094 bytes/sec)
 # cd
 # umount /HAMMER
 # hammer -f /dev/da1:/dev/da2:/dev/da3 strip
 You have requested that HAMMER filesystem (TEST) be stripped
 Do you really want to do this? [y/n] y
 Stripping HAMMER filesystem (TEST) in 5 4 3 2 1.. starting destruction pass
 8000000021000000
 9000000021800000
 800000019c000000
 800000030c000000
 800000047e000000
 80000005f7000000
 8000000767000000
 80000008d8000000
 8000000a51800000
 8000000bc5000000
 8000000d37800000
 8000000ead000000
 800000101e800000
 8000001193000000
 8000001304000000
 8000001478800000
 80000015ee000000
 8000001760800000
 80000018d1800000
 8000001a47000000
 8000001bb6000000
 801000013c000000
 /dev/da1
 /dev/da2
 /dev/da3
 # mount_hammer /dev/da1:/dev/da2:/dev/da3 /HAMMER
 mount: Invalid argument
 mount_hammer: /dev/da1: Invalid volume signature 4445505049525453
sbin/hammer/Makefile
sbin/hammer/cmd_strip.c [new file with mode: 0644]
sbin/hammer/hammer.8
sbin/hammer/hammer.c
sbin/hammer/hammer.h
sys/vfs/hammer/hammer_ondisk.c