如何在"sys"和"proc"之间进行选择. Linux内核中的文件 [英] How to choose between "sys' and "proc" files in linux kernel

查看:135
本文介绍了如何在"sys"和"proc"之间进行选择. Linux内核中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知

在Linux文件系统中,为了在用户空间和内核空间之间进行信息通信,使用了两种虚拟文件系统.

In Linux file system, for information communication between user space and kernel space, two kind of virtual file systems are used.

1) Proc文件系统 http://www.tldp.org/LDP/Linux-Filesystem -Hierarchy/html/proc.html

2) sysfs文件系统 https://en.wikipedia.org/wiki/Sysfs

在linux内核代码中,我看到某些子系统已使用proc文件执行此类用户空间-内核空间通信,而某些系统出于相同的考虑而已使用sysfs文件.

In linux kernel code, i see some sub system has used proc file to perform such userspace-kernelspace communication, and some system has used sysfs files for same concern.

所以我只想知道,如果我要编写新的Linux内核模块或驱动程序,那么如何选择虚拟文件?什么时候应该使用sysfs,什么时候应该使用proc文件?

So i just want to know, if i am going to write new linux kernel module or driver then how to choose virtual files ? when should i use sysfs and when should i use proc file?

如果我误解了这里的任何内容,请告诉我.

Please let me know if i misunderstood anything here.

推荐答案

看了很多书,我有以下理解

After reading much i have below understanding

1)Proc文件是较旧的方法.它会在每个读取或写入调用中分配PAGE大小的内存,并且该系统遍及所有错误(就像您正在读取/写入任何设备的proc条目,并且设备已从系统中删除..在Proc系统中不会处理此操作..{read it来自LDD :)}).因此,内核开发人员社区建议使用更高级,更复杂的SYS文件系统.

1) Proc file is the bit of older approaches. It allocates PAGE size memory on each read or write call and this system is over all buggy(Like you are reading/write proc entry of any device and device is removed from system..no handing of this in Proc system..{read it from LDD:) }). So kernel developer community suggest to use SYS file system which is more advance and sophisticated.

这篇关于如何在"sys"和"proc"之间进行选择. Linux内核中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆