Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/package/Scripts/Install/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
35echo "Found a FAT32 device formatted by Windows Explorer"
36echo "--------------------------------------------------"
37echo ""
38"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDeviceRaw} is on a FAT32 volume formatted by Windows Explorer"
39exit 2
40fi
41if [ "${partitionBootSector:36:2}" == "02" ] && [ "${partitionBootSector:42:2}" == "f8" ] && [ "${partitionBootSector:48:2}" == "3f" ]; then
42echo "Found a FAT16 device formatted by Windows Explorer"
43echo "--------------------------------------------------"
44echo ""
45"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDeviceRaw} is on a FAT16 volume formatted by Windows Explorer"
46exit 1
47fi
48if [ "${partitionBootSector:36:2}" == "00" ] && [ "${partitionBootSector:42:2}" == "f0" ] && [ "${partitionBootSector:48:2}" == "20" ]; then
49echo "Found a FAT32 device formatted by OS X Snow Leopard Disk Utility"
50echo "----------------------------------------------------------------"
51echo ""
52"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDeviceRaw} is on a FAT32 volume formatted by OS X Snow Leopard Disk Utility"
53exit 2
54fi
55if [ "${partitionBootSector:36:2}" == "02" ] && [ "${partitionBootSector:42:2}" == "f0" ] && [ "${partitionBootSector:48:2}" == "20" ]; then
56echo "Found a FAT16 device formatted by OS X Snow Leopard Disk Utility"
57echo "----------------------------------------------------------------"
58echo ""
59"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDeviceRaw} is on a FAT16 volume formatted by OS X Snow Leopard Disk Utility"
60exit 1
61fi
62if [ "${partitionBootSector:36:2}" == "00" ] && [ "${partitionBootSector:42:2}" == "f8" ] && [ "${partitionBootSector:48:2}" == "20" ]; then
63echo "Found a FAT32 device formatted by OS X Lion Disk Utility"
64echo "--------------------------------------------------------"
65echo ""
66"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDeviceRaw} is on a FAT32 volume formatted by OS X Lion Disk Utility"
67exit 2
68fi
69if [ "${partitionBootSector:36:2}" == "02" ] && [ "${partitionBootSector:42:2}" == "f8" ] && [ "${partitionBootSector:48:2}" == "20" ]; then
70echo "Found a FAT16 device formatted by OS X Lion Disk Utility"
71echo "--------------------------------------------------------"
72echo ""
73"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDeviceRaw} is on a FAT16 volume formatted by OS X Lion Disk Utility"
74exit 1
75fi
76echo "-----------------------------------------------"
77echo ""
78exit 0

Archive Download this file

Revision: 1568