Commit 2cf1bee5 by rfkelly0

fs.expose.fuse: compatability with 64bit inodes on OSX.

This fixes issue 98; thanks dmarkey and anatol.pomozov.
parent 315ea957
...@@ -478,10 +478,21 @@ def unmount(path): ...@@ -478,10 +478,21 @@ def unmount(path):
This function shells out to the 'fusermount' program to unmount a This function shells out to the 'fusermount' program to unmount a
FUSE filesystem. It works, but it would probably be better to use the FUSE filesystem. It works, but it would probably be better to use the
'unmount' method on the MountProcess class if you have it. 'unmount' method on the MountProcess class if you have it.
On darwin, "diskutil umount <path>" is called
On freebsd, "umount <path>" is called
""" """
if sys.platform == "darwin":
args = ["diskutil", "umount", path]
elif "freebsd" in sys.platform:
args = ["umount", path]
else:
args = ["fusermount", "-u", path]
for num_tries in xrange(3): for num_tries in xrange(3):
p = subprocess.Popen(["fusermount","-u",path],stderr=subprocess.PIPE) p = subprocess.Popen(args, stderr=subprocess.PIPE,
(stdout,stderr) = p.communicate() stdout=subprocess.PIPE)
(stdout, stderr) = p.communicate()
if p.returncode == 0: if p.returncode == 0:
return return
if "not mounted" in stderr: if "not mounted" in stderr:
......
...@@ -22,6 +22,27 @@ from platform import machine, system ...@@ -22,6 +22,27 @@ from platform import machine, system
from stat import S_IFDIR from stat import S_IFDIR
from traceback import print_exc from traceback import print_exc
_system = system()
_machine = machine()
# Locate the fuse shared library.
# On OSX this can be provided by a number of different packages
# with slightly incompatible interfaces.
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)
# Check whether OSX is using the legacy "macfuse" system.
# This has a different struct layout than the newer fuse4x system.
if _system == 'Darwin' and hasattr(_libfuse, 'macfuse_version'):
_system = 'Darwin-MacFuse'
class c_timespec(Structure): class c_timespec(Structure):
_fields_ = [('tv_sec', c_long), ('tv_nsec', c_long)] _fields_ = [('tv_sec', c_long), ('tv_nsec', c_long)]
...@@ -32,9 +53,7 @@ class c_utimbuf(Structure): ...@@ -32,9 +53,7 @@ class c_utimbuf(Structure):
class c_stat(Structure): class c_stat(Structure):
pass # Platform dependent pass # Platform dependent
_system = system() if _system in ('Darwin', 'Darwin-MacFuse', 'FreeBSD'):
if _system in ('Darwin', 'FreeBSD'):
_libiconv = CDLL(find_library("iconv"), RTLD_GLOBAL) # libfuse dependency
ENOTSUP = 45 ENOTSUP = 45
c_dev_t = c_int32 c_dev_t = c_int32
c_fsblkcnt_t = c_ulong c_fsblkcnt_t = c_ulong
...@@ -48,6 +67,29 @@ if _system in ('Darwin', 'FreeBSD'): ...@@ -48,6 +67,29 @@ if _system in ('Darwin', 'FreeBSD'):
c_size_t, c_int, c_uint32) c_size_t, c_int, c_uint32)
getxattr_t = CFUNCTYPE(c_int, c_char_p, c_char_p, POINTER(c_byte), getxattr_t = CFUNCTYPE(c_int, c_char_p, c_char_p, POINTER(c_byte),
c_size_t, c_uint32) c_size_t, c_uint32)
# OSX with fuse4x uses 64-bit inodes and so has a different
# struct layout. Other darwinish platforms use 32-bit inodes.
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_ = [ c_stat._fields_ = [
('st_dev', c_dev_t), ('st_dev', c_dev_t),
('st_ino', c_uint32), ('st_ino', c_uint32),
...@@ -62,6 +104,7 @@ if _system in ('Darwin', 'FreeBSD'): ...@@ -62,6 +104,7 @@ if _system in ('Darwin', 'FreeBSD'):
('st_size', c_off_t), ('st_size', c_off_t),
('st_blocks', c_int64), ('st_blocks', c_int64),
('st_blksize', c_int32)] ('st_blksize', c_int32)]
elif _system == 'Linux': elif _system == 'Linux':
ENOTSUP = 95 ENOTSUP = 95
c_dev_t = c_ulonglong c_dev_t = c_ulonglong
...@@ -239,10 +282,6 @@ def set_st_attrs(st, attrs): ...@@ -239,10 +282,6 @@ def set_st_attrs(st, attrs):
setattr(st, key, val) 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) _libfuse.fuse_get_context.restype = POINTER(fuse_context)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment