From: Dave Hansen <dave-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
To: Ingo Molnar <mingo-X9Un+BFzKDI@public.gmane.org>
Cc: containers
<containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Dave Hansen
<dave-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>,
Alexey Dobriyan
<adobriyan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: [RFC][PATCH 4/5] breakout fdinfo sprintf() into its own function
Date: Thu, 19 Feb 2009 10:20:11 -0800 [thread overview]
Message-ID: <20090219182011.6CFB5483@kernel> (raw)
In-Reply-To: <20090219182007.B4B47C1F@kernel>
I'll be adding to this in a moment and it is in a bad place
to do that cleanly now.
Also, increase the buffer size. Most /proc files can
output up to a page, so use the same here.
Signed-off-by: Dave Hansen <dave-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
---
linux-2.6.git-dave/fs/proc/base.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff -puN fs/proc/base.c~breakout-fdinfo fs/proc/base.c
--- linux-2.6.git/fs/proc/base.c~breakout-fdinfo 2009-02-19 10:17:25.000000000 -0800
+++ linux-2.6.git-dave/fs/proc/base.c 2009-02-19 10:17:25.000000000 -0800
@@ -1597,7 +1597,18 @@ out:
return ~0U;
}
-#define PROC_FDINFO_MAX 64
+#define PROC_FDINFO_MAX PAGE_SIZE
+
+static void proc_fd_write_info(struct file *file, char *info)
+{
+ int max = PROC_FDINFO_MAX;
+ int p = 0;
+ if (!info)
+ return;
+
+ p += snprintf(info+p, max-p, "pos:\t%lli\n", (long long) file->f_pos);
+ p += snprintf(info+p, max-p, "flags:\t0%o\n", file->f_flags);
+}
static int proc_fd_info(struct inode *inode, struct path *path, char *info)
{
@@ -1622,12 +1633,7 @@ static int proc_fd_info(struct inode *in
*path = file->f_path;
path_get(&file->f_path);
}
- if (info)
- snprintf(info, PROC_FDINFO_MAX,
- "pos:\t%lli\n"
- "flags:\t0%o\n",
- (long long) file->f_pos,
- file->f_flags);
+ proc_fd_write_info(file, info);
spin_unlock(&files->file_lock);
put_files_struct(files);
return 0;
@@ -1831,10 +1837,11 @@ static int proc_readfd(struct file *filp
static ssize_t proc_fdinfo_read(struct file *file, char __user *buf,
size_t len, loff_t *ppos)
{
- char tmp[PROC_FDINFO_MAX];
+ char *tmp = kmalloc(PROC_FDINFO_MAX, GFP_KERNEL);
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));
+ kfree(tmp);
return err;
}
_
WARNING: multiple messages have this Message-ID (diff)
From: Dave Hansen <dave@linux.vnet.ibm.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: containers <containers@lists.linux-foundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Serge E. Hallyn" <serue@us.ibm.com>,
Oren Laadan <orenl@cs.columbia.edu>,
Alexey Dobriyan <adobriyan@gmail.com>,
Dave Hansen <dave@linux.vnet.ibm.com>
Subject: [RFC][PATCH 4/5] breakout fdinfo sprintf() into its own function
Date: Thu, 19 Feb 2009 10:20:11 -0800 [thread overview]
Message-ID: <20090219182011.6CFB5483@kernel> (raw)
In-Reply-To: <20090219182007.B4B47C1F@kernel>
I'll be adding to this in a moment and it is in a bad place
to do that cleanly now.
Also, increase the buffer size. Most /proc files can
output up to a page, so use the same here.
Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com>
---
linux-2.6.git-dave/fs/proc/base.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff -puN fs/proc/base.c~breakout-fdinfo fs/proc/base.c
--- linux-2.6.git/fs/proc/base.c~breakout-fdinfo 2009-02-19 10:17:25.000000000 -0800
+++ linux-2.6.git-dave/fs/proc/base.c 2009-02-19 10:17:25.000000000 -0800
@@ -1597,7 +1597,18 @@ out:
return ~0U;
}
-#define PROC_FDINFO_MAX 64
+#define PROC_FDINFO_MAX PAGE_SIZE
+
+static void proc_fd_write_info(struct file *file, char *info)
+{
+ int max = PROC_FDINFO_MAX;
+ int p = 0;
+ if (!info)
+ return;
+
+ p += snprintf(info+p, max-p, "pos:\t%lli\n", (long long) file->f_pos);
+ p += snprintf(info+p, max-p, "flags:\t0%o\n", file->f_flags);
+}
static int proc_fd_info(struct inode *inode, struct path *path, char *info)
{
@@ -1622,12 +1633,7 @@ static int proc_fd_info(struct inode *in
*path = file->f_path;
path_get(&file->f_path);
}
- if (info)
- snprintf(info, PROC_FDINFO_MAX,
- "pos:\t%lli\n"
- "flags:\t0%o\n",
- (long long) file->f_pos,
- file->f_flags);
+ proc_fd_write_info(file, info);
spin_unlock(&files->file_lock);
put_files_struct(files);
return 0;
@@ -1831,10 +1837,11 @@ static int proc_readfd(struct file *filp
static ssize_t proc_fdinfo_read(struct file *file, char __user *buf,
size_t len, loff_t *ppos)
{
- char tmp[PROC_FDINFO_MAX];
+ char *tmp = kmalloc(PROC_FDINFO_MAX, GFP_KERNEL);
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));
+ kfree(tmp);
return err;
}
_
next prev parent reply other threads:[~2009-02-19 18:20 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-19 18:20 [RFC][PATCH 1/5] create fs flag to mark c/r supported fs's Dave Hansen
2009-02-19 18:20 ` Dave Hansen
2009-02-19 18:20 ` [RFC][PATCH 2/5] file c/r: expose functions to query fs support Dave Hansen
2009-02-19 18:20 ` Dave Hansen
2009-02-19 18:20 ` [RFC][PATCH 3/5] check files for checkpointability Dave Hansen
2009-02-19 18:20 ` Dave Hansen
2009-02-23 23:49 ` Serge E. Hallyn
2009-02-23 23:49 ` Serge E. Hallyn
[not found] ` <20090223234911.GB2590-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-02-24 0:30 ` Dave Hansen
2009-02-24 0:30 ` Dave Hansen
2009-02-24 1:10 ` Serge E. Hallyn
2009-02-24 1:20 ` Dave Hansen
2009-02-24 19:43 ` Serge E. Hallyn
[not found] ` <20090224194329.GC24007-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-02-24 19:47 ` Dave Hansen
2009-02-24 19:47 ` Dave Hansen
2009-02-24 19:43 ` Serge E. Hallyn
[not found] ` <20090224011037.GB4797-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-02-24 1:20 ` Dave Hansen
2009-02-24 1:10 ` Serge E. Hallyn
2009-02-19 18:20 ` Dave Hansen [this message]
2009-02-19 18:20 ` [RFC][PATCH 4/5] breakout fdinfo sprintf() into its own function Dave Hansen
2009-02-19 18:20 ` [RFC][PATCH 5/5] add c/r info to fdinfo Dave Hansen
2009-02-19 18:20 ` Dave Hansen
2009-02-19 18:23 ` [RFC][PATCH 1/5] create fs flag to mark c/r supported fs's Dave Hansen
2009-02-19 18:23 ` Dave Hansen
2009-02-19 19:00 ` Christoph Hellwig
2009-02-19 19:00 ` Christoph Hellwig
[not found] ` <20090219190009.GC28490-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2009-02-19 19:24 ` Dave Hansen
2009-02-19 19:24 ` Dave Hansen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090219182011.6CFB5483@kernel \
--to=dave-23vcf4htsmix0ybbhkvfkdbpr1lh4cv8@public.gmane.org \
--cc=adobriyan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mingo-X9Un+BFzKDI@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.