Presentation is loading. Please wait.

Presentation is loading. Please wait.

File Systems CSCI 4534. What is a file? A file is information that is stored on disks or other external media.

Similar presentations


Presentation on theme: "File Systems CSCI 4534. What is a file? A file is information that is stored on disks or other external media."— Presentation transcript:

1 File Systems CSCI 4534

2 What is a file? A file is information that is stored on disks or other external media

3 Why do we use files? We often need for several applications or users to share data That data needs to be stored and retrieved

4 What is a file system? The part of the operating system that deals with files is called a file system This section discusses how files are structured, named, accessed, used, protected, and implemented

5 File Systems Consist of two parts –A collection of files with stored data –A directory structure With organization of and information about all the files in the system There may be a third part –Partitions which separate directories

6 File Concepts The Operating System provides a uniform logical view of how information is stored –Physical: stored on nonvolatile media –Logical: named collection of related data Types of files –Data: numeric, alphabetic, alphanumeric, binary, ASCII –Programs: source, object, executable

7 File Concepts Meaning of a file is defined by the creator (or the user?) Files have structure according to their type –Text: sequence of characters organized into lines –Source: sequence of subprograms consisting of data and instructions –Object: sequence of bytes organized into blocks understandable by linker –Executable: binary code and data to be loaded into memory and executed

8 File Types Regular files: contain user information –ASCII – good for being edited with a text editor –Binary – have an internal structure that is meaningful to the programs that use them Directories: system files for maintaining the structure of the file system

9 File Attributes Typical Attributes – see also Figure 6-4 –Name –Type –Location –Size –Protection and access control –Time, date and user ID: for creation, last modification, last use

10 File Operations System calls are provided for: –Create a file: find space, add to directory –Delete: release file space, delete dir entry –Open: system fetches attributes and disk addresses –Close: space is freed –Read: name and location –Write: name and data –Append: add data to end of file –Seek: repositions file pointer

11 File Operations Other operations –Get attributes: see Make p. 388 –Set attributes: e.g. protection modes –Rename –Copy

12 File Operations Before files are used, an open( ) system call is usually made –Avoids searching for the file each time –O.S. keeps a table about all open files May have a count of users if shareable –File name is associated with index into table, open( ) returns a pointer (we have seen an int) –The open( ) call can specify access-mode information and can check for permissions

13 File Operations What happens when a file (such as in UNIX) is shared by several users? –The O.S. uses two tables A system-wide table: location, access dates, size A per-process table –Current file pointer for this process –Each entry points to the system-wide table

14 File Types What file types should an O.S. recognize? –See types in Figure 6-1 File names are followed by an extension –Extension specifies type of file and type of operations that can be done on the file.com,.bat,.exe can all be executed.asm is extension that an assembler is expecting

15 File Structure O.S.s may support different types of files –Some may support many or a few –However, all must support executable files Files can be seen as: –A sequence of 8-bit bytes no interpretation is made; flexible –A sequence of records –A tree (see Figure 6-2)

16 File Structure How can a specific logical record in a file be found? Disk I/O uses blocks –All blocks are the same size –Logical records are packed into physical blocks –In UNIX, files are simply a stream of bytes –Those bytes are stored into a specific # of bytes per block (eg. 512, 1024)

17 File Structure What determines how many logical records are in each block? –Logical record size –Physical block size A file, then, is a sequence of blocks –Some part of the last block is wasted (internal fragmentation)

18 Access Methods Sequential Access –One record is processed after the other Examples: compilers, editors Mostly reading and writing is done Works on sequential-access devices and on random- access devices –Operations: read next, write next

19 Access Methods Random Access –Records are accessed by key, not position –File seen as a #ed sequence of blocks or records –Useful in databases Provides immediate access to large amounts of data –Where to start reading? Each Read operation gives reading position Or Seek finds the first position, then reads sequentially from there

20 Directory Structure File systems are organized: –Disks are split into one or more partitions IBM calls them minidisks, others are called volumes Usually each disk has a partition that stores files and directories –Each partition contains information about the files within it Called a device directory or a volume table of contents which holds the file attributes for files on this partition

21 Directory Structure The directory can be viewed as a symbol table –Translates file names onto directory entries What do we want to do with directories? –Search for a file –Create, delete –Rename, list files –Traverse the file system

22 Directory Structure Single-Level Directory –All files have unique names Two-Level Directory –Each user has a UFD (user file directory) –A higher-level MFD (master) is indexed by user name or account number

23 Directory Structure Hierarchical Directories –Must specify pathname Absolute: begins at root Relative: begins at current directory –Directory contains pointers to files (0) or subdirectory (1) –Must have current directory, be able to change directories, be able to delete directories –Allow access to other users’ files if given access

24 Directory Operations Create Delete Opendir Closedir Readdir Rename Link

25 File-System Implementation Layout (see Figure 6-11) –Master Boot Record –Boot Block –Superblock

26 File-System Implementation Contiguous Allocation Linked List Allocation File Allocation Table I-nodes

27 Implementing Directories Directories provide information to find disk blocks –Disk address of file – contiguous –Number of the first block – linked list schemes –Number of the i-node Where are attributes stored? –In directory entry –In the i-nodes See Figure 6-17 for ways to handle long file names in directories

28 File Sharing Directed Acyclic Graph (DAG)

29 File Protection We want to keep information safe from: –physical damage (reliability) –improper access (protection) We need protection for these operations: –Read, write, execute, append, list, delete

30 File Protection Access control Use an access control list –specifies user name and types of access allowed –O.S. checks access list when a request is made –lists are tough to maintain Three classifications: –Owner, Group, Universe –Example of Sara


Download ppt "File Systems CSCI 4534. What is a file? A file is information that is stored on disks or other external media."

Similar presentations


Ads by Google