Commit 7a65c701 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

util: add ability to change a file descriptor on procfs (v2)

When a pidns is dumped, crtools uses procfs from this pidns
for getting information about zombies.

v2: Use close_proc() instead of restore_proc_fd().
    A current proc will be opened again, if it's required.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 5c171b13
...@@ -178,6 +178,7 @@ int set_proc_mountpoint(char *path); ...@@ -178,6 +178,7 @@ int set_proc_mountpoint(char *path);
void close_proc(void); void close_proc(void);
int open_pid_proc(pid_t pid); int open_pid_proc(pid_t pid);
int close_pid_proc(void); int close_pid_proc(void);
int set_proc_fd(int fd);
int do_open_proc(pid_t pid, int flags, const char *fmt, ...); int do_open_proc(pid_t pid, int flags, const char *fmt, ...);
......
...@@ -170,6 +170,21 @@ void close_proc() ...@@ -170,6 +170,21 @@ void close_proc()
proc_dir_fd = -1; proc_dir_fd = -1;
} }
int set_proc_fd(int fd)
{
int sfd = get_service_fd(PROC_FD_OFF);
sfd = dup2(fd, sfd);
if (sfd < 0) {
pr_perror("Can't set proc fd\n");
return -1;
}
proc_dir_fd = sfd;
return 0;
}
int set_proc_mountpoint(char *path) int set_proc_mountpoint(char *path)
{ {
int sfd = get_service_fd(PROC_FD_OFF), fd; int sfd = get_service_fd(PROC_FD_OFF), fd;
......
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