• Filipe Brandenburger's avatar
    cr-check: Inspect errno on syscall failures · e7ba9095
    Filipe Brandenburger authored
    After replacing sys_kcmp with syscall() and sys_prctl with prctl(), the
    API is changed to return -1 and set errno on failure (instead of
    returning the negative value of the error code directly on return.)
    
    Commit 8ceab588 ("crtools: no more linked with builtin syscall")
    replaced calls to sys_kcmp and sys_prctl, but did not update the checks
    for ret to check for -1 and errno, so update them here.
    
    Also make the comparisons for the return value explicit checks for a
    negative value (expected -1) instead of just failing on a non-zero value
    with the implicit comparison.
    
    Add %m to report what errno was set to on failed syscalls, to make it
    easier to troubleshoot a check failure.
    
    Tested that now `criu check --ms` stopped reporting the misleading:
      prctl: One needs CAP_SYS_RESOURCE capability to perform testing.
    Instead, now it reports:
      Error (cr-check.c:165): System call kcmp is not supported: No such process
      Warn  (cr-check.c:195): Skipping unssuported PR_SET_MM_MAP: Invalid argument
      prctl: PR_SET_MM is not supported: Invalid argument
    And those messages include the error message that explains why the
    syscall failed.
    Reported-by: 's avatarSaied Kazemi <saied@google.com>
    Fixes: 8ceab588 ("crtools: no more linked with builtin syscall")
    Cc: Laurent Dufour <ldufour@linux.vnet.ibm.com>
    Signed-off-by: 's avatarFilipe Brandenburger <filbranden@google.com>
    Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
    e7ba9095
Name
Last commit
Last update
Documentation Loading commit data...
contrib Loading commit data...
crit Loading commit data...
criu Loading commit data...
images Loading commit data...
lib Loading commit data...
scripts Loading commit data...
test Loading commit data...
.gitignore Loading commit data...
.mailmap Loading commit data...
.travis.yml Loading commit data...
COPYING Loading commit data...
CREDITS Loading commit data...
Makefile Loading commit data...
Makefile.install Loading commit data...
Makefile.versions Loading commit data...
README.md Loading commit data...