首页 | 资讯动态 | linux基础 | 系统管理 | 网络管理 | 编程开发 | linux数据库 | linux相关 | linux认证 | 下载中心 | 专题
oklinux
 系统管理:中文环境 系统管理 桌面应用 内核技术 Linux基础:安装配置 常用命令 经验技巧 软件应用 Linux数据库:Mysql POSTGRE
 网络管理:网络安全 网络应用 Linux服务器 编程开发:PHP CC++ Python Perl SHELL 嵌入式开发 | PHP基础 PHP技巧 PHP应用 PHP文摘
 首页 linux资讯动态 Linux专题 | 其他Unix Linux解决方案 硬件相关 Linux认证 企业应用 Apache | 相关下载:资料 参考手册 开发工具
 → 当前位置:首页>系统管理>内核技术>正文

Kernel command using Linux system calls

OKLinux www.oklinux.cn 2007-03-28 来源:IBM developerWorks Worldwide 会员收藏 游客收藏


Note that the __NR indexes are necessary in this application because the _syscall macro uses the func-name to construct the __NR index (getjiffies -> __NR_getjiffies). But the result is that you can call your kernel functions using their names, just like any other system call.



Back to top


Alternatives for user/kernel interactions

System calls are an efficient way of requesting services in the kernel. The biggest problem with them is that it's a standardized interface. It would be difficult to have your new system call added to the kernel, so any additions are likely served through other means. If you have no intent of mainlining your system calls into the public Linux kernel, then system calls are a convenient and efficient way to make kernel services available to user-space.

Another way to make your services visible to user-space is through the /proc file system. The /proc file system is a virtual file system for which you can surface a directory and files to the user, and then provide an interface in the kernel to your new services through a file system interface (read, write, and so on).



Back to top


Tracing system calls with strace

The Linux kernel provides a useful way to trace the system calls that a process invokes (as well as those signals that the process receives). The utility is called strace and is executed from the command line, using the application you want to trace as its argument. For example, if you wanted to know which system calls were invoked during the context of the date command, type the following command:

strace date

The result is a rather large dump showing the various system calls that are performed in the context of a date command call. You'll see the loading of shared libraries, mapping of memory, and -- at the end of the trace -- the emitting of the date information to standard-out:

...
write(1, "Fri Feb  9 23:06:41 MST 2007\n", 29Fri Feb  9 23:06:41 MST 2007) = 29
munmap(0xb747a000, 4096)	= 0
exit_group(0)			= ?
$ 

This tracing is accomplished in the kernel when the current system call request has a special field set called syscall_trace, which causes the function do_syscall_trace

共8页: 上一页 [1] [2] [3] [4] [5] 6 [7] [8] 下一页
上一篇:Novell称微软专利许可观点“强奸民意”   下一篇:Linux and symmetric multiprocessing

收藏于收藏夹】 【评论】 【推荐】 【投稿】 【打印】 【关闭

相关文章
·Linux and symmetric multiprocessing
·通过Linux内核观察/proc/pid/statm
·Linux内核源代码的目录结构简单介绍
·按需对Linux系统内核进行定制和修改
·将驱动及应用软件移植到Linux2.6内核
·全面了解Linux操作系统核心配置文件
·三分钟编译支持NTFS的Linux系统模块
·linux内核启动地址的确定
·ubuntu 6.10 下编译2.6.19内核并安装NVIDIA
·教菜鸟编译自己的内核2.6.19
发表评论
密码: 匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。)
站内搜索
阅读排行榜
·基于S3C44B0微处理器的uCl
· 深入理解LINUX内核中文版
·Linux操作系统的内核编译
·Process priority and con
·Linux 2.6内核如何武装Fed
·通过振动向Linux ThinkPad
·主流嵌入式Linux系统下GUI
·推荐:Linux用户态与内核
·用命令行加挂Linux的文件
·Linux系统内核接收以太帧
最新文章
·用Tftp向目标板烧写Linux
·交叉编译Linux内核(2.6.22
·UNIX操作系统的加锁解锁:
·基于2.6.9内核小型Linux系
·Linux系统中使用GCC CPU参
·Linux系统的引导过程详细
·Linux系统的内核初始化过
·Linux系统高手之路 内核编
·Linux高手之内核编译过程
·Linux系统内核模块和驱动
·Linux系统下编译支持NTFS
·Linux系统中用内核KHTTPD
·Linux系统内核分析 使用GD
·Linux操作系统的内核解读
·通过Linux系统的内核观察/

设为首页 - 加入收藏 - 版权声明 - 广告服务 - 关于我们 - 联系我们 - 友情连接
Copyright © 2007 All rights reserved OKLinux.Cn 版权所有
合作联系 QQ:18743986 Email:arlan8005#163.com