Download Operating Systems - File Abstraction - File Operation | CMSC 412 and more Study notes Operating Systems in PDF only on Docsity!
Announcements
z
Reading Chapter 11
z
Midterm #1– Last day to submit requests is today
File Abstraction
z^
What is a file?–
A named collection of information stored on secondary storage
z^
Properties of a file–
non-volatile
-^
can read, read, or update it
-^
has meta-data to describe attributes of the file
z^
File Attributes–
name: a way to describe the file
-^
type: some information about what is stored in the file
-^
location: how to find the file on disk
-^
size: number of bytes
-^
protection: access control
•^
may be different for read, write, execute, append, etc.
–^
time: access, modification, creation
-^
version: how many times has the file changed
File Operations (cont)
z
write– indicate what file to write (either name of handle)– provide data to write– specify where to write the data within the file
- generally this is implicit (file pointer)• could be explicit (direct access)
z
read– indicate what file to read (either name of handle)– provide place to put information read– indicate how much to read– specify where to write the data within the file
- generally this is implicit (file pointer)• could be explicit (direct access)
z
fsync (synchronize disk version with in-core version)– ensure any previous writes to the file are stored on disk
File Operations (cont)
z
seek– move the implicit file pointer to a new offset in the file
z
delete– remove named file
z
truncate– remove the data in the file from the current position to end
z
close– unlock the file (if open locked it)– update meta data about time– free system resources (file descriptors, buffers)
z
read meta data– get file size, time, owner, etc.
z
update meta data– change file size, time owner, etc.
Tree Directories
z
create a tree of files
z
each directory can contain files or directory entries
z
each process has a current directory– can name files relative to that directory– can change directories as needed
a^
b
hollings
user
user
vi^
gdb
one
to
cc
x^
y
system
users
mail
z
Acylic Graph Directories
z
Permit users to share subdirectories
a^
b
hollings
user
user
vi
gdb
one
to
cc
x^
y
system
users
mail
z
Does the OS know what is stored in a file? z^
needs to know about some types of files–
directories
-^
executables
z^
should other file types be visible to the OS?–
Example: word processing file vs. spreadsheet
-^
Advantages:
•^
OS knows what application to run
-^
Automatic make (tops-20)
- if source changed, re-compile before running
–^
Problems:
•^
to add new type, need to extend OS
-^
OS vs. application features are blurred
-^
what if a file is several types
- consider a compressed postscript file
Example of File Types
z
Macintosh– has a file type that is part of file meta-data– also has an application associated with each file type
z
Windows 95/NT– has a file type in the extension of the file name– has a table (per user) to map extensions to applications
z
Unix– can use last part of filename like an extension– applications can decide what (if anything) to do with it