linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Viro <viro@math.psu.edu>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: wwcopt@optonline.net, linux-kernel@vger.kernel.org
Subject: [PATCH][RFC] Re: 2.4.15-pre5: /proc/cpuinfo broken
Date: Sat, 17 Nov 2001 12:51:33 -0500 (EST)	[thread overview]
Message-ID: <Pine.GSO.4.21.0111171250310.11475-100000@weyl.math.psu.edu> (raw)
In-Reply-To: <15350.36701.89478.960625@kruemel.monster.org>

On Sat, 17 Nov 2001, Wolfgang Wander wrote:

>   Actually its bash - 2.04.0(1)-release (i386-suse-linux)

2.03.0(1)-release (i386-pc-linux-gnu) (Debian variant) works here.

OK, let's see what can be done.  Situation is the same for all seq_file-based
files.

	a) we can revert to old code.  Which had a lot of problems, quite
a few of them unfixable if we want to have lseek() to calculated position.

	b) we can change i_mode for these files, making them S_IFIFO.
That will stop any silliness (if something would rely on seeking
backwards for something that looks like a pipe, it would break on
real pipes, etc. and that's not too likely to stay unnoticed, to put
it mildly).  And that's trivial to implement.

	c) hunt down and fix the userland that relies on arithmetics
on file position in case of regular files (POSIX prohibits it, SuS allows).

(a) - lots of bad problems, including unsolvable userland races.
(b) - user-visible change, but one that is very unlikely to break
anything.
(c) - yeah, right.  In the middle of 2.4.  Since such stuff exists and is
widely used, it's out of question.  Pity, but there's nothing to do about
that.

Frankly, I'd prefer to try (b) before reverting to (a).  Patch doing that
variant follows.  Linus, your opinion?

diff -urN S15-pre5/fs/proc/inode.c S15-pre5-proc/fs/proc/inode.c
--- S15-pre5/fs/proc/inode.c	Tue Oct  9 21:47:27 2001
+++ S15-pre5-proc/fs/proc/inode.c	Sat Nov 17 12:38:08 2001
@@ -160,14 +160,12 @@
 			inode->i_nlink = de->nlink;
 		if (de->owner)
 			__MOD_INC_USE_COUNT(de->owner);
-		if (S_ISBLK(de->mode)||S_ISCHR(de->mode)||S_ISFIFO(de->mode))
+		if (de->proc_iops)
+			inode->i_op = de->proc_iops;
+		if (de->proc_fops)
+			inode->i_fop = de->proc_fops;
+		else if (S_ISBLK(de->mode)||S_ISCHR(de->mode)||S_ISFIFO(de->mode))
 			init_special_inode(inode,de->mode,kdev_t_to_nr(de->rdev));
-		else {
-			if (de->proc_iops)
-				inode->i_op = de->proc_iops;
-			if (de->proc_fops)
-				inode->i_fop = de->proc_fops;
-		}
 	}
 
 out:
diff -urN S15-pre5/fs/proc/proc_misc.c S15-pre5-proc/fs/proc/proc_misc.c
--- S15-pre5/fs/proc/proc_misc.c	Thu Nov 15 23:43:07 2001
+++ S15-pre5-proc/fs/proc/proc_misc.c	Sat Nov 17 12:38:15 2001
@@ -519,6 +519,14 @@
 
 struct proc_dir_entry *proc_root_kcore;
 
+static void create_seq_entry(char *name, mode_t mode, struct file_operations *f)
+{
+	struct proc_dir_entry *entry;
+	entry = create_proc_entry(name, mode|S_IFIFO, NULL);
+	if (entry)
+		entry->proc_fops = f;
+}
+
 void __init proc_misc_init(void)
 {
 	struct proc_dir_entry *entry;
@@ -568,16 +576,10 @@
 	entry = create_proc_entry("kmsg", S_IRUSR, &proc_root);
 	if (entry)
 		entry->proc_fops = &proc_kmsg_operations;
-	entry = create_proc_entry("mounts", 0, NULL);
-	if (entry)
-		entry->proc_fops = &proc_mounts_operations;
-	entry = create_proc_entry("cpuinfo", 0, NULL);
-	if (entry)
-		entry->proc_fops = &proc_cpuinfo_operations;
+	create_seq_entry("mounts", 0, &proc_mounts_operations);
+	create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations);
 #ifdef CONFIG_MODULES
-	entry = create_proc_entry("ksyms", 0, NULL);
-	if (entry)
-		entry->proc_fops = &proc_ksyms_operations;
+	create_seq_entry("cpuinfo", 0, &proc_ksyms_operations);
 #endif
 	proc_root_kcore = create_proc_entry("kcore", S_IRUSR, NULL);
 	if (proc_root_kcore) {



       reply	other threads:[~2001-11-17 17:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <15350.36701.89478.960625@kruemel.monster.org>
2001-11-17 17:51 ` Alexander Viro [this message]
2001-11-17 18:04   ` [PATCH][RFC] Re: 2.4.15-pre5: /proc/cpuinfo broken Alan Cox
2001-11-17 18:29     ` Alexander Viro
2001-11-17 23:51       ` [PATCH][CFT] seq_file and lseek() Alexander Viro
2001-11-17 18:53   ` [PATCH][RFC] Re: 2.4.15-pre5: /proc/cpuinfo broken Linus Torvalds
2001-11-17 19:03     ` Alexander Viro
2001-11-17 19:54       ` H. Peter Anvin

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=Pine.GSO.4.21.0111171250310.11475-100000@weyl.math.psu.edu \
    --to=viro@math.psu.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    --cc=wwcopt@optonline.net \
    /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 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).