Commit 60f6ec7d authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

files-reg: Rework strip_deleted helper

Make it handle both postfixes and return
non-zero code if stipping happened.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Acked-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 4f8f97e0
......@@ -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;
for (i = 0; i < ARRAY_SIZE(prepends); i++) {
size_t at;
if (link->len > plen) {
size_t at = link->len - plen;
if (!strcmp(&link->name[at], postfix)) {
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__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment