File Systems: Understanding File Concepts, Attributes, and Operations, Assignments of Operating Systems

A lecture note from cs423ug operating systems class by indranil gupta. It covers the basics of file systems, including file concepts, attributes, and operations. The lecture discusses the problem with files, file system requirements, file structures, and file types. It also explains what makes file systems hard and introduces file system components such as file descriptors and metadata.

Typology: Assignments

Pre 2010

Uploaded on 03/13/2009

koofers-user-5mn
koofers-user-5mn 🇺🇸

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
File Systems - I
Indranil Gupta
Lecture 22
10/17/2005
CS423UG Operating Systems GO!
CS 423UG Operating Systems,
Indranil Gupta
2
Content
File systems basic concepts
GO!
CS 423UG Operating Systems,
Indranil Gupta
3
Question for You
FastOS : the newest, hottest and fastest OS to be
invented yet– it relies on cheap hardware (CPU, I/O
devices, memory), it has close to 100% CPU
utilization, it has close to 100% I/O device utilization,
and it is very easy to understand.
The only catch is – it doesn’t support the concept of
a “file” or a “directory”.
Now, you’re asked to do your MP on a FastOS
machine.
How would you type up your CS 423UG HW on
FastOS?
CS 423UG Operating Systems,
Indranil Gupta
4
What’s the problem with Files?
Physical reality
Physical sector is
unit of storage
Block oriented
No protection among
users of the system
Data might be
corrupted if machine
crashes
File system model
File is a unit of storage
File is a sequence of
bytes
Users protected from
each other
Robust to machine
failures
CS 423UG Operating Systems,
Indranil Gupta
5
File System Requirements
Users must be able to:
create, modify, and delete files at will.
read, write, and modify file contents without
worrying about blocking, buffering, etc. (in other
words, buffering etc. should be transparentto the
user).
see a logical view of their own group of files
without concern for how they are stored. share
each other's files with proper authorization.
transfer information between files.
refer to files by symbolic names.
retrieve backup copies of files lost through
accident or malicious destruction.
CS 423UG Operating Systems,
Indranil Gupta
6
File Concepts
File=basic unit of storage as seen as one
entity by the user
Directory = a collection of files and/or other
directories, seen as one entity by the user
Partitions=a group of directories accessed
as one entity
OS abstracts from the physical properties of
its storage device to define a logical storage
unit, called file. Files are mapped by the OS
onto physical devices.
pf3
pf4

Partial preview of the text

Download File Systems: Understanding File Concepts, Attributes, and Operations and more Assignments Operating Systems in PDF only on Docsity!

File Systems - I

Indranil GuptaLecture 2210/17/

CS423UG Operating Systems

GO!

CS 423UG Operating Systems,

Indranil Gupta

Content

File systems basic concepts

GO!

CS 423UG Operating Systems,

Indranil Gupta

Question for You

FastOS : the newest, hottest and fastest OS to beinvented yet– it relies on cheap hardware (CPU, I/Odevices, memory), it has close to 100% CPUutilization, it has close to 100% I/O device utilization,and it is very easy to understand.

The only catch is – it doesn’t support the concept ofa “file” or a “directory”.

Now, you’re asked to do your MP on a FastOSmachine.

How would you type up your CS 423UG HW onFastOS?

CS 423UG Operating Systems,

Indranil Gupta

What’s the problem with Files?

Physical reality

Physical sector isunit of storage

Block oriented

No protection amongusers of the system

Data might becorrupted if machinecrashes

File system model

File is a unit of storage

File is a sequence ofbytes

Users protected fromeach other

Robust to machinefailures

CS 423UG Operating Systems,

Indranil Gupta

File System Requirements

Users must be able to:

create, modify, and delete files at will.

read, write, and modify file contents withoutworrying about blocking, buffering, etc. (in otherwords, buffering etc. should be

transparent

to the

user).

see a logical view of their own group of fileswithout concern for how they are stored. shareeach other's files with proper authorization.

transfer information between files.

refer to files by symbolic names.

retrieve backup copies of files lost throughaccident or malicious destruction.

CS 423UG Operating Systems,

Indranil Gupta

File Concepts

File

=basic unit of storage as seen as one

entity by the user

Directory

= a collection of files and/or other

directories, seen as one entity by the user

Partitions

=a group of directories accessed

as one entity

OS abstracts from the physical properties ofits storage device to define a logical storageunit, called file. Files are mapped by the OSonto physical devices.

CS 423UG Operating Systems,

Indranil Gupta

File Attributes



Name:

symbolic file name, human-readable form. Many OS’s

support two part file names (filename.filetype, e.g., foo.txt)



Type:

Regular files - user information, regular files are generally eitherbinary (e.g., .exe) or ASCII (e.g., all .cpp, all .txt)

Directories - system files for maintaining the structure of the filesystem

Character special files - related to input/output and used to modelserial I/O devices such as terminals, printers, and networks

Block special files - used to model disks



Location:

(1) pointer to a device and (2) pointer to the location

of the file on that device



Size:

current size and maximal possible size



Protection:

Access-control information, who can read, who can

write



Time, date, user identification

: creation time, last modification

time, last use time

CS 423UG Operating Systems,

Indranil Gupta

File Operations

Create a file

creat() or fopen()

Write a file

  • implicitly advances pointer

fwrite()

Read a file

  • implicitly advances pointer

fread()

Reposition within a file

lseek()

Delete a file

del or rm

Append to a file

cat

Copy or move a file

cp or mv

CS 423UG Operating Systems,

Indranil Gupta

File Structures

Byte sequence

Unstructured sequence of bytes

Record sequence

Fixed or variable length

Read or write a number of records

Tree

Records with keys

Read, insert, delete a record (typically using B-tree)

CS 423UG Operating Systems,

Indranil Gupta

File Structures Today

Sequence of bytes

Simplest to implement in kernel

Easy to manipulate in other forms

Little performance loss

More complicated structures

Hardware assistance fell out of favor

Special-purpose hardware slower, costly

CS 423UG Operating Systems,

Indranil Gupta

File Types

ASCII – plain text

A Unix executable file

header: magic number (Unix:compiled Java files have 0xCAFEBABE),

sizes, entry point, flags

Text (code)

Data

relocation bits

symbol table

Anything else in the system that needs a “name”,e.g., devices (/dev/*)

CS 423UG Operating Systems,

Indranil Gupta

So What Makes File systems Hard?

Files grow and shrink in pieces

Little

a priori

knowledge of this dynamism

Several orders of magnitude in file sizes –smallest files are 0B large, largest are a fewGB’s-TeraBytes’s (that’s 1024 GB’s)

Need to overcome/hide/mask diskperformance behavior

Desire for efficiency

Coping with failure (of devices, or by users)

CS 423UG Operating Systems,

Indranil Gupta

Reading And Writing

So, you’ve opened a file…What happens when you… 

read 10 bytes from a file?

write 10 bytes into an existing file?

write 4096 bytes into a file?

Problems: 

Is this a valid read within the file?

Where is this data located on disk?

Can we speed up the data access (through diskcache)

CS 423UG Operating Systems,

Indranil Gupta

Reading A Block

PCB Open

file table

Metadata

read( fd, userBuf, size )

Logical

physical

read( device, phyBlock, size )

Get physical block to sysBuf

copy to userBuf

Disk device driver

Buffer cache

CS 423UG Operating Systems,

Indranil Gupta

Reminders

MP2 due today

HW4 out today, due Nov 2

Reading for this lecture: Section 6.

Reading for next lecture: Sections 6.2 and6.