components/zsh/Completion/Unix/Command/_zfs
branchs11-update
changeset 2892 0309f67d63d6
parent 904 114a5240af22
equal deleted inserted replaced
2891:d90819d28c84 2892:0309f67d63d6
     1 #compdef zfs
     1 #compdef zfs
     2 # Synced with the S11U1 build 20 man page
     2 # Synced with the S11U1 man page
     3 
     3 
     4 _zfs() {
     4 _zfs() {
     5 	local context state line expl
     5 	local context state line expl
     6 	typeset -A opt_args
     6 	typeset -A opt_args
     7 	local -a subcmds rw_properties rw_propnames ro_properties create_properties
     7 	local -a subcmds rw_properties rw_propnames ro_properties create_properties
       
     8 	local -a share_nfs_ro_properties share_nfs_rw_properties
       
     9 	local -a share_smb_ro_properties share_nfs_rw_properties
       
    10 	local -a share_ro_properties share_rw_properties
     8 	local -a difffields delegatable_perms
    11 	local -a difffields delegatable_perms
     9 
    12 
    10 	subcmds=(
    13 	subcmds=(
    11 		"create" "destroy" "clone" "promote" "rename" "snapshot"
    14 		"create" "destroy" "clone" "promote" "rename" "snapshot"
    12 		"rollback" "list" "set" "get" "inherit" "mount" "unmount"
    15 		"rollback" "list" "set" "get" "inherit" "mount" "unmount"
    13 		"share" "unshare" "send" "receive" "allow" "unallow"
    16 		"share" "unshare" "send" "receive" "allow" "unallow"
    14 		"upgrade" "userspace" "groupspace" "hold" "holds" "release"
    17 		"upgrade" "userspace" "groupspace" "hold" "holds" "release"
    15 		"diff" "key" "help"
    18 		"diff" "key" "help"
       
    19 	)
       
    20 
       
    21 	share_nfs_ro_properties=(
       
    22 		"share.nfs.all"
       
    23 	)
       
    24 
       
    25 	share_nfs_rw_properties=(
       
    26 		"share.nfs:value:(on off)"
       
    27 		"share.nfs.aclok:value:(on off)"
       
    28 		"share.nfs.acflfab:value:(on off)"
       
    29 		"share.nfs.anon:uid:"
       
    30 		"share.nfs.charset.euc-cn:access-list:"
       
    31 		"share.nfs.charset.euc-jpms:access-list:"
       
    32 		"share.nfs.charset.euc-kr:access-list:"
       
    33 		"share.nfs.charset.euc-tw:access-list:"
       
    34 		"share.nfs.charset.iso8859-1:access-list:"
       
    35 		"share.nfs.charset.iso8859-2:access-list:"
       
    36 		"share.nfs.charset.iso8859-5:access-list:"
       
    37 		"share.nfs.charset.iso8859-6:access-list:"
       
    38 		"share.nfs.charset.iso8859-7:access-list:"
       
    39 		"share.nfs.charset.iso8859-8:access-list:"
       
    40 		"share.nfs.charset.iso8859-9:access-list:"
       
    41 		"share.nfs.charset.iso8859-13:access-list:"
       
    42 		"share.nfs.charset.iso8859-15:access-list:"
       
    43 		"share.nfs.charset.koi8-r:access-list:"
       
    44 		"share.nfs.index:file:_files"
       
    45 		"share.nfs.log:nfslog.conf tag:"
       
    46 		"share.nfs.nosub:value:(on off)"
       
    47 		"share.nfs.nosuid:value:(on off)"
       
    48 		"share.nfs.public:value:(on off)"
       
    49 		"share.nfs.sec:security-mode-list:"
       
    50 		"share.nfs.sec.default.none:access-list:"
       
    51 		"share.nfs.sec.default.ro:access-list:"
       
    52 		"share.nfs.sec.default.root:access-list:"
       
    53 		"share.nfs.sec.default.root_mapping:uid:"
       
    54 		"share.nfs.sec.default.rw:access-list:"
       
    55 		"share.nfs.sec.default.window:seconds"
       
    56 		"share.nfs.sec.dh.none:access-list:"
       
    57 		"share.nfs.sec.dh.ro:access-list:"
       
    58 		"share.nfs.sec.dh.root:access-list:"
       
    59 		"share.nfs.sec.dh.root_mapping:uid:"
       
    60 		"share.nfs.sec.dh.rw:access-list:"
       
    61 		"share.nfs.sec.dh.window:seconds"
       
    62 		"share.nfs.sec.krb5.none:access-list:"
       
    63 		"share.nfs.sec.krb5.ro:access-list:"
       
    64 		"share.nfs.sec.krb5.root:access-list:"
       
    65 		"share.nfs.sec.krb5.root_mapping:uid:"
       
    66 		"share.nfs.sec.krb5.rw:access-list:"
       
    67 		"share.nfs.sec.krb5.window:seconds"
       
    68 		"share.nfs.sec.krb5i.none:access-list:"
       
    69 		"share.nfs.sec.krb5i.ro:access-list:"
       
    70 		"share.nfs.sec.krb5i.root:access-list:"
       
    71 		"share.nfs.sec.krb5i.root_mapping:uid:"
       
    72 		"share.nfs.sec.krb5i.rw:access-list:"
       
    73 		"share.nfs.sec.krb5i.window:seconds"
       
    74 		"share.nfs.sec.krb5p.none:access-list:"
       
    75 		"share.nfs.sec.krb5p.ro:access-list:"
       
    76 		"share.nfs.sec.krb5p.root:access-list:"
       
    77 		"share.nfs.sec.krb5p.root_mapping:uid:"
       
    78 		"share.nfs.sec.krb5p.rw:access-list:"
       
    79 		"share.nfs.sec.krb5p.window:seconds"
       
    80 		"share.nfs.sec.none.none:access-list:"
       
    81 		"share.nfs.sec.none.ro:access-list:"
       
    82 		"share.nfs.sec.none.root:access-list:"
       
    83 		"share.nfs.sec.none.root_mapping:uid:"
       
    84 		"share.nfs.sec.none.rw:access-list:"
       
    85 		"share.nfs.sec.none.window:seconds"
       
    86 		"share.nfs.sec.sys.none:access-list:"
       
    87 		"share.nfs.sec.sys.ro:access-list:"
       
    88 		"share.nfs.sec.sys.root:access-list:"
       
    89 		"share.nfs.sec.sys.root_mapping:uid:"
       
    90 		"share.nfs.sec.sys.rw:access-list:"
       
    91 		"share.nfs.sec.sys.window:seconds"
       
    92 	)
       
    93 
       
    94 	share_smb_ro_properties=(
       
    95 		"share.smb.all"
       
    96 	)
       
    97 
       
    98 	share_smb_rw_properties=(
       
    99 		"share.smb:value:(on off)"
       
   100 		"share.smb.ad-container"
       
   101 		"share.smb.abe"
       
   102 		"share.smb.csc:value:(disabled manual auto vdo)"
       
   103 		"share.smb.catia:value:(on off)"
       
   104 		"share.smb.dfsroot:value:(on off)"
       
   105 		"share.smb.guestok:value:(on off)"
       
   106 		"share.smb.ro:access-list:"
       
   107 		"share.smb.rw:access-list:"
       
   108 		"share.smb.none:access-list:"
       
   109 	)
       
   110 
       
   111 	share_ro_properties=(
       
   112 		"share.all"
       
   113 		"share.fs"
       
   114 		"share.name"
       
   115 		"share.point"
       
   116 		"share.protocols"
       
   117 		"share.state"
       
   118 		$share_nfs_ro_properties
       
   119 		$share_smb_ro_properties
       
   120 	)
       
   121 
       
   122 	share_rw_properties=(
       
   123 		"share.desc:description:"
       
   124 		"share.noauto:value:(on off)"
       
   125 		"share.path:path:"
       
   126 		$share_nfs_rw_properties
       
   127 		$share_smb_rw_properties
    16 	)
   128 	)
    17 
   129 
    18 	# TODO: userused@ and groupused@ could have more extensive handling
   130 	# TODO: userused@ and groupused@ could have more extensive handling
    19 	ro_properties=(
   131 	ro_properties=(
    20 		"name" "type" "creation" "used" "available" "referenced"
   132 		"name" "type" "creation" "used" "available" "referenced"
    21 		"compressratio" "mounted" "origin" "usedbychildren"
   133 		"compressratio" "mounted" "origin" "usedbychildren"
    22 		"usedbydataset" "usedbyrefreservation" "usedbysnapshots"
   134 		"usedbydataset" "usedbyrefreservation" "usedbysnapshots"
    23 		"defer_destroy" "userused@" "userrefs" "groupused@"
   135 		"defer_destroy" "userused@" "userrefs" "groupused@"
    24 		"keychangedate" "keystatus" "rekeydate"
   136 		"keychangedate" "keystatus" "rekeydate"
       
   137 		$share_ro_properties
    25 	)
   138 	)
    26 
   139 
    27 	# TODO: Be cleverer about what values can be set.  Is there any way to
   140 	# TODO: Be cleverer about what values can be set.  Is there any way to
    28 	# set the sorting for *size properties to false by default?
   141 	# set the sorting for *size properties to false by default?
    29 	rw_properties=(
   142 	rw_properties=(
    55 		"rstchown:value:(on off)"
   168 		"rstchown:value:(on off)"
    56 		"secondarycache:value:(all none metadata)"
   169 		"secondarycache:value:(all none metadata)"
    57 		"setuid:value:(on off)"
   170 		"setuid:value:(on off)"
    58 		"shadow:value:" # TODO: complete URI|none
   171 		"shadow:value:" # TODO: complete URI|none
    59 		"share:share properties:"
   172 		"share:share properties:"
    60 		"sharenfs:value:(on off)"
       
    61 		"sharesmb:value:(on off)"
       
    62 		"snapdir:value:(hidden visible)"
   173 		"snapdir:value:(hidden visible)"
    63 		"sync:value:(standard always disabled)"
   174 		"sync:value:(standard always disabled)"
    64 		"userquota@:value:" # TODO: complete user=size|none
   175 		"userquota@:value:" # TODO: complete user=size|none
    65 		"version:value:(1 2 3 4 current)"
   176 		"version:value:(1 2 3 4 current)"
    66 		"volsize:value:" # <size>
   177 		"volsize:value:" # <size>
    67 		"vscan:value:(on off)"
   178 		"vscan:value:(on off)"
    68 		"xattr:value:(on off)"
   179 		"xattr:value:(on off)"
    69 		"zoned:value:(on off)"
   180 		"zoned:value:(on off)"
       
   181 		$share_rw_properties
    70 	)
   182 	)
    71 
   183 
    72 	create_properties=(
   184 	create_properties=(
    73 		$rw_properties
   185 		$rw_properties
    74 		"casesensitivity:value:(sensitive insensitive mixed)"
   186 		"casesensitivity:value:(sensitive insensitive mixed)"
   244 	("share")
   356 	("share")
   245 		_arguments -A "-*" \
   357 		_arguments -A "-*" \
   246 			- set1 \
   358 			- set1 \
   247 			'-a[Share all available ZFS filesystems]' \
   359 			'-a[Share all available ZFS filesystems]' \
   248 			- set2 \
   360 			- set2 \
   249 			':filesystem:_zfs_dataset -t fs'
   361 			'-r[Share filesystems recursively]' \
       
   362 			':filesystem:_zfs_dataset -t fs' \
       
   363 			- set3 \
       
   364 			'*-o[Create a share with these properties]:property:_values -w "share properties" $share_rw_properties' \
       
   365 			'-u[Create a share without sharing it]' \
       
   366 			':filesystem:_zfs_dataset -t fs' \
       
   367 			- set4 \
       
   368 			':filesystem:_zfs_dataset -t fs -t mtpt -t share'
   250 		;;
   369 		;;
   251 
   370 
   252 	("unshare")
   371 	("unshare")
   253 		_arguments -A "-*" \
   372 		_arguments -A "-*" \
   254 			- set1 \
   373 			- set1 \
   255 			'-a[Unshare all shared ZFS filesystems]' \
   374 			'-a[Unshare all shared ZFS filesystems]' \
   256 			- set2 \
   375 			- set2 \
   257 			':filesystem:_zfs_dataset -t fs -t mtpt'
   376 			'-r[Unshare filesystems recursively]' \
       
   377 			':filesystem:_zfs_dataset -t fs' \
       
   378 			- set3 \
       
   379 			':filesystem:_zfs_dataset -t fs -t mtpt -t share'
   258 		;;
   380 		;;
   259 
   381 
   260 	("send")
   382 	("send")
   261 		_arguments -A "-*" \
   383 		_arguments -A "-*" \
   262 			'-b' \
   384 			'-b' \
   408 			'-o[Change a property]:property:_zfs_keysource_props' \
   530 			'-o[Change a property]:property:_zfs_keysource_props' \
   409 			':filesystem or volume:_zfs_dataset -t fs -t vol'
   531 			':filesystem or volume:_zfs_dataset -t fs -t vol'
   410 		;;
   532 		;;
   411 
   533 
   412 	("help")
   534 	("help")
   413 		compadd property $subcmds $ro_properties ${rw_properties%%:*}
   535 		_arguments -A "-*" \
       
   536 			- set1 \
       
   537 			':command:($subcmds $delegatable_perms $ro_properties ${rw_properties%%:*} properties)' \
       
   538 			- set2 \
       
   539 			'-l[Display property information]' \
       
   540 			': :(properties)'
   414 		;;
   541 		;;
   415 
   542 
   416 	(*)
   543 	(*)
   417 		_message "unknown zfs subcommand: $service"
   544 		_message "unknown zfs subcommand: $service"
   418 		;;
   545 		;;