[23651] in Source-Commits
/svn/athena r23270 - in trunk/debathena/debathena/pyhesiodfs: . debian
daemon@ATHENA.MIT.EDU (broder@MIT.EDU)
Wed Jan 7 16:27:28 2009
Date: Wed, 7 Jan 2009 16:27:06 -0500 (EST)
From: broder@MIT.EDU
Message-Id: <200901072127.QAA04089@drugstore.mit.edu>
To: source-commits@MIT.EDU
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Author: broder
Date: 2009-01-07 16:27:05 -0500 (Wed, 07 Jan 2009)
New Revision: 23270
Modified:
trunk/debathena/debathena/pyhesiodfs/debian/changelog
trunk/debathena/debathena/pyhesiodfs/pyHesiodFS.py
Log:
Updates to pyHesiodFS from MacAthena (various bugfixes, and making the
negative cache per-user and shorter lasting)
Modified: trunk/debathena/debathena/pyhesiodfs/debian/changelog
===================================================================
--- trunk/debathena/debathena/pyhesiodfs/debian/changelog 2009-01-07 20:45:16 UTC (rev 23269)
+++ trunk/debathena/debathena/pyhesiodfs/debian/changelog 2009-01-07 21:27:05 UTC (rev 23270)
@@ -1,8 +1,8 @@
-debathena-pyhesiodfs (0.0.r162-0debathena1) unstable; urgency=low
+debathena-pyhesiodfs (0.0.r167-0debathena1) unstable; urgency=low
* New upstream release
- -- Evan Broder <broder@mit.edu> Mon, 22 Dec 2008 14:03:14 -0500
+ -- Evan Broder <broder@mit.edu> Tue, 30 Dec 2008 02:23:01 -0500
debathena-pyhesiodfs (0.0.r157-0debathena2) unstable; urgency=low
Modified: trunk/debathena/debathena/pyhesiodfs/pyHesiodFS.py
===================================================================
--- trunk/debathena/debathena/pyhesiodfs/pyHesiodFS.py 2009-01-07 20:45:16 UTC (rev 23269)
+++ trunk/debathena/debathena/pyhesiodfs/pyHesiodFS.py 2009-01-07 21:27:05 UTC (rev 23270)
@@ -37,8 +37,8 @@
return super(defaultdict, self).__getitem__(y)
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):
"""
@@ -48,14 +48,17 @@
This only supports add, remove, and __contains__
"""
- def __init__(self, cache_time):
+ def __init__(self, cache_time=0.5):
self.cache_time = cache_time
def add(self, obj):
self[obj] = time.time()
def remove(self, obj):
- del self[obj]
+ try:
+ del self[obj]
+ except KeyError:
+ pass
def __contains__(self, k):
if super(negcache, self).__contains__(k):
@@ -116,26 +119,33 @@
self.fuse_args.add("fsname", "pyHesiodFS")
self.mounts = defaultdict(dict)
- # Cache deletions for 10 seconds - should give people time to
- # make a new symlink
- self.negcache = negcache(10)
+ # Cache deletions for half a second - should give `ln -nsf`
+ # enough time to make a new symlink
+ self.negcache = defaultdict(negcache)
- def _user(self):
+ 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 | 0755
+ st.st_gid = self._gid()
st.st_nlink = 2
elif path == hello_path:
st.st_mode = stat.S_IFREG | 0444
st.st_nlink = 1
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._uid()] 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:]))
else:
@@ -148,12 +158,12 @@
return st.toTuple()
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:
filsys = hesiod.FilsysLookup(name)
@@ -170,7 +180,7 @@
syslog(LOG_NOTICE, "Unknown locker type "+pointer['type']+" for locker "+name+" ("+repr(pointer)+" )")
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']
else:
@@ -210,9 +220,8 @@
if path == '/' or path == hello_path:
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._uid()].remove(path[1:])
else:
return -errno.EPERM
@@ -220,8 +229,8 @@
if path == '/' or path == hello_path:
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._uid()].add(path[1:])
else:
return -errno.EPERM