1 diff -Naur fusd-kor.old/include/kfusd.h fusd-kor.new/include/kfusd.h
2 --- fusd-kor.old/include/kfusd.h 2010-05-16 21:11:25.000000000 +0200
3 +++ fusd-kor.new/include/kfusd.h 2010-05-16 17:00:40.000000000 +0200
8 +#include <linux/version.h>
10 /* magic numbers for structure checking; unique w.r.t
11 * /usr/src/linux/Documentation/magic-number.txt */
16 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
17 struct class_device *class_device;
19 + struct device *class_device;
22 void *private_data; /* User's private data */
24 diff -Naur fusd-kor.old/kfusd/kfusd.c fusd-kor.new/kfusd/kfusd.c
25 --- fusd-kor.old/kfusd/kfusd.c 2010-05-16 21:11:30.000000000 +0200
26 +++ fusd-kor.new/kfusd/kfusd.c 2010-05-16 18:04:45.000000000 +0200
28 #include <linux/modversions.h>
31 -//#include <linux/config.h>
32 #include <linux/stddef.h>
33 #include <linux/kernel.h>
34 #include <linux/module.h>
37 #include <linux/slab.h>
38 #include <linux/vmalloc.h>
39 -//#include <linux/devfs_fs_kernel.h>
40 #include <linux/poll.h>
41 #include <linux/version.h>
42 #include <linux/major.h>
46 /* Define this if you want to emit debug messages (adds ~8K) */
47 -#define CONFIG_FUSD_DEBUG
48 +/*#define CONFIG_FUSD_DEBUG*/
50 /* Default debug level for FUSD messages. Has no effect unless
51 * CONFIG_FUSD_DEBUG is defined. */
53 #define CLASS_DEVICE_CREATE(a, b, c, d, e) class_device_create(a, c, d, e)
56 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
58 #define CLASS_DEVICE_CREATE(a, b, c, d, e) class_device_create(a, b, c, d, e)
62 +#define CLASS_DEVICE_CREATE(a, b, c, d, e) device_create(a, b, c, d, e)
63 +#define class_device_destroy(a, b) device_destroy(a, b)
71 static inline struct kobject * to_kobj(struct dentry * dentry)
73 - struct sysfs_dirent * sd = dentry->d_fsdata;
75 - return ((struct kobject *) sd->s_element);
76 + struct kobject * penis = {0};
77 + penis->sd = (struct sysfs_dirent *) dentry->d_fsdata;
84 -#define to_class(obj) container_of(obj, struct class, subsys.kset.kobj)
85 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
86 +# define to_class(obj) container_of(obj, struct class, subsys.kset.kobj)
88 +# define to_class(obj) container_of(obj, struct class, dev_kobj)
92 /**************************************************************************/
96 static struct CLASS *fusd_class;
98 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
99 static struct class_device *fusd_control_class_device;
100 static struct class_device *fusd_status_class_device;
102 +static struct device *fusd_control_class_device;
103 +static struct device *fusd_status_class_device;
106 extern struct CLASS *sound_class;
109 LIST_HEAD(fusd_devlist_head);
110 DECLARE_MUTEX(fusd_devlist_sem);
112 -//#ifdef MODULE_LICENSE
113 MODULE_AUTHOR("Jeremy Elson <jelson@acm.org> (c)2001");
114 MODULE_LICENSE("GPL");
117 /***************************Debugging Support*****************************/
121 /* fill the rest of the structure */
122 fusd_msg->parm.fops_msg.pid = current->pid;
123 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
124 fusd_msg->parm.fops_msg.uid = current->uid;
125 fusd_msg->parm.fops_msg.gid = current->gid;
127 fusd_msg->parm.fops_msg.flags = fusd_file->file->f_flags;
128 fusd_msg->parm.fops_msg.offset = fusd_file->file->f_pos;
129 fusd_msg->parm.fops_msg.device_info = fusd_dev->private_data;
130 @@ -1562,6 +1579,7 @@
132 static void fusd_client_mm_open(struct vm_area_struct * vma);
133 static void fusd_client_mm_close(struct vm_area_struct * vma);
134 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
135 static struct page* fusd_client_nopage(struct vm_area_struct* vma, unsigned long address, int* type);
136 static struct vm_operations_struct fusd_remap_vm_ops =
138 @@ -1569,6 +1587,15 @@
139 close: fusd_client_mm_close,
140 nopage: fusd_client_nopage,
143 +static int fusd_client_fault(struct vm_area_struct* vma, struct vm_fault *vmf, int* type);
144 +static struct vm_operations_struct fusd_remap_vm_ops =
146 + .fault = fusd_client_fault,
147 + .open = fusd_client_mm_open,
148 + .close = fusd_client_mm_close,
152 struct fusd_mmap_instance
154 @@ -1665,6 +1692,7 @@
158 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
159 static struct page* fusd_client_nopage(struct vm_area_struct* vma, unsigned long address,
162 @@ -1697,8 +1725,44 @@
170 +static int fusd_client_fault(struct vm_area_struct* vma, struct vm_fault *vmf,
173 + struct fusd_mmap_instance* mmap_instance = (struct fusd_mmap_instance*) vma->vm_private_data;
174 + unsigned long offset;
176 + struct page *page = NULL;
177 + offset = ((unsigned long)vmf->virtual_address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT);
178 + // todo: worry about size
179 + if(offset > mmap_instance->size)
182 + down_read(&mmap_instance->fusd_dev->task->mm->mmap_sem);
183 + result = get_user_pages(mmap_instance->fusd_dev->task, mmap_instance->fusd_dev->task->mm, mmap_instance->addr + offset, 1, 1, 0, &page, NULL);
184 + up_read(&mmap_instance->fusd_dev->task->mm->mmap_sem);
189 + RDEBUG(2, "Cannot mmap anonymous pages. Be sure to allocate your shared buffer with MAP_SHARED | MAP_ANONYMOUS");
190 + return VM_FAULT_SIGBUS;
198 + *type = VM_FAULT_MINOR;
207 @@ -2596,13 +2660,17 @@
210 STATIC struct file_operations fusd_fops = {
211 - owner: THIS_MODULE,
215 - writev: fusd_writev,
216 - release: fusd_release,
218 + owner: THIS_MODULE,
222 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
223 + writev: fusd_writev,
225 + aio_write: fusd_writev,
227 + release: fusd_release,
232 diff -Naur fusd-kor.old/kfusd/Makefile fusd-kor.new/kfusd/Makefile
233 --- fusd-kor.old/kfusd/Makefile 2010-05-16 21:11:30.000000000 +0200
234 +++ fusd-kor.new/kfusd/Makefile 2010-05-16 14:36:54.000000000 +0200
236 ifneq ($(KERNELRELEASE),)
239 -KDIR ?= /lib/modules/$(shell uname -r)/build
241 +KREL := $(shell uname -r)
242 +KDIR ?= /lib/modules/$(KREL)/build
246 $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) EXTRA_CFLAGS=-I$(PWD)/../include modules
249 - $(INSTALL) -d -m 0755 /lib/modules/$(shell uname -r)/kernel/drivers/misc
250 - $(INSTALL) -m 0755 kfusd.ko /lib/modules/$(shell uname -r)/kernel/drivers/misc
251 + $(INSTALL) -d -m 0755 /lib/modules/$(KREL)/kernel/drivers/misc
252 + $(INSTALL) -m 0755 kfusd.ko /lib/modules/$(KREL)/kernel/drivers/misc