[LTP] [PATCH v2 4/8] Rewrite userns04.c using new LTP API
Petr Vorel
pvorel@suse.cz
Thu Mar 24 21:55:43 CET 2022
Hi Andrea,
LGTM, thanks!
Reviewed-by: Petr Vorel <pvorel@suse.cz>
> testcases/kernel/containers/userns/userns04.c | 139 ++++++------------
..
> +#include <stdio.h>
> +#include <stdbool.h>
<stdbool.h> belongs to common.h.
> +#include "common.h"
> +#include "tst_test.h"
> +#include "lapi/syscalls.h"
...
> +static void run(void)
> {
> pid_t cpid1, cpid2, cpid3;
> char path[BUFSIZ];
> int fd;
...
> + cpid1 = ltp_clone_quick(CLONE_NEWUSER | SIGCHLD, (void *)child_fn1, NULL);
> if (cpid1 < 0)
> - tst_brkm(TBROK | TERRNO, cleanup, "clone failed");
> + tst_brk(TBROK | TTERRNO, "clone failed");
We could create SAFE_LTP_CLONE_QUICK() (as a separate effort).
> - /* child 2 */
> sprintf(path, "/proc/%d/ns/user", cpid1);
> - fd = SAFE_OPEN(cleanup, path, O_RDONLY, 0644);
> - cpid2 = ltp_clone_quick(CLONE_NEWUSER | SIGCHLD,
> - (void *)child_fn2, (void *)((long)fd));
> +
> + fd = SAFE_OPEN(path, O_RDONLY, 0644);
> + cpid2 = ltp_clone_quick(CLONE_NEWUSER | SIGCHLD, (void *)child_fn2, (void *)((long)fd));
> if (cpid2 < 0)
> - tst_brkm(TBROK | TERRNO, cleanup, "clone failed");
> + tst_brk(TBROK | TTERRNO, "clone failed");
...
Kind regards,
Petr
More information about the ltp
mailing list