diff options
Diffstat (limited to 'mystat.py')
-rw-r--r-- | mystat.py | 57 |
1 files changed, 57 insertions, 0 deletions
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 <ludovic@pouzenc.fr> +# +# 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 <http://www.gnu.org/licenses/> + +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() |