2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00

anon: Factor out checking for anon inode link types

Funny, but kernel reports some of them with []-s and some (well,
ok, inotofy only) without...

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Pavel Emelyanov
2012-05-04 14:22:18 +04:00
parent 6cebc48420
commit 50ff1438b0
5 changed files with 20 additions and 42 deletions

16
util.c
View File

@@ -310,3 +310,19 @@ bool is_anon_inode(struct statfs *statfs)
{
return statfs->f_type == ANON_INODE_FS_MAGIC;
}
int is_anon_link_type(int lfd, char *type)
{
char link[PATH_MAX], aux[32];
ssize_t ret;
snprintf(aux, sizeof(aux), "/proc/self/fd/%d", lfd);
ret = readlink(aux, link, sizeof(link));
if (ret < 0) {
pr_perror("Can't read link of fd %d\n", lfd);
return 0;
}
link[ret] = 0;
snprintf(aux, sizeof(aux), "anon_inode:%s", type);
return !strcmp(link, aux);
}