From 5943acb92ce0159e9f482748e4fa4aadddae6851 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Fri, 12 Jun 2015 08:34:26 +0200 Subject: Initial import. RAID 5 xor parity checking is working, data reading on left-assymetric RAID 5 is working. Nothing done on other RAID types. --- mystat.py | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 mystat.py (limited to 'mystat.py') diff --git a/mystat.py b/mystat.py new file mode 100644 index 0000000..719c7e3 --- /dev/null +++ b/mystat.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python + +# RaidGuessFS, a FUSE pseudo-filesystem to guess RAID parameters of a damaged device +# Copyright (C) 2015 Ludovic Pouzenc +# +# This file is part of RaidGuessFS. +# +# RaidGuessFS 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 3 of the License, or +# (at your option) any later version. +# +# RaidGuessFS 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 RaidGuessFS. If not, see + +import stat, os, time, copy, fuse + +class MyStat(fuse.Stat): + """Handy class to produce fake file or dir attributes""" + + def __init__(self): + self.st_mode = stat.S_IFDIR | 0555 + self.st_ino = 0 + self.st_dev = 0 + self.st_nlink = 2 + self.st_uid = os.getuid() + self.st_gid = os.getgid() + self.st_size = 0 + self.st_atime = time.time() + self.st_mtime = self.st_atime + self.st_ctime = self.st_atime + + def __str__(self): + return str(self.__dict__) + + def make_fake_dir(self): + return copy.copy(self) + + def make_fake_file(self,size,mode=0444): + st = copy.copy(self) + st.st_size = size + st.st_mode = stat.S_IFREG | mode + st.st_nlink = 1 + return st + +#def main(): +# st = MyStat() +# print st.make_fake_dir() +# print st.make_fake_file(12) +# +#if __name__ == '__main__': +# main() -- cgit v1.2.3