CS 4410 Operating Systems File-System Interface Summer 2013 Cornell University 1
Today ● Why do we use files and how are they organized? ● File ● Attributes ● Operations ● Directories ● Logical structure of directory ● File protection 2
Organizing Data ● Every user has much useful data. ● Text, images, music, code ● Data is stored in storage devices. ● Magnetic Disk, Tape, USB ● How data is organized in storage devices? 3
File ● The OS defines the File. ● Logical storage unit ● Abstraction ● The same abstraction for all storage devices. ● Different implementation. 4
File ● A named collection of related information. ● Recorded on secondary storage. ● The smallest allotment of logical secondary storage. ● Each file has a structure. ● Independent entity. 5
File Attributes How do we identify a file? ● Name ● Type ● Location ● Size ● Protection ● Time, date and user identification ● Where are they saved? ● Directory structure ● 6
File Operations What can we do with files? ● Create ● Write ● Read ● Reposition ● Delete ● Truncate ● What about the constant searching of the file? ● 7
Open File ● An open() system call is made before a file is used. ● It saves the file information into the open-file table of the OS. ● The open() returns a pointer to the corresponding entry of the open-file table. ● Subsequent accesses do not search the directory, but they get the information needed from the pointer. ● What happens when multiple processes open the same file? 8
Open File The OS uses two levels of internal tables: ● Per-process table ● System-wide table ● Per-process table: ● One entry for each open file (by the process). ● Stores information concerning the specific use of the file by the specific ● process . Current file pointer, access rights ● Every entry has a pointer to the corresponding entry in the System-wide table . ● System-wide table: ● One entry for each open file (by all the processes) ● Contains process-independent information ● Location, access dates, size ● What happens when a process opens a file? ● 9
Access Methods ● After we open the file, how can we access it? ● Sequentially ● Directly ● A file is made up of fixed-length logical records. 10
File System ● How the files are organized in the secondary storage device? ● A file belongs to a File System. ● A File System lives in a volume. ● A volume is a subset of the device storage space. ● A File System consists of files and directories . 11
Logical Structure of a Directory ● Single-Level ● All the files in one directory. ● Limitations? 12
Logical Structure of a Directory ● Two-Level ● User file directory ● Master file directory ● Path name for every file. ● Limitations? 13
Logical Structure of a Directory ● Tree-Structured ● A directory is, simply, another file. ● It is treated in a special way. ● One bit distinguishes files from directories. ● Limitations? 14
Logical Structure of a Directory ● Acyclic-Graph ● Shared directories/files ● Link – Symbolic ● The file contains the path of the shared file. ● Can span different file systems. – Hard ● The file entry shows directly to the shared file. ● More efficient. 15
File Protection ● Type of Access ● Read ● Write ● Execute ● Append ● Delete ● List ● Access Control List ● Who can access what and in what way. 16
Today ● Why do we use files and how are they organized? ● File ● Attributes ● Operations ● Directories ● Logical structure of directory ● File protection 17
Recommend
More recommend