3 # Copyright 2015 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 # This script is used to generate an HFS file system with several types of
8 # files of different sizes.
16 VOLUME_NAME
="SafeBrowsingDMG"
17 UNICODE_FILENAME
="Tĕsẗ 🐐 "
19 if [[ ! $FILESYSTEM_TYPE ]]; then
20 echo "Need to specify a filesystem type. See \`diskutil listfilesystems'."
24 if [[ ! $RAMDISK_SIZE ]]; then
25 echo "Need to specify a volume size in bytes."
29 if [[ ! $OUT_FILE ]]; then
30 echo "Need to specify a destination filename."
34 RAMDISK_VOLUME
=$
(hdiutil attach
-nomount ram
://$RAMDISK_SIZE)
35 diskutil erasevolume
"${FILESYSTEM_TYPE}" "${VOLUME_NAME}" ${RAMDISK_VOLUME}
37 pushd "/Volumes
/${VOLUME_NAME}"
39 touch .metadata_never_index
41 mkdir -p first/second/third/fourth/fifth
49 dd if=/dev/random of=random bs=1 count=768
54 touch "hEllo wOrld
" # No-op on case-insensitive filesystem.
58 ln -s fourth/fifth/random symlink-random
62 echo "Poop
" > "${UNICODE_FILENAME}"
63 ditto --hfsCompression "${UNICODE_FILENAME}" goat-output.txt
67 ln "second
/${UNICODE_FILENAME}" unicode_name
71 echo "This is a
test HFS
+ filesystem generated by
" \
72 "chrome
/test
/data
/safe_browsing
/dmg
/make_hfs.sh.
" > README.txt
76 # Unmount the volume, copy the raw device to a file, and then destroy it.
77 diskutil unmount ${RAMDISK_VOLUME}
78 dd if=${RAMDISK_VOLUME} of="${OUT_FILE}"
79 diskutil eject ${RAMDISK_VOLUME}