mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [GIT] /proc/*/task getdents fixlet
@ 2009-03-17 16:06 Alexey Dobriyan
  2009-03-17 16:15 ` Linus Torvalds
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Dobriyan @ 2009-03-17 16:06 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel, r0bertz, viro

[third time Linus's email should written right]

Linus, please from

	git://git.kernel.org/pub/scm/linux/kernel/git/adobriyan/proc.git proc-linus

to get the following patch:

Zhang Le (1):
      proc: update ->f_pos correctly in proc_task_readdir()

fs/proc/base.c |   16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -3066,7 +3066,6 @@ static int proc_task_readdir(struct file * filp, void * dirent, filldir_t filldi
 	int retval = -ENOENT;
 	ino_t ino;
 	int tid;
-	unsigned long pos = filp->f_pos;  /* avoiding "long long" filp->f_pos */
 	struct pid_namespace *ns;
 
 	task = get_proc_task(inode);
@@ -3083,18 +3082,18 @@ static int proc_task_readdir(struct file * filp, void * dirent, filldir_t filldi
 		goto out_no_task;
 	retval = 0;
 
-	switch (pos) {
+	switch ((unsigned long)filp->f_pos) {
 	case 0:
 		ino = inode->i_ino;
-		if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
+		if (filldir(dirent, ".", 1, filp->f_pos, ino, DT_DIR) < 0)
 			goto out;
-		pos++;
+		filp->f_pos++;
 		/* fall through */
 	case 1:
 		ino = parent_ino(dentry);
-		if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
+		if (filldir(dirent, "..", 2, filp->f_pos, ino, DT_DIR) < 0)
 			goto out;
-		pos++;
+		filp->f_pos++;
 		/* fall through */
 	}
 
@@ -3104,9 +3103,9 @@ static int proc_task_readdir(struct file * filp, void * dirent, filldir_t filldi
 	ns = filp->f_dentry->d_sb->s_fs_info;
 	tid = (int)filp->f_version;
 	filp->f_version = 0;
-	for (task = first_tid(leader, tid, pos - 2, ns);
+	for (task = first_tid(leader, tid, filp->f_pos - 2, ns);
 	     task;
-	     task = next_tid(task), pos++) {
+	     task = next_tid(task), filp->f_pos++) {
 		tid = task_pid_nr_ns(task, ns);
 		if (proc_task_fill_cache(filp, dirent, filldir, task, tid) < 0) {
 			/* returning this tgid failed, save it as the first
@@ -3117,7 +3116,6 @@ static int proc_task_readdir(struct file * filp, void * dirent, filldir_t filldi
 		}
 	}
 out:
-	filp->f_pos = pos;
 	put_task_struct(leader);
 out_no_task:
 	return retval;

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

* Re: [GIT] /proc/*/task getdents fixlet
  2009-03-17 16:06 [GIT] /proc/*/task getdents fixlet Alexey Dobriyan
@ 2009-03-17 16:15 ` Linus Torvalds
  2009-03-17 17:00   ` Alexey Dobriyan
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Torvalds @ 2009-03-17 16:15 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: linux-kernel, r0bertz, viro



On Tue, 17 Mar 2009, Alexey Dobriyan wrote:
> 
> Linus, please from
> 
> 	git://git.kernel.org/pub/scm/linux/kernel/git/adobriyan/proc.git proc-linus
> 
> to get the following patch:
> 
> Zhang Le (1):
>       proc: update ->f_pos correctly in proc_task_readdir()

Grr. I already took the previous patch.

I assume the only difference is to avoid using a "switch()" on a 64-bit 
variable, and just cast it to "unsigned long". No?

		Linus

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

* Re: [GIT] /proc/*/task getdents fixlet
  2009-03-17 16:15 ` Linus Torvalds
@ 2009-03-17 17:00   ` Alexey Dobriyan
  2009-03-17 17:02     ` Linus Torvalds
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Dobriyan @ 2009-03-17 17:00 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel, r0bertz, viro

On Tue, Mar 17, 2009 at 09:15:46AM -0700, Linus Torvalds wrote:
> 
> 
> On Tue, 17 Mar 2009, Alexey Dobriyan wrote:
> > 
> > Linus, please from
> > 
> > 	git://git.kernel.org/pub/scm/linux/kernel/git/adobriyan/proc.git proc-linus
> > 
> > to get the following patch:
> > 
> > Zhang Le (1):
> >       proc: update ->f_pos correctly in proc_task_readdir()
> 
> Grr. I already took the previous patch.
> 
> I assume the only difference is to avoid using a "switch()" on a 64-bit 
> variable, and just cast it to "unsigned long". No?

Yes,

	+	switch ((unsigned long)filp->f_pos) {

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

* Re: [GIT] /proc/*/task getdents fixlet
  2009-03-17 17:00   ` Alexey Dobriyan
@ 2009-03-17 17:02     ` Linus Torvalds
  0 siblings, 0 replies; 4+ messages in thread
From: Linus Torvalds @ 2009-03-17 17:02 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: linux-kernel, r0bertz, viro



On Tue, 17 Mar 2009, Alexey Dobriyan wrote:

> On Tue, Mar 17, 2009 at 09:15:46AM -0700, Linus Torvalds wrote:
> > 
> > I assume the only difference is to avoid using a "switch()" on a 64-bit 
> > variable, and just cast it to "unsigned long". No?
> 
> Yes,
> 
> 	+	switch ((unsigned long)filp->f_pos) {

Ok, I'll do just that one by hand.

		Linus

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

end of thread, other threads:[~2009-03-17 17:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-17 16:06 [GIT] /proc/*/task getdents fixlet Alexey Dobriyan
2009-03-17 16:15 ` Linus Torvalds
2009-03-17 17:00   ` Alexey Dobriyan
2009-03-17 17:02     ` Linus Torvalds

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®