Linux Kernel 2.6.36的重大更新之一

      前段时间稳定般的Linux Kernel 2.6.36正式发布,我就借这个机会使用了一下这个新版的内核,结果发现一些问题,记录在这里供网友参考。

      相比于之前的版本,我发现的内核改动是在fs.h这个文件中

     

      2.6.36 fs.h文件中的file_operations结构体有所变化

1483 /* 1484 * NOTE: 1485 * all file operations except setlease can be called without 1486 * the big kernel lock held in all filesystems. 1487 */ 1488 struct file_operations { 1489 struct module *owner; 1490 loff_t (*llseek) (struct file *, loff_t, int); 1491 ssize_t (*read) (struct file *, char __user *, size_t, loff_t *); 1492 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *); 1493 ssize_t (*aio_read) (struct kiocb *, const struct iovec *, unsigned long, loff_t); 1494 ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t); 1495 int (*readdir) (struct file *, void *, filldir_t); 1496 unsigned int (*poll) (struct file *, struct poll_table_struct *); 1497 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); 1498 long (*compat_ioctl) (struct file *, unsigned int, unsigned long); 1499 int (*mmap) (struct file *, struct vm_area_struct *); 1500 int (*open) (struct inode *, struct file *); 1501 int (*flush) (struct file *, fl_owner_t id); 1502 int (*release) (struct inode *, struct file *); 1503 int (*fsync) (struct file *, int datasync); 1504 int (*aio_fsync) (struct kiocb *, int datasync); 1505 int (*fasync) (int, struct file *, int); 1506 int (*lock) (struct file *, int, struct file_lock *); 1507 ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int); 1508 unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); 1509 int (*check_flags)(int); 1510 int (*flock) (struct file *, int, struct file_lock *); 1511 ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); 1512 ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); 1513 int (*setlease)(struct file *, long, struct file_lock **); 1514 };   

 

      2.6.34版本的fs.h这里如下

1480 /* 1481 * NOTE: 1482 * read, write, poll, fsync, readv, writev, unlocked_ioctl and compat_ioctl 1483 * can be called without the big kernel lock held in all filesystems. 1484 */ 1485 struct file_operations { 1486 struct module *owner; 1487 loff_t (*llseek) (struct file *, loff_t, int); 1488 ssize_t (*read) (struct file *, char __user *, size_t, loff_t *); 1489 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *); 1490 ssize_t (*aio_read) (struct kiocb *, const struct iovec *, unsigned long, loff_t); 1491 ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t); 1492 int (*readdir) (struct file *, void *, filldir_t); 1493 unsigned int (*poll) (struct file *, struct poll_table_struct *); 1494 int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long); 1495 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); 1496 long (*compat_ioctl) (struct file *, unsigned int, unsigned long); 1497 int (*mmap) (struct file *, struct vm_area_struct *); 1498 int (*open) (struct inode *, struct file *); 1499 int (*flush) (struct file *, fl_owner_t id); 1500 int (*release) (struct inode *, struct file *); 1501 int (*fsync) (struct file *, struct dentry *, int datasync); 1502 int (*aio_fsync) (struct kiocb *, int datasync); 1503 int (*fasync) (int, struct file *, int); 1504 int (*lock) (struct file *, int, struct file_lock *); 1505 ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int); 1506 unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); 1507 int (*check_flags)(int); 1508 int (*flock) (struct file *, int, struct file_lock *); 1509 ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); 1510 ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); 1511 int (*setlease)(struct file *, long, struct file_lock **); 1512 };

 

仔细观察可以发现

 

int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);

 

这个函数指针的定义不见了,结果在笔者的一些程序中出现了不兼容情况,具体解决办法还要等内核开发人员给出,所以打算更新内核的朋友千万要注意这个问题。 

你可能感兴趣的:(linux,struct,File,user,Module,table)