Codebase list python-fuse / 774d029
New upstream version 1.0.2 Sébastien Delafond 3 years ago
3 changed file(s) with 38 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
55 # This program can be distributed under the terms of the GNU LGPL.
66 # See the file COPYING.
77 #
8
9 from __future__ import print_function
810
911 import os, sys
1012 from errno import *
1113 from stat import *
1214 import fcntl
15 from threading import Lock
1316 # pull in some spaghetti to make this stuff work without fuse-py being installed
1417 try:
1518 import _find_fuse_parts
165168 self.file = os.fdopen(os.open("." + path, flags, *mode),
166169 flag2mode(flags))
167170 self.fd = self.file.fileno()
171 if hasattr(os, 'pread'):
172 self.iolock = None
173 else:
174 self.iolock = Lock()
168175
169176 def read(self, length, offset):
170 self.file.seek(offset)
171 return self.file.read(length)
177 if self.iolock:
178 self.iolock.acquire()
179 try:
180 self.file.seek(offset)
181 return self.file.read(length)
182 finally:
183 self.iolock.release()
184 else:
185 return os.pread(self.fd, length, offset)
172186
173187 def write(self, buf, offset):
174 self.file.seek(offset)
175 self.file.write(buf)
176 return len(buf)
188 if self.iolock:
189 self.iolock.acquire()
190 try:
191 self.file.seek(offset)
192 return self.file.write(buf)
193 finally:
194 self.iolock.release()
195 else:
196 return os.pwrite(self.fd, buf, offset)
177197
178198 def release(self, flags):
179199 self.file.close()
0 __version__ = "1.0.1"
0 __version__ = "1.0.2"
409409 static int
410410 fsyncdir_func(const char *path, int datasync, struct fuse_file_info *fi)
411411 {
412 #ifdef FIX_PATH_DECODING
413 PROLOGUE( PYO_CALLWITHFI(fi, fsyncdir_cb, &Oi, &Path_AsDecodedUnicode, path, datasync) )
414 #else
412415 PROLOGUE( PYO_CALLWITHFI(fi, fsyncdir_cb, si, path, datasync) )
416 #endif
413417 EPILOGUE
414418 }
415419
461465 {
462466 PyObject *iter, *w;
463467
468 #ifdef FIX_PATH_DECODING
469 PROLOGUE( PYO_CALLWITHFI(fi, readdir_cb, O&K, &Path_AsDecodedUnicode, path, off) )
470 #else
464471 PROLOGUE( PYO_CALLWITHFI(fi, readdir_cb, sK, path, off) )
472 #endif
465473 #else
466474 static int
467475 readdir_func(const char *path, fuse_dirh_t buf, fuse_dirfil_t df)
682690 #endif
683691 {
684692 #if PY_MAJOR_VERSION >= 3
693 #ifdef FIX_PATH_DECODING
694 PROLOGUE( PYO_CALLWITHFI(fi, write_cb, O&y#K, &Path_AsDecodedUnicode, path, buf, t, off) )
695 #else
685696 PROLOGUE( PYO_CALLWITHFI(fi, write_cb, sy#K, path, buf, t, off) )
697 #endif
686698 #else
687699 PROLOGUE( PYO_CALLWITHFI(fi, write_cb, ss#K, path, buf, t, off) )
688700 #endif