mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-22 01:51:51 +00:00
files-reg: Rework strip_deleted helper
Make it handle both postfixes and return non-zero code if stipping happened. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Acked-by: Tycho Andersen <tycho.andersen@canonical.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
4f8f97e0bd
commit
60f6ec7dd6
34
files-reg.c
34
files-reg.c
@ -639,20 +639,38 @@ static inline bool nfs_silly_rename(char *rpath, const struct fd_parms *parms)
|
||||
return (parms->fs_type == NFS_SUPER_MAGIC) && is_sillyrename_name(rpath);
|
||||
}
|
||||
|
||||
static void strip_deleted(struct fd_link *link)
|
||||
int 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",
|
||||
.len = 9,
|
||||
}
|
||||
};
|
||||
size_t i;
|
||||
|
||||
if (link->len > plen) {
|
||||
size_t at = link->len - plen;
|
||||
if (!strcmp(&link->name[at], postfix)) {
|
||||
for (i = 0; i < ARRAY_SIZE(prepends); i++) {
|
||||
size_t at;
|
||||
|
||||
if (link->len <= prepends[i].len)
|
||||
continue;
|
||||
|
||||
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;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int check_path_remap(struct fd_link *link, const struct fd_parms *parms,
|
||||
|
@ -51,4 +51,6 @@ extern struct collect_image_info remap_cinfo;
|
||||
extern void delete_link_remaps(void);
|
||||
extern void free_link_remaps(void);
|
||||
|
||||
extern int strip_deleted(struct fd_link *link);
|
||||
|
||||
#endif /* __CR_FILES_REG_H__ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user