[CRIU] [PATCH] tests: do not try to read more than packet in AutoFS test

Andrei Vagin avagin at virtuozzo.com
Wed Sep 13 20:39:46 MSK 2017


Applied, thanks!

On Wed, Sep 13, 2017 at 02:35:06PM +0300, Stanislav Kinsburskiy wrote:
> The intention was to make sure, that only one packet is sent at a time.
> And thus read has to return exactly the size of one packet.
> 
> But it doesnt' work as expected, because size of autofs_v5_packet_union
> differs on 32 bit and 64 bit architectures.
> 
> This is a bug, but it's hidden so deeply, that no one really cares by the
> following 2 aspects:
> 
>  1) Autofs pipe has O_DIRECT flag, which means excess bytes will be discarded
>     upon read.
>  2) No one tries to read more than one packet size at a time.
> 
> So let's fix the test instead and do not try to read more bytes, than
> expected.
> 
> Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
> Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
> ---
>  test/zdtm/static/autofs.c |   13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/test/zdtm/static/autofs.c b/test/zdtm/static/autofs.c
> index 747ab69..ae78538 100644
> --- a/test/zdtm/static/autofs.c
> +++ b/test/zdtm/static/autofs.c
> @@ -460,7 +460,7 @@ static int automountd_loop(int pipe, const char *mountpoint, struct autofs_param
>  {
>  	union autofs_v5_packet_union *packet;
>  	ssize_t bytes;
> -	size_t psize = sizeof(*packet) + 1;
> +	size_t psize = sizeof(*packet);
>  	int err = 0;
>  
>  	packet = malloc(psize);
> @@ -473,7 +473,7 @@ static int automountd_loop(int pipe, const char *mountpoint, struct autofs_param
>  	siginterrupt(SIGUSR2, 1);
>  
>  	while (!stop && !err) {
> -		memset(packet, 0, sizeof(*packet));
> +		memset(packet, 0, psize);
>  
>  		bytes = read(pipe, packet, psize);
>  		if (bytes < 0) {
> @@ -483,12 +483,9 @@ static int automountd_loop(int pipe, const char *mountpoint, struct autofs_param
>  			}
>  			continue;
>  		}
> -		if (bytes == psize) {
> -			pr_err("read more that expected\n");
> -			return -EINVAL;
> -		}
> -		if (bytes != sizeof(*packet)) {
> -			pr_err("read less than expected: %zd\n", bytes);
> +		if (bytes != psize) {
> +			pr_err("read less than expected: %zd < %zd\n",
> +					bytes, psize);
>  			return -EINVAL;
>  		}
>  		err = automountd_serve(mountpoint, param, packet);
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list