作者markchen ()
看板LinuxDev
标题[问题]VFS的概念
时间Mon Jul 7 18:44:24 2008
http://www.jollen.org/blog/2006/05/linux_2_system_calls.html
不好意思 里头有提到jollen里头说到VFS(virtual file system)
我不知道这个VFS是不是 我们常说的file system ex:ext3、ext2之类的
以下是我对这个概念了解 还请高手们指点一下
通常 在user space 切到 kernel space需要经由一个system call
| |
user application device driver
而user ap 与 device driver 透过一个device file作个媒介(放在/dev 下)
这个device file 可以是一个字元装置档/区块装置档(依你的device driver而定)
之後 我们只要针对这个device file引用system call的函式 即可与device driver
作沟通
只是 device file 依我们的file system来规画 就如上所说
今天 我是ext3的 file system 这个device file就是ext3格式的
如果 我是ext2的 file system 这个device file就是ext2格式
也就是 jollen所说的
『Linux 驱动程式与 user application 间的沟通方式是透过 system call,
实际上 user application 是以 device file 与装置驱动程式沟通。
要达成此目的,驱动程式必须建构在此「file」之上,因此 Linux 驱动程式必须透过
VFS(virtual file system)层来实作 system call。
』
以下的code
int main(int argc, char *argv[])
{
int devfd;
devfd = open("/dev/debug", O_RDONLY); //open() system call函式
// debug是一个device file
if (devfd == -1)
{
printf("Can't open /dev/debug\n");
return -1;
}
ioctl(devfd, IOCTL_WRITE, num); //ioctl() system call函式
close(devfd);
return 0;}
以上 是我的想法 想请大大们指正我的想法
--
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.161.170.127
※ 编辑: markchen 来自: 118.161.170.127 (07/07 18:44)