forked from manishmohanlal/Fuse---KVFS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkfs.py
119 lines (80 loc) · 3.12 KB
/
kfs.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import os, sys, stat, errno, time
import fuse
import logging
from metafs import MetaFS
from helper import *
fuse.fuse_python_api = (0, 2)
class KFS(fuse.Fuse):
def __init__(self, metafs, *args, **kwargs):
fuse.Fuse.__init__(self, *args, **kwargs)
self.metafs=metafs
# --- Metadata -----------------------------------------------------------
def getattr(self, path):
logging.info("getattr")
return self.metafs.getattr(path)
def chmod(self, path, mode):
return self.metafs.chmod(path, mode)
def chown(self, path, uid, gid):
return self.metafs.chown(path, uid, gid)
def utime(self, path, times):
return self.metafs.utime(path, times)
# --- Namespace ----------------------------------------------------------
def unlink(self, path):
return self.metafs.unlink(path)
def rename(self, oldpath, newpath):
return self.metafs.rename(self, oldpath, newpath)
# --- Links --------------------------------------------------------------
def symlink(self, path, newpath):
return self.metafs.symlink(path, newpath)
def readlink(self, path):
return self.metafs.readlink(path)
# --- Files --------------------------------------------------------------
def mknod(self, path, mode, dev):
return self.metafs.mknod(path, mode, dev)
def create(self, path, flags, mode):
return self.metafs.create(path, flags, mode)
def truncate(self, path, len):
return self.metafs.truncate(path, len)
def read(self, path, size, offset):
return self.metafs.read(path, size, offset)
def write(self, path, buf, offset):
return self.metafs.write(path, buf, offset)
# --- Directories --------------------------------------------------------
def mkdir(self, path, mode):
logging.info("Inside mkdir")
return self.metafs.mkdir(path, mode)
def rmdir(self, path):
return self.metafs.rmdir(path)
def readdir(self, path, offset):
return self.metafs.readdir(path, offset)
#--- Extra Attributes -----------------------------------------------------
def setxattr(self, path, name, value, flags):
return self.metafs.setxattr(path, name, value, flags)
def getxattr(self, path, name, size):
value = self.metafs.getxattr(path, name, size)
return value
def listxattr(self, path, size):
return self.metafs.listxattr(path, size)
def removexattr(self, path, name):
return self.metafs.removexattr(path, name)
def main():
usage="""
HTFS - HashTable File-System
""" + fuse.Fuse.fusage
os.environ["KFS_PATH"] = os.getcwd()
print os.getenv("KFS_PATH")
print os.getcwd()
initialValSet = initialize()
module = sys.modules[__name__]
for key,value in initialValSet.items():
globals()[key] = value
#for key, value in globals():
# print "%s = %s\n" % (key, value)
logging.basicConfig(filename=log,level=logging.DEBUG)
metafs = MetaFS(db_loc=db_loc, host=mongo_host, port=int(mongo_port), log=log, mode=mode,
attributes=Attributes, extensions=Extensions)
server = KFS(metafs,version="%prog " + fuse.__version__,usage=usage,dash_s_do='setsingle')
server.parse(errex=1)
server.main()
if __name__ == '__main__':
main()