[CRIU] [PATCH 2/9] files: Add ability to use read link in dump_one_reg_file
Pavel Emelyanov
xemul at parallels.com
Fri May 17 09:43:41 EDT 2013
On 05/17/2013 05:20 PM, Cyrill Gorcunov wrote:
>
> To be able to dump procfs namespace entries we will need to
> analyze the link name first and then figure out if the file
> referred indeed a procfs entry or it's plain regular file.
>
> This means we read link early, and to escape double reading
> of same link, once we read it we remember it in fd_parms
> structure which we pass to dump_one_reg_file.
>
> Still the dump_one_reg_file is not solely used from inside
> of dump_one_file, but from a number of other places (fifo,
> special files) where fd_parms is filled only partially
> and fill_fd_params is not even called. Thus dump_one_reg_file
> must be ready for such scenario and read the link name by own
> if the caller has not provided one.
>
> To achieve all this we do
>
> - extend fd_parms structure to have a reference on a new
> fd_link structure, thus if caller already read the link
> name it might assign the reference and call for dump_one_reg_file
>
> - tune up dump_one_reg_file to fill own copy of fd_link
> structure if the caller has not provied one
>
> Important: Because fdtype_ops::dump declares "const struct fd_parms *p"
> argument, I can't assign link inside dump_one_reg_file with fill_fdlink
> help (otherwise it leads to incorrect result when members declared as
> const are written). Thus we do use struct fd_link pointer explicitly.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
> files-reg.c | 25 +++++++++++++------------
> files.c | 28 +++++++++++++++++++++++++++-
> include/files.h | 9 +++++++++
> 3 files changed, 49 insertions(+), 13 deletions(-)
>
> + if (!p->link) {
> + if (fill_fdlink(lfd, (struct fd_parms *)p, &_link, false))
What is this cast for? To facilitate the fill_fdlink prototype?
Plz, remove this ugly bool assign and always assign it there.
> + return -1;
> + link = &_link;
> + } else
> + link = p->link;
More information about the CRIU
mailing list