summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Martini <seb@dbzteam.org>2010-07-27 12:40:18 +0200
committerSebastien Martini <seb@dbzteam.org>2010-07-27 12:40:18 +0200
commit77f9641291794db929a8a891137998b982f7585f (patch)
tree661bbb02e25b5fde5c4a972ff0b74f96d1cdbd7c
parentec5a9f42c0e79d2017818cc2f522efd61cbc7952 (diff)
downloadpyinotify-77f9641291794db929a8a891137998b982f7585f.tar.gz
Check that loaded libc has needed inotify functions instead of
checking for glibc version number (reported by przemyslaw.wrzos@calyptech.com).
-rwxr-xr-xpython2/pyinotify.py26
-rwxr-xr-xpython3/pyinotify.py27
2 files changed, 17 insertions, 36 deletions
diff --git a/python2/pyinotify.py b/python2/pyinotify.py
index 694dd4a..e947270 100755
--- a/python2/pyinotify.py
+++ b/python2/pyinotify.py
@@ -51,14 +51,9 @@ class UnsupportedLibcVersionError(PyinotifyError):
"""
Raised on unsupported libc versions.
"""
- def __init__(self, version):
- """
- @param version: Current Libc version
- @type version: string
- """
- PyinotifyError.__init__(self,
- ('Libc %s is not supported, requires '
- 'at least Libc 2.4') % version)
+ def __init__(self):
+ err = 'libc does not provide required inotify support'
+ PyinotifyError.__init__(self, err)
# Check Python version
@@ -119,15 +114,12 @@ else:
LIBC = ctypes.CDLL(ctypes.util.find_library('c'))
STRERRNO = lambda : ''
-# The libc version > 2.4 check.
-# XXX: Maybe it is better to check if the libc has the needed functions inside?
-# Because there are inotify patches for libc 2.3.6.
-LIBC.gnu_get_libc_version.restype = ctypes.c_char_p
-LIBC_VERSION = LIBC.gnu_get_libc_version()
-if (int(LIBC_VERSION.split('.')[0]) < 2 or
- (int(LIBC_VERSION.split('.')[0]) == 2 and
- int(LIBC_VERSION.split('.')[1]) < 4)):
- raise UnsupportedLibcVersionError(LIBC_VERSION)
+
+# Check that libc has needed functions inside.
+if (not hasattr(LIBC, 'inotify_init') or
+ not hasattr(LIBC, 'inotify_add_watch') or
+ not hasattr(LIBC, 'inotify_rm_watch')):
+ raise UnsupportedLibcVersionError()
class PyinotifyLogger(logging.Logger):
diff --git a/python3/pyinotify.py b/python3/pyinotify.py
index c8d5cf4..d9b9dfc 100755
--- a/python3/pyinotify.py
+++ b/python3/pyinotify.py
@@ -51,14 +51,9 @@ class UnsupportedLibcVersionError(PyinotifyError):
"""
Raised on unsupported libc versions.
"""
- def __init__(self, version):
- """
- @param version: Current Libc version
- @type version: string
- """
- PyinotifyError.__init__(self,
- ('Libc %s is not supported, requires '
- 'at least Libc 2.4') % version)
+ def __init__(self):
+ err = 'libc does not provide required inotify support'
+ PyinotifyError.__init__(self, err)
# Check Python version
@@ -111,17 +106,11 @@ def STRERRNO():
code = ctypes.get_errno()
return '%s (%s)' % (os.strerror(code), errno.errorcode[code])
-# The libc version > 2.4 check.
-# XXX: Maybe it is better to check if the libc has the needed functions inside?
-# Because there are inotify patches for libc 2.3.6.
-LIBC.gnu_get_libc_version.restype = ctypes.c_char_p
-LIBC_VERSION = LIBC.gnu_get_libc_version()
-if not isinstance(LIBC_VERSION, str):
- LIBC_VERSION = LIBC_VERSION.decode()
-if (int(LIBC_VERSION.split('.')[0]) < 2 or
- (int(LIBC_VERSION.split('.')[0]) == 2 and
- int(LIBC_VERSION.split('.')[1]) < 4)):
- raise UnsupportedLibcVersionError(LIBC_VERSION)
+# Check that libc has needed functions inside.
+if (not hasattr(LIBC, 'inotify_init') or
+ not hasattr(LIBC, 'inotify_add_watch') or
+ not hasattr(LIBC, 'inotify_rm_watch')):
+ raise UnsupportedLibcVersionError()
class PyinotifyLogger(logging.Logger):