PageRenderTime 26ms CodeModel.GetById 1ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_006_pos.ksh

http://github.com/zfsonlinux/zfs
Korn Shell | 105 lines | 38 code | 17 blank | 50 comment | 6 complexity | 95f8f7d6dedd3f21570f772779c86dc8 MD5 | raw file
Possible License(s): Apache-2.0, MPL-2.0-no-copyleft-exception
  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) 2016 by Delphix. All rights reserved.
  28. #
  29. . $STF_SUITE/include/libtest.shlib
  30. #
  31. # DESCRIPTION:
  32. # Verify that a dataset could not be shared but filesystems are shared.
  33. #
  34. # STRATEGY:
  35. # 1. Create a dataset and file system
  36. # 2. Set the sharenfs property on the dataset
  37. # 3. Verify that the dataset is unable be shared.
  38. # 4. Add a new file system to the dataset.
  39. # 5. Verify that the newly added file system be shared.
  40. #
  41. verify_runnable "global"
  42. function cleanup
  43. {
  44. log_must zfs set sharenfs=off $TESTPOOL/$TESTCTR
  45. if mounted $TESTDIR2; then
  46. log_must zfs unmount $TESTDIR2
  47. fi
  48. datasetexists $TESTPOOL/$TESTCTR/$TESTFS2 && \
  49. log_must zfs destroy $TESTPOOL/$TESTCTR/$TESTFS2
  50. typeset fs=""
  51. for fs in $mntp $TESTDIR1 $TESTDIR2
  52. do
  53. log_must unshare_fs $fs
  54. done
  55. }
  56. #
  57. # Main test routine.
  58. #
  59. # Given a mountpoint and a dataset, this routine will set the
  60. # sharenfs property on the dataset and verify that dataset
  61. # is unable to be shared but the existing contained file systems
  62. # could be shared.
  63. #
  64. function test_ctr_share # mntp ctr
  65. {
  66. typeset mntp=$1
  67. typeset ctr=$2
  68. not_shared $mntp || \
  69. log_fail "Mountpoint: $mntp is already shared."
  70. log_must zfs set sharenfs=on $ctr
  71. not_shared $mntp || \
  72. log_fail "File system $mntp is shared (set sharenfs)."
  73. #
  74. # Add a new file system to the dataset and verify it is shared.
  75. #
  76. typeset mntp2=$TESTDIR2
  77. log_must zfs create $ctr/$TESTFS2
  78. log_must zfs set mountpoint=$mntp2 $ctr/$TESTFS2
  79. is_shared $mntp2 || \
  80. log_fail "File system $mntp2 was not shared (set sharenfs)."
  81. }
  82. log_assert "Verify that a dataset could not be shared, " \
  83. "but its sub-filesystems could be shared."
  84. log_onexit cleanup
  85. typeset mntp=$(get_prop mountpoint $TESTPOOL/$TESTCTR)
  86. test_ctr_share $mntp $TESTPOOL/$TESTCTR
  87. log_pass "A dataset could not be shared, " \
  88. "but its sub-filesystems could be shared as expect."