Docsity

File Management: Overview of Files, Operations, and Protection in OS - Prof. Jeffrey K. Ho, Study notes of Operating Systems

Partial preview of the text

Download File Management: Overview of Files, Operations, and Protection in OS - Prof. Jeffrey K. Ho and more Study notes Operating Systems in PDF only on Docsity!

Announcements

z^

Reading Chapter 11

z^

Look for update on Web Site– Mem.c

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

File Protection Example (UNIX)

z^

each file has three classifications– user: the user who owns the file– group: a named group of other users– world: all others

z^

each file has three access types:– read, write, execute

z^

directory protection– read: list the files in the sub dir– write: delete or create a file– execute: see the attributes of the files in the subdir– sticky bit: can only modify directory entries owned by

yourself

Unix File Protection (cont)

z^

Files have 12 bits of protection– 9 bits are user, group, and world for:

  • read: list the files in the sub dir• write: delete or create a file• execute: see the attributes of the files in the subdir
    • sticky bit: leave executable in memory after is done– setuid: run the program with the uid of the file’s owner
      • used to provide extra privilege to some processes
        • example: passwd command
          • setgid: run the program with the group id of the file’s owner