Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / data / safe_browsing / dmg / make_hfs.sh
blobdf08184584fc5cacaca9752b7a50ac3b85ccf1fc
1 #!/bin/sh
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.
10 set -e
12 FILESYSTEM_TYPE="$1"
13 RAMDISK_SIZE="$2"
14 OUT_FILE="$3"
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'."
21 exit 1
24 if [[ ! $RAMDISK_SIZE ]]; then
25 echo "Need to specify a volume size in bytes."
26 exit 1
29 if [[ ! $OUT_FILE ]]; then
30 echo "Need to specify a destination filename."
31 exit 1
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
43 pushd first
44 pushd second
45 pushd third
46 pushd fourth
47 pushd fifth
49 dd if=/dev/random of=random bs=1 count=768
51 popd # fourth
53 touch "Hello World"
54 touch "hEllo wOrld" # No-op on case-insensitive filesystem.
56 popd # third
58 ln -s fourth/fifth/random symlink-random
60 popd # second
62 echo "Poop" > "${UNICODE_FILENAME}"
63 ditto --hfsCompression "${UNICODE_FILENAME}" goat-output.txt
65 popd # first
67 ln "second/${UNICODE_FILENAME}" unicode_name
69 popd # volume root
71 echo "This is a test HFS+ filesystem generated by" \
72 "chrome/test/data/safe_browsing/dmg/make_hfs.sh." > README.txt
74 popd # Original PWD
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}