[CRIU] Re: [PATCH v2 09/11] dump: remove redundant do_close_lfd flag

Kinsbursky Stanislav skinsbursky at openvz.org
Mon Mar 5 11:15:34 EST 2012


05.03.2012 19:43, Pavel Emelyanov пишет:
> On 03/05/2012 04:38 PM, Kinsbursky Stanislav wrote:
>
> This one de-factors severall close() calls. What for?

This looks more logical to me. Caller of dump_one_reg_file_fd() have to close 
the fd is passed to dump_one_reg_file_fd().
Yet again - the matter of taste from my pow.

>> Signed-off-by: Stanislav Kinsbursky<skinsbursky at openvz.org>
>>
>> ---
>>   cr-dump.c |   16 +++++++---------
>>   1 files changed, 7 insertions(+), 9 deletions(-)
>>
>> diff --git a/cr-dump.c b/cr-dump.c
>> index 03062e5..a1f7d3b 100644
>> --- a/cr-dump.c
>> +++ b/cr-dump.c
>> @@ -100,8 +100,7 @@ struct fd_parms {
>>   };
>>
>>   static int dump_one_reg_file_fd(struct fd_parms *p, int lfd,
>> -				struct cr_fdset *cr_fdset,
>> -				bool do_close_lfd)
>> +				struct cr_fdset *cr_fdset)
>>   {
>>   	struct fdinfo_entry e;
>>   	char fd_str[128];
>> @@ -118,9 +117,6 @@ static int dump_one_reg_file_fd(struct fd_parms *p, int lfd,
>>   	pr_info("Dumping path for %lx fd via self %d [%s]\n",
>>   		p->fd_name, lfd, big_buffer);
>>
>> -	if (do_close_lfd)
>> -		close(lfd);
>> -
>>   	e.type	= p->type;
>>   	e.len	= len;
>>   	e.flags = p->flags;
>> @@ -166,7 +162,7 @@ static int dump_one_reg_file(struct fd_parms *p, struct cr_fdset *cr_fdset)
>>   		pr_perror("Failed to open regular file %d/%ld\n", p->pid_fd_dir, p->fd_name);
>>   		return -1;
>>   	}
>> -	ret = dump_one_reg_file_fd(p, lfd, cr_fdset, 0);
>> +	ret = dump_one_reg_file_fd(p, lfd, cr_fdset);
>>   	close_safe(&lfd);
>>   	return ret;
>>   }
>> @@ -187,9 +183,10 @@ static int dump_task_special_files(pid_t pid, struct cr_fdset *cr_fdset)
>>   	fd = open_proc(pid, "cwd");
>>   	if (fd<  0)
>>   		return -1;
>> -	ret = dump_one_reg_file_fd(&params, fd, cr_fdset, 1);
>> +	ret = dump_one_reg_file_fd(&params, fd, cr_fdset);
>>   	if (ret)
>>   		return ret;
>> +	close(fd);
>>
>>   	/* Dump /proc/pid/exe */
>>   	params = (struct fd_parms) {
>> @@ -202,7 +199,8 @@ static int dump_task_special_files(pid_t pid, struct cr_fdset *cr_fdset)
>>   	fd = open_proc(pid, "exe");
>>   	if (fd<  0)
>>   		return -1;
>> -	ret = dump_one_reg_file_fd(&params, fd, cr_fdset, 1);
>> +	ret = dump_one_reg_file_fd(&params, fd, cr_fdset);
>> +	close(fd);
>>
>>   	return ret;
>>   }
>> @@ -491,7 +489,7 @@ static int dump_task_mappings(pid_t pid, struct list_head *vma_area_list, struct
>>   			else
>>   				p.flags = O_RDONLY;
>>
>> -			ret = dump_one_reg_file_fd(&p, vma_area->vm_file_fd, cr_fdset, 0);
>> +			ret = dump_one_reg_file_fd(&p, vma_area->vm_file_fd, cr_fdset);
>>   			if (ret)
>>   				goto err;
>>   		}
>>


-- 
Best regards,
Stanislav Kinsbursky




More information about the CRIU mailing list