aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/generic.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2013-04-10 22:20:50 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-04-29 15:42:00 -0400
commit3cb5bf1bf947d325fcf6e9458952b51cfd7e6677 (patch)
treeaa7fd55a3f9547ffd5a080adc5b38a18953c4033 /fs/proc/generic.c
parent526c59784c09fb794a5f0181429525bc473453c9 (diff)
proc: Delete create_proc_read_entry()
Delete create_proc_read_entry() as it no longer has any users. Also delete read_proc_t, write_proc_t, the read_proc member of the proc_dir_entry struct and the support functions that use them. This saves a pointer for every PDE allocated. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/proc/generic.c')
-rw-r--r--fs/proc/generic.c168
1 files changed, 1 insertions, 167 deletions
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index bec58323629c..1c07cadeb8db 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -36,141 +36,6 @@ static int proc_match(unsigned int len, const char *name, struct proc_dir_entry
36 return !memcmp(name, de->name, len); 36 return !memcmp(name, de->name, len);
37} 37}
38 38
39/* buffer size is one page but our output routines use some slack for overruns */
40#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
41
42ssize_t
43__proc_file_read(struct file *file, char __user *buf, size_t nbytes,
44 loff_t *ppos)
45{
46 struct inode * inode = file_inode(file);
47 char *page;
48 ssize_t retval=0;
49 int eof=0;
50 ssize_t n, count;
51 char *start;
52 struct proc_dir_entry * dp;
53 unsigned long long pos;
54
55 /*
56 * Gaah, please just use "seq_file" instead. The legacy /proc
57 * interfaces cut loff_t down to off_t for reads, and ignore
58 * the offset entirely for writes..
59 */
60 pos = *ppos;
61 if (pos > MAX_NON_LFS)
62 return 0;
63 if (nbytes > MAX_NON_LFS - pos)
64 nbytes = MAX_NON_LFS - pos;
65
66 dp = PDE(inode);
67 if (!(page = (char*) __get_free_page(GFP_TEMPORARY)))
68 return -ENOMEM;
69
70 while ((nbytes > 0) && !eof) {
71 count = min_t(size_t, PROC_BLOCK_SIZE, nbytes);
72
73 start = NULL;
74 if (!dp->read_proc)
75 break;
76
77 /* How to be a proc read function
78 * ------------------------------
79 * Prototype:
80 * int f(char *buffer, char **start, off_t offset,
81 * int count, int *peof, void *dat)
82 *
83 * Assume that the buffer is "count" bytes in size.
84 *
85 * If you know you have supplied all the data you have, set
86 * *peof.
87 *
88 * You have three ways to return data:
89 *
90 * 0) Leave *start = NULL. (This is the default.) Put the
91 * data of the requested offset at that offset within the
92 * buffer. Return the number (n) of bytes there are from
93 * the beginning of the buffer up to the last byte of data.
94 * If the number of supplied bytes (= n - offset) is greater
95 * than zero and you didn't signal eof and the reader is
96 * prepared to take more data you will be called again with
97 * the requested offset advanced by the number of bytes
98 * absorbed. This interface is useful for files no larger
99 * than the buffer.
100 *
101 * 1) Set *start = an unsigned long value less than the buffer
102 * address but greater than zero. Put the data of the
103 * requested offset at the beginning of the buffer. Return
104 * the number of bytes of data placed there. If this number
105 * is greater than zero and you didn't signal eof and the
106 * reader is prepared to take more data you will be called
107 * again with the requested offset advanced by *start. This
108 * interface is useful when you have a large file consisting
109 * of a series of blocks which you want to count and return
110 * as wholes.
111 * (Hack by Paul.Russell@rustcorp.com.au)
112 *
113 * 2) Set *start = an address within the buffer. Put the data
114 * of the requested offset at *start. Return the number of
115 * bytes of data placed there. If this number is greater
116 * than zero and you didn't signal eof and the reader is
117 * prepared to take more data you will be called again with
118 * the requested offset advanced by the number of bytes
119 * absorbed.
120 */
121 n = dp->read_proc(page, &start, *ppos, count, &eof, dp->data);
122
123 if (n == 0) /* end of file */
124 break;
125 if (n < 0) { /* error */
126 if (retval == 0)
127 retval = n;
128 break;
129 }
130
131 if (start == NULL) {
132 if (n > PAGE_SIZE) /* Apparent buffer overflow */
133 n = PAGE_SIZE;
134 n -= *ppos;
135 if (n <= 0)
136 break;
137 if (n > count)
138 n = count;
139 start = page + *ppos;
140 } else if (start < page) {
141 if (n > PAGE_SIZE) /* Apparent buffer overflow */
142 n = PAGE_SIZE;
143 if (n > count) {
144 /*
145 * Don't reduce n because doing so might
146 * cut off part of a data block.
147 */
148 pr_warn("proc_file_read: count exceeded\n");
149 }
150 } else /* start >= page */ {
151 unsigned long startoff = (unsigned long)(start - page);
152 if (n > (PAGE_SIZE - startoff)) /* buffer overflow? */
153 n = PAGE_SIZE - startoff;
154 if (n > count)
155 n = count;
156 }
157
158 n -= copy_to_user(buf, start < page ? page : start, n);
159 if (n == 0) {
160 if (retval == 0)
161 retval = -EFAULT;
162 break;
163 }
164
165 *ppos += start < page ? (unsigned long)start : n;
166 nbytes -= n;
167 buf += n;
168 retval += n;
169 }
170 free_page((unsigned long) page);
171 return retval;
172}
173
174static int proc_notify_change(struct dentry *dentry, struct iattr *iattr) 39static int proc_notify_change(struct dentry *dentry, struct iattr *iattr)
175{ 40{
176 struct inode *inode = dentry->d_inode; 41 struct inode *inode = dentry->d_inode;
@@ -476,8 +341,7 @@ static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp
476 } else if (S_ISLNK(dp->mode)) { 341 } else if (S_ISLNK(dp->mode)) {
477 dp->proc_iops = &proc_link_inode_operations; 342 dp->proc_iops = &proc_link_inode_operations;
478 } else if (S_ISREG(dp->mode)) { 343 } else if (S_ISREG(dp->mode)) {
479 if (dp->proc_fops == NULL) 344 BUG_ON(dp->proc_fops == NULL);
480 dp->proc_fops = &proc_file_operations;
481 dp->proc_iops = &proc_file_inode_operations; 345 dp->proc_iops = &proc_file_inode_operations;
482 } else { 346 } else {
483 WARN_ON(1); 347 WARN_ON(1);
@@ -604,36 +468,6 @@ struct proc_dir_entry *proc_mkdir(const char *name,
604} 468}
605EXPORT_SYMBOL(proc_mkdir); 469EXPORT_SYMBOL(proc_mkdir);
606 470
607struct proc_dir_entry *create_proc_read_entry(
608 const char *name, umode_t mode, struct proc_dir_entry *parent,
609 read_proc_t *read_proc, void *data)
610{
611 struct proc_dir_entry *ent;
612
613 if ((mode & S_IFMT) == 0)
614 mode |= S_IFREG;
615
616 if (!S_ISREG(mode)) {
617 WARN_ON(1); /* use proc_mkdir(), damnit */
618 return NULL;
619 }
620
621 if ((mode & S_IALLUGO) == 0)
622 mode |= S_IRUGO;
623
624 ent = __proc_create(&parent, name, mode, 1);
625 if (ent) {
626 ent->read_proc = read_proc;
627 ent->data = data;
628 if (proc_register(parent, ent) < 0) {
629 kfree(ent);
630 ent = NULL;
631 }
632 }
633 return ent;
634}
635EXPORT_SYMBOL(create_proc_read_entry);
636
637struct proc_dir_entry *proc_create_data(const char *name, umode_t mode, 471struct proc_dir_entry *proc_create_data(const char *name, umode_t mode,
638 struct proc_dir_entry *parent, 472 struct proc_dir_entry *parent,
639 const struct file_operations *proc_fops, 473 const struct file_operations *proc_fops,