[CRIU] Re: [PATCH 7/8] util: Add open_proc_nocheck helper

Cyrill Gorcunov gorcunov at openvz.org
Sat Mar 24 13:48:02 EDT 2012


On Sat, Mar 24, 2012 at 09:38:46PM +0400, Pavel Emelyanov wrote:
> On 03/24/2012 08:19 PM, Cyrill Gorcunov wrote:
> > On Sat, Mar 24, 2012 at 08:11:18PM +0400, Pavel Emelyanov wrote:
> >> On 03/23/2012 05:30 PM, Cyrill Gorcunov wrote:
> >>> Will need it to test if file descriptor
> >>> is rather a socket.
> >>
> >> What socket? You cannot open other task's sockets via proc!
> > 
> > This helper is used to test a file descriptor for being socket
> > or not, if it fails then it's a socket.
> 
> If you do so, then I can say that the series is wrong without looking
> into it :)

Nope ;)

Look, what we have had before the patch

dump_one_fd
	lfd = openat(pid_fd_dir, d_name, O_RDONLY);
	if (lfd < 0) {
		err = try_dump_socket(pid, p.fd_name, cr_fdset, sk_queue);
		if (err != 1)
			return err;

		pr_perror("Failed to open %d/%ld", pid_fd_dir, p.fd_name);
		return -1;
	}

the pid_fd_dir is the /proc/pid/fd of the process we do dump,
d_name is the name of fd (actually a socket).

The new code does the same but via open_proc_nocheck,

dump_one_fd
	err = open_proc_nocheck(pid, "fd/%d", fd);
	if (err < 0) {
		err = try_dump_socket(pid, fd, cr_fdset, sk_queue);

the pid and fd -- both are from dumpee, ie it tries to open
exactle the same file as we were doing before.

	Cyrill


More information about the CRIU mailing list