3 # A FUSE filesystem implementation to provide a file interface for
4 # vsys_publickeys VSYS script. To be used by OMF Resource Controller.
13 fuse.fuse_python_api = (0, 2)
16 keys_file = os.path.join(keys_dir, "all")
20 return "reading PLC users' public keys\n"
22 class MyStat(fuse.Stat):
37 def __init__(self, *args, **kw):
38 Fuse.__init__(self, *args, **kw)
40 def getattr(self, path):
43 st.st_mode = stat.S_IFDIR | 0755
46 st.st_mode = stat.S_IFREG | 0444
48 st.st_size = len(read_keys())
51 def readdir(self, path, offset):
52 for r in '.', '..', os.path.basename(keys_file):
53 yield fuse.Direntry(r)
55 def open(self, path, flags):
56 accmode = os.O_RDONLY | os.O_WRONLY | os.O_RDWR
57 if (flags & accmode) != os.O_RDONLY:
60 def read (self, path, size, offset):
65 if offset + size > slen:
67 buf = keys[offset:offset+size]
74 if __name__ == '__main__':
77 fs.parse(values=fs, errex=1)
79 if fs.fuse_args.mount_expected():
82 sys.stderr.write("can't enter root of underlying filesystem\n")