Linux块设备驱动(1) 块驱动中相关的结构体及其操作
1.字符设备与块设备IO操做的区别
1)块设备只能以块为单位接收输入返回输出,而字符设备则以byte为单位.大多数设备是字符设备,他们不需要缓冲并且不以固定块大小进行操作.
2)块设备对于IO请求有对应的缓冲区,所以他们可以选择以什么顺序进行响应.字符设备无须缓冲且被直接读写.
3)字符设备只能被顺序读写,块设备可以随机访问.
2.block_device_operations结构体
block_device_operations描述了对块设备的操作的集合
struct block_device_operations {
int (*open) (struct inode *, struct file *);/*打开*/
int (*release) (struct inode *, struct file *);/*释放*/
int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long);
long (*unlocked_ioctl) (struct file *, unsigned, unsigned long);
long (*compat_ioctl) (struct file *, unsigned, unsigned long);
int (*direct_access) (struct block_device *, sector_t, unsigned long *);
int (*media_changed) (struct gendisk *);/*介质被改变?*/
int (*revalidate_disk) (struct gendisk *);/*使介质改变*/
int (*getgeo)(struct block_device *, struct hd_geometry *);/*填充驱动器信息*/
struct module *owner;/*模块拥有者,一般初始化为THIS_MODULE*/
};
关于block_device_operations的操作:
&nb
相关文档:
linux下添加路由的方法:
一:使用 route 命令添加
使用route 命令添加的路由,机器重启或者网卡重启后路由就失效了,方法:
//添加到主机的路由
# route add –host 192.168.168.110 dev eth0
# route add –host 192.168.168.119 gw 192.168.168.1
//添加到网络的路由
# route add –net IP netma ......
现在大家对Q5的讨论已经上升到发行版和桌面环境的程度了……估计坛子里有许多非LINUX玩家可能听得云里雾里吧?我大概讲一些我知道的,比较简单而且实用的小知识,希望能够同学们一点帮助。
按照惯例,首先必须澄清一下Linux的定义。很多同学可能都误以为Linux就是一个操作系统,严格来讲,这是不对的。linux作 ......
在配置虚拟环境的时候 连接方式选择桥接方式,在linux其他版本的系统中进去就可以直接上网的,但是在redhat9的浏览器下进入网站老是提示找不到。此时如果你试一下ifup eth0你会发现提示如下:
determining ip information for eth0... failed no link present. check cable
网卡激活失败。
此时你可以尝试修改一下/etc/s ......
进入/boot/grub
修改grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, ......