Linux 文件系统学习

对于Linux来说一起皆文件。

The Virtual Filesystem (sometimes called the Virtual File Switch or more commonly simply
the VFS) is the subsystem of the kernel that implements the file and filesystem-related
interfaces provided to user-space programs.All filesystems rely on the VFS to enable them
not only to coexist, but also to interoperate.This enables programs to use standard Unix
system calls to read and write to different filesystems, even on different media ( from Linux.Kernel.Development,.3ed)

虚拟文件系统(有时称为虚拟文件交换,或者更简单地说VFS)是内核中实现文件和文件系统相关的子系统提供给用户空间程序的接口。所有文件系统都依赖于VFS来启用它们不仅要共存,而且要互操作。这使程序能够使用标准Unix读取和写入不同文件系统的系统调用,即使是在不同的媒体上。

cp file from  ext3 to  ext2

                            cp(1)

                                ^

                                |

                                v 

hard disk (ext3)->  VFS   < -- removable disk(ex2)

The VFS in action: Using the cp(1) utility to move
data from a hard disk mounted as ext3 to a removable disk mounted
as ext2. Two different filesystems, two different media, one VFS.

1 Common Filesystem Interface
The VFS is the glue that enables system calls such as open(), read(), and write()to
work regardless of the filesystem or underlying physical medium.

In older operating systems, such as DOS, this would never have worked; any access to a nonnative filesystem required special tools. It is only because modern operating systems, such
as Linux, abstract access to the filesystems via a virtual interface that such interoperation
and generic access is possible.

--上面的cp操作在dos系统上市无法完成的,Linux系统抽象了虚拟接口来实现了cp操作(linux code 的实现可能是分别在  fs/ex4   fs/ex2 )

Together, the VFS and the block I/O layer provide the abstractions, interfaces, and glue that allow user-space programs to issue generic system calls to access files via a uniform naming policy on any filesystem, which itself exists on any storage medium.

VFS和块I/O层一起提供了抽象、接口和粘合剂,这些抽象、接口和粘合剂允许用户空间程序通过任何文件系统上的统一命名策略发出通用的系统调用来访问文件,而文件系统本身存在于任何存储介质上。

2 Filesystem Abstraction Layer
Such a generic interface for any type of filesystem is feasible only because the kernel
implements an abstraction layer around its low-level filesystem interface.This abstraction
layer enables Linux to support different filesystems, even if they differ in supported features
or behavior.This is possible because the VFS provides a common file model that can
represent any filesystem’s general feature set and behavior.

文件系统抽象层

对于任何类型的文件系统,这样的通用接口之所以可行,仅仅是因为内核在底层文件系统接口周围实现一个抽象层。这种抽象层使Linux能够支持不同的文件系统,即使它们支持的特性不同或行为。这是可能的,因为VFS提供了一个通用的文件模型表示任何文件系统的一般特性集和行为。

The abstraction layer works by defining the basic conceptual interfaces and data structures
that all filesystems support.The filesystems mold their view of concepts such as “this
is how I open files” and “this is what a directory is to me” to match the expectations of the
VFS.The actual filesystem code hides the implementation details.To the VFS layer and the
rest of the kernel, however, each filesystem looks the same.They all support notions such
as files and directories, and they all support operations such as creating and deleting files.
The result is a general abstraction layer that enables the kernel to support many types
of filesystems easily and cleanly.The filesystems are programmed to provide the abstracted
interfaces and data structures the VFS expects; in turn, the kernel easily works with any
filesystem and the exported user-space interface seamlessly works on any filesystem.

In fact, nothing in the kernel needs to understand the underlying details of the filesystems,
except the filesystems themselves

抽象层通过定义所有文件系统都支持基本的概念接口和数据结构来工作。文件系统塑造了它们对诸如“this”之类的概念的看法是我如何打开文件”和“这是什么目录是我”,以匹配的期望VFS。实际的文件系统代码隐藏了实现细节到VFS层,然而,内核的其余部分,每个文件系统看起来都是一样的。他们都支持这样的观点,作为文件和目录,它们都支持创建和删除文件等操作。其结果是一个通用抽象层,使内核能够支持多种类型文件系统的简单和干净。文件系统被编程来提供抽象的VFS期望的接口和数据结构;反过来,内核可以很容易地处理任何文件系统和导出的用户空间接口可以无缝地在任何文件系统上工作。

实际上,除了文件系统本身,内核其他部分不需要了解文件系统的底层细节

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值