(个人笔记)操作系统之文件系统

文件系统是存储在硬盘上的,如UFS,包括Boot Control Block、Superblock、Directory Structure和File Control Block。文件由data blocks和inodes组成,目录也是文件,其data blocks包含文件名和inode number。文件的访问方法有Sequential Access、Direct Access等。分区是硬盘的逻辑划分,文件系统负责文件的命名和组织。理解文件系统涉及Sectors、Blocks和层级结构。文件创建和打开涉及inode分配、目录结构更新和open-file表管理。
摘要由CSDN通过智能技术生成

文件系统概括

文件系统是存储在 Disk 上的,因为我们需要永久的保存文件,而不是在关机以后就把数据丢掉!除非特殊说明,我下面提到的所有东西都是存储在 Disk 上的。假设我们有一个1T的硬盘,我们可以把它划分成一个或多个分区,每个分区都可以有各自的文件系统。接下来,我们把这个硬盘分成一个带有 Unix File System(UFS) 的分区,那么这个分区大致包含以下4个结构:

 

  1. Boot Control Block:information needed by the system to boot from that volume
  2. Superblock:volume or partition details, such as the number of blocks in the partition, size of the blocks, freeblock count and free-block pointers, and free FCB count and FCB pointers
  3. Directory structure:in UFS, this includes file names and associated inode numbers
  4. File Control Block:contains file details including permissions, ownership, size, and location of the data blocks. In UFS, this is called the inode

 

下面我总结一些常见的误区和容易混淆的概念!

1、一个 Unix 文件包括两部分:the data blocks(文件的实际内容) and the inodes(文件的元数据,比如文件大小,创建日期,指向 data blocks 的指针等)。

2、目录并不包含文件,它本身实际上就是一个文件!因此像所有文件一样,目录的元数据存储在 inodes 中,inodes 中有指向实际内容(data blocks)的 pointers. 那么一个目录的 data blocks 包含什么呢?答案是:目录中文件的名字和与之相对应的 inode number(它们2个结合在一起成为一个 Directory Entry). The file’s actual attributes and pointers to disk blocks are kept elsewhere, in the inode for the file. Therefore, Directories(or Directory Structure) can be thought of as “files containing lists of names and inode numbers”. Files have data blocks containing file data; directories also have data blocks; but, the blocks contain lists of names and inode numbers. If a directory is damaged in Unix, only the names are lost, not any of the file data blocks or the file attributes. 因此,当我们给定一个文件名字的时候,可以通过搜索相应目录结构得到一个 Directory Entry,然后得到相应的 inode number,再通过 inode number 得到对应的 inode.

 

文件的逻辑结构

 

The file system consists of two distinct parts: a collection of files, each storing related data, and a directory structure, which organizes and provides information a

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值