From: ebiederm@xmission.com (Eric W. Biederman)
To: Andrew Morton <akpm@osdl.org>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH 20/23] proc: Make the generation of the self symlink table driven.
Date: Thu, 23 Feb 2006 09:28:42 -0700 [thread overview]
Message-ID: <m164n6f39h.fsf_-_@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <m1accif3bx.fsf_-_@ebiederm.dsl.xmission.com> (Eric W. Biederman's message of "Thu, 23 Feb 2006 09:27:14 -0700")
By not rolling our own inode we get a little more code reuse,
and things get a little simpler and we don't have special
cases to contend with later.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
fs/proc/base.c | 40 +++++++++++++++++-----------------------
1 files changed, 17 insertions(+), 23 deletions(-)
a0e7796422bcb45748f230194723ef1b4afe1228
diff --git a/fs/proc/base.c b/fs/proc/base.c
index b27175a..a6bff2f 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1666,6 +1666,12 @@ static struct inode_operations proc_tgid
.lookup = proc_tgid_base_lookup,
};
+static struct pid_entry proc_base_stuff[] = {
+ NOD(PROC_TGID_INO, "self", S_IFLNK|S_IRWXUGO,
+ &proc_self_inode_operations, NULL, {}),
+ {}
+};
+
/**
* proc_flush_task - Remove dcache entries for @task from the /proc dcache.
*
@@ -1747,24 +1753,12 @@ struct dentry *proc_pid_lookup(struct in
struct dentry *result = ERR_PTR(-ENOENT);
struct task_struct *task;
struct inode *inode;
- struct proc_inode *ei;
unsigned tgid;
- if (dentry->d_name.len == 4 && !memcmp(dentry->d_name.name,"self",4)) {
- inode = new_inode(dir->i_sb);
- if (!inode)
- return ERR_PTR(-ENOMEM);
- ei = PROC_I(inode);
- inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
- inode->i_ino = fake_ino(0, PROC_TGID_INO);
- ei->pde = NULL;
- inode->i_mode = S_IFLNK|S_IRWXUGO;
- inode->i_uid = inode->i_gid = 0;
- inode->i_size = 64;
- inode->i_op = &proc_self_inode_operations;
- d_add(dentry, inode);
- return NULL;
- }
+ result = proc_pident_lookup(dir, dentry, proc_base_stuff);
+ if (!IS_ERR(result) || PTR_ERR(result) != -ENOENT)
+ goto out;
+
tgid = name_to_int(dentry);
if (tgid == ~0U)
goto out;
@@ -1887,14 +1881,13 @@ int proc_pid_readdir(struct file * filp,
struct task_struct *task;
int tgid;
- if (!nr) {
- ino_t ino = fake_ino(0,PROC_TGID_INO);
- if (filldir(dirent, "self", 4, filp->f_pos, ino, DT_LNK) < 0)
- return 0;
- filp->f_pos++;
- nr++;
+ for (;nr < (ARRAY_SIZE(proc_base_stuff) - 1); filp->f_pos++, nr++) {
+ struct pid_entry *p = &proc_base_stuff[nr];
+ if (filldir(dirent, p->name, p->len, filp->f_pos,
+ fake_ino(0, p->type), p->mode >> 12) < 0)
+ goto out;
}
- nr -= 1;
+ nr -= (ARRAY_SIZE(proc_base_stuff) - 1);
/* f_version caches the tgid value that the last readdir call couldn't
* return. lseek aka telldir automagically resets f_version to 0.
@@ -1917,6 +1910,7 @@ int proc_pid_readdir(struct file * filp,
break;
}
}
+out:
return 0;
}
--
1.2.2.g709a
next prev parent reply other threads:[~2006-02-23 16:29 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-23 15:52 [PATCH 00/23] proc cleanup Eric W. Biederman
2006-02-23 15:54 ` [PATCH 01/23] tref: Implement task references Eric W. Biederman
2006-02-23 15:56 ` [PATCH 02/23] proc: Fix the .. inode number on /proc/<pid>/fd Eric W. Biederman
2006-02-23 15:57 ` [PATCH 03/23] proc: Remove useless BKL in proc_pid_readlink Eric W. Biederman
2006-02-23 15:58 ` [PATCH 04/23] proc: Remove unnecessary and misleading assignments from proc_pid_make_inode Eric W. Biederman
2006-02-23 16:00 ` [PATCH 05/23] proc: Simplify the ownership rules for /proc Eric W. Biederman
2006-02-23 16:02 ` Eric W. Biederman
2006-02-23 16:04 ` [PATCH 06/23] proc: Replace proc_inode.type with proc_inode.fd Eric W. Biederman
2006-02-23 16:05 ` [PATCH 07/23] proc: Remove bogus proc_task_permission Eric W. Biederman
2006-02-23 16:06 ` [PATCH 08/23] proc: Kill proc_mem_inode_operations Eric W. Biederman
2006-02-23 16:08 ` [PATCH 09/23] proc: Properly filter out files that are not visible to a process Eric W. Biederman
2006-02-23 16:10 ` [PATCH 10/23] proc: Fix the link count for /proc/<pid>/task Eric W. Biederman
2006-02-23 16:12 ` [PATCH 11/23] proc: Move proc_maps_operations into task_mmu.c Eric W. Biederman
2006-02-23 16:15 ` [PATCH 12/23] proc: Rewrite the proc dentry flush on exit optimization Eric W. Biederman
2006-02-23 16:16 ` [PATCH 13/23] proc: Close the race of a process dying durning lookup Eric W. Biederman
2006-02-23 16:18 ` [PATCH 14/23] proc: Make PROC_NUMBUF the buffer size for holding a integers as strings Eric W. Biederman
2006-02-23 16:20 ` [PATCH 15/23] proc: refactor reading directories of tasks Eric W. Biederman
2006-02-23 16:23 ` [PATCH 16/23] proc: Don't lock task_structs indefinitely Eric W. Biederman
2006-02-23 16:24 ` [PATCH 17/23] proc: Give the root directory a task Eric W. Biederman
2006-02-23 16:25 ` [PATCH 18/23] proc: Reorder the functions in base.c Eric W. Biederman
2006-02-23 16:27 ` [PATCH 19/23] proc: Modify proc_pident_lookup to be completely table driven Eric W. Biederman
2006-02-23 16:28 ` Eric W. Biederman [this message]
2006-02-23 16:30 ` [PATCH 21/23] proc: Factor out an instantiate method from every lookup method Eric W. Biederman
2006-02-23 16:32 ` [PATCH 22/23] proc: Remove the hard coded inode numbers Eric W. Biederman
2006-02-23 16:34 ` [PATCH 23/23] proc: Merge proc_tid_attr and proc_tgid_attr Eric W. Biederman
2006-02-23 16:49 ` [PATCH 01/23] tref: Implement task references Eric W. Biederman
2006-03-02 19:16 ` Oleg Nesterov
2006-03-02 20:37 ` Oleg Nesterov
2006-03-02 22:19 ` Eric W. Biederman
2006-03-03 16:56 ` Oleg Nesterov
2006-03-03 17:48 ` Eric W. Biederman
2006-03-04 11:16 ` Eric W. Biederman
2006-03-04 12:31 ` Oleg Nesterov
2006-03-04 17:30 ` Oleg Nesterov
2006-03-06 21:06 ` Oleg Nesterov
2006-03-06 22:18 ` Eric W. Biederman
2006-03-07 20:44 ` Oleg Nesterov
2006-03-07 1:39 ` Eric W. Biederman
2006-03-07 20:38 ` Oleg Nesterov
2006-03-07 13:12 ` Eric W. Biederman
2006-03-07 21:02 ` Oleg Nesterov
2006-03-07 23:00 ` Eric W. Biederman
2006-03-03 19:23 ` Oleg Nesterov
2006-03-04 10:51 ` Eric W. Biederman
2006-02-25 12:27 ` [PATCH 00/23] proc cleanup Andrew Morton
2006-02-25 13:34 ` Eric W. Biederman
2006-02-25 15:20 ` Eric W. Biederman
2006-02-27 15:26 ` Serge E. Hallyn
2006-02-27 15:56 ` Eric W. Biederman
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=m164n6f39h.fsf_-_@ebiederm.dsl.xmission.com \
--to=ebiederm@xmission.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.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.