* [GIT] /proc/uptime fix
@ 2008-11-03 14:50 Alexey Dobriyan
2008-11-03 18:14 ` Linus Torvalds
0 siblings, 1 reply; 3+ messages in thread
From: Alexey Dobriyan @ 2008-11-03 14:50 UTC (permalink / raw)
To: torvalds; +Cc: linux-kernel
Linus, please, pull from
git://git.kernel.org/pub/scm/linux/kernel/git/adobriyan/proc.git proc-linus
to get pread("/proc/uptime") back for some VMware userspace:
fs/proc/uptime.c | 38 ++++++++++++++++++++------------------
1 files changed, 20 insertions(+), 18 deletions(-)
Alexey Dobriyan (1):
proc: revert /proc/uptime to ->read_proc hook
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [GIT] /proc/uptime fix 2008-11-03 14:50 [GIT] /proc/uptime fix Alexey Dobriyan @ 2008-11-03 18:14 ` Linus Torvalds 2008-11-03 20:25 ` Alexey Dobriyan 0 siblings, 1 reply; 3+ messages in thread From: Linus Torvalds @ 2008-11-03 18:14 UTC (permalink / raw) To: Alexey Dobriyan, Al Viro; +Cc: Linux Kernel Mailing List On Mon, 3 Nov 2008, Alexey Dobriyan wrote: > > Alexey Dobriyan (1): > proc: revert /proc/uptime to ->read_proc hook Ok, pulled, but it's a bit sad. Al: the commit is 6c87df37dcb9c6c33923707fa5191e0a65874d60, and the message explains it all: Turned out some VMware userspace does pread(2) on /proc/uptime, but seqfiles currently don't allow pread() resulting in -ESPIPE. Seqfiles in theory can do pread(), but this can be a long story, so revert to ->read_proc until then. and I bet that the pread() usage is just with a constant loff_t of 0, and just there to avoid a simple case of "lseek+read". I wonder how hard it is to make seqfiles support pread. Maybe it's something as trivial as just flushing the buffer whenever 'pos' doesn't match f_pos? ie something like the following (TOTALLY UNTESTED!) I may be way off base here, Al needs to whack some sense into this. Linus --- fs/seq_file.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/seq_file.c b/fs/seq_file.c index eba2eab..eb95ec9 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -48,8 +48,8 @@ int seq_open(struct file *file, const struct seq_operations *op) */ file->f_version = 0; - /* SEQ files support lseek, but not pread/pwrite */ - file->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); + /* SEQ files support lseek, but not pwrite */ + file->f_mode &= ~(FMODE_PWRITE); return 0; } EXPORT_SYMBOL(seq_open); @@ -91,6 +91,8 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) if (!m->buf) goto Enomem; } + if (pos != file->f_pos) + m->count = 0; /* if not empty - flush it first */ if (m->count) { n = min(m->count, size); @@ -175,6 +177,8 @@ Done: else *ppos += copied; file->f_version = m->version; + if (pos != file->f_pos) + m->count = 0; mutex_unlock(&m->lock); return copied; Enomem: ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [GIT] /proc/uptime fix 2008-11-03 18:14 ` Linus Torvalds @ 2008-11-03 20:25 ` Alexey Dobriyan 0 siblings, 0 replies; 3+ messages in thread From: Alexey Dobriyan @ 2008-11-03 20:25 UTC (permalink / raw) To: Linus Torvalds; +Cc: Al Viro, linux-kernel On Mon, Nov 03, 2008 at 10:14:16AM -0800, Linus Torvalds wrote: > On Mon, 3 Nov 2008, Alexey Dobriyan wrote: > > > > Alexey Dobriyan (1): > > proc: revert /proc/uptime to ->read_proc hook > > Ok, pulled, but it's a bit sad. > > Al: the commit is 6c87df37dcb9c6c33923707fa5191e0a65874d60, and the > message explains it all: > > Turned out some VMware userspace does pread(2) on /proc/uptime, but > seqfiles currently don't allow pread() resulting in -ESPIPE. > > Seqfiles in theory can do pread(), but this can be a long story, > so revert to ->read_proc until then. > > and I bet that the pread() usage is just with a constant loff_t of 0, and > just there to avoid a simple case of "lseek+read". > > I wonder how hard it is to make seqfiles support pread. Not hard at all, if ->read hook has information if it's called from read(2) or pread(2) (or something equivalent). > Maybe it's something as trivial as just flushing the buffer whenever 'pos' > doesn't match f_pos? > --- a/fs/seq_file.c > +++ b/fs/seq_file.c > @@ -48,8 +48,8 @@ int seq_open(struct file *file, const struct seq_operations *op) > */ > file->f_version = 0; > > - /* SEQ files support lseek, but not pread/pwrite */ > - file->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); > + /* SEQ files support lseek, but not pwrite */ > + file->f_mode &= ~(FMODE_PWRITE); FMODE_PWRITE is aliased to FMODE_PREAD so you have to split them first. ;-) > @@ -91,6 +91,8 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) > if (!m->buf) > goto Enomem; > } > + if (pos != file->f_pos) > + m->count = 0; > /* if not empty - flush it first */ > if (m->count) { > n = min(m->count, size); > @@ -175,6 +177,8 @@ Done: > else > *ppos += copied; > file->f_version = m->version; > + if (pos != file->f_pos) > + m->count = 0; ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-11-03 20:32 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2008-11-03 14:50 [GIT] /proc/uptime fix Alexey Dobriyan 2008-11-03 18:14 ` Linus Torvalds 2008-11-03 20:25 ` Alexey Dobriyan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®