[LTP] [PATCH v2 1/8] Rewrite userns01.c using new LTP API

Petr Vorel pvorel@suse.cz
Thu Mar 24 21:50:38 CET 2022


Hi Andrea,

...
> +static inline void updatemap(int cpid, bool type, int idnum, int parentmappid)
nit: This header should #include <stdbool.h>, not all tests (they use UID_MAP,
thus they don't need it).

Kind regards,
Petr

> +{
> +	char path[BUFSIZ];
> +	char content[BUFSIZ];
> +	int fd;
> +
> +	if (type == UID_MAP)
> +		sprintf(path, "/proc/%d/uid_map", cpid);
> +	else if (type == GID_MAP)
> +		sprintf(path, "/proc/%d/gid_map", cpid);
> +	else
> +		tst_brk(TBROK, "invalid type parameter");
> +
> +	sprintf(content, "%d %d 1", idnum, parentmappid);
> +
> +	fd = SAFE_OPEN(path, O_WRONLY, 0644);
> +	SAFE_WRITE(1, fd, content, strlen(content));
> +	SAFE_CLOSE(fd);
> +}


More information about the ltp mailing list