## File Concept 废话一大堆 ### File - A named collection of related information that is recorded on secondary storage (e.g. Disk, SSD, Flash, etc.). - A sequence of bits, bytes, lines, or records, the meaning of which is defined by the file’s creator. - Smallest logical storage unit for user view. - **Uses contiguous logical address space.** - Represents programs or data. ### File system - Resides on secondary storage (disks). - **Provides user interface to storage, mapping logical to physical.** - Provides efficient and **convenient access** to disk by allowing data to be stored, located, retrieved easily. ### File Attributes A file usually has the following basic attributes: - Name: Only information kept in human - readable form - Identifier: A unique tag (number) that identifies the file within the file system - Type: Needed for systems that support different types - Location: A pointer to the file location on the 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 Information about files' metadata are kept in the directory structure, which is maintained on the disk Information about files (metadata) are kept in the directory structure, which is maintained on the disk. ### File Operations - File is an abstract data type. - Six basic file operations - Create - Write - Read - Reposition within a file - Truncate a file - File is reset to length zero - File space is released - File attributes are unchanged - Delete ### File Lock 基础的 Lock: - Reader-Writter Lock: 「读操作」可以多人同时进行(共享),不会冲突;「写操作」必须一人独占,否则数据会乱。 于是有的 OS 提供以下两种锁: - Shared Lock - Similar to reader lock - Several processes can acquire concurrently - Exclusive lock - Similar to writter lock - Mandotory Lock - Once a process acquires an **exclusive** lock, the OS will prevent any other process from accessing the locked file - Advisory Lock - It is up to software developers to ensure that locks are appriopriately acqured and released. ## File Access Methods 主要有三种方法,下面只有简单介绍他们的指令 ### Sequential Access - `read_next` - `write_next` - `reset` (to the beginning) ### Direct/Random Access - `read next` - `write next` - `read n` - `write n` - `position to n` - `rewrite n` ### Index and Relative Files Access - Keep index in memory for fast determination of location of data to be operated on ### Directory Structure - 目录可以被视为一个符号表 (symbol table),它将文件名翻译成它们对应的文件控制块 (File Control Block, FCB)。FCB(在 UNIX 文件系统中称为 inode)包含了文件的详细信息,例如所有权、权限以及文件内容在存储设备上的位置等 - Both the directory structure and the files reside on disk ### Disk Structure - A **drive** is a **physical block** disk. - A drive can be subdivided into several **logic block disks (partitions).** - Disk or partition can be used **raw**, i.e., without a file system. - **Partition** can be formatted with a **file system (cooked)**. - **Root partition** contains the **OS kernel**, and other system files. - **Other partitions** can hold other OSes, other file systems, or be **raw**. - A **volume** is a single accessible storage area with a single file system, a volume can contain multiple partitions. - File system types: - **General purpose file systems:** Mostly used, like Windows - **Special purpose file systems**: E.g., Solaris’s contract file system  ## Operations Performed on Directory Basic operations including: - Search for a file - Create a file - Delete a file - List a directory - Rename a file - Traverse the file system ### The object of directory - **The directory is organized logically to obtain**: - Effiecient location of a file - Naming conveniently to users - *i.e.* Two files in different diretories can have the same name - The same file can have several different names - Grouping of files with similar properties ### Directory organization - Single level directory - Two-level directory - Tree-structured directories - Acyclic graph directories #### Tree-Structured Directories - Tree structures is a tree of arbitrary height, mostly common directory structure - It allows users to create their own subdirectories and to organize their files accordingly. - Advantages: - Efficient searching - Grouping capability #### Acyclic-Graph Directories - A tree structure prohibits the sharing of files or directories. - **DAG allows directories to share subdirectories and files** - **A file may have multiple different path names** - Some OSes simply do not allow shared directories or links - How do we gaurantee co cycles? - Allow **only links to file not subdirectories ** - Every time a new link is added, use a cycle detector algorithm to determine whether it is okay. **Costing** ## File System Mounting ### Definition - A **file system** must be mounted before it can be accessed - An unmounted file system can be mounted at a **mount point** - The amount point must be **an empty directory**, *i.e.* original file system at the mount point must be removed if exists  ## File Sharing 1. A file can be shared by multiple users. 2. Access might be protected. 3. The **owner** of a file is the user who can change attributes and grant access and who has the most control over the file. 4. The **group** attribute defines a subset of users who can share access to the file. 5. The **owner and group IDs** of a given file (or directory) are stored as part of file attributes. - **User IDs** identify users, allowing permissions and protections for a user. - **Group IDs** allow users to be in groups, permitting group access rights. Loading... ## File Concept 废话一大堆 ### File - A named collection of related information that is recorded on secondary storage (e.g. Disk, SSD, Flash, etc.). - A sequence of bits, bytes, lines, or records, the meaning of which is defined by the file’s creator. - Smallest logical storage unit for user view. - **Uses contiguous logical address space.** - Represents programs or data. ### File system - Resides on secondary storage (disks). - **Provides user interface to storage, mapping logical to physical.** - Provides efficient and **convenient access** to disk by allowing data to be stored, located, retrieved easily. ### File Attributes A file usually has the following basic attributes: - Name: Only information kept in human - readable form - Identifier: A unique tag (number) that identifies the file within the file system - Type: Needed for systems that support different types - Location: A pointer to the file location on the 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 Information about files' metadata are kept in the directory structure, which is maintained on the disk Information about files (metadata) are kept in the directory structure, which is maintained on the disk. ### File Operations - File is an abstract data type. - Six basic file operations - Create - Write - Read - Reposition within a file - Truncate a file - File is reset to length zero - File space is released - File attributes are unchanged - Delete ### File Lock 基础的 Lock: - Reader-Writter Lock: 「读操作」可以多人同时进行(共享),不会冲突;「写操作」必须一人独占,否则数据会乱。 于是有的 OS 提供以下两种锁: - Shared Lock - Similar to reader lock - Several processes can acquire concurrently - Exclusive lock - Similar to writter lock - Mandotory Lock - Once a process acquires an **exclusive** lock, the OS will prevent any other process from accessing the locked file - Advisory Lock - It is up to software developers to ensure that locks are appriopriately acqured and released. ## File Access Methods 主要有三种方法,下面只有简单介绍他们的指令 ### Sequential Access - `read_next` - `write_next` - `reset` (to the beginning) ### Direct/Random Access - `read next` - `write next` - `read n` - `write n` - `position to n` - `rewrite n` ### Index and Relative Files Access - Keep index in memory for fast determination of location of data to be operated on ### Directory Structure - 目录可以被视为一个符号表 (symbol table),它将文件名翻译成它们对应的文件控制块 (File Control Block, FCB)。FCB(在 UNIX 文件系统中称为 inode)包含了文件的详细信息,例如所有权、权限以及文件内容在存储设备上的位置等 - Both the directory structure and the files reside on disk ### Disk Structure - A **drive** is a **physical block** disk. - A drive can be subdivided into several **logic block disks (partitions).** - Disk or partition can be used **raw**, i.e., without a file system. - **Partition** can be formatted with a **file system (cooked)**. - **Root partition** contains the **OS kernel**, and other system files. - **Other partitions** can hold other OSes, other file systems, or be **raw**. - A **volume** is a single accessible storage area with a single file system, a volume can contain multiple partitions. - File system types: - **General purpose file systems:** Mostly used, like Windows - **Special purpose file systems**: E.g., Solaris’s contract file system  ## Operations Performed on Directory Basic operations including: - Search for a file - Create a file - Delete a file - List a directory - Rename a file - Traverse the file system ### The object of directory - **The directory is organized logically to obtain**: - Effiecient location of a file - Naming conveniently to users - *i.e.* Two files in different diretories can have the same name - The same file can have several different names - Grouping of files with similar properties ### Directory organization - Single level directory - Two-level directory - Tree-structured directories - Acyclic graph directories #### Tree-Structured Directories - Tree structures is a tree of arbitrary height, mostly common directory structure - It allows users to create their own subdirectories and to organize their files accordingly. - Advantages: - Efficient searching - Grouping capability #### Acyclic-Graph Directories - A tree structure prohibits the sharing of files or directories. - **DAG allows directories to share subdirectories and files** - **A file may have multiple different path names** - Some OSes simply do not allow shared directories or links - How do we gaurantee co cycles? - Allow **only links to file not subdirectories ** - Every time a new link is added, use a cycle detector algorithm to determine whether it is okay. **Costing** ## File System Mounting ### Definition - A **file system** must be mounted before it can be accessed - An unmounted file system can be mounted at a **mount point** - The amount point must be **an empty directory**, *i.e.* original file system at the mount point must be removed if exists  ## File Sharing 1. A file can be shared by multiple users. 2. Access might be protected. 3. The **owner** of a file is the user who can change attributes and grant access and who has the most control over the file. 4. The **group** attribute defines a subset of users who can share access to the file. 5. The **owner and group IDs** of a given file (or directory) are stored as part of file attributes. - **User IDs** identify users, allowing permissions and protections for a user. - **Group IDs** allow users to be in groups, permitting group access rights. 最后修改:2025 年 05 月 27 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏