summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mytasks.py46
-rwxr-xr-xraidguessfs.py2
2 files changed, 42 insertions, 6 deletions
diff --git a/mytasks.py b/mytasks.py
index 9ec40b7..3e4056f 100644
--- a/mytasks.py
+++ b/mytasks.py
@@ -18,15 +18,51 @@
# You should have received a copy of the GNU General Public License
# along with RaidGuessFS. If not, see <http://www.gnu.org/licenses/>
-import multiprocessing, logging
+import multiprocessing, binascii, logging
import mydisks
def do_find_files(d,state):
- state['TODO'] = 'Not yet implemented'
+ logging.info("Enter do_find_files()")
+ try:
+ state['TODO'] = 'Not yet implemented'
+ state['progress'] = 100
+ except Exception as e:
+ logging.exception(e)
+ logging.info("Exit. do_find_files()")
def do_find_bootsect(d,state):
- state['TODO'] = 'Not yet implemented'
+ logging.info("Enter do_find_bootsect()")
+ try:
+ ref_sig = binascii.unhexlify('55AA')
+
+ start = 0
+ end = min(d.disks_size)
+ one_percent = (end - start) / 100
+ one_percent = one_percent + ( (-one_percent)%512 )
+ logging.debug("start/end/1pc : %i / %i / %i"%(start,end,one_percent))
+
+ state['found'] = []
+ state['progress'] = 0
+ for offset in range(start, end, 512):
+ for disk_no in range(d.disk_count):
+ d.disks[disk_no].seek(offset)
+ data = d.disks[disk_no].read(512)
+ sig = data[510:]
+ if sig == ref_sig:
+ f = state['found']
+ if len(f) < 200:
+ f.append((disk_no,offset))
+ state['found'] = f
+ else:
+ raise Exception('Aborting after too many matches')
+
+ if offset % one_percent == 0:
+ state['progress'] = state['progress'] + 1
+ state['progress'] = 100
+ except Exception as e:
+ logging.exception(e)
+ logging.info("Exit. do_find_bootsect()")
@@ -84,11 +120,11 @@ class MyTasks():
if self.find_bootsect_process == None:
return 'This task has never been started\n'
else:
- return 'TODO\n%s\n'%self.find_bootsect_state
+ return '%s\n'%self.find_bootsect_state
def read_find_files(self):
if self.find_files_process == None:
return 'This task has never been started\n'
else:
- return 'TODO\n%s\n'%self.find_files_state
+ return '%s\n'%self.find_files_state
diff --git a/raidguessfs.py b/raidguessfs.py
index 5aa8347..409ef0c 100755
--- a/raidguessfs.py
+++ b/raidguessfs.py
@@ -241,7 +241,7 @@ class RaidGuessFS(fuse.Fuse):
}
self.fattr.update( {
- '/tasks/%s'%s: self.st.make_fake_file(512) for s in self.tasks.TASK_NAMES
+ '/tasks/%s'%s: self.st.make_fake_file(4096) for s in self.tasks.TASK_NAMES
})
for raid_type in myraid.MyRaid.RAID_TYPES: