-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtoyfs.py
More file actions
executable file
·47 lines (37 loc) · 1.2 KB
/
Copy pathtoyfs.py
File metadata and controls
executable file
·47 lines (37 loc) · 1.2 KB
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
#!/usr/bin/env python
import os
import logging
import fuse
import time
import toy
fuse.fuse_python_api = (0, 2)
# Logging
logger = logging.getLogger("toyfs")
handler = logging.FileHandler('toyfs.log')
logger.addHandler(handler)
logger.setLevel(logging.INFO)
fs = toy.Toy()
# ToyFS
class ToyFS(fuse.Fuse):
def getattr(self, path):
logger.info("[getattr] (path=%s)" % path)
st = fs.getattr(path)
return st
def readdir(self, path, offset):
logger.info("[readdir] (path=%s, offset=%s)" % (path, offset))
directories = fs.readdir(path)
for directory in directories:
yield fuse.Direntry(directory)
def open(self, path, flags):
logger.info("[open] (path=%s, flags=%s)" % (path, flags))
def read(self, path, length, offset):
logger.info("[read] (path=%s, length=%s, offset=%s)" % (path, length, offset))
return fs.read(path, length, offset)
if __name__ == '__main__':
toyfs = ToyFS(version = '%prog ' + '0.0.1',
usage = 'Toy filesystem ' + fuse.Fuse.fusage,
dash_s_do = 'setsingle')
toyfs.parse(errex = 1)
toyfs.flags = 0
toyfs.multithreaded = 0
toyfs.main()