public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH] ps command race fix take 4 [4/4] proc root open/release/llseek
@ 2006-08-25  9:29 KAMEZAWA Hiroyuki
  2006-09-04 23:13 ` [PATCH] proc: readdir race fix Eric W. Biederman
  0 siblings, 1 reply; 25+ messages in thread
From: KAMEZAWA Hiroyuki @ 2006-08-25  9:29 UTC (permalink / raw)
  To: LKML; +Cc: ebiederm, kamezawa.hiroyu, Andrew Morton, saito.tadashi, ak

implements open/release/llseek ops are needed by new proc_pid_readdir()

llseek()'s offset is specified by 'bytes' but /proc root doesn't handle
file->f_pos as bytes. So I disabled llseek for /proc for now.

Signed-Off-By: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

 fs/proc/root.c |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+)

Index: linux-2.6.18-rc4/fs/proc/root.c
===================================================================
--- linux-2.6.18-rc4.orig/fs/proc/root.c
+++ linux-2.6.18-rc4/fs/proc/root.c
@@ -16,6 +16,7 @@
 #include <linux/module.h>
 #include <linux/bitops.h>
 #include <linux/smp_lock.h>
+#include <linux/adaptive_pointer.h>
 
 #include "internal.h"
 
@@ -118,14 +119,47 @@ static int proc_root_readdir(struct file
 	return ret;
 }
 
+static int proc_root_open(struct inode *inode, struct file *filp)
+{
+	struct adaptive_pointer *ap;
+	ap = kzalloc(sizeof(*ap), GFP_KERNEL);
+	init_adaptive_pointer(ap);
+	if (ap) {
+		filp->private_data = ap;
+		return 0;
+	}
+	return -ENOMEM;
+}
+
+static int proc_root_release(struct inode *inode, struct file *filp)
+{
+	struct adaptive_pointer *ap;
+	ap = filp->private_data;
+	rcu_read_lock();
+	__ap_get_remove_pointer(ap);
+	rcu_read_unlock();
+	kfree(ap);
+	filp->private_data = NULL;
+	return 0;
+}
+
+static loff_t proc_root_llseek(struct file *file, loff_t off, int pos)
+{
+	/* pos is bytes...but we don't use fp->f_pos as bytes... */
+	return -ENOTSUPP;
+}
+
 /*
  * The root /proc directory is special, as it has the
  * <pid> directories. Thus we don't use the generic
  * directory handling functions for that..
  */
 static struct file_operations proc_root_operations = {
+	.open		 = proc_root_open,
 	.read		 = generic_read_dir,
 	.readdir	 = proc_root_readdir,
+	.release	= proc_root_release,
+	.llseek		= proc_root_llseek,
 };
 
 /*


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2006-09-08  6:39 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-25  9:29 [RFC][PATCH] ps command race fix take 4 [4/4] proc root open/release/llseek KAMEZAWA Hiroyuki
2006-09-04 23:13 ` [PATCH] proc: readdir race fix Eric W. Biederman
2006-09-05  1:30   ` KAMEZAWA Hiroyuki
2006-09-05  2:30     ` Eric W. Biederman
2006-09-05  2:41     ` KAMEZAWA Hiroyuki
2006-09-05  2:26   ` KAMEZAWA Hiroyuki
2006-09-05  2:54     ` Eric W. Biederman
2006-09-05  3:07     ` Eric W. Biederman
2006-09-05  5:39       ` KAMEZAWA Hiroyuki
2006-09-05 10:10       ` Oleg Nesterov
2006-09-05 11:36         ` Eric W. Biederman
2006-09-05 14:52         ` [PATCH] proc: readdir race fix (take 3) Eric W. Biederman
2006-09-06  9:01           ` Jean Delvare
2006-09-06 21:12             ` Jean Delvare
2006-09-06 22:25               ` Oleg Nesterov
2006-09-06 22:38                 ` [PATCH] proc-readdir-race-fix-take-3-fix-3 Oleg Nesterov
2006-09-06 22:59                   ` Eric W. Biederman
2006-09-08  6:38                   ` Eric W. Biederman
2006-09-06 22:43               ` [PATCH] proc: readdir race fix (take 3) Eric W. Biederman
2006-09-07  8:31                 ` Jean Delvare
2006-09-07 13:57                   ` Eric W. Biederman
2006-09-07 18:07                     ` Jean Delvare
2006-09-07 18:40                       ` Eric W. Biederman
2006-09-05  5:26   ` [PATCH] proc: readdir race fix KAMEZAWA Hiroyuki
2006-09-05  5:41     ` KAMEZAWA Hiroyuki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox