[CRIU] [PATCH] files-reg: Rework strip_deleted

Pavel Emelyanov xemul at parallels.com
Tue Jul 28 03:36:40 PDT 2015


On 07/28/2015 11:03 AM, Cyrill Gorcunov wrote:
> At moment here are two postfixes kernel supports,
> so rework the routine to handle both.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  files-reg.c | 30 +++++++++++++++++++++++-------
>  1 file changed, 23 insertions(+), 7 deletions(-)
> 
> diff --git a/files-reg.c b/files-reg.c
> index 2a6269b2a550..1a89e45a89bd 100644
> --- a/files-reg.c
> +++ b/files-reg.c
> @@ -647,16 +647,32 @@ static inline bool nfs_silly_rename(char *rpath, const struct fd_parms *parms)
>  
>  static void strip_deleted(struct fd_link *link)
>  {
> -	const char postfix[] = " (deleted)";
> -	const size_t plen = strlen(postfix);
> +	struct dcache_prepends {
> +		const char	*str;
> +		size_t		len;
> +	} static const prepends[] = {
> +		{
> +			.str	= " (deleted)",
> +			.len	= 10,
> +		}, {
> +			.str	= "//deleted",

Huh? Never seen one, which FS adds such?

> +			.len	= 10,
> +		}
> +	};
> +	size_t i;
> +
> +	for (i = 0; i < ARRAY_SIZE(prepends); i++) {
> +		size_t at;
> +
> +		if (link->len <= prepends[i].len)
> +			continue;
>  
> -	if (link->len > plen) {
> -		size_t at = link->len - plen;
> -		if (!strcmp(&link->name[at], postfix)) {
> +		at = link->len - prepends[i].len;
> +		if (!strcmp(&link->name[at], prepends[i].str)) {
>  			pr_debug("Stip %s' tag from '%s'\n",
> -				 postfix, link->name);
> +				 prepends[i].str, link->name);
>  			link->name[at] = '\0';
> -			link->len -= plen;
> +			link->len -= prepends[i].len;
>  		}
>  	}
>  }
> 



More information about the CRIU mailing list