-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtoy.py
36 lines (33 loc) · 1.13 KB
/
toy.py
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
import fuse
import stat
import errno
import time
class ToyStat(fuse.Stat):
def __init__(self):
"""
The following stat structure members are implemented.
"""
self.st_mode = 0 # (protection bits)
self.st_ino = 0 # (inode number)
self.st_dev = 0 # (device)
self.st_nlink = 0 # (number of hard links)
self.st_uid = 500 # (user ID of owner)
self.st_gid = 500 # (group ID of owner)
self.st_size = 0 # (size of file, in bytes)
self.st_atime = 0 # (time of most recent access)
self.st_mtime = 0 # (time of most recent content modification)
self.st_ctime = 0 # (time of most recent metadata change)
# Helper for Toy filesystem
class Toy():
def getattr(self, path):
st = ToyStat()
st.st_mode = stat.S_IFDIR | 0755
return st
def readdir(self, path):
contents = {
'/': ['hello', 'world'],
'/hello': ['welt'],
'/hello/welt': ['last_level']
}
res = ['.','..'] + contents.get(path)
return res