Use ctypesand get the system call from libc:
import ctypes, os
libc = ctypes.CDLL(None, use_errno=True)
off64_t = ctypes.c_longlong
def readahead(fobj, offset, count):
fno = fobj if isinstance(fobj, int) else fobj.fileno()
code = libc.readahead(
ctypes.c_int(fno),
off64_t(offset),
ctypes.c_size_t(count)
)
if code != 0:
errno = ctypes.get_errno()
raise OSError(errno, os.strerror(errno))
source
share