blob: 719c7e37fca3805cac170a07ae371d547769d9e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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()
|