From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pavel Emelyanov Subject: Re: [rfc 2/7] procfs: Convert /proc/pid/fdinfo/ handling routines to seq-file Date: Wed, 04 Jul 2012 11:37:26 +0400 Message-ID: <4FF3F2B6.5040909@parallels.com> References: <20120627110116.201735815@openvz.org> <20120627110512.485189390@openvz.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , Al Viro , Alexey Dobriyan , Andrew Morton , James Bottomley To: Cyrill Gorcunov Return-path: In-Reply-To: <20120627110512.485189390@openvz.org> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org > @@ -130,7 +159,31 @@ static const struct dentry_operations ti > > static int proc_fd_link(struct dentry *dentry, struct path *path) > { > - return proc_fd_info(dentry->d_inode, path, NULL); > + struct inode *inode = dentry->d_inode; > + struct task_struct *task = get_proc_task(inode); > + struct files_struct *files = NULL; > + int fd = proc_fd(inode); > + struct file *file; > + int err = -ENOENT; > + > + if (task) { > + files = get_files_struct(task); > + put_task_struct(task); > + } > + > + if (files) { > + spin_lock(&files->file_lock); > + file = fcheck_files(files, fd); > + if (file) { > + *path = file->f_path; > + path_get(&file->f_path); > + } > + spin_unlock(&files->file_lock); > + put_files_struct(files); > + err = 0; > + } > + > + return err; > } > > static struct dentry * > @@ -245,22 +298,6 @@ out_no_task: > return retval; > } > > -static ssize_t proc_fdinfo_read(struct file *file, char __user *buf, > - size_t len, loff_t *ppos) > -{ > - char tmp[PROC_FDINFO_MAX]; > - int err = proc_fd_info(file->f_path.dentry->d_inode, NULL, tmp); > - if (!err) > - err = simple_read_from_buffer(buf, len, ppos, tmp, strlen(tmp)); > - return err; > -} > - I believe we can still have the proc_fdinfo_read and proc_fd_link code non-splitted. Just push a callback pointer ino the proc_fd_info (as usual -- we an opaque void *argument). Thanks, Pavel