debuggers.hg

view unmodified_drivers/linux-2.6/platform-pci/platform-compat.c @ 22855:1d1eec7e1fb4

xl: Perform minimal validation of virtual disk file while parsing config file

This patch performs some very basic validation on the virtual disk
file passed through the config file. This validation ensures that we
don't go too far with the initialization like spawn qemu and more
while there could be some potentially fundamental issues.

[ Patch fixed up to work with PHYSTYPE_EMPTY 22808:6ec61438713a -iwj ]

Signed-off-by: Kamala Narasimhan <kamala.narasimhan@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Kamala Narasimhan <kamala.narasimhan@gmail.com>
date Tue Jan 25 18:09:49 2011 +0000 (2011-01-25)
parents 0b8c6c91c5a4
children
line source
1 #include <linux/version.h>
3 #include <linux/mm.h>
4 #include <linux/module.h>
5 #include <linux/sched.h>
6 #include <linux/slab.h>
8 #include <xen/platform-compat.h>
10 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)
11 static int system_state = 1;
12 EXPORT_SYMBOL(system_state);
13 #endif
15 void ctrl_alt_del(void)
16 {
17 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
18 kill_proc(1, SIGINT, 1); /* interrupt init */
19 #else
20 kill_cad_pid(SIGINT, 1);
21 #endif
22 }
24 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8)
25 size_t strcspn(const char *s, const char *reject)
26 {
27 const char *p;
28 const char *r;
29 size_t count = 0;
31 for (p = s; *p != '\0'; ++p) {
32 for (r = reject; *r != '\0'; ++r) {
33 if (*p == *r)
34 return count;
35 }
36 ++count;
37 }
39 return count;
40 }
41 EXPORT_SYMBOL(strcspn);
42 #endif
44 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
45 /*
46 * Map a vmalloc()-space virtual address to the physical page frame number.
47 */
48 unsigned long vmalloc_to_pfn(void * vmalloc_addr)
49 {
50 return page_to_pfn(vmalloc_to_page(vmalloc_addr));
51 }
52 EXPORT_SYMBOL(vmalloc_to_pfn);
53 #endif
55 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
56 unsigned long wait_for_completion_timeout(struct completion *x, unsigned long timeout)
57 {
58 might_sleep();
60 spin_lock_irq(&x->wait.lock);
61 if (!x->done) {
62 DECLARE_WAITQUEUE(wait, current);
64 wait.flags |= WQ_FLAG_EXCLUSIVE;
65 __add_wait_queue_tail(&x->wait, &wait);
66 do {
67 __set_current_state(TASK_UNINTERRUPTIBLE);
68 spin_unlock_irq(&x->wait.lock);
69 timeout = schedule_timeout(timeout);
70 spin_lock_irq(&x->wait.lock);
71 if (!timeout) {
72 __remove_wait_queue(&x->wait, &wait);
73 goto out;
74 }
75 } while (!x->done);
76 __remove_wait_queue(&x->wait, &wait);
77 }
78 x->done--;
79 out:
80 spin_unlock_irq(&x->wait.lock);
81 return timeout;
82 }
83 EXPORT_SYMBOL(wait_for_completion_timeout);
84 #endif
86 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
87 /*
88 fake do_exit using complete_and_exit
89 */
90 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
91 asmlinkage NORET_TYPE void do_exit(long code)
92 #else
93 fastcall NORET_TYPE void do_exit(long code)
94 #endif
95 {
96 complete_and_exit(NULL, code);
97 }
98 EXPORT_SYMBOL_GPL(do_exit);
99 #endif
101 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
102 signed long schedule_timeout_interruptible(signed long timeout)
103 {
104 __set_current_state(TASK_INTERRUPTIBLE);
105 return schedule_timeout(timeout);
106 }
107 EXPORT_SYMBOL(schedule_timeout_interruptible);
108 #endif
110 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
111 /**
112 * kzalloc - allocate memory. The memory is set to zero.
113 * @size: how many bytes of memory are required.
114 * @flags: the type of memory to allocate.
115 */
116 void *kzalloc(size_t size, int flags)
117 {
118 void *ret = kmalloc(size, flags);
119 if (ret)
120 memset(ret, 0, size);
121 return ret;
122 }
123 EXPORT_SYMBOL(kzalloc);
124 #endif
126 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
127 /* Simplified asprintf. */
128 char *kasprintf(gfp_t gfp, const char *fmt, ...)
129 {
130 va_list ap;
131 unsigned int len;
132 char *p, dummy[1];
134 va_start(ap, fmt);
135 len = vsnprintf(dummy, 0, fmt, ap);
136 va_end(ap);
138 p = kmalloc(len + 1, gfp);
139 if (!p)
140 return NULL;
141 va_start(ap, fmt);
142 vsprintf(p, fmt, ap);
143 va_end(ap);
144 return p;
145 }
146 EXPORT_SYMBOL(kasprintf);
147 #endif