Download presentation
Presentation is loading. Please wait.
1
File Management System The way a user or application may access files Programmer does not need to develop file management software You take files for granted but they actually are not FMS is part of Operating System Provides operation for file access and maintenance
2
Objectives for FMS Meet the data management needs and requirements of the user Guarantee that the data in the file are valid Optimize performance Provide I/O support for a variety of storage device types Minimize or eliminate the potential for lost or destroyed data Provide a standardized set of I/O interface routines Provide I/O support for multiple users
3
Minimal Set of Requirements Each user should be able to –create, delete, read, and change files –have controlled access to other users’ files –control what type of accesses are allowed to the users’ files –move data between files –back up and recover the user’s files in case of damage –access the user’s files by using symbolic names
4
File Management Functions Identify and locate a selected file Use a directory to describe the location of all files plus their attributes On a shared system describe user access control Blocking for access to files Allocate files to free blocks Manage free storage for available blocks
5
File Content In the responsibility of the user or the application that created the file Different file types have different conventions You can only use a file with the correct application –Open a.doc file in the notepad and change something –Now word can’t read it anymore DOS: defines by the ending UNIX: the first part of the file “magic number”
6
Example: a) UNIX executable b)code archive (.jar file)
7
Directory Structure: A Way to organize things Files reside on the hard drive Directories Contains file information –Attributes (Size, Date of change) –Ownership Directory itself is a file owned by the operating system Provides mapping between file names and the files themselves
8
Hierarchical Directory Structure
9
Tree-Structured Directory Master directory with user directories underneath it (usually /) Each user directory may have subdirectories and files as entries Files can be located by following a path from the root, or master, directory down various branches –This is the pathname for the file, directories are separated by / Can have several files with the same file name as long as they have unique path names
10
Tree-Structured Directory Current directory is the working directory Files are referenced relative to the working directory UNIX –ls -la List all files with full information –cd dir change directory –pwd show current path –~ your home directory –. current directory –.. Parent directory (one step up in the tree)
11
More UNIX –rm file Remove file –mkdir dir Create directory dir –rmdir dir Remove directory (only if it is empty) –rm -r dir Remove it! Empty or not! Regular Expression: Pattern Matching –Will make your life with UNIX much easier if you get into serious work! –* stands for any character, any number of characters –+ Stands for at least one character –example: ls *.ppt Show all PowerPint files in dir
12
File Sharing In multi user system, allow files to be shared among users Two issues –Access rights –Management of simultaneous access
13
Access Rights None Execution (x) Reading (r) Updating (w) –The user can modify, deleted, and add to the file’s data. This includes creating the file, rewriting it, and removing all or part of the data UNIX –access right exist for 3 different groups: Owner, same group and rest of the world (ls-la)
14
Access Rights Owners –Has all rights previously listed –May grant rights to others using the following classes of users Himself Group Others –chmod nnn file where n is a decimal number <=7 –Alternative: chmod who+access file who: u=user, g=group, o=other access: r=read, w=write, x=execute Restrict access using – instead of + Remark: All files that you want to be available from you home page have to be world readable!
15
Simultaneous Access User locks entire file when it is to be updated Mutual exclusion and deadlock are issues for shared access
16
How to find an executable You wrote a c program and compiled it, you can only start it if you are in the directory or if you include the full path But how does the OS do with all other applications? It knows where to look! UNIX: which command tells you where it found it PATH variable contains a list of all directories in which the OS looks for executable UNIX: echo $PATH
17
What is a link? A shortcut to an existing file or directory across the directory tree Advantage of link: –If you still change you program you would have to update the copy of the executable every time, no need with link Command: ln -s source destination
18
Solution for your applications If you want to include your own executables: –add them separately to path (cumbersome) –or create a directory that either contains all executables or links to them Solution: –create cperlich/bin directory –add it to path: setenv PATH $HOME/bin:${PATH} –create links to all you executable But where did this $PATH and $HOME come from?
19
Environment variables Now we are getting down and dirty with UNIX! Whenever you log in, the OS executes a number of little scripts for you that define your environment (.login,.cshrc) In particular you have a list of environment variables: take a look at : setenv If you want to change the PATH permanently you have to change it in one of those scripts These scripts are in your home directory and start with. (that is why you don’t see them)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.