about summary refs log tree commit diff
path: root/Completion/Darwin/Command/_hdiutil
blob: c3180871608fcd74e1569dd87b9ca19aad3f00e9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
#compdef hdiutil

# utilities
#
_hdiutil_disk() {
  local -a disk_desc
  _call_program devices hdiutil info | while read; do
    local disk_name="${${(M)REPLY[(w)1]%/dev/disk*}#/dev/}"
    if (( #disk_name )); then
      disk_desc+=( "$disk_name:${${(M)REPLY%	*}#?}" )
    fi
  done
  _describe -t devices disks disk_desc
}

_hdiutil_device() {
  local -a device_desc
  _call_program devices /usr/bin/hdiutil burn -list | while read; do
    if [[ "$REPLY" == [:space:]#IOService:* ]]; then
      device_desc+=( "$REPLY" )
    fi
  done
  local expl
  _wanted devices expl device compadd "$device_desc[@]"
}

_hdiutil_imagesize(){
  local -a arr
  local num="${PREFIX%%[^0-9]*}"
  if [[ -n "$num" ]]; then
    arr=(
      "$num"b:"$(($num / 2.**11)) mega bytes"
      "$num"k:"$(($num / 2.**10)) mega bytes"
      "$num"m:"$(($num)) mega bytes"
      "$num"g:"$(($num)) giga bytes"
      "$num"t:"$(($num * 2**10)) giga bytes"
      "$num"p:"$(($num * 2**20)) giga bytes"
      "$num"e:"$(($num * 2**30)) giga bytes"
    )
  
    local expl
    _describe -t values "size (b, k, m, g..)" arr -V1
  else
    _message "size (b, k, m, g..)"
  fi
}

_hdiutil_imageformat(){
  local -a fmts
  fmts=(
    "UDRW:UDIF read/write image"
    "UDRO:UDIF read-only image"
    "UDZO:UDIF zlib-compressed image"
    "UDCO:UDIF ADC-compressed image"
    "UFBI:UDIF entire image with MD5 checksum"
    "UDTO:DVD/CD-R master for export"
    "UDxx:UDIF stub image"
    "UDSP:SPARSE (growable with content)"
    "Rdxx:NDIF read-only image (Disk Copy 6.3.3 format)"
    "DC42:Disk Copy 4.2 image"
  )
  ofmts=(
    "UDRo:UDIF read-only"
    "UDCo:UDIF compressed"
    "RdWr:NDIF read/write image"
    "ROCo:NDIF compressed image"
    "Rken:NDIF compressed"
  )
  _describe -t types "image format" fmts -V1 ||
  _describe -t types "obsolete/deprecated image format" ofmts -V1 
}

_hdiutil(){
  local -a _common_options
  _common_options=(
    '(: -)'-help'[display help message of a verb]'
    '(-quiet)-verbose' '(-verbose debug)-quiet' '(-quiet)-debug'
  )

  local -A _common_usage_options
  _common_usage_options=(
    -shadow "-shadow:shadow file:_files -g '*.shadow(-.)'"
    -encryption "-encryption:encryption method:(CEncryptedEncoding)"
    -stdinpass "-stdinpass[specify password from standard input]"
    -certificate "-certificate[secondary access certificate]:certificate file:_files"
    -cacert "-cacert[certificate authority certificate]: :_files"
    -imagekey "*-imagekey[image key]: :->keyvalue"
    -srcimagekey "*-srcimagekey[source image key]: :->keyvalue"
    -tgtimagekey "*-tgtimagekey[target image key]: :->keyvalue"
    -insecurehttp "-insecurehttp[ignore SSL host validation failure]"
    -plist "-plist[display output in plist format]"
    -recover "-recover[keychain to unlock]:keychain file:_files -g '*.keychain(-.)'"
  )

  local -a _1st_arguments
  _1st_arguments=(
    'help:display minimal usage information'
    'attach:attach a disk image'
    'mount:attach a disk image'
    'detach:detach a disk image'
    'eject:detach a disk image'
    'verify:verify the checksum of a disk image'
    'create:create a disk image'
    'convert:convert a disk image into another format'
    'burn:burn image to optical media'
    'makehybrid:generate cross-platform hybrid images'
    'compact:compacts a SPARSE disk image'
    'info:display information about the disk image driver and attached images'
    'load:manually load the disk image driver'
    'checksum:calculate the specified checksum on the image data'
    'chpass:change the passphrase for an encrypted image'
    'unflatten:extract any UDIF metadata into resource fork'
    'flatten:embed any resource fork into UDIF data fork'
    'hfsanalyze:print information about an HFS/HFS+ volume'
    'mountvol:mount a volume'
    'unmount:unmount a volume'
    'imageinfo:print out information about a disk image'
    'plugins:print information about DiskImages framework plugins'
    'internet-enable:enable or disable post-processing for the image'
    'resize:resize partition or image'
    'segment:segment disk image'
    'pmap:display the partition map'
  )

  local size_spec='-size -sectors -megabytes -srcfolder -srcdir'

  #
  local curcontext="$curcontext" state line expl
  local -A opt_args

  _arguments -C '*:: :->subcmds'

  if (( CURRENT == 1 )); then
    _describe -t commands "hdiutil subcommands" _1st_arguments
    return
  fi

  case "$words[1]" in
    attach|mount)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-imagekey]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-plist]" \
        "$_common_usage_options[-shadow]" \
        "$_common_usage_options[-insecurehttp]" \
        "$_common_usage_options[-cacert]" \
        "$_common_usage_options[-recover]" \
        "(-readwrite)-readonly[force the resulting device to be read-only]" \
        "(-readonly)-readwrite[attempt to set the device to be read/write]" \
        "(-nokernel)-nokernel[attach with/without a helper process]" \
        "(-kernel)-kernel[attach with/without a helper process]" \
        "-notremovable[prevent this image from being detached]" \
        "(-nomount)-mount[indicate whether image should be mounted]:mount?:(required optional suppressed)" \
        "(-mount)-nomount[indicate whether image should be mounted]" \
        "-mountroot[mount volumes in specified path]: :_directories" \
        "-mountpoint[mount volume at specified path]: :_directories" \
        "-union[perform a union mount]" \
        "-private[suppress mount notifications to the rest of the system]" \
        "-nobrowse[mark the volumes non-browsable in applications]" \
        "-owners[enable or disable owners for HFS+ volumes]: :(on off)" \
        "*-drivekey[key/value pair in the IOKit registry]:key=value:" \
        "(-noverify)-verify[verify image checksums]" \
        "(-verify)-noverify" \
        "(-noignorebadchecksums)-ignorebadchecksums[indicate bad checksums should be ignored]" \
        "(-ignorebadchecksums)-noignorebadchecksums" \
        "(-noidme)-idme[perform IDME actions]" \
        "(-idme)-noidme" \
        "(-noidmereveal)-idmereveal[reveal the results of IDME processing]" \
        "(-idmereveal)-noidmereveal" \
        "(-noidmetrash)-idmetrash[put IDME images in the trash after processing]" \
        "(-idmetrash)-noidmetrash" \
        "(-noautoopen)-autoopen[auto-open volumes after attaching an image]" \
        "(-autoopen)-noautoopen" \
        "(-noautoopenro)-autoopenro[auto-open read-only volumes]" \
        "(-autoopenro)-noautoopenro" \
        "(-noautoopenrw)-autoopenrw[auto-open read/write volumes]" \
        "(-autoopenrw)-noautoopenrw" \
        "1:disk image to attach:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)\(-.\)" \
        && return 0
      ;;
    detach|eject)
      _arguments \
        "$_common_options[@]" \
        "-force[unmount any filesystems and detaches the image]" \
        "1: :_hdiutil_disk" && return 0
      ;;
    verify)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-imagekey]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-plist]" \
        "1:disk image to verify:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)\(-.\)" \
        && return 0
      ;;
    create)
      local fold_opts="-format -crossdev -nocrossdev -scrub -noscrub"
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-imagekey]:" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-tgtimagekey]" \
        "$_common_usage_options[-plist]" \
        "($size_spec $fold_opts)-size[specify size]: :_hdiutil_imagesize" \
        "($size_spec $fold_opts)-sectors[specify size]:512 byte sectors" \
        "($size_spec $fold_opts)-megabytes[specify size]:mega bytes" \
        "($size_spec)-srcfolder[specify directory]: :_directories" \
        "($size_spec)-srcdir[specify directory]: :_directories" \
        "-align[size to which partition is aligned]:size" \
        "-type[image type]:image type:(UDIF SPARSE)" \
        "-fs[filesystem to make]:filesystem:(HFS+ HFS+J HFSX HFS MS-DOS UFS)" \
        "-volname[volume name]:name" \
        "-uid[uid of root directory]:uid in number" \
        "-gid[gid of root directory]:gid in number" \
        "-mode[mode of root directory]:mode" \
        "-nouuid[suppress adding a UUID]" \
        "(-noautostretch)-autostretch" \
        "(-autostretch)-noautostretch" \
        "-stretch[max_stretch]: :_hdiutil_imagesize" \
        "-fsargs[additional arguments to pass to newfs]:arguments" \
        "-layout[partition layout]:partition layout:(NONE SPUD UNIVERSAL\ CD UNIVERSAL\ HD)" \
        "-partitionType[partition type]:partition type:(Apple_HFS Apple_UFS)" \
        "-ov[overwrite an existing file]" \
        "-attach[attach the image after creating it]" \
        "-format:format:_hdiutil_imageformat" \
        "(-nocrossdev)-crossdev[cross device boundaries when copying from the source]" \
        "(-crossdev)-nocrossdev" \
        "(-noscrub)-scrub[skip temporary files and trashes]" \
        "(-scrub)-noscrub" \
        "(-noanyowners)-anyowners[allow user files being copied]" \
        "(-anyowners)-noanyowners" \
        "1:disk image to create:_files" && return 0
        
      if [[ $state = keyvalue ]]; then
        _values 'key=value' \
          "di-sparse-puma-compatible: :(TRUE FALSE)" \
          "di-shadow-puma-compatible: :(TRUE FALSE)" \
          "encrypted-encoding-version:version:(1 2)" \
          "zlib-level:compression level:(1 2 3 4 5 6 7 8 9)" && return 0
      fi
      ;;
    convert)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-certificate]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-tgtimagekey]" \
        "$_common_usage_options[-shadow]" \
        "$_common_usage_options[-insecurehttp]" \
        "$_common_usage_options[-cacert]" \
        "$_common_usage_options[-plist]" \
        "-align:size (512 byte sectors)" \
        "-segmentSize: :_hdiutil_imagesize" \
        "-pmap[add partition map]" \
        "-tasks[number of tasks for compression operation]:number:" \
        "-ov[overwrite an existing file]" \
        "-format:format:_hdiutil_imageformat" \
        "-o:target disk image:_files" \
        "1:source disk image:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)\(-.\)" \
        && return 0

      if [[ $state = keyvalue ]]; then
        _values 'key=value' \
          "zlib-level:compression level:(1 2 3 4 5 6 7 8 9)" && return 0
      fi
      ;;
    burn)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-shadow]" \
        "$_common_usage_options[-insecurehttp]" \
        "$_common_usage_options[-cacert]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "-device[device to use for burning]:device:_hdiutil_device" \
        "-testburn[don\'t turn on laser]" \
        "-anydevice[allow burning to devices not qualified by Apple]" \
        "(-eject)-noeject[don\'t eject disc after burning]" \
        "(-noeject)-eject" \
        "(-verifyburn)-noverifyburn[don\'t verify disc contents after burn]" \
        "(-noverifyburn)-verifyburn" \
        "(-addpmap)-noaddpmap[don\'t add partition map]" \
        "(-noaddpmap)-addpmap" \
        "(-skipfinalfree)-noskipfinalfree[don\'t skip final free partition]" \
        "(-noskipfinalfree)-skipfinalfree" \
        "(-nooptimizeimage)-optimizeimage[optimize filesystem for burning]" \
        "(-optimizeimage)-nooptimizeimage" \
        "-nounderrun[turn off buffer underrun protection]" \
        "-forceclose[force the disc to be closed after burning]" \
        "-speed[desired \"x-factor\"]:x_factor:(1 2 4 6 max)" \
        "-sizequery[calculate the required size without burning anything]" \
        "-erase[erase the media]" \
        "-fullerase[erase all sectors of the disc]" \
        "-list[list all burning devices with paths suitable for -device]" \
        "1:disk image:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)\(-.\)" \
        && return 0
      ;;
    makehybrid)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-shadow]" \
        "$_common_usage_options[-insecurehttp]" \
        "$_common_usage_options[-cacert]" \
        "-hfs[generate an HFS+ filesystem]" \
        "-iso[generate an ISO9660 filesystem with Rock Ridge extensions]" \
        "-joliet[generate Joliet extensions to ISO9660]" \
        "-hfs-blessed-directory[blessed folder for booting Mac OS X]: :_directories" \
        "-hfs-openfolder[folder automatically opened]: :_directories" \
        "-hfs-startupfile-size[Startup File size]:bytes" \
        "-abstract-file[path to an ISO9660/Joliet Abstract file]: :_file" \
        "-bibliography-file[path to a ISO9660/Joliet Bibliography file]: :_file" \
        "-copyright-file[path to a ISO9660/Joliet Copyright file]: :_file" \
        "-application[creator application name]:creator name" \
        "-preparer[data preparer name]:preparer name" \
        "-publisher[publisher name]:publisher name" \
        "-system-id[system identifier]:system identifier" \
        "-keep-mac-specific[keep Macintosh-specific files in non-HFS+ filesystems]" \
        "-default-volume-name[default volume name for all filesystems]:name" \
        "-hfs-volume-name[volume name for HFS+ filesystem]:name" \
        "-iso-volume-name[volume name for ISO9660 filesystem]:name" \
        "-joliet-volume-name[volume name for Joliet]:name" \
        "-hide-all[glob expression to hide]:glob expression" \
        "-hide-hfs[glob expression to hide in HFS+]:glob expression" \
        "-hide-iso[glob expression to hide in ISO9660]:glob expression" \
        "-hide-joliet[glob expression to hide in Joliet]:glob expression" \
        "-print-size[print size estimate and quit]" \
        "-plistin[accept command-line options as a plist on stdin]" \
        "-ov[overwrite an existing file]" \
        "(-noverify)-verify[verify image checksums]" \
        "(-verify)-noverify" \
        "(-nokernel)-nokernel[attach with a helper process]" \
        "(-kernel)-kernel[attach without a helper process]" \
        "-o:target disk image:_files" \
        "1:source disk image or directory:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)\(-.\)" \
        && return 0
      ;;
    compact)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-shadow]" \
        "$_common_usage_options[-insecurehttp]" \
        "$_common_usage_options[-cacert]" \
        "$_common_usage_options[-plist]" \
        "1:sparse image:_files -g '*.sparseimage(-.)'" && return 0
      ;;
    info)
      _arguments "$_common_options[@]" \
        "$_common_usage_options[-plist]" && return 0
      ;;
    load)
      _arguments "$_common_options[@]" && return 0
      ;;
    checksum)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-shadow]" \
        "$_common_usage_options[-insecurehttp]" \
        "$_common_usage_options[-cacert]" \
        "$_common_usage_options[-plist]" \
        "-type:image type:(UDIF-CRC32 UDIF-MD5 DC42 CRC28 CRC32 MD5)" \
        "1:disk image:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)\(-.\)" \
        && return 0
      ;;
    chpass)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-recover]" \
        "$_common_usage_options[-srcimagekey]" \
        "-oldstdinpass[specify old password from standard input]" \
        "-newstdinpass[specify new password from standard input]" \
        "1:disk image:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)\(-.\)" \
        && return 0
      ;;
    unflatten)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-srcimagekey]" \
        "1:disk image:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)\(-.\)" \
        && return 0
      ;;
    flatten)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-srcimagekey]" \
        "(-xml)-noxml[don\'t embed XML data for in-kernel attachment]" \
        "(-noxml)-xml" \
        "(-rsrcfork)-norsrcfork[don\'t embed resource fork data]" \
        "(-norsrcfork)-rsrcfork" \
        "1:disk image:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)\(-.\)" \
        && return 0
      ;;
    hfsanalyze)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-shadow]" \
        "$_common_usage_options[-insecurehttp]" \
        "$_common_usage_options[-cacert]" \
        "1:disk image or device:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)\(-.\)" \
        && return 0
      ;;
    mountvol)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-plist]" \
        "1: :_path_files -W /dev -g disk\*" && return 0
      ;;
    unmount)
      _arguments \
        "$_common_options[@]" \
        "-force[unmount filesystem regardless of open files]" \
        "1:device or mount point:_files" && return 0
      ;;
    imageinfo)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-shadow]" \
        "$_common_usage_options[-insecurehttp]" \
        "$_common_usage_options[-cacert]" \
        "$_common_usage_options[-plist]" \
        "-format[just print out the image format]" \
        "-checksum[just print out the image checksum]" \
        "1:disk image:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)\(-.\)" \
        && return 0
      ;;
    plugins)
      _arguments \
        "$_common_options[@]" "$_common_usage_options[-plist]" && return 0
      ;;
    internet-enable)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-plist]" \
        "(-yes -no -query)"{-yes,-no,-query} \
        "1:disk image:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)\(-.\)" \
        && return 0
      ;;

    resize)
      _arguments -C \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-shadow]" \
        "$_common_usage_options[-insecurehttp]" \
        "$_common_usage_options[-cacert]" \
        "$_common_usage_options[-plist]" \
        "(-sectors)-size[specify size]: :_hdiutil_imagesize" \
        "(-size)-sectors[specify size]:size (512 byte sectors)/min/max:" \
        "-imageonly[only resize image file]" \
        "-partitiononly[only resize partition(s) in the image]" \
        "-partitionNumber[partition to resize]:partition number" \
        "-growonly[only allow the image to grow]" \
        "-shrinkonly[only allow the image to shrink]" \
        "-nofinalgap[allow elimination of trailing free partition]" \
        "-limits[displays min/current/max size]" \
        "1:disk image:_files -g \*.dmg\(\|.bin\)\(-.\)" \
        && return 0
      ;;
    segment)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-tgtimagekey]" \
        "$_common_usage_options[-plist]" \
        "(-segmentSize)-segmentCount[number of segments]:number" \
        "(-segmentCount)-segmentSize[segment size]: :_hdiutil_imagesize" \
        "-firstSegmentSize[first segment size]: :_hdiutil_imagesize" \
        "-restricted[make restricted segments]" \
        "-o[first segment name]:name" \
        "1:source disk image:_files -g \*.dmg\(\|.bin\)\(-.\)" \
        && return 0
      ;;
    pmap)
      _arguments \
        "$_common_options[@]" \
        "$_common_usage_options[-encryption]" \
        "$_common_usage_options[-stdinpass]" \
        "$_common_usage_options[-srcimagekey]" \
        "$_common_usage_options[-shadow]" \
        "$_common_usage_options[-insecurehttp]" \
        "$_common_usage_options[-cacert]" \
        "-options[just print out the image checksum]: :->option" \
        "1:disk image:_files -g \*.\(dmg\|sparseimage\)\(\|.bin\)\(-.\)" \
        && return 0

      case "$state" in
        option)
          _values -s '' option \
            "r[process all without modification]" \
            "x[process 2K & 512 entries and merge]" \
            "s[return all quantities in sectors]" \
            "S[sort all entries by block number]" \
            "g[account for all unmapped space]" \
            "c[combine adjacent freespace entries]" \
            "f[extend last partition to device end]" \
            "v[synthesize single volumes as a single partition entry]" \
            "k[skip zero length entries]" \
            "K[skip all free & void partitions]" \
            "m[merge small free partitions into a previous partition]" \
            "i[ignore small free partitions caused by block alignment]"
          ;;
      esac
      ;;
    *)
      _message "unknown hdiutil command: $words[1]"
      _default
      ;;
  esac
  return 1
}

_hdiutil "$@"