Chameleon

Chameleon Svn Source Tree

Root/branches/blackosx/package/Scripts/Sub/CheckFatType.sh

  • Property svn:executable set to *
1#!/bin/bash
2
3echo "==============================================="
4echo "CheckFatType: Do we have FAT16 or FAT32?"
5echo "****************************************"
6
7# Looks for the following in the partition boot sector
8# Byte number 19 to see if it's either 00 or 02
9# Byte number 22 to see if it's either F8 or F0
10# Byte number 25 to see if it's either 3F or 20
11#
12# Exit with value 1 for FAT16, 2 for FAT32
13# Exit with value 0 if nothing is found - this shouldn't happen.?
14
15# Receives targetDeviceRaw: for example, /dev/rdisk0s2.
16# Receives targetVolume: Volume to install to.
17# Receives scriptDir: The location of the main script dir.
18
19
20if [ "$#" -eq 3 ]; then
21targetDeviceRaw="$1"
22targetVolume="$2"
23scriptDir="$3"
24echo "DEBUG: passed argument = $targetDeviceRaw"
25echo "DEBUG: passed argument for targetVolume = $targetVolume"
26echo "DEBUG: passed argument for scriptDir = $scriptDir"
27else
28echo "Error - wrong number of values passed"
29exit 9
30fi
31
32
33partitionBootSector=$( dd 2>/dev/null if="$targetDeviceRaw" count=1 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
34if [ "${partitionBootSector:36:2}" == "00" ] && [ "${partitionBootSector:42:2}" == "f8" ] && [ "${partitionBootSector:48:2}" == "3f" ]; then
35#echo "DEBUG: Found a FAT32 device formatted by Windows Explorer"
36"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDeviceRaw} is on a FAT32 volume formatted by Windows Explorer"
37exit 2
38fi
39if [ "${partitionBootSector:36:2}" == "02" ] && [ "${partitionBootSector:42:2}" == "f8" ] && [ "${partitionBootSector:48:2}" == "3f" ]; then
40#echo "DEBUG: Found a FAT16 device formatted by Windows Explorer"
41"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDeviceRaw} is on a FAT16 volume formatted by Windows Explorer"
42exit 1
43fi
44if [ "${partitionBootSector:36:2}" == "00" ] && [ "${partitionBootSector:42:2}" == "f0" ] && [ "${partitionBootSector:48:2}" == "20" ]; then
45#echo "DEBUG: Found a FAT32 device formatted by OS X Snow Leopard Disk Utility"
46"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDeviceRaw} is on a FAT32 volume formatted by OS X Snow Leopard Disk Utility"
47exit 2
48fi
49if [ "${partitionBootSector:36:2}" == "02" ] && [ "${partitionBootSector:42:2}" == "f0" ] && [ "${partitionBootSector:48:2}" == "20" ]; then
50#echo "DEBUG: Found a FAT16 device formatted by OS X Snow Leopard Disk Utility"
51"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDeviceRaw} is on a FAT16 volume formatted by OS X Snow Leopard Disk Utility"
52exit 1
53fi
54if [ "${partitionBootSector:36:2}" == "00" ] && [ "${partitionBootSector:42:2}" == "f8" ] && [ "${partitionBootSector:48:2}" == "20" ]; then
55#echo "DEBUG: Found a FAT32 device formatted by OS X Lion Disk Utility"
56"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDeviceRaw} is on a FAT32 volume formatted by OS X Lion Disk Utility"
57exit 2
58fi
59if [ "${partitionBootSector:36:2}" == "02" ] && [ "${partitionBootSector:42:2}" == "f8" ] && [ "${partitionBootSector:48:2}" == "20" ]; then
60#echo "DEBUG: Found a FAT16 device formatted by OS X Lion Disk Utility"
61"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDeviceRaw} is on a FAT16 volume formatted by OS X Lion Disk Utility"
62exit 1
63fi
64
65exit 0

Archive Download this file

Revision: 1615