[CRIU] files-reg.c dump_ghost_file()

Adrian Reber adrian at lisas.de
Tue May 28 12:21:25 MSK 2019


Going through the review of https://github.com/checkpoint-restore/criu/pull/697
I had a closer look at dump_ghost_file() in files-reg.c and it seems
wrong:

	if (gfe.chunks)
		ret = copy_file_to_chunks(fd, img, st->st_size);
	else
		ret = copy_file(fd, img_raw_fd(img), st->st_size);
	close(fd);
	if (ret)
		return -1;

copy_file_to_chunks() returns -1 if something failed and else 0
copy_file() returns -1 if something failed and else the number of bytes
written (never 0).

copy_file() seems to have changed its return value with:

commit 3315681b4d9fb494ed35d5c78056e6199aef3ad1
Author: rbruno at gsd.inesc-id.pt <rbruno at gsd.inesc-id.pt>
Date:   Sat Feb 11 04:34:43 2017 +0100

    util: Copy file w/o sendfile
    
    This is the case when the in/out files are image cache/proxy sockets.
    
    Signed-off-by: Rodrigo Bruno <rbruno at gsd.inesc-id.pt>
    Signed-off-by: Katerina Koukiou <k.koukiou at gmail.com>
    Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>


I think the right thing to do is to fix copy_file() to again return 0 on
success.

cc-ing Radostin as this seems to be image proxy related.

		Adrian


More information about the CRIU mailing list