-
- def getattr(self, path):
- """
- - st_mode (protection bits)
- - st_ino (inode number)
- - st_dev (device)
- - st_nlink (number of hard links)
- - st_uid (user ID of owner)
- - st_gid (group ID of owner)
- - st_size (size of file, in bytes)
- - st_atime (time of most recent access)
- - st_mtime (time of most recent content modification)
- - st_ctime (platform dependent; time of most recent metadata change on Unix,
- or the time of creation on Windows).
- """
-
- syslog(LOG_DEBUG, "*** getattr: " + path)
-
- depth = getDepth(path)
- parts = getParts(path)
-
- st = MyStat()
- if path == '/':
- st.st_mode = stat.S_IFDIR | 0755
- st.st_nlink = 2
- elif depth == 1:
- if parts[0] == 'acl':
- st.st_mode = stat.S_IFDIR | 0755
- st.st_nlink = 2
- elif parts[0] == 'conf':
- st.st_mode = stat.S_IFREG | 0444
- st.st_nlink = 1
- st.st_size = len(self.getconf())
- else:
- return -errno.ENOENT
- elif depth == 2:
- if parts[0] != 'acl':
- return -errno.ENOENT
- if parts[1] not in self.getMachines():
- return -errno.ENOENT
- st.st_mode = stat.S_IFREG | 0444
- st.st_nlink = 1
- st.st_size = len(self.getacl(parts[1]))
-
- return st.toTuple()
-
- # This call isn't actually used in the version of Fuse on console, but we
- # wanted to leave it implemented to ease the transition in the future
- def readdir(self, path, offset):
- """Return a generator with the listing for a directory
- """
- syslog(LOG_DEBUG, '*** readdir %s %s' % (path, offset))
- for (value, zero) in self.getdir(path):
- yield fuse.Direntry(value)
-
- def getdir(self, path):
- """Return a list of tuples of the form (item, 0) with the contents of
- the directory path
-
- Fuse doesn't add '.' or '..' on its own, so we have to
- """
- syslog(LOG_DEBUG, '*** getdir %s' % path)
-
- parts, depth = parse(path)
-
- if depth == 0:
- contents = ('acl', 'conf')
- elif depth == 1:
- if parts[0] == 'acl':
- contents = self.getMachines()
- else:
- return -errno.ENOENT
- else:
- return -errno.ENOTDIR
-
- # Format the list the way that Fuse wants it - and don't forget to add
- # '.' and '..'
- return [(i, 0) for i in (list(contents) + ['.', '..'])]
-
- def read(self, path, length, offset):
- """Read length bytes starting at offset of path. In most cases, this
- just gets passed on to the OS
- """
- syslog(LOG_DEBUG, '*** read %s %s %s' % (path, length, offset))
-
- parts, depth = parse(path)
-
- if depth == 0:
- return -errno.EISDIR
- elif parts[0] == 'conf':
- return self.getconf()[offset:offset+length]
- elif parts[0] == 'acl':
- if depth == 1:
- return -errno.EISDIR
- if parts[1] in self.getMachines():
- return self.getacl(parts[1])[offset:offset+length]
- return -errno.ENOENT
-
- def readlink(self, path):
- syslog(LOG_DEBUG, '*** readlink %s' % path)
- return -errno.ENOENT
-