Commit 5a397e8a authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Cyrill Gorcunov

Rework fdinfo readinf to use FILE *

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
parent 4389c021
...@@ -292,20 +292,18 @@ static int dump_one_fd(char *pid_fd_dir, int dir, char *fd_name, unsigned long p ...@@ -292,20 +292,18 @@ static int dump_one_fd(char *pid_fd_dir, int dir, char *fd_name, unsigned long p
static int read_fd_params(pid_t pid, char *fd, unsigned long *pos, unsigned int *flags) static int read_fd_params(pid_t pid, char *fd, unsigned long *pos, unsigned int *flags)
{ {
char fd_str[128]; char fd_str[128];
int ifd; FILE *file;
snprintf(fd_str, sizeof(fd_str), "/proc/%d/fdinfo/%s", pid, fd); snprintf(fd_str, sizeof(fd_str), "/proc/%d/fdinfo/%s", pid, fd);
ifd = open(fd_str, O_RDONLY); file = fopen(fd_str, "r");
if (ifd < 0) { if (!file) {
pr_perror("Can't open %s\n", fd_str); pr_perror("Can't open %s\n", fd_str);
return -1; return -1;
} }
read(ifd, big_buffer, sizeof(big_buffer)); fscanf(file, "pos:\t%li\nflags:\t%o\n", pos, flags);
close(ifd); fclose(file);
sscanf(big_buffer, "pos:\t%li\nflags:\t%o\n", pos, flags);
pr_info("%s: pos: %16lx flags: %16lx\n", fd_str, *pos, *flags); pr_info("%s: pos: %16lx flags: %16lx\n", fd_str, *pos, *flags);
......
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