操作系统概念(第十章) 文件系统接口
2015-12-23 20:20
211 查看
文件概念
文件是记录在外存上得相关信息的具有名称的集合。其具有连续的逻辑地址空间通常,文件表示数据和程序。
数据文件可以包括,数字、字符、字符串或二进制。文件可以是自由形式,如文本文件,也可以具有严格的格式。
文件必须具有可以长期信息存储的性质、必须能够保存大容量数据、在进程终止后信息能够保留下来、能够多进程并发访问文件中的信息。
其中a是执行文件,b是文档文件。
文件属性(File Attributes)
Name名称 – only information kept in human-readableform.
Type类型 – needed for systems that support different types.
Location位置 – pointer to file location on device.
Size大小 – current file size.
Protection保护 – controls who can do reading, writing, executing.
Time, date, and user identification – data for protection, security, and usage monitoring.
文件的属性信息保存在硬盘上的目录结构中
文件结构
None - sequence of words, bytes无序的字,字节Simple record structure简单记录结构
Lines 行
Fixed length固定长度
Variable length变长
Complex Structures复杂结构
Formatteddocument 格式文档
Relocatable load file 可重定位装载文件
Can simulate last two with first method by inserting appropriate control characters.
由程序和操作系统决定文件的结构。
文件的操作(File Operations)
Create 创建Write 写
Read 读
Reposition within file – file seek 定位
Delete 删除
Truncate 截断
Open(Fi) 打开– search the directory structure on disk for
entry Fi, and move the content of entry to memory.
Close (Fi) 关闭– move the content of entry Fi in memory
to directory structure on disk.
扩展名(File Types – Name, Extension)
访问方法
顺序(Sequential Access)
read next write next reset noread after last write (rewrite)
随机(Random Access)
read n write n position to n read next write next rewrite n
其中n表示相关的块(block)数。
其他访问方式
其他访问方式可建立在直接访问方式上,这些访问通常涉及创建文件索引。索引包括各块的指针。为了查找文件中的记录,首先搜索索引,再根据指针直接访问文件,以查找所需要的内容。索引及其对应文件关系如下图所示。
有很多例题考察一级索引、二级索引之类的。
里面有很多的内容,所以需要更加仔细地看题。
目录结构(Directory Structure)
目录是一个包含若干文件属性信息的节点的集合,结构如下图所示。目录和文件都保存在磁盘上。逻辑卷(可跨磁盘)的概念
有时候需要在一个磁盘上装多种文件系统,这些部分称为分区(partition)或者片。
设备上目录中的文件属性信息
NameType
Address
Current length当前长度
Maximum length最大长度
Date last accessed (for archival)最后访问日期
Date last updated (for dump)最后更新
Owner ID (who pays)属主ID
Protection information (discuss later)
对目录的操作
Search for a file查找文件Create a file创建文件
Delete a file删除文件
List a directory罗列目录内容
Rename a file文件重命名
Traverse the file system遍历文件系统
组织目录的目标
高效(Efficiency)–locating a file quickly.命名(Naming)–convenient to users.
Two users can have same name for different files.
The same file can have several different names.
分组(Grouping)–logical grouping of files by properties, (e.g., all Java programs, all games, …)
单级目录(Single-Level Directory)
在一个目录下存在:
命名问题:文件位于同一个目录下,他们必须具有唯一名称。
分组问题
两级目录(Two-Level Directory)
对于双层结构目录的结构,每个用户都有自己的用户文件目录(user file directory,UFD)。因此在每个UFD中所有的文件名称唯一即可,不同的用户可以有相同拥有文件名的问题。
虽然双层结构目录解决了名称冲突问题,但是它仍有缺点。这种解耦股有效地对用户加以隔离。这种隔离在用户需要完全独立时是有点,但是在用户需要在某个任务上进行合作和访问其他文件时却是一个缺点。
为了访问指定的文件唯一,用户必须知道要访问文件的路径名(path name)。
树型目录(Tree-Structured Directories)
高效的搜索(Efficient searching)
分组能力(Grouping Capability)
当前目录(Current directory / working directory)
路径名有两种形式:绝对路径和相对路径。
无环图目录(Acyclic-Graph Directories)
这样对于相同的文件可能有不同的名字,因此有别名。一个文件也可有多个绝对路径名。
如果文件被删除,这样可能会留下悬挂指针指向不再存在的文件,更为糟糕的是,这些剩余文件指针可能指向包括实际磁盘地址,而该空间可能正在被其他文件使用。
通用图目录(General Graph Directory)
采用五环图解耦股的一个特别重要的问题是如何保证没有环。
Allow only links to file not subdirectories.
只允许连接到文件
Garbage collection.
垃圾收集
Every time a new link is added use a cycle detection
algorithm to determine whether it is OK.
建立新连接时进行循环检测
文件共享(Two-Level Directory)
Sharing of files on multi-user systems is desirable.对多用户系统尤其必要
Sharing may be done through a protectionscheme.
通过“保护”系统实现
On distributed systems, files may be shared across a
network.
在分布式系统中,文件甚至可通过网络共享
Network File System (NFS)网络文件系统is a common
distributed file-sharing method.
NFS是一种普遍的分布式文件共享方式
保护
文件的属主(owner)应该能够控制what can be done对文件可做什么
by whom 谁来做
访问的类型
Read读
Write写
Execute执行
Append追加
Delete删除
List罗列
相关文章推荐
- 应用领航:盘点那些年我们一起追过的OS
- 无奇不有!盘点各国自己开发的操作系统
- 可自定义oem的萝卜家园 Ghost XP 新春装机版 V200801 下载
- C#实现判断操作系统是否为Win8以上版本
- js获取本机操作系统类型的两种方法
- Linux操作系统添加新硬盘方法
- java如何获取本地操作系统进程列表
- Linux rdesktop操作系统下远程登录Windows XP桌面
- 32位操作系统认出超出4G内存的方法
- Linux rpm tar 操作系统下软件的安装与卸载方法
- 文件系统变为raw 无法访问的解决方法
- PHP 文件系统详解
- JavaScript 获取用户客户端操作系统版本
- jsp 获取客户端的浏览器和操作系统信息
- Windows 操作系统的安全设置
- php判断当前操作系统类型
- PHP获取用户的浏览器与操作系统信息的代码
- Powershell实现克隆NTFS文件系统权限
- Perl操作系统环境变量的脚本代码
- javascript获取本机操作系统类型的方法