[CRIU] [PATCH 1/3] files-reg: Refactor create_ghost()
Kirill Tkhai
ktkhai at virtuozzo.com
Mon Dec 21 07:01:56 PST 2015
On 21.12.2015 11:56, Pavel Emelyanov wrote:
> On 12/15/2015 04:29 PM, Kirill Tkhai wrote:
>> In the most cases, file descriptor is not need in this function.
>> We can use chown() instead of fchown(), and operate with a path
>> directly.
>>
>> The patch moves copying content of a regular file to new function
>> mkreg_ghost(). This will be used in next patches.
>>
>> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
>> ---
>> files-reg.c | 42 ++++++++++++++++++++++--------------------
>> 1 file changed, 22 insertions(+), 20 deletions(-)
>>
>> diff --git a/files-reg.c b/files-reg.c
>> index 425dc04..8469417 100644
>> --- a/files-reg.c
>> +++ b/files-reg.c
>> @@ -94,10 +94,24 @@ static int note_link_remap(char *path, struct ns_id *nsid)
>> return -1;
>> }
>>
>> +static int mkreg_ghost(char *path, u32 mode, struct ghost_file *gf, struct cr_img *img)
>
> The gf arg is unused here.
It's used in [patch 2/3]. I've added it here just to do not divert a reader's attention there.
>> +{
>> + int gfd, ret;
>> +
>> + gfd = open(path, O_WRONLY | O_CREAT | O_EXCL, mode);
>> + if (gfd < 0)
>> + return -1;
>> +
>> + ret = copy_file(img_raw_fd(img), gfd, 0);
>> + close(gfd);
>> +
>> + return ret;
>> +}
>> +
>> static int create_ghost(struct ghost_file *gf, GhostFileEntry *gfe, struct cr_img *img)
>> {
>> - int gfd, ghost_flags, ret;
>> char path[PATH_MAX];
>> + int ret;
>>
>> ret = rst_get_mnt_root(gf->remap.rmnt_id, path, sizeof(path));
>> if (ret < 0) {
>
More information about the CRIU
mailing list