summaryrefslogtreecommitdiff
path: root/genisoimage/hdisk.pl
diff options
context:
space:
mode:
authorPhilippe Coval <philippe.coval@eurogiciel.fr>2013-03-01 11:33:00 +0100
committerPhilippe Coval <philippe.coval@eurogiciel.fr>2013-03-01 11:33:00 +0100
commita119991b98b043ef5a2432a7a0e2c4f2cf484674 (patch)
tree7346d42a282562a3937d82307012b5857d642ce6 /genisoimage/hdisk.pl
parent17a3b002800b60ee4863bd971c0068c324a27fd7 (diff)
downloadcdrkit-a119991b98b043ef5a2432a7a0e2c4f2cf484674.tar.gz
cdrkit-a119991b98b043ef5a2432a7a0e2c4f2cf484674.tar.bz2
cdrkit-a119991b98b043ef5a2432a7a0e2c4f2cf484674.zip
Imported Upstream version 1.1.11upstream/1.1.11upstream
Diffstat (limited to 'genisoimage/hdisk.pl')
-rwxr-xr-xgenisoimage/hdisk.pl65
1 files changed, 65 insertions, 0 deletions
diff --git a/genisoimage/hdisk.pl b/genisoimage/hdisk.pl
new file mode 100755
index 0000000..55ef66c
--- /dev/null
+++ b/genisoimage/hdisk.pl
@@ -0,0 +1,65 @@
+#!/usr/bin/perl
+
+###############################################################################
+#
+# hfsutils - tools for reading and writing Macintosh HFS volumes
+# Copyright (C) 1996, 1997 Robert Leslie
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+###############################################################################
+
+die "Usage: $0 device-path\n" unless (@ARGV == 1);
+
+($disk) = @ARGV;
+
+format STDOUT_TOP =
+ # Partition Type HFS Volume Name Start Length
+-------------------------------------------------------------------------------
+.
+
+format STDOUT =
+@# @<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<< @####### @########
+$bnum, $pmParType, $drVN, $pmPyPartStart, $pmPartBlkCnt
+.
+
+open(DISK, $disk) || die "$disk: $!\n";
+
+$bnum = 1;
+
+do {
+ seek(DISK, 512 * $bnum, 0) || die "seek: $!\n";
+ read(DISK, $block, 512) || die "read: $!\n";
+
+ ($pmSig, $pmMapBlkCnt, $pmPyPartStart, $pmPartBlkCnt, $pmParType) =
+ (unpack('n2 N3 A32 A32 N10 A16', $block))[0, 2..4, 6];
+
+ die "$disk: unsupported partition map\n" if ($pmSig == 0x5453);
+ die "$disk: no partition map\n" unless ($pmSig == 0x504d);
+
+ if ($pmParType eq 'Apple_HFS') {
+ seek(DISK, 512 * ($pmPyPartStart + 2), 0) || die "seek: $!\n";
+ read(DISK, $block, 512) || die "read: $!\n";
+
+ ($len, $drVN) = (unpack('n N2 n5 N2 n N n c A27', $block))[13, 14];
+ $drVN = substr($drVN, 0, $len);
+ } else {
+ $drVN = '';
+ }
+
+ write;
+} while ($bnum++ < $pmMapBlkCnt);
+
+close(DISK);