* [PATCH 3/18] allow callers of seq_open do allocation themselves
@ 2005-11-08 2:01 Al Viro
2005-11-08 3:03 ` [OT] " Randy.Dunlap
2005-11-08 20:33 ` Jonathan Corbet
0 siblings, 2 replies; 8+ messages in thread
From: Al Viro @ 2005-11-08 2:01 UTC (permalink / raw)
To: torvalds; +Cc: linux-kernel, linux-fsdevel, linuxram
From: Al Viro <viro@zeniv.linux.org.uk>
Date: 1131401734 -0500
Allows caller of seq_open() to kmalloc() seq_file + whatever else they want
and set ->private_data to it. seq_open() will then abstain from doing
allocation itself.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
fs/seq_file.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
57865a0565080cc56de9aa5369ea1fc2b6477398
diff --git a/fs/seq_file.c b/fs/seq_file.c
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -28,13 +28,17 @@
*/
int seq_open(struct file *file, struct seq_operations *op)
{
- struct seq_file *p = kmalloc(sizeof(*p), GFP_KERNEL);
- if (!p)
- return -ENOMEM;
+ struct seq_file *p = file->private_data;
+
+ if (!p) {
+ p = kmalloc(sizeof(*p), GFP_KERNEL);
+ if (!p)
+ return -ENOMEM;
+ file->private_data = p;
+ }
memset(p, 0, sizeof(*p));
sema_init(&p->sem, 1);
p->op = op;
- file->private_data = p;
/*
* Wrappers around seq_open(e.g. swaps_open) need to be
^ permalink raw reply [flat|nested] 8+ messages in thread
* [OT] Re: [PATCH 3/18] allow callers of seq_open do allocation themselves
2005-11-08 2:01 [PATCH 3/18] allow callers of seq_open do allocation themselves Al Viro
@ 2005-11-08 3:03 ` Randy.Dunlap
2005-11-08 3:24 ` Neil Brown
2005-11-08 20:33 ` Jonathan Corbet
1 sibling, 1 reply; 8+ messages in thread
From: Randy.Dunlap @ 2005-11-08 3:03 UTC (permalink / raw)
To: Al Viro; +Cc: torvalds, linux-kernel, linux-fsdevel, linuxram
On Tue, 08 Nov 2005 02:01:31 +0000 Al Viro wrote:
> From: Al Viro <viro@zeniv.linux.org.uk>
> Date: 1131401734 -0500
What format is that date in, please?
> Allows caller of seq_open() to kmalloc() seq_file + whatever else they want
> and set ->private_data to it. seq_open() will then abstain from doing
> allocation itself.
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
~Randy
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [OT] Re: [PATCH 3/18] allow callers of seq_open do allocation themselves
2005-11-08 3:24 ` Neil Brown
@ 2005-11-08 3:12 ` Randy.Dunlap
2005-11-08 3:30 ` Al Viro
2005-11-08 3:45 ` Linus Torvalds
2 siblings, 0 replies; 8+ messages in thread
From: Randy.Dunlap @ 2005-11-08 3:12 UTC (permalink / raw)
To: Neil Brown; +Cc: viro, torvalds, linux-kernel, linux-fsdevel, linuxram
On Tue, 8 Nov 2005 14:24:33 +1100 Neil Brown wrote:
> On Monday November 7, rdunlap@xenotime.net wrote:
> > On Tue, 08 Nov 2005 02:01:31 +0000 Al Viro wrote:
> >
> > > From: Al Viro <viro@zeniv.linux.org.uk>
> > > Date: 1131401734 -0500
> >
> > What format is that date in, please?
> >
>
> %s %z
>
> (as date(1) understands it).
Thanks. I sorta guessed that after I sent the mail.
> Or was this a rhetorical question, meaning to say "Who in their right
> mind would used that sort of date format on a public mailing list?" :-)
nope 8:)
---
~Randy
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [OT] Re: [PATCH 3/18] allow callers of seq_open do allocation themselves
2005-11-08 3:03 ` [OT] " Randy.Dunlap
@ 2005-11-08 3:24 ` Neil Brown
2005-11-08 3:12 ` Randy.Dunlap
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Neil Brown @ 2005-11-08 3:24 UTC (permalink / raw)
To: Randy.Dunlap; +Cc: Al Viro, torvalds, linux-kernel, linux-fsdevel, linuxram
On Monday November 7, rdunlap@xenotime.net wrote:
> On Tue, 08 Nov 2005 02:01:31 +0000 Al Viro wrote:
>
> > From: Al Viro <viro@zeniv.linux.org.uk>
> > Date: 1131401734 -0500
>
> What format is that date in, please?
>
%s %z
(as date(1) understands it).
Or was this a rhetorical question, meaning to say "Who in their right
mind would used that sort of date format on a public mailing list?" :-)
NeilBrown
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [OT] Re: [PATCH 3/18] allow callers of seq_open do allocation themselves
2005-11-08 3:24 ` Neil Brown
2005-11-08 3:12 ` Randy.Dunlap
@ 2005-11-08 3:30 ` Al Viro
2005-11-08 3:48 ` Linus Torvalds
2005-11-08 3:45 ` Linus Torvalds
2 siblings, 1 reply; 8+ messages in thread
From: Al Viro @ 2005-11-08 3:30 UTC (permalink / raw)
To: Neil Brown; +Cc: Randy.Dunlap, torvalds, linux-kernel, linux-fsdevel, linuxram
On Tue, Nov 08, 2005 at 02:24:33PM +1100, Neil Brown wrote:
> On Monday November 7, rdunlap@xenotime.net wrote:
> > On Tue, 08 Nov 2005 02:01:31 +0000 Al Viro wrote:
> >
> > > From: Al Viro <viro@zeniv.linux.org.uk>
> > > Date: 1131401734 -0500
> >
> > What format is that date in, please?
> >
>
> %s %z
>
> (as date(1) understands it).
>
> Or was this a rhetorical question, meaning to say "Who in their right
> mind would used that sort of date format on a public mailing list?" :-)
git format-patch and used by git applymbox and friends...
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [OT] Re: [PATCH 3/18] allow callers of seq_open do allocation themselves
2005-11-08 3:24 ` Neil Brown
2005-11-08 3:12 ` Randy.Dunlap
2005-11-08 3:30 ` Al Viro
@ 2005-11-08 3:45 ` Linus Torvalds
2 siblings, 0 replies; 8+ messages in thread
From: Linus Torvalds @ 2005-11-08 3:45 UTC (permalink / raw)
To: Neil Brown; +Cc: Randy.Dunlap, Al Viro, linux-kernel, linux-fsdevel, linuxram
On Tue, 8 Nov 2005, Neil Brown wrote:
> On Monday November 7, rdunlap@xenotime.net wrote:
> >
> > What format is that date in, please?
>
> %s %z
>
> (as date(1) understands it).
Yes. It happens to be one of the formats git understands, and is also
the least ambiguous.
> Or was this a rhetorical question, meaning to say "Who in their right
> mind would used that sort of date format on a public mailing list?" :-)
Yeah, it's really only machine-readable. In this case git-readable,
although git will accept dates in almost any format.
It happens to be the format internally used by git, since it's easy to
parse and you can't get it wrong.
It may be a mistake to expose it outside in that format, though. The git
"format patch as email" script will just use the internal date format,
which is nice from a "you can't get it wrong" angle, but arguably not very
human-friendly.
Not being able to get it wrong by converting it to a human-readable format
and then converting it back is a pretty big advantage, though (it's damn
easy to screw up summer-time and timezone when converting to/from UTC:
the "%s %z" format doesn't leave any confusion: the seconds is always
since the epoch in UTC, and the %z is purely informational to tell in
which timezone the change was made).
Linus
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [OT] Re: [PATCH 3/18] allow callers of seq_open do allocation themselves
2005-11-08 3:30 ` Al Viro
@ 2005-11-08 3:48 ` Linus Torvalds
0 siblings, 0 replies; 8+ messages in thread
From: Linus Torvalds @ 2005-11-08 3:48 UTC (permalink / raw)
To: Al Viro; +Cc: Neil Brown, Randy.Dunlap, linux-kernel, linux-fsdevel, linuxram
On Tue, 8 Nov 2005, Al Viro wrote:
>
> git format-patch and used by git applymbox and friends...
Note that git applymbox can (and normally does) take the date in regular
RFC 822 email format too, so it's really git format-patch that is the
culprit here. It _could_ try to turn it back into a regular date, but just
uses the git internal format because it's easy, lazy, and unambigious.
The easy and lazy parts are probably not very strong arguments. The
unambigious part is the thing that makes it a killer format.
Linus
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/18] allow callers of seq_open do allocation themselves
2005-11-08 2:01 [PATCH 3/18] allow callers of seq_open do allocation themselves Al Viro
2005-11-08 3:03 ` [OT] " Randy.Dunlap
@ 2005-11-08 20:33 ` Jonathan Corbet
1 sibling, 0 replies; 8+ messages in thread
From: Jonathan Corbet @ 2005-11-08 20:33 UTC (permalink / raw)
To: Al Viro; +Cc: linux-kernel, linux-fsdevel
Al Viro <viro@ftp.linux.org.uk> wrote:
> Allows caller of seq_open() to kmalloc() seq_file + whatever else they want
> and set ->private_data to it. seq_open() will then abstain from doing
> allocation itself.
It looks like seq_release() frees the structure regardless of where it
came from. So the seq_file structure must be the first field in
whatever structure contains it, and one has to hope that won't change in
the future. Is that really the way the interface was meant to work?
jon
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2005-11-08 20:33 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-08 2:01 [PATCH 3/18] allow callers of seq_open do allocation themselves Al Viro
2005-11-08 3:03 ` [OT] " Randy.Dunlap
2005-11-08 3:24 ` Neil Brown
2005-11-08 3:12 ` Randy.Dunlap
2005-11-08 3:30 ` Al Viro
2005-11-08 3:48 ` Linus Torvalds
2005-11-08 3:45 ` Linus Torvalds
2005-11-08 20:33 ` Jonathan Corbet
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).