Commit 6140f673 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

util: Use read_fd_link helper in is_anon_link_type

Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 03040be5
...@@ -439,15 +439,10 @@ int read_fd_link(int lfd, char *buf, size_t size) ...@@ -439,15 +439,10 @@ int read_fd_link(int lfd, char *buf, size_t size)
int is_anon_link_type(int lfd, char *type) int is_anon_link_type(int lfd, char *type)
{ {
char link[32], aux[32]; char link[32], aux[32];
ssize_t ret;
snprintf(aux, sizeof(aux), "/proc/self/fd/%d", lfd); if (read_fd_link(lfd, link, sizeof(link)))
ret = readlink(aux, link, sizeof(link)); return -1;
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); snprintf(aux, sizeof(aux), "anon_inode:%s", type);
return !strcmp(link, aux); return !strcmp(link, aux);
} }
......
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