In the past two days, ldd3 has been viewed very well and clearly understood. When I started compiling the routine code scull today, it was a great tragedy and I had to go over it for a long time, the main reason is that the kernel version of ubuntu11.04 is 2.6.38, and the kernel version compiled by the routine is 2.6.10. This intermediate kernel itself has undergone earth-shaking changes. To put it bluntly, you can make the past, so it's just a ghost. Well, it's a mistake and a mistake. Don't worry.
Directly make, the first problem comes ....
Run the cflags command in makefile as prompted.
Change to extra_cflags.
You can continue ......
Tip:
If you are using vi, you can use the same command as me to solve the problem.: 0, $ S/cflags/extra_cflags/g
Don't forget to save and continue make ......
The second question is ....
Well, I don't understand. I will talk about the most common IOCTL driver.
You don't know, why?
Previously, in version 2.6.36, file_operations changed a lot, removing IOCTL and adding two new functions.
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
Note: The file_operation struct of 2.6.38
struct file_operations {
struct module *owner;
loff_t (*llseek) (struct file *, loff_t, int);
ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
ssize_t (*aio_read) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
int (*readdir) (struct file *, void *, filldir_t);
unsigned int (*poll) (struct file *, struct poll_table_struct *);
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
int (*mmap) (struct file *, struct vm_area_struct *);
int (*open) (struct inode *, struct file *);
int (*flush) (struct file *, fl_owner_t id);
int (*release) (struct inode *, struct file *);
int (*fsync) (struct file *, int datasync);
int (*aio_fsync) (struct kiocb *, int datasync);
int (*fasync) (int, struct file *, int);
int (*lock) (struct file *, int, struct file_lock *);
ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
int (*check_flags)(int);
int (*flock) (struct file *, int, struct file_lock *);
ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int);
ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int);
int (*setlease)(struct file *, long, struct file_lock **);
long (*fallocate)(struct file *file, int mode, loff_t offset,
loff_t len);
};
After the problem is found, how can this problem be solved? In Main. c
File:
Follow the code below to change it.
* The unlocked_ioctl() implementation
*/
int scull_unlocked_ioctl(struct file *filp,
unsigned int cmd, unsigned long arg)
In file_operation
Modify the value assignment field as follows:
struct file_operations scull_fops = {
.owner = THIS_MODULE,
.llseek = scull_llseek,
.read = scull_read,
.write = scull_write,
.unlocked_ioctl = scull_unlocked_ioctl,
.open = scull_open,
.release = scull_release,
};
In pipe. c
And scull. h
And access. h
The modification is also similar.
Make again, at least this problem has been solved, but the new problem comes ......
The third question is ....
Set init_mutex (& scull_devices [I]. SEM );
Change to sema_init (& scull_devices [I]. SEM, 1 );
In access. c
File.
The fourth question is ....
In pipe. c
Add a header file: # include <Linux/sched. h>
The fifth question is ....
In access. c
Add a header file: # include <Linux/sched. h>
The sixth question is ....
Truct task_struct is defined in include/Linux/sched. in H, the definition of the original task_struct struct has been changed, and UID and EUID are moved to cred. See include/Linux/sched. H and include/Linux/cred. h.
Therefore, you only need to modify the Error Code as follows:
Current-> uid changed to current-> cred-> uid
Modify current-> EUID to current-> cred-> EUID
Bytes ------------------------------------------------------------------------------------------------------------
OK, make successful !!!!!!!!!!!!!
Bytes ------------------------------------------------------------------------------------------------------------------
Author: PANG Hui
Source: http://www.cnblogs.com/pang123hui/
This article is based on the signature 2.5 mainland China license agreement. You are welcome to repost, interpret, or use it for commercial purposes. However, you must keep the signature Pang Hui (including the link) of this Article ).