LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] seq_file conversion: coda
@ 2007-01-15 21:53 Alexey Dobriyan
  2007-01-24  0:53 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Alexey Dobriyan @ 2007-01-15 21:53 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, jaharkes

Compile-tested.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 fs/coda/sysctl.c |   76 ++++++++++++++++++++++++++++---------------------------
 1 file changed, 39 insertions(+), 37 deletions(-)

--- a/fs/coda/sysctl.c
+++ b/fs/coda/sysctl.c
@@ -15,6 +15,7 @@ #include <linux/time.h>
 #include <linux/mm.h>
 #include <linux/sysctl.h>
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/stat.h>
 #include <linux/ctype.h>
@@ -84,15 +85,11 @@ static int do_reset_coda_cache_inv_stats
 	return 0;
 }
 
-static int coda_vfs_stats_get_info( char * buffer, char ** start,
-				    off_t offset, int length)
+static int proc_vfs_stats_show(struct seq_file *m, void *v)
 {
-	int len=0;
-	off_t begin;
 	struct coda_vfs_stats * ps = & coda_vfs_stat;
   
-  /* this works as long as we are below 1024 characters! */
-	len += sprintf( buffer,
+	seq_printf(m,
 			"Coda VFS statistics\n"
 			"===================\n\n"
 			"File Operations:\n"
@@ -132,28 +129,14 @@ static int coda_vfs_stats_get_info( char
 			ps->rmdir,
 			ps->rename,
 			ps->permission); 
-
-	begin = offset;
-	*start = buffer + begin;
-	len -= begin;
-
-	if ( len > length )
-		len = length;
-	if ( len < 0 )
-		len = 0;
-
-	return len;
+	return 0;
 }
 
-static int coda_cache_inv_stats_get_info( char * buffer, char ** start,
-					  off_t offset, int length)
+static int proc_cache_inv_stats_show(struct seq_file *m, void *v)
 {
-	int len=0;
-	off_t begin;
 	struct coda_cache_inv_stats * ps = & coda_cache_inv_stat;
   
-	/* this works as long as we are below 1024 characters! */
-	len += sprintf( buffer,
+	seq_printf(m,
 			"Coda cache invalidation statistics\n"
 			"==================================\n\n"
 			"flush\t\t%9d\n"
@@ -170,19 +153,35 @@ static int coda_cache_inv_stats_get_info
 			ps->zap_vnode,
 			ps->purge_fid,
 			ps->replace );
-  
-	begin = offset;
-	*start = buffer + begin;
-	len -= begin;
+	return 0;
+}
 
-	if ( len > length )
-		len = length;
-	if ( len < 0 )
-		len = 0;
+static int proc_vfs_stats_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, proc_vfs_stats_show, NULL);
+}
 
-	return len;
+static int proc_cache_inv_stats_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, proc_cache_inv_stats_show, NULL);
 }
 
+static const struct file_operations proc_vfs_stats_fops = {
+	.owner		= THIS_MODULE,
+	.open		= proc_vfs_stats_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
+static const struct file_operations proc_cache_inv_stats_fops = {
+	.owner		= THIS_MODULE,
+	.open		= proc_cache_inv_stats_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
 static ctl_table coda_table[] = {
  	{CODA_TIMEOUT, "timeout", &coda_timeout, sizeof(int), 0644, NULL, &proc_dointvec},
  	{CODA_HARD, "hard", &coda_hard, sizeof(int), 0644, NULL, &proc_dointvec},
@@ -212,9 +211,6 @@ static struct proc_dir_entry* proc_fs_co
 
 #endif
 
-#define coda_proc_create(name,get_info) \
-	create_proc_info_entry(name, 0, proc_fs_coda, get_info)
-
 void coda_sysctl_init(void)
 {
 	reset_coda_vfs_stats();
@@ -223,9 +219,15 @@ void coda_sysctl_init(void)
 #ifdef CONFIG_PROC_FS
 	proc_fs_coda = proc_mkdir("coda", proc_root_fs);
 	if (proc_fs_coda) {
+		struct proc_dir_entry *pde;
+
 		proc_fs_coda->owner = THIS_MODULE;
-		coda_proc_create("vfs_stats", coda_vfs_stats_get_info);
-		coda_proc_create("cache_inv_stats", coda_cache_inv_stats_get_info);
+		pde = create_proc_entry("vfs_stats", 0, proc_fs_coda);
+		if (pde)
+			pde->proc_fops = &proc_vfs_stats_fops;
+		pde = create_proc_entry("cache_inv_stats", 0, proc_fs_coda);
+		if (pde)
+			pde->proc_fops = &proc_cache_inv_stats_fops;
 	}
 #endif
 


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

* Re: [PATCH] seq_file conversion: coda
  2007-01-15 21:53 [PATCH] seq_file conversion: coda Alexey Dobriyan
@ 2007-01-24  0:53 ` Andrew Morton
  2007-01-24  5:45   ` Alexey Dobriyan
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2007-01-24  0:53 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: linux-kernel, jaharkes

On Tue, 16 Jan 2007 00:53:05 +0300
Alexey Dobriyan <adobriyan@gmail.com> wrote:

> Compile-tested.

You can runtime-test this interface without ever having mounted a CODA fs.

Please.   compile-tested-only patches are always a worry.


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

* Re: [PATCH] seq_file conversion: coda
  2007-01-24  0:53 ` Andrew Morton
@ 2007-01-24  5:45   ` Alexey Dobriyan
  0 siblings, 0 replies; 3+ messages in thread
From: Alexey Dobriyan @ 2007-01-24  5:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, jaharkes

On Tue, Jan 23, 2007 at 04:53:33PM -0800, Andrew Morton wrote:
> On Tue, 16 Jan 2007 00:53:05 +0300
> Alexey Dobriyan <adobriyan@gmail.com> wrote:
> 
> > Compile-tested.
> 
> You can runtime-test this interface without ever having mounted a CODA fs.
> 
> Please.   compile-tested-only patches are always a worry.

OK, I've built coda. Patch doesn't change output of
/proc/fs/coda/{cache_inv_stats,vfs_stats}. Though I haven't mounted
filesystems.


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

end of thread, other threads:[~2007-01-24  5:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-15 21:53 [PATCH] seq_file conversion: coda Alexey Dobriyan
2007-01-24  0:53 ` Andrew Morton
2007-01-24  5:45   ` Alexey Dobriyan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).