#!/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()