Move OS version check into main body and have it throw an exception on failure so the import fails.

This commit is contained in:
Thomas Hurst 2008-05-22 20:17:53 +01:00
parent 66ae80200e
commit 9d72385231

View File

@ -39,20 +39,19 @@ class kinfo_file(Structure):
('kf_sa_peer', sockaddr_storage),
]
libc = CDLL('libc.so')
len = c_uint(sizeof(c_uint))
ver = c_uint(0)
if (libc.sysctlbyname('kern.osreldate', byref(ver), byref(len), None, 0) < 0):
raise OSError, "sysctlbyname returned < 0"
# kern.proc.filedesc added for procstat(1) after these __FreeBSD_versions
if ver.value < 700104 and ver.value < 800019:
raise NotImplementedError, "cwd detection requires a recent 7.0-STABLE or 8-CURRENT"
def get_process_cwd(pid):
libc = CDLL('libc.so')
len = c_uint(sizeof(c_uint))
ver = c_uint(0)
if (libc.sysctlbyname('kern.osreldate', byref(ver), byref(len), None, 0) < 0):
return None
# kern.proc.filedesc added for procstat(1) after these __FreeBSD_versions
if ver.value < 700104 and ver.value < 800019:
return None
# /usr/include/sys/sysctl.h
# CTL_KERN, KERN_PROC, KERN_PROC_FILEDESC
oid = (c_uint * 4)(1, 14, 14, pid)