patch-2.1.45 linux/fs/proc/fd.c
Next file: linux/fs/proc/inode.c
Previous file: linux/fs/proc/array.c
Back to the patch index
Back to the overall index
- Lines: 75
- Date:
Wed Jul 16 15:45:03 1997
- Orig file:
v2.1.44/linux/fs/proc/fd.c
- Orig date:
Mon Jul 7 12:43:07 1997
diff -u --recursive --new-file v2.1.44/linux/fs/proc/fd.c linux/fs/proc/fd.c
@@ -14,7 +14,7 @@
#include <linux/stat.h>
static int proc_readfd(struct inode *, struct file *, void *, filldir_t);
-static int proc_lookupfd(struct inode *,struct qstr *,struct inode **);
+static int proc_lookupfd(struct inode *, struct dentry *);
static struct file_operations proc_fd_operations = {
NULL, /* lseek - default */
@@ -52,15 +52,24 @@
NULL /* permission */
};
-static int proc_lookupfd(struct inode * dir, struct qstr *str, struct inode ** result)
+/*
+ * NOTE! Normally we'd indicate that a file does not
+ * exist by creating a negative dentry and returning
+ * a successful return code. However, for this case
+ * we do not want to create negative dentries, because
+ * the state of the world can change behind our backs.
+ *
+ * Thus just return -ENOENT instead.
+ */
+static int proc_lookupfd(struct inode * dir, struct dentry * dentry)
{
unsigned int ino, pid, fd, c;
struct task_struct * p;
struct super_block * sb;
+ struct inode *inode;
const char *name;
int len;
- *result = NULL;
ino = dir->i_ino;
pid = ino >> 16;
ino &= 0x0000ffff;
@@ -71,8 +80,8 @@
return -ENOENT;
fd = 0;
- len = str->len;
- name = str->name;
+ len = dentry->d_name.len;
+ name = dentry->d_name.name;
while (len-- > 0) {
c = *name - '0';
name++;
@@ -100,13 +109,16 @@
if (fd >= NR_OPEN ||
!p->files ||
!p->files->fd[fd] ||
- !p->files->fd[fd]->f_inode)
+ !p->files->fd[fd]->f_dentry)
return -ENOENT;
ino = (pid << 16) + (PROC_PID_FD_DIR << 8) + fd;
- if (!(*result = proc_get_inode(sb, ino, NULL)))
+ inode = proc_get_inode(sb, ino, NULL);
+ if (!inode)
return -ENOENT;
+
+ d_add(dentry, inode);
return 0;
}
@@ -144,7 +156,7 @@
for (fd -= 2 ; fd < NR_OPEN; fd++, filp->f_pos++) {
if (!p->files)
break;
- if (!p->files->fd[fd] || !p->files->fd[fd]->f_inode)
+ if (!p->files->fd[fd] || !p->files->fd[fd]->f_dentry)
continue;
j = NUMBUF;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov