Chameleon

Chameleon Svn Source Tree

Root/branches/blackosx/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# Receives passed value for the raw Target Device
8# for example: /dev/rdisk0s2
9# Then looks for the following in the partition boot sector
10# Byte number 19 to see if it's either 00 or 02
11# Byte number 22 to see if it's either F8 or F0
12# Byte number 25 to see if it's either 3F or 20
13#
14# Exit with value 1 for FAT16, 2 for FAT32
15# Exit with value 0 if nothing is found - this shouldn't happen.?
16
17if [ "$#" -eq 1 ]; then
18targetDeviceRaw="$1"
19echo "DEBUG: passed argument = $targetDeviceRaw"
20else
21echo "Error - wrong number of values passed"
22exit 9
23fi
24
25
26partitionBootSector=$( dd 2>/dev/null if="$targetDeviceRaw" count=1 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
27if [ "${partitionBootSector:36:2}" == "00" ] && [ "${partitionBootSector:42:2}" == "f8" ] && [ "${partitionBootSector:48:2}" == "3f" ]; then
28echo "Found a FAT32 device formatted by Windows Explorer"
29echo "--------------------------------------------------"
30echo ""
31exit 2
32fi
33if [ "${partitionBootSector:36:2}" == "02" ] && [ "${partitionBootSector:42:2}" == "f8" ] && [ "${partitionBootSector:48:2}" == "3f" ]; then
34echo "Found a FAT16 device formatted by Windows Explorer"
35echo "--------------------------------------------------"
36echo ""
37exit 1
38fi
39if [ "${partitionBootSector:36:2}" == "00" ] && [ "${partitionBootSector:42:2}" == "f0" ] && [ "${partitionBootSector:48:2}" == "20" ]; then
40echo "Found a FAT32 device formatted by OS X Snow Leopard Disk Utility"
41echo "----------------------------------------------------------------"
42echo ""
43exit 2
44fi
45if [ "${partitionBootSector:36:2}" == "02" ] && [ "${partitionBootSector:42:2}" == "f0" ] && [ "${partitionBootSector:48:2}" == "20" ]; then
46echo "Found a FAT16 device formatted by OS X Snow Leopard Disk Utility"
47echo "----------------------------------------------------------------"
48echo ""
49exit 1
50fi
51if [ "${partitionBootSector:36:2}" == "00" ] && [ "${partitionBootSector:42:2}" == "f8" ] && [ "${partitionBootSector:48:2}" == "20" ]; then
52echo "Found a FAT32 device formatted by OS X Lion Disk Utility"
53echo "--------------------------------------------------------"
54echo ""
55exit 2
56fi
57if [ "${partitionBootSector:36:2}" == "02" ] && [ "${partitionBootSector:42:2}" == "f8" ] && [ "${partitionBootSector:48:2}" == "20" ]; then
58echo "Found a FAT16 device formatted by OS X Lion Disk Utility"
59echo "--------------------------------------------------------"
60echo ""
61exit 1
62fi
63echo "-----------------------------------------------"
64echo ""
65exit 0

Archive Download this file

Revision: 1548