Re: [LTP] [PATCH v2 3/5] swapon03: Try to swapon() as many files until it fails

Cyril Hrubis
2025-11-11T13:06:36Z

Hi!
> is_swap_supported(TEST_FILE);
> +
> + swapfiles = SAFE_MMAP(NULL, sizeof(*swapfiles), PROT_READ | PROT_WRITE,
> + MAP_SHARED | MAP_ANONYMOUS, -1, 0);
> + *swapfiles = 0;
> +
> setup_swap();
> }
>
> static void cleanup(void)
> {
> - clean_swap();
> + if (swapfiles) {
> + clean_swap();
> + SAFE_MUNMAP(swapfiles, sizeof(*swapfiles));
> + }
> }

This gets complicated for no good reason since we run the setup code in the
child.

--
Cyril Hrubis
chrubis@suse.cz