diff --git a/.gitignore b/.gitignore index 193ae00..1b263ba 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ pycscope.* build dist doc/_build +.idea/ +publish.sh +test/ \ No newline at end of file diff --git a/gluster/gfapi/__init__.py b/gluster/gfapi/__init__.py index 3372415..ea9daa7 100644 --- a/gluster/gfapi/__init__.py +++ b/gluster/gfapi/__init__.py @@ -8,7 +8,7 @@ # later), or the GNU General Public License, version 2 (GPLv2), in all # cases as published by the Free Software Foundation. -__version__ = '1.2' +__version__ = '1.4' from .gfapi import File, Dir, DirEntry, Volume __all__ = ['File', 'Dir', 'DirEntry', 'Volume'] diff --git a/gluster/gfapi/api.py b/gluster/gfapi/api.py index e4f0b14..273f138 100644 --- a/gluster/gfapi/api.py +++ b/gluster/gfapi/api.py @@ -8,6 +8,7 @@ # later), or the GNU General Public License, version 2 (GPLv2), in all # cases as published by the Free Software Foundation. +import sys import ctypes from ctypes.util import find_library from ctypes import sizeof @@ -67,24 +68,54 @@ class Stat (ctypes.Structure): - _fields_ = [ - ("st_dev", ctypes.c_ulong), - ("st_ino", ctypes.c_ulong), - ("st_nlink", ctypes.c_ulong), - ("st_mode", ctypes.c_uint), - ("st_uid", ctypes.c_uint), - ("st_gid", ctypes.c_uint), - ("st_rdev", ctypes.c_ulong), - ("st_size", ctypes.c_ulong), - ("st_blksize", ctypes.c_ulong), - ("st_blocks", ctypes.c_ulong), - ("st_atime", ctypes.c_ulong), - ("st_atimensec", ctypes.c_ulong), - ("st_mtime", ctypes.c_ulong), - ("st_mtimensec", ctypes.c_ulong), - ("st_ctime", ctypes.c_ulong), - ("st_ctimensec", ctypes.c_ulong), - ] + if sys.platform == 'darwin': + _fields_ = [ + ("st_dev", ctypes.c_int32), + ("st_mode", ctypes.c_uint16), + ("st_ino", ctypes.c_uint32), + ("st_nlink", ctypes.c_uint16), + ("st_uid", ctypes.c_uint), + ("st_gid", ctypes.c_uint), + ("st_rdev", ctypes.c_uint32), + + ("st_atime", ctypes.c_long), + ("st_atimensec", ctypes.c_long), + ("st_mtime", ctypes.c_long), + ("st_mtimensec", ctypes.c_long), + ("st_ctime", ctypes.c_long), + ("st_ctimensec", ctypes.c_long), + ("st_birthtime", ctypes.c_long), + ("st_birthtimespec", ctypes.c_long), + + ("st_size", ctypes.c_int64), + ("st_blocks", ctypes.c_int64), + ("st_blksize", ctypes.c_int32), + + ("st_flags", ctypes.c_uint32), + ("st_gen", ctypes.c_uint32), + ("st_lspare", ctypes.c_int32), + ("st_qspare1", ctypes.c_int64), + ("st_qspare2", ctypes.c_int64), + ] + else: + _fields_ = [ + ("st_dev", ctypes.c_ulong), + ("st_ino", ctypes.c_ulong), + ("st_nlink", ctypes.c_ulong), + ("st_mode", ctypes.c_uint), + ("st_uid", ctypes.c_uint), + ("st_gid", ctypes.c_uint), + ("st_rdev", ctypes.c_ulong), + ("st_size", ctypes.c_ulong), + ("st_blksize", ctypes.c_ulong), + ("st_blocks", ctypes.c_ulong), + ("st_atime", ctypes.c_ulong), + ("st_atimensec", ctypes.c_ulong), + ("st_mtime", ctypes.c_ulong), + ("st_mtimensec", ctypes.c_ulong), + ("st_ctime", ctypes.c_ulong), + ("st_ctimensec", ctypes.c_ulong), + ] class Statvfs (ctypes.Structure): @@ -105,14 +136,23 @@ class Statvfs (ctypes.Structure): class Dirent (ctypes.Structure): - _fields_ = [ - ("d_ino", ctypes.c_ulong), - ("d_off", ctypes.c_ulong), - ("d_reclen", ctypes.c_ushort), - ("d_type", ctypes.c_char), - ("d_name", ctypes.c_char * 256), - ] - + if sys.platform == 'darwin': + _fields_ = [ + ("d_ino", ctypes.c_ulong), + ("d_off", ctypes.c_ulong), + ("d_reclen", ctypes.c_uint16), + ("d_namelen", ctypes.c_uint16), + ("d_type", ctypes.c_uint8), + ("d_name", ctypes.c_char * 256), + ] + else: + _fields_ = [ + ("d_ino", ctypes.c_ulong), + ("d_off", ctypes.c_ulong), + ("d_reclen", ctypes.c_ushort), + ("d_type", ctypes.c_char), + ("d_name", ctypes.c_char * 256), + ] class Timespec (ctypes.Structure): _fields_ = [