Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

David Howells and committed by
Al Viro
3cb5bf1b 526c5978

+1 -220
+1 -167
fs/proc/generic.c
··· 36 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 - 42 - ssize_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 - 174 39 static int proc_notify_change(struct dentry *dentry, struct iattr *iattr) 175 40 { 176 41 struct inode *inode = dentry->d_inode; ··· 341 476 } else if (S_ISLNK(dp->mode)) { 342 477 dp->proc_iops = &proc_link_inode_operations; 343 478 } else if (S_ISREG(dp->mode)) { 344 - if (dp->proc_fops == NULL) 345 - dp->proc_fops = &proc_file_operations; 479 + BUG_ON(dp->proc_fops == NULL); 346 480 dp->proc_iops = &proc_file_inode_operations; 347 481 } else { 348 482 WARN_ON(1); ··· 467 603 return proc_mkdir_mode(name, S_IRUGO | S_IXUGO, parent); 468 604 } 469 605 EXPORT_SYMBOL(proc_mkdir); 470 - 471 - struct proc_dir_entry *create_proc_read_entry( 472 - const char *name, umode_t mode, struct proc_dir_entry *parent, 473 - read_proc_t *read_proc, void *data) 474 - { 475 - struct proc_dir_entry *ent; 476 - 477 - if ((mode & S_IFMT) == 0) 478 - mode |= S_IFREG; 479 - 480 - if (!S_ISREG(mode)) { 481 - WARN_ON(1); /* use proc_mkdir(), damnit */ 482 - return NULL; 483 - } 484 - 485 - if ((mode & S_IALLUGO) == 0) 486 - mode |= S_IRUGO; 487 - 488 - ent = __proc_create(&parent, name, mode, 1); 489 - if (ent) { 490 - ent->read_proc = read_proc; 491 - ent->data = data; 492 - if (proc_register(parent, ent) < 0) { 493 - kfree(ent); 494 - ent = NULL; 495 - } 496 - } 497 - return ent; 498 - } 499 - EXPORT_SYMBOL(create_proc_read_entry); 500 606 501 607 struct proc_dir_entry *proc_create_data(const char *name, umode_t mode, 502 608 struct proc_dir_entry *parent,
-35
fs/proc/inode.c
··· 183 183 spin_unlock(&de->pde_unload_lock); 184 184 } 185 185 186 - /* ->read_proc() users - legacy crap */ 187 - static ssize_t 188 - proc_file_read(struct file *file, char __user *buf, size_t nbytes, 189 - loff_t *ppos) 190 - { 191 - struct proc_dir_entry *pde = PDE(file_inode(file)); 192 - ssize_t rv = -EIO; 193 - if (use_pde(pde)) { 194 - rv = __proc_file_read(file, buf, nbytes, ppos); 195 - unuse_pde(pde); 196 - } 197 - return rv; 198 - } 199 - 200 - static loff_t 201 - proc_file_lseek(struct file *file, loff_t offset, int orig) 202 - { 203 - loff_t retval = -EINVAL; 204 - switch (orig) { 205 - case 1: 206 - offset += file->f_pos; 207 - /* fallthrough */ 208 - case 0: 209 - if (offset < 0 || offset > MAX_NON_LFS) 210 - break; 211 - file->f_pos = retval = offset; 212 - } 213 - return retval; 214 - } 215 - 216 - const struct file_operations proc_file_operations = { 217 - .llseek = proc_file_lseek, 218 - .read = proc_file_read, 219 - }; 220 - 221 186 static loff_t proc_reg_llseek(struct file *file, loff_t offset, int whence) 222 187 { 223 188 struct proc_dir_entry *pde = PDE(file_inode(file));
-2
fs/proc/internal.h
··· 157 157 struct completion *c; 158 158 }; 159 159 160 - ssize_t __proc_file_read(struct file *, char __user *, size_t, loff_t *); 161 - extern const struct file_operations proc_file_operations; 162 160 void proc_entry_rundown(struct proc_dir_entry *); 163 161 164 162 extern spinlock_t proc_subdir_lock;
-16
include/linux/proc_fs.h
··· 47 47 * non-directory entries). 48 48 */ 49 49 50 - typedef int (read_proc_t)(char *page, char **start, off_t off, 51 - int count, int *eof, void *data); 52 - typedef int (write_proc_t)(struct file *file, const char __user *buffer, 53 - unsigned long count, void *data); 54 - 55 50 struct proc_dir_entry { 56 51 unsigned int low_ino; 57 52 umode_t mode; ··· 58 63 const struct file_operations *proc_fops; 59 64 struct proc_dir_entry *next, *parent, *subdir; 60 65 void *data; 61 - read_proc_t *read_proc; 62 66 atomic_t count; /* use count */ 63 67 atomic_t in_use; /* number of callers into module in progress; */ 64 68 /* negative -> it's going away RSN */ ··· 148 154 { 149 155 return proc_create_data(name, mode, parent, proc_fops, NULL); 150 156 } 151 - 152 - extern __deprecated 153 - struct proc_dir_entry *create_proc_read_entry(const char *name, 154 - umode_t mode, struct proc_dir_entry *base, 155 - read_proc_t *read_proc, void *data); 156 157 157 158 extern struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name, 158 159 struct proc_dir_entry *parent); ··· 180 191 struct proc_dir_entry *parent) {return NULL;} 181 192 static inline struct proc_dir_entry *proc_mkdir_mode(const char *name, 182 193 umode_t mode, struct proc_dir_entry *parent) { return NULL; } 183 - 184 - static inline __deprecated 185 - struct proc_dir_entry *create_proc_read_entry(const char *name, 186 - umode_t mode, struct proc_dir_entry *base, 187 - read_proc_t *read_proc, void * data) { return NULL; } 188 194 189 195 struct tty_driver; 190 196 static inline void proc_tty_register_driver(struct tty_driver *driver) {};