patch by Steven James
authorMiklos Szeredi <miklos@szeredi.hu>
Mon, 27 Sep 2004 17:07:10 +0000 (17:07 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Mon, 27 Sep 2004 17:07:10 +0000 (17:07 +0000)
python/_fusemodule.c
python/fuse.py
python/xmp.py

index 60fb66cf23d34954d59e95093980a7dbe68bc08e..fba65b47c031ee1d85fe087825a4532d1acbf20f 100644 (file)
@@ -474,6 +474,24 @@ Fuse_main(PyObject *self, PyObject *args, PyObject *kw)
 // List of functions defined in the module
 //@-at
 //@@c
+static char FuseInvalidate__doc__[] =
+       "Tell Fuse kernel module to explicitly invalidate a cached inode's contents\n";
+
+static PyObject *FuseInvalidate( PyObject *self, PyObject *args) {
+       char *path;
+       PyObject *ret;
+       int err;
+
+       PyString_Check(args);
+
+       path = PyString_AsString(args);
+
+       err = fuse_invalidate(fuse, path);
+
+       ret = PyInt_FromLong(err);
+
+       return(ret);
+}
 
 static char FuseGetContext__doc__[] =
        "Return the context of a filesystem operation in a dict. uid, gid, pid\n";
@@ -505,6 +523,7 @@ static PyObject *FuseGetContext( PyObject *self, PyObject *args) {
 static PyMethodDef Fuse_methods[] = {
        {"main",        (PyCFunction)Fuse_main,  METH_VARARGS|METH_KEYWORDS},
        {"FuseGetContext", (PyCFunction)FuseGetContext, METH_VARARGS, FuseGetContext__doc__},
+       {"FuseInvalidate", (PyCFunction)FuseInvalidate, METH_VARARGS, FuseInvalidate__doc__},
        {NULL,          NULL}           /* sentinel */
 };
 
index 3b0cd6d57083ec0137ebd131a6a70c2fa23c5135..ece9686263d5ffee1aabc92f803b4b3c24109936 100644 (file)
@@ -21,7 +21,8 @@ try:
 except:
     pass
  
-from _fuse import main
+from _fuse import main, FuseGetContext, FuseInvalidate
+from string import join
 import os, sys
 from errno import *
 
@@ -82,6 +83,13 @@ class Fuse:
                     self.optdict[k] = v
                 except:
                     self.optlist.append(o)
+
+    def GetContext(self):
+       return FuseGetContext(self)
+
+    def Invalidate(self, path):
+        return FuseInvalidate(self, path)
+
     #@-node:__init__
     #@+node:main
     def main(self):
@@ -91,8 +99,16 @@ class Fuse:
         if hasattr( self, 'debug'):
             d['lopts'] = 'debug';
 
-        d['kopts'] = 'allow_other,kernel_cache';
+        k=[]
+        if hasattr(self,'allow_other'):
+                k.append('allow_other')
+
+        if hasattr(self,'kernel_cache'):
+                k.append('kernel_cache')
 
+       if len(k):
+                d['kopts'] = join(k,',')
+       
        for a in self._attrs:
                if hasattr(self,a):
                        d[a] = ErrnoWrapper(getattr(self, a))
index e3ad74112de6e011f6668dd9882679f84f7cb2ab..946bca86932d6e6eae8678a5c923eac53f1352a2 100755 (executable)
@@ -179,7 +179,6 @@ class Xmp(Fuse):
 if __name__ == '__main__':
 
        server = Xmp()
-       server.flags = 0
        server.multithreaded = 1;
        server.main()
 #@-node:mainline