summaryrefslogtreecommitdiff
path: root/fuse.py
diff options
context:
space:
mode:
authorverigak <verigak@1ebed218-b0a3-11dd-8075-91d349ce83ee>2011-12-05 16:37:49 +0000
committerverigak <verigak@1ebed218-b0a3-11dd-8075-91d349ce83ee>2011-12-05 16:37:49 +0000
commita711b0a6d2e58a291a1f6b7a136bf0bc2030717c (patch)
tree6c8a5b39b31962a28dad2e1f036eac49dcf52d68 /fuse.py
parent7e6ef2d7f05d30dca5c22ed938a76292f86cf009 (diff)
downloadfusepy-a711b0a6d2e58a291a1f6b7a136bf0bc2030717c.tar.gz
Fix fuse4x for the Mac. MacFuse support should now be considered legacy.
Fixes #35 Thanks to dmarkey for providing the correct stat fields and Anatol Pomozov for suggesting checking for macfuse_version(). git-svn-id: http://fusepy.googlecode.com/svn/trunk@59 1ebed218-b0a3-11dd-8075-91d349ce83ee
Diffstat (limited to 'fuse.py')
-rw-r--r--fuse.py82
1 files changed, 57 insertions, 25 deletions
diff --git a/fuse.py b/fuse.py
index b68e737..c675dcb 100644
--- a/fuse.py
+++ b/fuse.py
@@ -24,6 +24,24 @@ from stat import S_IFDIR
from traceback import print_exc
+_system = system()
+_machine = machine()
+
+if _system == 'Darwin':
+ _libfuse_path = find_library('fuse4x') or find_library('fuse')
+else:
+ _libfuse_path = find_library('fuse')
+if not _libfuse_path:
+ raise EnvironmentError('Unable to find libfuse')
+
+if _system == 'Darwin':
+ _libiconv = CDLL(find_library('iconv'), RTLD_GLOBAL) # libfuse dependency
+_libfuse = CDLL(_libfuse_path)
+
+if _system == 'Darwin' and hasattr(_libfuse, 'macfuse_version'):
+ _system = 'Darwin-MacFuse'
+
+
class c_timespec(Structure):
_fields_ = [('tv_sec', c_long), ('tv_nsec', c_long)]
@@ -33,9 +51,8 @@ class c_utimbuf(Structure):
class c_stat(Structure):
pass # Platform dependent
-_system = system()
-if _system in ('Darwin', 'FreeBSD'):
- _libiconv = CDLL(find_library("iconv"), RTLD_GLOBAL) # libfuse dependency
+
+if _system in ('Darwin', 'Darwin-MacFuse', 'FreeBSD'):
ENOTSUP = 45
c_dev_t = c_int32
c_fsblkcnt_t = c_ulong
@@ -49,20 +66,41 @@ if _system in ('Darwin', 'FreeBSD'):
c_size_t, c_int, c_uint32)
getxattr_t = CFUNCTYPE(c_int, c_char_p, c_char_p, POINTER(c_byte),
c_size_t, c_uint32)
- c_stat._fields_ = [
- ('st_dev', c_dev_t),
- ('st_ino', c_uint32),
- ('st_mode', c_mode_t),
- ('st_nlink', c_uint16),
- ('st_uid', c_uid_t),
- ('st_gid', c_gid_t),
- ('st_rdev', c_dev_t),
- ('st_atimespec', c_timespec),
- ('st_mtimespec', c_timespec),
- ('st_ctimespec', c_timespec),
- ('st_size', c_off_t),
- ('st_blocks', c_int64),
- ('st_blksize', c_int32)]
+ if _system == 'Darwin':
+ c_stat._fields_ = [
+ ('st_dev', c_dev_t),
+ ('st_mode', c_mode_t),
+ ('st_nlink', c_uint16),
+ ('st_ino', c_uint64),
+ ('st_uid', c_uid_t),
+ ('st_gid', c_gid_t),
+ ('st_rdev', c_dev_t),
+ ('st_atimespec', c_timespec),
+ ('st_mtimespec', c_timespec),
+ ('st_ctimespec', c_timespec),
+ ('st_birthtimespec', c_timespec),
+ ('st_size', c_off_t),
+ ('st_blocks', c_int64),
+ ('st_blksize', c_int32),
+ ('st_flags', c_int32),
+ ('st_gen', c_int32),
+ ('st_lspare', c_int32),
+ ('st_qspare', c_int64)]
+ else:
+ c_stat._fields_ = [
+ ('st_dev', c_dev_t),
+ ('st_ino', c_uint32),
+ ('st_mode', c_mode_t),
+ ('st_nlink', c_uint16),
+ ('st_uid', c_uid_t),
+ ('st_gid', c_gid_t),
+ ('st_rdev', c_dev_t),
+ ('st_atimespec', c_timespec),
+ ('st_mtimespec', c_timespec),
+ ('st_ctimespec', c_timespec),
+ ('st_size', c_off_t),
+ ('st_blocks', c_int64),
+ ('st_blksize', c_int32)]
elif _system == 'Linux':
ENOTSUP = 95
c_dev_t = c_ulonglong
@@ -76,7 +114,6 @@ elif _system == 'Linux':
setxattr_t = CFUNCTYPE(c_int, c_char_p, c_char_p, POINTER(c_byte), c_size_t, c_int)
getxattr_t = CFUNCTYPE(c_int, c_char_p, c_char_p, POINTER(c_byte), c_size_t)
- _machine = machine()
if _machine == 'x86_64':
c_stat._fields_ = [
('st_dev', c_dev_t),
@@ -180,6 +217,8 @@ class fuse_context(Structure):
('pid', c_pid_t),
('private_data', c_voidp)]
+_libfuse.fuse_get_context.restype = POINTER(fuse_context)
+
class fuse_operations(Structure):
_fields_ = [
('getattr', CFUNCTYPE(c_int, c_char_p, POINTER(c_stat))),
@@ -239,13 +278,6 @@ def set_st_attrs(st, attrs):
setattr(st, key, val)
-_libfuse_path = find_library('fuse')
-if not _libfuse_path:
- raise EnvironmentError('Unable to find libfuse')
-_libfuse = CDLL(_libfuse_path)
-_libfuse.fuse_get_context.restype = POINTER(fuse_context)
-
-
def fuse_get_context():
"""Returns a (uid, gid, pid) tuple"""
ctxp = _libfuse.fuse_get_context()