summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorLudovic Pouzenc <lpouzenc@gmail.com>2015-06-28 01:04:37 +0200
committerLudovic Pouzenc <lpouzenc@gmail.com>2015-06-28 01:04:37 +0200
commit2e121ce4cd7e9a5ec856351459e5c683a33c9a80 (patch)
treeef61a12306bc32eda20d299684dbe3bc8ed2fa7d /tools
parent6e6c3eabb0d08bed0b7d85f90326c2853e99e9b7 (diff)
downloadraidguessfs-2e121ce4cd7e9a5ec856351459e5c683a33c9a80.tar.gz
raidguessfs-2e121ce4cd7e9a5ec856351459e5c683a33c9a80.tar.bz2
raidguessfs-2e121ce4cd7e9a5ec856351459e5c683a33c9a80.zip
New tool to guess raid_start (bootsector detector)
Diffstat (limited to 'tools')
-rwxr-xr-xtools/find_bootsect.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/find_bootsect.py b/tools/find_bootsect.py
new file mode 100755
index 0000000..f52e910
--- /dev/null
+++ b/tools/find_bootsect.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+import os, logging, binascii
+
+disk_count = 15
+disk_order = [ 0,1,2,4,5,6,7,8,9,10,11,12,13,14,15 ]
+disk_paths = [ 'disk%02i.img'%d for d in disk_order ]
+disks = [ None for d in range(disk_count) ]
+disks_size = [ 0 for d in range(disk_count) ]
+
+for d in range(disk_count):
+ path = disk_paths[d]
+ logging.debug("Try to open disk #%2d"%d)
+ try:
+ disks[d] = open(path, "r")
+ disks_size[d] = os.lstat(path).st_size
+ logging.debug("Opened disk #%2d"%d)
+ except IOError as e:
+ logging.error("Can't open disk #%2d ('%s') : %s"%(d, path, e.strerror))
+ disks_size[d] = 0
+ except:
+ logging.error("Can't open disk #%2d ('%s') : unhandled exception"%(d, path))
+ disks_size[d] = 0
+logging.debug("Exit. open_disks()")
+
+ref_sig = binascii.unhexlify('55AA')
+
+for offset in range(0, min(disks_size), 512):
+ for disk_no in range(disk_count):
+ disks[disk_no].seek(offset)
+ data = disks[disk_no].read(512)
+ sig = data[510:]
+ if sig == ref_sig:
+ print "%s@%x:%s"%(disk_paths[disk_no],offset,binascii.hexlify(sig))
+
+