Package: python-fuse Version: 2.5-5 Followup-For: Bug #407695 Bellow is my second attempt for the 64 bit offset support as well as multithreading patch which the current version would result in deadlock(basically not usable).
The multithreading patch is basically taken from upstream, the 64 bit support is more hackery but it does maintain full compatibility with existing programs and unlike the previous patch, no changes is needed for apps in order to support 64 bit offset/size. --- _fusemodule.c.old 2006-02-04 11:21:38.000000000 +0800 +++ _fusemodule.c 2007-01-27 22:08:36.000000000 +0800 @@ -31,14 +31,40 @@ ; static int debuglevel=0; +static PyInterpreterState *interp=NULL; + +#ifdef WITH_THREAD + +#define PYLOCK() \ +PyThreadState *_state = NULL; \ +if (interp) { \ + PyEval_AcquireLock(); \ + _state = PyThreadState_New(interp); \ + PyThreadState_Swap(_state); \ +} + +#define PYUNLOCK() if (interp) { \ + PyThreadState_Clear(_state); \ + PyThreadState_Swap(NULL); \ + PyThreadState_Delete(_state); \ + PyEval_ReleaseLock(); \ +} + +#else +#define PYLOCK() +#define PYUNLOCK() +#endif /* WITH_THREAD */ //@-node:globals //@+node:PROLOGUE -#define PROLOGUE \ +#define PROLOGUE(pyval) \ int ret = -EINVAL; \ +PyObject *v; \ +PYLOCK(); \ +v = pyval; \ if (!v) { PyErr_Print(); goto OUT; } \ if(v == Py_None) { ret = 0; goto OUT_DECREF; } \ -if(PyInt_Check(v)) { ret = PyInt_AsLong(v); goto OUT_DECREF; } +if(PyInt_Check(v) || PyLong_Check(v)) { ret = PyInt_AsLong(v); goto OUT_DECREF; } //@-node:PROLOGUE //@+node:EPILOGUE @@ -46,6 +72,7 @@ OUT_DECREF: \ Py_DECREF(v); \ OUT: \ + PYUNLOCK(); \ return ret; //@-node:EPILOGUE //@+node:getattr_func @@ -63,8 +90,8 @@ static int getattr_func(const char *path, struct stat *st) { int i; -PyObject *v = PyObject_CallFunction(getattr_cb, "s", path); -PROLOGUE + +PROLOGUE(PyObject_CallFunction(getattr_cb, "s", path)) if(!PySequence_Check(v)) { goto OUT_DECREF; } if(PySequence_Size(v) < 10) { goto OUT_DECREF; } @@ -81,10 +108,13 @@ st->st_uid = PyInt_AsLong(PySequence_GetItem(v, 4)); st->st_gid = PyInt_AsLong(PySequence_GetItem(v, 5)); st->st_size = PyInt_AsLong(PySequence_GetItem(v, 6)); +if (st->st_size < 0 && sizeof(st->st_size) > sizeof(long)) + st->st_size = PyLong_AsUnsignedLongLong(PySequence_GetItem(v, 6)); st->st_atime= PyInt_AsLong(PySequence_GetItem(v, 7)); st->st_mtime= PyInt_AsLong(PySequence_GetItem(v, 8)); st->st_ctime= PyInt_AsLong(PySequence_GetItem(v, 9)); + /* Fill in fields not provided by Python lstat() */ st->st_blksize= 4096; st->st_blocks= (st->st_size + 511)/512; @@ -98,9 +128,8 @@ static int readlink_func(const char *path, char *link, size_t size) { - PyObject *v = PyObject_CallFunction(readlink_cb, "s", path); char *s; - PROLOGUE + PROLOGUE(PyObject_CallFunction(readlink_cb, "s", path)) if(!PyString_Check(v)) { ret = -EINVAL; goto OUT_DECREF; } s = PyString_AsString(v); @@ -153,9 +182,8 @@ static int getdir_func(const char *path, fuse_dirh_t dh, fuse_dirfil_t df) { - PyObject *v = PyObject_CallFunction(getdir_cb, "s", path); int i; - PROLOGUE + PROLOGUE(PyObject_CallFunction(getdir_cb, "s", path)) if(!PySequence_Check(v)) { printf("getdir_func not sequence\n"); @@ -177,8 +205,7 @@ static int mknod_func(const char *path, mode_t m, dev_t d) { - PyObject *v = PyObject_CallFunction(mknod_cb, "sii", path, m, d); - PROLOGUE + PROLOGUE(PyObject_CallFunction(mknod_cb, "sii", path, m, d)) EPILOGUE } //@-node:mknod_func @@ -186,8 +213,7 @@ static int mkdir_func(const char *path, mode_t m) { - PyObject *v = PyObject_CallFunction(mkdir_cb, "si", path, m); - PROLOGUE + PROLOGUE(PyObject_CallFunction(mkdir_cb, "si", path, m)) EPILOGUE } //@-node:mkdir_func @@ -195,8 +221,7 @@ static int unlink_func(const char *path) { - PyObject *v = PyObject_CallFunction(unlink_cb, "s", path); - PROLOGUE + PROLOGUE(PyObject_CallFunction(unlink_cb, "s", path)) EPILOGUE } //@-node:unlink_func @@ -204,8 +229,7 @@ static int rmdir_func(const char *path) { - PyObject *v = PyObject_CallFunction(rmdir_cb, "s", path); - PROLOGUE + PROLOGUE(PyObject_CallFunction(rmdir_cb, "s", path)) EPILOGUE } //@-node:rmdir_func @@ -213,8 +237,7 @@ static int symlink_func(const char *path, const char *path1) { - PyObject *v = PyObject_CallFunction(symlink_cb, "ss", path, path1); - PROLOGUE + PROLOGUE(PyObject_CallFunction(symlink_cb, "ss", path, path1)) EPILOGUE } //@-node:symlink_func @@ -222,8 +245,7 @@ static int rename_func(const char *path, const char *path1) { - PyObject *v = PyObject_CallFunction(rename_cb, "ss", path, path1); - PROLOGUE + PROLOGUE(PyObject_CallFunction(rename_cb, "ss", path, path1)) EPILOGUE } //@-node:rename_func @@ -231,8 +253,7 @@ static int link_func(const char *path, const char *path1) { - PyObject *v = PyObject_CallFunction(link_cb, "ss", path, path1); - PROLOGUE + PROLOGUE(PyObject_CallFunction(link_cb, "ss", path, path1)) EPILOGUE } //@-node:link_func @@ -240,8 +261,7 @@ static int chmod_func(const char *path, mode_t m) { - PyObject *v = PyObject_CallFunction(chmod_cb, "si", path, m); - PROLOGUE + PROLOGUE(PyObject_CallFunction(chmod_cb, "si", path, m)) EPILOGUE } //@-node:chmod_func @@ -249,8 +269,7 @@ static int chown_func(const char *path, uid_t u, gid_t g) { - PyObject *v = PyObject_CallFunction(chown_cb, "sii", path, u, g); - PROLOGUE + PROLOGUE(PyObject_CallFunction(chown_cb, "sii", path, u, g)) EPILOGUE } //@-node:chown_func @@ -258,8 +277,8 @@ static int truncate_func(const char *path, off_t o) { - PyObject *v = PyObject_CallFunction(truncate_cb, "si", path, o); - PROLOGUE + char *format = sizeof(o) > sizeof(long) ? "sK" : "si"; + PROLOGUE(PyObject_CallFunction(truncate_cb, format, path, o)) EPILOGUE } //@-node:truncate_func @@ -268,9 +287,7 @@ static int utime_func(const char *path, struct utimbuf *u) { int actime = u ? u->actime : time(NULL); int modtime = u ? u->modtime : actime; - PyObject *v = PyObject_CallFunction(utime_cb, "s(ii)", - path, actime, modtime); - PROLOGUE + PROLOGUE(PyObject_CallFunction(utime_cb, "s(ii)", path, actime, modtime)) EPILOGUE } //@-node:utime_func @@ -278,8 +295,9 @@ static int read_func(const char *path, char *buf, size_t s, off_t off) { - PyObject *v = PyObject_CallFunction(read_cb, "sii", path, s, off); - PROLOGUE + char *format = sizeof(off) > sizeof(long) ? "siK" : "sii"; + PROLOGUE(PyObject_CallFunction(read_cb, format, path, s, off)) + if(PyString_Check(v)) { if(PyString_Size(v) > s) goto OUT_DECREF; memcpy(buf, PyString_AsString(v), PyString_Size(v)); @@ -292,8 +310,8 @@ static int write_func(const char *path, const char *buf, size_t t, off_t off) { - PyObject *v = PyObject_CallFunction(write_cb,"ss#i", path, buf, t, off); - PROLOGUE + char *format = sizeof(off) > sizeof(long) ? "ss#K" : "ss#i"; + PROLOGUE(PyObject_CallFunction(write_cb, format, path, buf, t, off)); EPILOGUE } //@-node:write_func @@ -301,8 +319,7 @@ static int open_func(const char *path, int mode) { - PyObject *v = PyObject_CallFunction(open_cb, "si", path, mode); - PROLOGUE + PROLOGUE(PyObject_CallFunction(open_cb, "si", path, mode)) printf("open_func: path=%s\n", path); EPILOGUE } @@ -310,8 +327,7 @@ //@+node:release_func static int release_func(const char *path, int flags) { - PyObject *v = PyObject_CallFunction(release_cb, "si", path, flags); - PROLOGUE + PROLOGUE(PyObject_CallFunction(release_cb, "si", path, flags)) //printf("release_func: path=%s flags=%d\n", path, flags); EPILOGUE } @@ -321,8 +337,7 @@ { int i; long retvalues[7]; - PyObject *v = PyObject_CallFunction(statfs_cb, ""); -PROLOGUE + PROLOGUE(PyObject_CallFunction(statfs_cb, "")) if (!PySequence_Check(v)) { goto OUT_DECREF; } @@ -361,42 +376,24 @@ //@+node:fsync_func static int fsync_func(const char *path, int isfsyncfile) { - PyObject *v = PyObject_CallFunction(fsync_cb, "si", path, isfsyncfile); - PROLOGUE + PROLOGUE(PyObject_CallFunction(fsync_cb, "si", path, isfsyncfile)) EPILOGUE } //@-node:fsync_func -//@+node:process_cmd - -static void process_cmd(struct fuse *f, struct fuse_cmd *cmd, void *data) -{ - PyInterpreterState *interp = (PyInterpreterState *) data; - PyThreadState *state; - - PyEval_AcquireLock(); - state = PyThreadState_New(interp); - PyThreadState_Swap(state); - __fuse_process_cmd(f, cmd); - PyThreadState_Clear(state); - PyThreadState_Swap(NULL); - PyThreadState_Delete(state); - PyEval_ReleaseLock(); -} -//@-node:process_cmd //@+node:pyfuse_loop_mt static void pyfuse_loop_mt(struct fuse *f) { - PyInterpreterState *interp; +#ifdef WITH_THREAD PyThreadState *save; PyEval_InitThreads(); interp = PyThreadState_Get()->interp; save = PyEval_SaveThread(); - __fuse_loop_mt(f, process_cmd, interp); - /* Not yet reached: */ + fuse_loop_mt(f); PyEval_RestoreThread(save); +#endif } //@-node:pyfuse_loop_mt //@+node:Fuse_main -- System Information: Debian Release: 4.0 APT prefers testing APT policy: (500, 'testing') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.17-co-0.8 Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) Versions of packages python-fuse depends on: ii libfuse2 2.5.3-4.1 Filesystem in USErspace library ii python 2.4.4-2 An interactive high-level object-o ii python-central 0.5.12 register and build utility for Pyt python-fuse recommends no packages. -- no debconf information -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]