summaryrefslogtreecommitdiff
path: root/raidguessfs.py
diff options
context:
space:
mode:
Diffstat (limited to 'raidguessfs.py')
-rwxr-xr-xraidguessfs.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/raidguessfs.py b/raidguessfs.py
index ffb0912..6b78a7d 100755
--- a/raidguessfs.py
+++ b/raidguessfs.py
@@ -120,7 +120,7 @@ class RaidGuessFS(fuse.Fuse):
for raid_type in self.raid.raid_types:
self.fattr['/raid/%s/data_xor'%raid_type].st_size = 0 # self.raid.raid_size
self.fattr['/raid/%s/parity'%raid_type].st_size = min(self.d.disks_size) / self.raid.raid_sector_size * 16
- self.fattr['/raid/%s/result'%raid_type].st_size = self.raid.raid_size
+ self.fattr['/raid/%s/result'%raid_type].st_size = self.raid.get_raid_size(raid_type)
logging.debug("Exit. _refresh_raid_fattr()")
@@ -178,10 +178,15 @@ class RaidGuessFS(fuse.Fuse):
logging.debug("Enter update_raid_disk_order(%s)"%arg)
if type(arg) is str:
l = arg.split()
- else:
+ elif type(arg) is list:
l = arg
- # TODO : sanity checks (every disk number below disk count, len(list) below disk count, no double...)
+ else:
+ raise TypeError('update_raid_disk_order() wants a list or str')
logging.debug("==> %s (%d/%d)"%(l,len(l),self.d.disk_count))
+
+ if len(l) != self.d.disk_count:
+ raise ValueError('Value count does not match disk count')
+
self.raid.set_raid_disk_order(l)
logging.debug("Exit. update_raid_disk_order(%s)"%arg)
@@ -195,7 +200,7 @@ class RaidGuessFS(fuse.Fuse):
"""Make some run-time initalisations after argument parsing"""
logging.info("Mounting filesystem...")
# WARNING : this method is called by FUSE in a context that don't show fatal exceptions,
- # even with -d[ebug] flag set, so log all exceptions stupidly
+ # even with -d[ebug] flag set, so log all exceptions
try:
self.dattr = {
path: self.st.make_fake_dir() for path in self.dentries.keys()
@@ -218,7 +223,7 @@ class RaidGuessFS(fuse.Fuse):
logging.info("Mounted.")
except Exception as e:
- logging.error(e)
+ logging.exception(e)
def getattr(self, path):
logging.info("getattr: %s" % path)
@@ -281,7 +286,7 @@ class RaidGuessFS(fuse.Fuse):
return self.raid.check_data(raid_type,self.d.disks,offset,size)
except Exception as e:
- logging.error(e)
+ logging.exception(e)
return -errno.ENOENT
logging.error("Unimplemented read of '%s' (%s)"%(path, str(path_chuncks)))
@@ -297,14 +302,14 @@ class RaidGuessFS(fuse.Fuse):
# TODO take care here
idx = self.settings.index(path_chuncks[1])
try:
- self.settings_updaters[idx](buf)
+ self.settings_updaters[idx](buf.rstrip())
return len(buf)
except Exception as e:
- logging.error(e)
+ logging.exception(e)
return -errno.EIO
except Exception as e:
- logging.error(e)
+ logging.exception(e)
return -errno.ENOENT
logging.error("Unimplemented write of '%s' (%s)"%(path, str(path_chuncks)))
@@ -321,9 +326,9 @@ RaidGuessFS is a pseudo-filesystem that allows to guess parameters and disk orde
fuse.fuse_python_api = (0, 2)
LOG_FILENAME = "raidguessfs.log"
- logging.basicConfig(filename=LOG_FILENAME,level=logging.WARN,)
+ #logging.basicConfig(filename=LOG_FILENAME,level=logging.WARN,)
#logging.basicConfig(filename=LOG_FILENAME,level=logging.INFO,)
- #logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG,)
+ logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG,)
server = RaidGuessFS(version="%prog " + fuse.__version__,usage=usage,dash_s_do='setsingle')
server.multithreaded = False