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

Cyril Hrubis chrubis@suse.cz
Tue Nov 11 14:07:01 CET 2025


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


More information about the ltp mailing list