Module11:File- System Interface(文件系统接口) File Concept(文件概念) Access Methods(存取方法) Directory Structure(目录结构) Protection(保护) File-System Structure(文件系统结构) Allocation Methods(分配方法) Free-Space Management(自由空间管理) Directory Implementation(目录实现) Efficiency and Performance(效率和性能) Recovery 恢复) Applied Operating System Concepts 1 Silberschatz, Galvin, and Gagne @1999
11.1 Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts Module 11: File-System Interface(文件系统接口) • File Concept(文件概念) • Access Methods(存取方法) • Directory Structure (目录结构) • Protection(保护) • File-System Structure (文件系统结构) • Allocation Methods(分配方法) • Free-Space Management (自由空间管理) • Directory Implementation(目录实现) • Efficiency and Performance(效率和性能) • Recovery(恢复)
File Concept(文件概念) ° Contiguous logical address space(相邻的逻辑地址空间) ° Types:(类型) Data(数据) Numeric(数字) Character(字符) Binary(二进制) Program(程序) Applied Operating System Concepts 112 Silberschatz, Galvin, and Gagne @1999
11.2 Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts File Concept(文件概念) • Contiguous logical address space(相邻的逻辑地址空间) • Types: (类型) – Data(数据) Numeric(数字) Character(字符) Binary(二进制) – Program(程序)
File structure(文件结构) None- sequence of words, bytes(顺序的字和字节) Simple record structure(简单的记录结构) Lines(线性) Fixed length(固定长度) Variab|e| ength(可变长度) ° Complex Structures(复杂结构) Formatted document(规格化的文档) Relocatable load file(可重定位文件) Can simulate last two with first method by inserting appropriate control characters (可以用第一个方法通过增加适当的控制字符来模拟后两种方法 Who decides(需要决定) Operating system(操作系统) program(程序) Applied Operating System Concepts 11.3 Silberschatz, Galvin, and Gagne @1999
11.3 Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts File Structure(文件结构) • None - sequence of words, bytes(顺序的字和字节) • Simple record structure(简单的记录结构) – Lines (线性) – Fixed length(固定长度) – Variable length(可变长度) • Complex Structures(复杂结构) – Formatted document(规格化的文档) – Relocatable load file(可重定位文件) • Can simulate last two with first method by inserting appropriate control characters. (可以用第一个方法通过增加适当的控制字符来模拟后两种方法 ) • Who decides(需要决定) – Operating system(操作系统) – Program(程序)
Fille attributes(文件属性) Name -only information kept in human-readable form. (文件名:唯一的以人们可以理解的方式保存的信息) 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 (保护:控制对文件的读取,改写和执行的权限) esmn时间,日期和用户身份:保护和安 全需要的数据) Information about files are kept in the directory structure, which is maintained on the disk.(文件的信息保存在磁盘上的目录结构中) Applied Operating System Concepts 11.4 Silberschatz, Galvin, and Gagne @1999
11.4 Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts File Attributes(文件属性) • Name – only information kept in human-readable form. (文件名:唯一的以人们可以理解的方式保存的信息) • 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.(时间,日期和用户身份:保护和安 全需要的数据) • Information about files are kept in the directory structure, which is maintained on the disk.(文件的信息保存在磁盘上的目录结构中)
File operations(文件操作) Create(创建) Write(改写) Read(读取) ° reposition within file- file seek(重定位文件,文件搜索) Delete(删除) ° Truncate(截去) open (Fi-search the directory structure on disk for entry Fis and move the content of entry to memory. (打开(Fi):在磁盘上的目录结构中搜寻F的表项,然后把表项 的内容移动到内存中) close(Fi-move the content of entry F; in memory to directory structure on disk. (关闭(Fi):把F在内存中的表项内容移动到磁盘中) Applied Operating System Concepts 1.5 Silberschatz, Galvin, and Gagne @1999
11.5 Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts 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. (打开(Fi):在磁盘上的目录结构中搜寻Fi的表项,然后把表项 的内容移动到内存中) • close (Fi) – move the content of entry Fi in memory to directory structure on disk. (关闭(Fi):把Fi在内存中的表项内容移动到磁盘中)
File Types- name, extension 文件类型,名称,扩 ile Type Fi Usual extension Function 「 Executable exe, com, bin or ready-to-run machine none language progra Object obL, o complied, machine anguage, not linked Source code C, p, pas, 177 source code in various asm. a languages Batch I bat, sh commands to the commandinterpreter Text txt. doc textual data documents Word processor wp, tex, rrf, etc.various word-processor. formats Library a libraries of routines Print or view ps, dvi, gif ASCll or binary file Archive arc, zip tar related files grouped into one file. sometime compressed Applied Operating System Concepts 116 Silberschatz, Galvin, and Gagne @1999
11.6 Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts File Types – name, extension 文件类型,名称,扩展名 Executable exe, com, bin or none ready-to-run machinelanguage program Object obj, o complied, machine language, not linked Source code c, p, pas, 177, asm, a source code in various languages Batch bat, sh commands to the command interpreter Text txt, doc textual data documents Word processor wp, tex, rrf, etc. various word-processor formats Library lib, a libraries of routines Print or view ps, dvi, gif ASCII or binary file Archive arc, zip, tar related files grouped into one file, sometimes compressed. File Type Usual extension Function
Access Methods(存取方法) Sequential Access(顺序存取) read next(读下一个) write next(写下一个) reset(复位) no read after| ast write(曾读政) (rewrite Direct Access直接存取)dn(被第们项) read Wten(写第项) position to n(移动位置到第项) read next(读下一个) write next(写下一个) rewrite n(重写第n个) n= relative block number(n为相对块数) Applied Operating System Concepts 117 Silberschatz, Galvin, and Gagne @1999
11.7 Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts Access Methods(存取方法) • Sequential Access(顺序存取) read next(读下一个) write next (写下一个) reset(复位) no read after last write(未曾读取) (rewrite) • Direct Access(直接存取) read n(读第n项) write n(写第n项) position to n(移动位置到第n项) read next(读下一个) write next (写下一个) rewrite n(重写第n个) n = relative block number(n为相对块数)
Directory Structure(目录结构) A collection of nodes containing information about all files (一个包含着所有文件信息的节点的集合) Directory 目录 Files 文件 F1F2 F 4 F3 Fn ° Both the directory structure and the files reside on disk.(目录结构和文 件都在磁盘上) Backups of these two structures are kept on tapes.(备份放在磁带上 Applied Operating System Concepts 11.8 Silberschatz, Galvin, and Gagne 1999
11.8 Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts Directory Structure(目录结构) • A collection of nodes containing information about all files. (一个包含着所有文件信息的节点的集合) F 1 F 2 F 3 F 4 F n Directory 目录 Files 文件 • Both the directory structure and the files reside on disk.(目录结构和文 件都在磁盘上) • Backups of these two structures are kept on tapes.(备份放在磁带上)
Information in a device directory 设条目录由的信息 Name(名称) Type(类型) Address(地址) Current length(当前长度) ° Maximum length(最大长度) Date last accessed( for archival)(最后访问时间) Date last updated( for dump)(数据最后更新时间) Owner|D( who pays)(所有者D) Protection information( discuss later)(保护信息) Applied Operating System Concepts 11. Silberschatz, Galvin, and Gagne @1999
11.9 Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts Information in a Device Directory 设备目录中的信息 • Name (名称) • Type(类型) • Address (地址) • Current length(当前长度) • Maximum length(最大长度) • Date last accessed (for archival)(最后访问时间) • Date last updated (for dump)(数据最后更新时间) • Owner ID (who pays)(所有者ID) • Protection information (discuss later)(保护信息)
Operations Performed on Directory 操作系练的目录行为 Search for a file(寻找一个文件) Create a file(建立一个文件) ° Delete a file(删除一个文件) List a directory((列出目录的列表) Rename a file(重命名文件) ° Traverse the file system(整体操作文件系统) Applied Operating System Concepts 1.10 Silberschatz, Galvin, and Gagne @1999
11.10 Silberschatz, Galvin, and Gagne ©1999 Applied Operating System Concepts Operations Performed on Directory 操作系统的目录行为 • Search for a file(寻找一个文件) • Create a file(建立一个文件) • Delete a file(删除一个文件) • List a directory((列出目录的列表) • Rename a file(重命名文件) • Traverse the file system(整体操作文件系统)