aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/drivers
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /arch/um/drivers
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'arch/um/drivers')
-rw-r--r--arch/um/drivers/line.c5
-rw-r--r--arch/um/drivers/mconsole_kern.c79
-rw-r--r--arch/um/drivers/mmapper_kern.c11
-rw-r--r--arch/um/drivers/net_kern.c1
-rw-r--r--arch/um/drivers/port_kern.c1
-rw-r--r--arch/um/drivers/random.c3
-rw-r--r--arch/um/drivers/ubd_kern.c41
7 files changed, 63 insertions, 78 deletions
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index cf8a97f34518..7a656bd8bd3c 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -6,6 +6,7 @@
6#include "linux/irqreturn.h" 6#include "linux/irqreturn.h"
7#include "linux/kd.h" 7#include "linux/kd.h"
8#include "linux/sched.h" 8#include "linux/sched.h"
9#include "linux/slab.h"
9#include "chan_kern.h" 10#include "chan_kern.h"
10#include "irq_kern.h" 11#include "irq_kern.h"
11#include "irq_user.h" 12#include "irq_user.h"
@@ -18,10 +19,10 @@ static irqreturn_t line_interrupt(int irq, void *data)
18{ 19{
19 struct chan *chan = data; 20 struct chan *chan = data;
20 struct line *line = chan->line; 21 struct line *line = chan->line;
21 struct tty_struct *tty = line->tty; 22 struct tty_struct *tty;
22 23
23 if (line) 24 if (line)
24 chan_interrupt(&line->chan_list, &line->task, tty, irq); 25 chan_interrupt(&line->chan_list, &line->task, line->tty, irq);
25 return IRQ_HANDLED; 26 return IRQ_HANDLED;
26} 27}
27 28
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index e14629c87de4..de317d0c3294 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -6,6 +6,7 @@
6 6
7#include <linux/console.h> 7#include <linux/console.h>
8#include <linux/ctype.h> 8#include <linux/ctype.h>
9#include <linux/string.h>
9#include <linux/interrupt.h> 10#include <linux/interrupt.h>
10#include <linux/list.h> 11#include <linux/list.h>
11#include <linux/mm.h> 12#include <linux/mm.h>
@@ -124,50 +125,36 @@ void mconsole_log(struct mc_request *req)
124void mconsole_proc(struct mc_request *req) 125void mconsole_proc(struct mc_request *req)
125{ 126{
126 struct nameidata nd; 127 struct nameidata nd;
127 struct file_system_type *proc; 128 struct vfsmount *mnt = current->nsproxy->pid_ns->proc_mnt;
128 struct super_block *super;
129 struct file *file; 129 struct file *file;
130 int n, err; 130 int n, err;
131 char *ptr = req->request.data, *buf; 131 char *ptr = req->request.data, *buf;
132 mm_segment_t old_fs = get_fs();
132 133
133 ptr += strlen("proc"); 134 ptr += strlen("proc");
134 while (isspace(*ptr)) ptr++; 135 ptr = skip_spaces(ptr);
135 136
136 proc = get_fs_type("proc"); 137 err = vfs_path_lookup(mnt->mnt_root, mnt, ptr, LOOKUP_FOLLOW, &nd);
137 if (proc == NULL) { 138 if (err) {
138 mconsole_reply(req, "procfs not registered", 1, 0); 139 mconsole_reply(req, "Failed to look up file", 1, 0);
139 goto out; 140 goto out;
140 } 141 }
141 142
142 super = (*proc->get_sb)(proc, 0, NULL, NULL); 143 err = may_open(&nd.path, MAY_READ, O_RDONLY);
143 put_filesystem(proc); 144 if (result) {
144 if (super == NULL) { 145 mconsole_reply(req, "Failed to open file", 1, 0);
145 mconsole_reply(req, "Failed to get procfs superblock", 1, 0); 146 path_put(&nd.path);
146 goto out; 147 goto out;
147 } 148 }
148 up_write(&super->s_umount);
149
150 nd.path.dentry = super->s_root;
151 nd.path.mnt = NULL;
152 nd.flags = O_RDONLY + 1;
153 nd.last_type = LAST_ROOT;
154
155 /* START: it was experienced that the stability problems are closed
156 * if commenting out these two calls + the below read cycle. To
157 * make UML crash again, it was enough to readd either one.*/
158 err = link_path_walk(ptr, &nd);
159 if (err) {
160 mconsole_reply(req, "Failed to look up file", 1, 0);
161 goto out_kill;
162 }
163 149
164 file = dentry_open(nd.path.dentry, nd.path.mnt, O_RDONLY, 150 file = dentry_open(nd.path.dentry, nd.path.mnt, O_RDONLY,
165 current_cred()); 151 current_cred());
152 err = PTR_ERR(file);
166 if (IS_ERR(file)) { 153 if (IS_ERR(file)) {
167 mconsole_reply(req, "Failed to open file", 1, 0); 154 mconsole_reply(req, "Failed to open file", 1, 0);
168 goto out_kill; 155 path_put(&nd.path);
156 goto out;
169 } 157 }
170 /*END*/
171 158
172 buf = kmalloc(PAGE_SIZE, GFP_KERNEL); 159 buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
173 if (buf == NULL) { 160 if (buf == NULL) {
@@ -175,10 +162,13 @@ void mconsole_proc(struct mc_request *req)
175 goto out_fput; 162 goto out_fput;
176 } 163 }
177 164
178 if ((file->f_op != NULL) && (file->f_op->read != NULL)) { 165 if (file->f_op->read) {
179 do { 166 do {
180 n = (*file->f_op->read)(file, buf, PAGE_SIZE - 1, 167 loff_t pos;
181 &file->f_pos); 168 set_fs(KERNEL_DS);
169 n = vfs_read(file, buf, PAGE_SIZE - 1, &pos);
170 file_pos_write(file, pos);
171 set_fs(old_fs);
182 if (n >= 0) { 172 if (n >= 0) {
183 buf[n] = '\0'; 173 buf[n] = '\0';
184 mconsole_reply(req, buf, 0, (n > 0)); 174 mconsole_reply(req, buf, 0, (n > 0));
@@ -196,8 +186,6 @@ void mconsole_proc(struct mc_request *req)
196 kfree(buf); 186 kfree(buf);
197 out_fput: 187 out_fput:
198 fput(file); 188 fput(file);
199 out_kill:
200 deactivate_super(super);
201 out: ; 189 out: ;
202} 190}
203#endif 191#endif
@@ -212,8 +200,7 @@ void mconsole_proc(struct mc_request *req)
212 char *ptr = req->request.data; 200 char *ptr = req->request.data;
213 201
214 ptr += strlen("proc"); 202 ptr += strlen("proc");
215 while (isspace(*ptr)) 203 ptr = skip_spaces(ptr);
216 ptr++;
217 snprintf(path, sizeof(path), "/proc/%s", ptr); 204 snprintf(path, sizeof(path), "/proc/%s", ptr);
218 205
219 fd = sys_open(path, 0, 0); 206 fd = sys_open(path, 0, 0);
@@ -560,8 +547,7 @@ void mconsole_config(struct mc_request *req)
560 int err; 547 int err;
561 548
562 ptr += strlen("config"); 549 ptr += strlen("config");
563 while (isspace(*ptr)) 550 ptr = skip_spaces(ptr);
564 ptr++;
565 dev = mconsole_find_dev(ptr); 551 dev = mconsole_find_dev(ptr);
566 if (dev == NULL) { 552 if (dev == NULL) {
567 mconsole_reply(req, "Bad configuration option", 1, 0); 553 mconsole_reply(req, "Bad configuration option", 1, 0);
@@ -588,7 +574,7 @@ void mconsole_remove(struct mc_request *req)
588 int err, start, end, n; 574 int err, start, end, n;
589 575
590 ptr += strlen("remove"); 576 ptr += strlen("remove");
591 while (isspace(*ptr)) ptr++; 577 ptr = skip_spaces(ptr);
592 dev = mconsole_find_dev(ptr); 578 dev = mconsole_find_dev(ptr);
593 if (dev == NULL) { 579 if (dev == NULL) {
594 mconsole_reply(req, "Bad remove option", 1, 0); 580 mconsole_reply(req, "Bad remove option", 1, 0);
@@ -712,7 +698,7 @@ void mconsole_sysrq(struct mc_request *req)
712 char *ptr = req->request.data; 698 char *ptr = req->request.data;
713 699
714 ptr += strlen("sysrq"); 700 ptr += strlen("sysrq");
715 while (isspace(*ptr)) ptr++; 701 ptr = skip_spaces(ptr);
716 702
717 /* 703 /*
718 * With 'b', the system will shut down without a chance to reply, 704 * With 'b', the system will shut down without a chance to reply,
@@ -757,8 +743,7 @@ void mconsole_stack(struct mc_request *req)
757 */ 743 */
758 744
759 ptr += strlen("stack"); 745 ptr += strlen("stack");
760 while (isspace(*ptr)) 746 ptr = skip_spaces(ptr);
761 ptr++;
762 747
763 /* 748 /*
764 * Should really check for multiple pids or reject bad args here 749 * Should really check for multiple pids or reject bad args here
@@ -833,8 +818,8 @@ static int __init mconsole_init(void)
833 818
834__initcall(mconsole_init); 819__initcall(mconsole_init);
835 820
836static int write_proc_mconsole(struct file *file, const char __user *buffer, 821static ssize_t mconsole_proc_write(struct file *file,
837 unsigned long count, void *data) 822 const char __user *buffer, size_t count, loff_t *pos)
838{ 823{
839 char *buf; 824 char *buf;
840 825
@@ -855,6 +840,11 @@ static int write_proc_mconsole(struct file *file, const char __user *buffer,
855 return count; 840 return count;
856} 841}
857 842
843static const struct file_operations mconsole_proc_fops = {
844 .owner = THIS_MODULE,
845 .write = mconsole_proc_write,
846};
847
858static int create_proc_mconsole(void) 848static int create_proc_mconsole(void)
859{ 849{
860 struct proc_dir_entry *ent; 850 struct proc_dir_entry *ent;
@@ -862,15 +852,12 @@ static int create_proc_mconsole(void)
862 if (notify_socket == NULL) 852 if (notify_socket == NULL)
863 return 0; 853 return 0;
864 854
865 ent = create_proc_entry("mconsole", S_IFREG | 0200, NULL); 855 ent = proc_create("mconsole", 0200, NULL, &mconsole_proc_fops);
866 if (ent == NULL) { 856 if (ent == NULL) {
867 printk(KERN_INFO "create_proc_mconsole : create_proc_entry " 857 printk(KERN_INFO "create_proc_mconsole : create_proc_entry "
868 "failed\n"); 858 "failed\n");
869 return 0; 859 return 0;
870 } 860 }
871
872 ent->read_proc = NULL;
873 ent->write_proc = write_proc_mconsole;
874 return 0; 861 return 0;
875} 862}
876 863
diff --git a/arch/um/drivers/mmapper_kern.c b/arch/um/drivers/mmapper_kern.c
index eb240323c40a..d22f9e5c0eac 100644
--- a/arch/um/drivers/mmapper_kern.c
+++ b/arch/um/drivers/mmapper_kern.c
@@ -16,7 +16,7 @@
16#include <linux/miscdevice.h> 16#include <linux/miscdevice.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/smp_lock.h> 19
20#include <asm/uaccess.h> 20#include <asm/uaccess.h>
21#include "mem_user.h" 21#include "mem_user.h"
22 22
@@ -78,7 +78,6 @@ out:
78 78
79static int mmapper_open(struct inode *inode, struct file *file) 79static int mmapper_open(struct inode *inode, struct file *file)
80{ 80{
81 cycle_kernel_lock();
82 return 0; 81 return 0;
83} 82}
84 83
@@ -115,18 +114,16 @@ static int __init mmapper_init(void)
115 v_buf = (char *) find_iomem("mmapper", &mmapper_size); 114 v_buf = (char *) find_iomem("mmapper", &mmapper_size);
116 if (mmapper_size == 0) { 115 if (mmapper_size == 0) {
117 printk(KERN_ERR "mmapper_init - find_iomem failed\n"); 116 printk(KERN_ERR "mmapper_init - find_iomem failed\n");
118 goto out; 117 return -ENODEV;
119 } 118 }
119 p_buf = __pa(v_buf);
120 120
121 err = misc_register(&mmapper_dev); 121 err = misc_register(&mmapper_dev);
122 if (err) { 122 if (err) {
123 printk(KERN_ERR "mmapper - misc_register failed, err = %d\n", 123 printk(KERN_ERR "mmapper - misc_register failed, err = %d\n",
124 err); 124 err);
125 goto out; 125 return err;;
126 } 126 }
127
128 p_buf = __pa(v_buf);
129out:
130 return 0; 127 return 0;
131} 128}
132 129
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index a74245ae3a84..f05372694233 100644
--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -16,6 +16,7 @@
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/rtnetlink.h> 17#include <linux/rtnetlink.h>
18#include <linux/skbuff.h> 18#include <linux/skbuff.h>
19#include <linux/slab.h>
19#include <linux/spinlock.h> 20#include <linux/spinlock.h>
20#include "init.h" 21#include "init.h"
21#include "irq_kern.h" 22#include "irq_kern.h"
diff --git a/arch/um/drivers/port_kern.c b/arch/um/drivers/port_kern.c
index 4ebc8a34738f..a11573be0961 100644
--- a/arch/um/drivers/port_kern.c
+++ b/arch/um/drivers/port_kern.c
@@ -7,6 +7,7 @@
7#include "linux/interrupt.h" 7#include "linux/interrupt.h"
8#include "linux/list.h" 8#include "linux/list.h"
9#include "linux/mutex.h" 9#include "linux/mutex.h"
10#include "linux/slab.h"
10#include "linux/workqueue.h" 11#include "linux/workqueue.h"
11#include "asm/atomic.h" 12#include "asm/atomic.h"
12#include "init.h" 13#include "init.h"
diff --git a/arch/um/drivers/random.c b/arch/um/drivers/random.c
index 6eabb7022a2d..4949044773ba 100644
--- a/arch/um/drivers/random.c
+++ b/arch/um/drivers/random.c
@@ -7,7 +7,6 @@
7 * of the GNU General Public License, incorporated herein by reference. 7 * of the GNU General Public License, incorporated herein by reference.
8 */ 8 */
9#include <linux/sched.h> 9#include <linux/sched.h>
10#include <linux/smp_lock.h>
11#include <linux/module.h> 10#include <linux/module.h>
12#include <linux/fs.h> 11#include <linux/fs.h>
13#include <linux/interrupt.h> 12#include <linux/interrupt.h>
@@ -34,8 +33,6 @@ static DECLARE_WAIT_QUEUE_HEAD(host_read_wait);
34 33
35static int rng_dev_open (struct inode *inode, struct file *filp) 34static int rng_dev_open (struct inode *inode, struct file *filp)
36{ 35{
37 cycle_kernel_lock();
38
39 /* enforce read-only access to this chrdev */ 36 /* enforce read-only access to this chrdev */
40 if ((filp->f_mode & FMODE_READ) == 0) 37 if ((filp->f_mode & FMODE_READ) == 0)
41 return -EINVAL; 38 return -EINVAL;
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 635d16d90a80..da992a3ad6b7 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -27,9 +27,11 @@
27#include "linux/init.h" 27#include "linux/init.h"
28#include "linux/cdrom.h" 28#include "linux/cdrom.h"
29#include "linux/proc_fs.h" 29#include "linux/proc_fs.h"
30#include "linux/seq_file.h"
30#include "linux/ctype.h" 31#include "linux/ctype.h"
31#include "linux/capability.h" 32#include "linux/capability.h"
32#include "linux/mm.h" 33#include "linux/mm.h"
34#include "linux/slab.h"
33#include "linux/vmalloc.h" 35#include "linux/vmalloc.h"
34#include "linux/blkpg.h" 36#include "linux/blkpg.h"
35#include "linux/genhd.h" 37#include "linux/genhd.h"
@@ -200,23 +202,25 @@ static void make_proc_ide(void)
200 proc_ide = proc_mkdir("ide0", proc_ide_root); 202 proc_ide = proc_mkdir("ide0", proc_ide_root);
201} 203}
202 204
203static int proc_ide_read_media(char *page, char **start, off_t off, int count, 205static int fake_ide_media_proc_show(struct seq_file *m, void *v)
204 int *eof, void *data)
205{ 206{
206 int len; 207 seq_puts(m, "disk\n");
207 208 return 0;
208 strcpy(page, "disk\n"); 209}
209 len = strlen("disk\n"); 210
210 len -= off; 211static int fake_ide_media_proc_open(struct inode *inode, struct file *file)
211 if (len < count){ 212{
212 *eof = 1; 213 return single_open(file, fake_ide_media_proc_show, NULL);
213 if (len <= 0) return 0;
214 }
215 else len = count;
216 *start = page + off;
217 return len;
218} 214}
219 215
216static const struct file_operations fake_ide_media_proc_fops = {
217 .owner = THIS_MODULE,
218 .open = fake_ide_media_proc_open,
219 .read = seq_read,
220 .llseek = seq_lseek,
221 .release = single_release,
222};
223
220static void make_ide_entries(const char *dev_name) 224static void make_ide_entries(const char *dev_name)
221{ 225{
222 struct proc_dir_entry *dir, *ent; 226 struct proc_dir_entry *dir, *ent;
@@ -227,11 +231,8 @@ static void make_ide_entries(const char *dev_name)
227 dir = proc_mkdir(dev_name, proc_ide); 231 dir = proc_mkdir(dev_name, proc_ide);
228 if(!dir) return; 232 if(!dir) return;
229 233
230 ent = create_proc_entry("media", S_IFREG|S_IRUGO, dir); 234 ent = proc_create("media", S_IRUGO, dir, &fake_ide_media_proc_fops);
231 if(!ent) return; 235 if(!ent) return;
232 ent->data = NULL;
233 ent->read_proc = proc_ide_read_media;
234 ent->write_proc = NULL;
235 snprintf(name, sizeof(name), "ide0/%s", dev_name); 236 snprintf(name, sizeof(name), "ide0/%s", dev_name);
236 proc_symlink(dev_name, proc_ide_root, name); 237 proc_symlink(dev_name, proc_ide_root, name);
237} 238}
@@ -747,7 +748,7 @@ static int ubd_open_dev(struct ubd *ubd_dev)
747 ubd_dev->fd = fd; 748 ubd_dev->fd = fd;
748 749
749 if(ubd_dev->cow.file != NULL){ 750 if(ubd_dev->cow.file != NULL){
750 blk_queue_max_sectors(ubd_dev->queue, 8 * sizeof(long)); 751 blk_queue_max_hw_sectors(ubd_dev->queue, 8 * sizeof(long));
751 752
752 err = -ENOMEM; 753 err = -ENOMEM;
753 ubd_dev->cow.bitmap = vmalloc(ubd_dev->cow.bitmap_len); 754 ubd_dev->cow.bitmap = vmalloc(ubd_dev->cow.bitmap_len);
@@ -849,7 +850,7 @@ static int ubd_add(int n, char **error_out)
849 } 850 }
850 ubd_dev->queue->queuedata = ubd_dev; 851 ubd_dev->queue->queuedata = ubd_dev;
851 852
852 blk_queue_max_hw_segments(ubd_dev->queue, MAX_SG); 853 blk_queue_max_segments(ubd_dev->queue, MAX_SG);
853 err = ubd_disk_register(UBD_MAJOR, ubd_dev->size, n, &ubd_gendisk[n]); 854 err = ubd_disk_register(UBD_MAJOR, ubd_dev->size, n, &ubd_gendisk[n]);
854 if(err){ 855 if(err){
855 *error_out = "Failed to register device"; 856 *error_out = "Failed to register device";