#include
by xiangyu1986 - BSD - 2008-05-05 17:03:29 阅读(3988) 回复(14)
我这里说的ioctl函数是在驱动程序里的,因为我不知道还有没有别的场合用到了ioctl, 所以就规定了我们讨论的范围。为什么要写篇文章呢,是因为我前一阵子被ioctl给搞混了,这几天才弄明白它,于是在这里清理一下头脑。 一、 什么是ioctl。 ioctl是设备驱动程序中对设备的I/O通道进行管理的函数。所谓对I/O通道进行管理,就是对设备的一些特性进行控制,例如串口的传输波特率、马达的转速等等。它的调用个数如下: int ioctl(int f...
是这样,我编写一个独立的内核模块,要添加一个ioctl的系统调用 在inet_ioctl函数中添加了自己的case分支 inet_ioctl函数如下: int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { struct sock *sk = sock->sk; int err = 0; struct net *net = sock_net(sk); switch (cmd) { xxxxxx case SIOCGTEST err = test_ioctl(net, cmd, (void __user *)arg);/*该函数在自己的独立内...
ioctl函数 本函数影响由fd参数引用的一个打开的文件。 #include int ioctl( int fd, int request, .../* void *arg */ ); 返回0:成功 -1:出错 第三个参数总是一个指针,但指针的类型依赖于request参数。 我们可以把和网络相关的请求划分为6类: 套接口操作 文件操作 接口操作 ARP高速缓存操作 路由表操作 流系统 下表列出了网络相关ioctl请求的request参数以及arg地址必须指向的数据类型: ...
ioctl From Wikipedia, the free encyclopedia Jump to: navigation, search In computing, an ioctl (pronounced or "i-o-control") is part of the user-to-kernel interface of a conventional operating system. Short for "Input/output control", ioctls are typically employed to allow userspace code to communicate with hardware devices or kernel components. Contents 1 Background 2 Uses 2.1 Terminals 2.2...
小弟有個問題想請教 我目前利用ioctl去使用我掛載的driver 但因為呼叫ioctl 失敗,所以無法使用我掛載的driver。 於是我去印出錯誤訊息,錯誤訊息為bad file descriptor 但fd=open("/dev/dsp",O_RDWR)也成功,掛載driver也成功 一直找不到答案 懇請大家幫忙
一个程序中的截取部分,ioctl这个函数不太明白,哪位给说说个大概的意思就行,大概干什么的,感谢啦! #define proc_fd "/proc/check/ctrl" #define CR_OP_CHKPT_REQ _IOW (0xA1, 0x10, struct cr_chkpt_req *) #define CR_OP_CHKPT_DONE _IOWR(0xA1, 0x11, struct timeval *) #define CR_OP_CHKPT_REAP _IO (0xA1, 0x12) err = ioctl(proc_fd, CR_OP_CHKPT_REQ, &req); err = ioctl(proc_fd, CR_OP_CHKPT_DONE, NUL...
1.用户空间的ioctl: int ioctl(int fd,int cmd,...); /* ... 表示一个可选的参数,而不是一个可变参数 */ 2.驱动程序空间的ioctl: int (*ioctl)(struct inode *inode,struct file *filp,unsigned int cmd,unsigned long arg); 3.注册ioctl: struct file_operations f_ops={ read: .., write: .., ... ioctl:scull_ioctl, }; 4.ioctl的命令号要唯一,用四个宏来生成命令号: type :一个magic数,比如'k' nr : 序号,...