linux 0.11 内核学习 ioctl.c
/*
* ioctl.c 文件实现了输入/输出控制系统调用ioctl(),该函数
* 主要是调用函数tty_ioctl()对终端的IO进行控制
*/
/*
* linux/fs/ioctl.c
*
* (C) 1991 Linus Torvalds
*/
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <linux/sched.h>
extern int tty_ioctl(int dev, int cmd, int arg);
typedef int (*ioctl_ptr)(int dev,int cmd,int arg);
/* 定义系统中设备种数 */
#define NRDEVS ((sizeof (ioctl_table))/(sizeof (ioctl_ptr)))
/* ioctl 操作函数指针表 */
static ioctl_ptr ioctl_table[]={
NULL, /* nodev */
NULL, /* /dev/mem */
NULL, /* /dev/fd */
NULL, /* /dev/hd */
tty_ioctl, /* /dev/ttyx */
tty_ioctl, /* /dev/tty */
NULL, /* /dev/lp */
NULL}; /* named pipes */
/* 输入输出控制函数 */
int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
{
struct file * filp;
int dev,mode;
// 如果文件描述符超出可打开的文件数,或者对应描述符的文件结构指针为空,则返回出错码
if (fd >= NR_OPEN || !(filp = current->filp[fd]))
return -EBADF;
// 取对应文件的属性
mode=filp->f_inode->i_mode;
// 如果该文件不是字符文件,也不是块设备文件,则返回出错码
if (!S_ISCHR(mode) && !S_ISBLK(mode))
return -EINVAL;
// 从字符或块设备文件的i 节点中取设备号。如果设备号大于系统现有的设备数,则返回出错号
dev = filp->f_inode->i_zone[0];
if (MAJOR(dev) >= NRDEVS)
return -ENODEV;
// 如果该设备在ioctl 函数指针表中没有对应函数
if (!ioctl_table[MAJOR(dev)])
return -ENOTTY;
// 否则返回实际ioctl 函数返回码
return ioctl_table[MAJOR(dev)](dev,cmd,arg);
}
参考《linux内核完全注释》和网上相关文章
相关文档:
打包: tar [-j] | [-z] [cv] [-f tar包文件] 要打入包的源文件
解包: tar [-j] | [-z] [xv] [-f tar包文件] [-C 指定解包的目录]
查看: tar [-j] | [-z] [tv] [-f tar包文件]
常用的打包选项:
选项
描述
-c
建立tar包文件
-t
查看tar包文件中的文件列表
-x
解开tar包文件
-C path
与解包选项(-x)配合使用,指定 ......
RedHat Linux安装Oracle10g(图文详解 教程)
http://winie.javaeye.com/blog/405120
关键字: redhat linux安装oracle10g(图文详解 教程)
另,本人有Word电子文档格式,如需要,请联系本人:asima127@gmail.com
1
安装RedHat Enterprise Linux 3 ......
1101 linux中刻录iso的方法(hutuworm)
方法一:使用xcdroast,选择制作光碟,选择ISO文件,刻录!
参见[url]http://www.xcdroast.org/xcdr098/faq-a15.html#17[/url]
方法二:找刻录机的命令:
cdrecord --scanbus
输出结果为:
0,0,0 0) 'ATAPI ' 'CD-R/RW 8X4X32 ' '5.EZ' Removable CD-ROM
刻录的命令:
cdrecord ......
GDB是GNU开源组织发布的一个强大的UNIX下的程序调试工具。或许,各位比较喜欢那种图形
界面方式的,像VC、BCB等IDE的调试,但如果你是在UNIX平台下做软件,你会发现GDB这个
调试工具有比VC、BCB的图形化调试器更强大的功能。所谓“寸有所长,尺有所短”就是这
个道理。
一 ......
/*
* linux/fs/inode.c
*
* (C) 1991 Linus Torvalds
*/
#include <string.h>
#include <sys/stat.h> // 文件状态头文件
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <asm/system.h>
......