From 3298139e65d5132c8895923b251f4fe84b2b2568 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Mon, 6 May 2024 19:44:49 +0200 Subject: syscalls: allow logging of syscalls --- linuxnamespaces/syscalls.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/linuxnamespaces/syscalls.py b/linuxnamespaces/syscalls.py index d9d37eb..986238c 100644 --- a/linuxnamespaces/syscalls.py +++ b/linuxnamespaces/syscalls.py @@ -10,12 +10,16 @@ import ctypes import dataclasses import enum import errno +import logging import os import typing from .atlocation import AtFlags, AtLocation, AtLocationLike, PathConvertible +logger = logging.getLogger(__name__) + + LIBC_SO = ctypes.CDLL(None, use_errno=True) @@ -363,7 +367,9 @@ def call_libc(funcname: str, *args: typing.Any) -> int: the function returns an integer that is non-negative on success. On failure, an OSError with errno is raised. """ + logger.debug("calling libc function %s%r", funcname, args) ret: int = LIBC_SO[funcname](*args) + logger.debug("%s returned %d", funcname, ret) if ret < 0: err = ctypes.get_errno() raise OSError( -- cgit v1.2.3