Presentation is loading. Please wait.

Presentation is loading. Please wait.

File Concept l Contiguous logical address space l Types: Data: numeric, character, binary Program: source, object (load image) Documents.

Similar presentations


Presentation on theme: "File Concept l Contiguous logical address space l Types: Data: numeric, character, binary Program: source, object (load image) Documents."— Presentation transcript:

1 File Concept l Contiguous logical address space l Types: Data: numeric, character, binary Program: source, object (load image) Documents

2 File Structure l None - sequence of words, bytes l Simple record structure Lines Fixed length Variable length l Complex Structures Formatted document Relocatable load file

3 File Structure (cont) l Can simulate last two with first method by inserting appropriate control characters. l Who decides: Operating system Program

4 File Attributes l Name – only information kept in human-readable form. l Type – needed for systems that support different types. l Location – pointer to file location on device. l Size – current file size.

5 File Attributes (cont) l Protection – controls who can do reading, writing, executing. l Time, date, and user identification – data for protection, security, and usage monitoring. l Information about files are kept in the directory structure, which is maintained on the disk.

6 File Operations l create l write l read l reposition within file – file seek l delete l truncate

7 File Operations (cont) l open(F i ) – search the directory structure on disk for the name F i, and move the contents of the entry to memory. l close (F i ) – move the contents of entry F i in memory to directory structure on disk.

8 Information on Open File l File pointer – where in the file to read or write. l File open count – number of processes that are using this file. l Disk location of file – where the file is located on disk.

9 File Types – name.extension

10 Access Methods l Sequential Access read next write next reset rewrite

11 Access Methods (cont) l Direct Access read n, write n position to n, read next, write next, rewrite n n = relative block number

12 Directory Structure l A collection of nodes containing information about all files. Directory F 1 F 2 F 3 F 4 F n Files

13 Directory Structure (cont) l Both the directory structure and the files reside on disk. l Backups of these two structures are kept on tapes.

14 Information in a Device Directory l Name l Type l Address l Current length l Maximum length l Date last accessed (for archival)

15 Information in a Device Directory (cont) l Date last updated (for dump) l Owner ID (who pays) l Protection information (discuss later)

16 Operations Performed on Directory l Search for a file l Create a file l Delete a file l List a directory l Rename a file l Traverse the file system

17 Organize the Directory (Logically) to Obtain l Efficiency – locating a file quickly. l Naming – convenient to users. Two users can have same name for different files. The same file can have several different names. l Grouping – logical grouping of files by properties, (e.g., all C programs, all games, …)

18 Single-Level Directory l A single directory for all users. l Naming problem l Grouping problem

19 Two-Level Directory l Separate directory for each user.

20 Two Level Directory (cont) l Path name l Can have the same file name for different users l Efficient searching l No grouping capability

21 Tree Structured Directories

22 Tree Structured Directories (cont) l Efficient searching l Grouping Capability l Current directory (working directory) cd /spell/mail/prog type list

23 Tree Structured Directories (cont) l Absolute or relative path name l Creating a new file is done in current directory. l Delete a file – rm l Creating a new subdirectory is done in current directory. mkdir

24 Tree Structured Directories (cont) Example: if in current directory /spell/mail – mkdir count l Deleting “mail”  deleting the entire subtree rooted by “mail”. mail progcopyprtexpcount

25 Acyclic Graph Directories l Have shared subdirectories and files.

26 Acyclic Graph Directories (cont) l Two different names (aliasing) l If dict deletes count  dangling pointer. Solutions: Backpointers, so we can delete all pointers. Variable size records a problem. Backpointers using a daisy chain organization. Entry-hold-count solution.

27 General Graph Directory

28 General Graph Directory (cont) l How do we guarantee no cycles? Allow only links to file not subdirectories. Garbage collection. Every time a new link is added use a cycle detection algorithm to determine whether it is OK.

29 Protection l File owner/creator should be able to control: What can be done By whom l Types of access: Read Write Execute Append Delete List

30 Access Lists and Groups l Mode of access: read, write, execute l Three classes of users owner RWX 7  1 1 1 group RWX 6  1 1 0 publicRWX 1  0 0 1

31 Access Lists and Groups (cont) l Ask manager to create a group (unique name), say G, and add some users to the group. l For a particular file (say game) or subdirectory, define an appropriate access. l Attach a group to a file chgrp G game ownergrouppublic chmod761game


Download ppt "File Concept l Contiguous logical address space l Types: Data: numeric, character, binary Program: source, object (load image) Documents."

Similar presentations


Ads by Google