Chameleon Applications

Chameleon Applications Svn Source Tree

Root/branches/blackosx/trunk/PackageBuilder/Main_Package_Elements/Scripts/CheckFatType.sh

  • Property svn:executable set to *
1#!/bin/bash
2
3echo "==============================================="
4echo "Check the FAT type"
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"
20fi
21
22
23partitionBootSector=$( dd 2>/dev/null if="$targetDeviceRaw" count=1 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
24if [ "${partitionBootSector:36:2}" == "00" ] && [ "${partitionBootSector:42:2}" == "f8" ] && [ "${partitionBootSector:48:2}" == "3f" ]; then
25echo "Found a FAT32 device formatted by Windows Explorer"
26echo "-----------------------------------------------"
27echo ""
28exit 2
29fi
30if [ "${partitionBootSector:36:2}" == "02" ] && [ "${partitionBootSector:42:2}" == "f8" ] && [ "${partitionBootSector:48:2}" == "3f" ]; then
31echo "Found a FAT16 device formatted by Windows Explorer"
32echo "-----------------------------------------------"
33echo ""
34exit 1
35fi
36if [ "${partitionBootSector:36:2}" == "00" ] && [ "${partitionBootSector:42:2}" == "f0" ] && [ "${partitionBootSector:48:2}" == "20" ]; then
37echo "Found a FAT32 device formatted by OSX Disk Utility"
38echo "-----------------------------------------------"
39echo ""
40exit 2
41fi
42if [ "${partitionBootSector:36:2}" == "02" ] && [ "${partitionBootSector:42:2}" == "f0" ] && [ "${partitionBootSector:48:2}" == "20" ]; then
43echo "Found a FAT16 device formatted by OSX Disk Utility"
44echo "-----------------------------------------------"
45echo ""
46exit 1
47fi
48
49echo "-----------------------------------------------"
50echo ""
51exit 0

Archive Download this file

Revision: 235