/tests/zfs-tests/tests/functional/devices/devices_002_neg.ksh

https://github.com/adilger/zfs · Korn Shell · 70 lines · 14 code · 10 blank · 46 comment · 0 complexity · 5005e79b40d8f08f1b0a16ac72118080 MD5 · raw file

  1. #!/bin/ksh -p
  2. #
  3. # CDDL HEADER START
  4. #
  5. # The contents of this file are subject to the terms of the
  6. # Common Development and Distribution License (the "License").
  7. # You may not use this file except in compliance with the License.
  8. #
  9. # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10. # or http://www.opensolaris.org/os/licensing.
  11. # See the License for the specific language governing permissions
  12. # and limitations under the License.
  13. #
  14. # When distributing Covered Code, include this CDDL HEADER in each
  15. # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16. # If applicable, add the following below this CDDL HEADER, with the
  17. # fields enclosed by brackets "[]" replaced with your own identifying
  18. # information: Portions Copyright [yyyy] [name of copyright owner]
  19. #
  20. # CDDL HEADER END
  21. #
  22. #
  23. # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
  24. # Use is subject to license terms.
  25. #
  26. #
  27. # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
  28. #
  29. . $STF_SUITE/include/libtest.shlib
  30. . $STF_SUITE/tests/functional/devices/devices.cfg
  31. . $STF_SUITE/tests/functional/devices/devices_common.kshlib
  32. #
  33. # DESCRIPTION:
  34. # When set property devices=off on file system, device files cannot be used
  35. # in this file system.
  36. #
  37. # STRATEGY:
  38. # 1. Create pool and file system.
  39. # 2. Set devices=off on this file system.
  40. # 3. Separately create block device file and character file.
  41. # 4. Separately read and write from those two device files.
  42. # 5. Check the return value, and make sure it failed.
  43. #
  44. verify_runnable "global"
  45. log_assert "Setting devices=off on file system, the devices files in this file"\
  46. "system can not be used."
  47. log_onexit cleanup
  48. log_must zfs set devices=off $TESTPOOL/$TESTFS
  49. #
  50. # Create block device file backed by a ZFS volume.
  51. # Verify it cannot be opened, written, and read.
  52. #
  53. create_dev_file b $TESTDIR/$TESTFILE1 $ZVOL_DEVDIR/$TESTPOOL/$TESTVOL
  54. log_mustnot dd if=/dev/urandom of=$TESTDIR/$TESTFILE1 count=1 bs=128k
  55. log_mustnot dd if=$TESTDIR/$TESTFILE1 of=/dev/null count=1 bs=128k
  56. # Create character device file backed by /dev/null
  57. # Verify it cannot be opened and written.
  58. create_dev_file c $TESTDIR/$TESTFILE2
  59. log_mustnot dd if=/dev/urandom of=$TESTDIR/$TESTFILE2 count=1 bs=128k
  60. log_pass "Setting devices=off on file system and testing it pass."