1 / 23

ITFN 2601 Introduction to Operating Systems

ITFN 2601 Introduction to Operating Systems. Lecture 22 Files & Directories. Agenda. Files Naming Structure Attributes Operations Directories Structure Operations. File Naming. File names are used to reflect the content The name is useful to the user

tala
Download Presentation

ITFN 2601 Introduction to Operating Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ITFN 2601Introduction to Operating Systems Lecture 22 Files & Directories

  2. Agenda • Files • Naming • Structure • Attributes • Operations • Directories • Structure • Operations

  3. File Naming • File names are used to reflect the content • The name is useful to the user • The extension(s) are knowledge for the OS • DOS supported 8.3 • 8 characters (a-z, _, -) in the filename • 3 characters as an extension • Most modern systems allow arbitrarily long filenames and extensions

  4. File Structure (Byte) • Byte Ordered • File is a sequence of bytes • Binary values • System doesn’t care • FAT32, NTFS, ext2fs

  5. File Structure (Records) • Files are kept as a set of records • Each record contains data • Records are typed • Data in a record is expected to be the proper type

  6. File Structure (Keyed) • Files stored as a tree of records • Each record has some “key” value • Tree is restructured whenever it becomes unbalanced

  7. File Attributes (Type) • Files have a type • ASCII • Binary • Either Executable or construct file • Can be dictated by the file extension • .exe is an executable windows file • Can be appointed in the file • All JAVA programs start with CAFÉ OS

  8. File Attributes (Access) • Files can be accessed in multiple methods • Usually based on storage • Sequential Access • Reel-to-Reel storage media • Movement is linear • Random Access • Platter-based media • Movement is multi-dimensional

  9. File Attributes (General) • Informational • Who owns the file • Who can read the file • System/Hidden flag • Creation Time • Modification Time • Size • Etc

  10. File Operations • Create • Create a 0-size file • Announces the file is coming • Reserves the filename • Delete • Destroys the file • Removes all OS information about the file

  11. File Operations (2) • Open • Open the file for use • Locks the file (if the open is for a write) • Close • Close the file after use • Releases any locks held on the file

  12. File Operations (3) • Read • Reads the next chunk from the file • Starts from the file-cursor • Write • Writes the designated chunk to the file • Starts at the file-cursor

  13. File Operations (4) • Append • Special write that ALWAYS goes to the end of the file • Seek • Move the file-cursor to the location specified • Rename • Changes the files name • Sometimes a copy-delete

  14. File Operations (5) • GetAttr • Get Attributes • Returns the list of file-attributes for the file • Can request specific attributes • SetAttr • Set Attributes • Sets the file-attributes • Given an attribute-list to use

  15. Directory Structure(Single Level) • One directory listing • All files at one level • Two users can’t have the same filename • Very restrictive

  16. Directory Structure(Two-Level) • Main listing shows user-directories • Each user gets their own file-name-space • Same filename can be used by every user! • System files • How does everyone get access? • Copy to every user directory?

  17. Hierarchical Directory Structures

  18. Directory Structure(Hierarchical) • Main directory lists other directories • Uses paths to reach other directories for system or shared files • At some level are “user” directories • C:\documents and settings\jjones (Win 2k) • /home/jjones (unix) • User directories can have their own directory listings, too!

  19. Directory Paths • Each file is in some directory • Path tells the OS how to find the file • Absolute Path • C:\windows\command.exe • Relative Path • ..\windows\command.exe

  20. Directory Operations • Create • Generates an empty directory • Has two entries • . – Current directory • .. – Directory one level up • Delete • Removes the directory listing • Generally only works on empty directories

  21. Directory Operations (2) • Opendir • Opens the directory for reading by a program • Necessary to retrieve a directory listing • Closedir • Closes the directory after a read

  22. Directory Operations (3) • Readdir • Reads the next filename from the directory listing • Starts at the directory-cursor

  23. Directory Operations (4) • Rename • Rename the directory • Link • Create a special file that mimics the linked file • Saves disk-space by not needing a true copy

More Related