Index: /trunk/source/pyhesiodfs/pyHesiodFS.py =================================================================== --- /trunk/source/pyhesiodfs/pyHesiodFS.py (revision 163) +++ /trunk/source/pyhesiodfs/pyHesiodFS.py (revision 165) @@ -38,6 +38,6 @@ def __str__(self): - print 'defaultdict(%s, %s)' % (self.default_factory, - super(defaultdict, self).__str__()) + return 'defaultdict(%s, %s)' % (self.default_factory, + super(defaultdict, self).__str__()) class negcache(dict): @@ -49,5 +49,5 @@ """ - def __init__(self, cache_time): + def __init__(self, cache_time=0.5): self.cache_time = cache_time @@ -56,5 +56,8 @@ def remove(self, obj): - del self[obj] + try: + del self[obj] + except KeyError: + pass def __contains__(self, k): @@ -119,13 +122,20 @@ # Cache deletions for half a second - should give `ln -nsf` # enough time to make a new symlink - self.negcache = negcache(0.5) - - def _user(self): + self.negcache = defaultdict(negcache) + + def _uid(self): return fuse.FuseGetContext()['uid'] + + def _gid(self): + return fuse.FuseGetContext()['gid'] + + def _pid(self): + return fuse.FuseGetContext()['pid'] def getattr(self, path): st = MyStat() if path == '/': - st.st_mode = stat.S_IFDIR | 0777 + st.st_mode = stat.S_IFDIR | 0775 + st.st_gid = self._gid() st.st_nlink = 2 elif path == hello_path: @@ -134,7 +144,7 @@ st.st_size = len(hello_str) elif '/' not in path[1:]: - if path[1:] not in self.negcache and self.findLocker(path[1:]): + if path[1:] not in self.negcache[self._pid()] and self.findLocker(path[1:]): st.st_mode = stat.S_IFLNK | 0777 - st.st_uid = self._user() + st.st_uid = self._uid() st.st_nlink = 1 st.st_size = len(self.findLocker(path[1:])) @@ -149,10 +159,10 @@ def getCachedLockers(self): - return self.mounts[self._user()].keys() + return self.mounts[self._uid()].keys() def findLocker(self, name): """Lookup a locker in hesiod and return its path""" - if name in self.mounts[self._user()]: - return self.mounts[self._user()][name] + if name in self.mounts[self._uid()]: + return self.mounts[self._uid()][name] else: try: @@ -171,5 +181,5 @@ return None else: - self.mounts[self._user()][name] = pointer['location'] + self.mounts[self._uid()][name] = pointer['location'] syslog(LOG_INFO, "Mounting "+name+" on "+pointer['location']) return pointer['location'] @@ -211,7 +221,6 @@ return -errno.EPERM elif '/' not in path[1:]: - self.mounts[self._user()][path[1:]] = src - self.negcache.remove(path[1:]) - print self.mounts[self._user()] + self.mounts[self._uid()][path[1:]] = src + self.negcache[self._pid()].remove(path[1:]) else: return -errno.EPERM @@ -221,6 +230,6 @@ return -errno.EPERM elif '/' not in path[1:]: - del self.mounts[self._user()][path[1:]] - self.negcache.add(path[1:]) + del self.mounts[self._uid()][path[1:]] + self.negcache[self._pid()].add(path[1:]) else: return -errno.EPERM