Docsity

Introduction to Files in Operating Systems, Lecture notes of Operating Systems

Toggle sidebar
bg1
UNIVERSITY of WISCONSIN-MADISON
Computer Sciences Department
CS 537 A. Arpaci-Dusseau
Intro to Operating Systems Spring 2000
Questions answered in these notes
•What is a file and what operations can be performed on them?
•What information (meta-data) must be associated with a file?
•How are directories organized?
•What is the difference between hard and soft links?
Reading for this topic: Chapter 10
Introduction to
Files
A.Arpaci-DusseauCS 537:Operating Systems file.fm.2
What is a File?
User view
•Named collection of bytes
Type defined by creator
Example: Text, source, object, executables
•Permanently and conveniently available
Operating System view
•Map bytes as collection of blocks on physical storage
•Nonvolatile storage device
Magnetic disks
Persistent across reboots and power failures
A.Arpaci-DusseauCS 537:Operating Systems file.fm.3
Role of File System
Naming
•How do users select files?
•Convert “name” + offset --> logical disk block --> cylinder #, sec #
Protection
•All users are not equal
Reliability
•Information must last safely for long periods of time
Disk Management and Allocation
•Efficient use of disk space
•Fast access to files
A.Arpaci-DusseauCS 537:Operating Systems file.fm.4
File Operations
Create file
•Find space on disk
•Give name to file
Write or Read from named file
•Find current location in file (track per-file & per-process)
•Seek within file to desired location
Delete file
•Release disk space
Truncate
•Set size to 0, but keep other attributes
Rename
Change access permissions
pf3

Partial preview of the text

Download Introduction to Files in Operating Systems and more Lecture notes Operating Systems in PDF only on Docsity!

UNIVERSITY of WISCONSIN-MADISON Computer Sciences Department CS 537 A. Arpaci-Dusseau Intro to Operating Systems Spring 2000

Questions answered in these notes

-^ What is a file and what operations can be performed on them? -^ What information (meta-data) must be associated with a file? -^ How are directories organized? -^ What is the difference between hard and soft links?

Reading for this topic: Chapter 10

Introduction to

Files

CS 537:Operating Systems file.fm.

What is a File?

User view

-^ Named collection of bytes Type defined by creatorExample: Text, source, object, executables -^ Permanently and conveniently available

Operating System view

-^ Map bytes as collection of blocks on physical storage -^ Nonvolatile storage device Magnetic disksPersistent across reboots and power failures A.Arpaci-Dusseau CS 537:Operating Systems file.fm.

Role of File System

Naming

-^ How do users select files? -^ Convert “name” + offset --> logical disk block --> cylinder #, sec #

Protection

-^ All users are not equal

Reliability

-^ Information must last safely for long periods of time

Disk Management and Allocation

-^ Efficient use of disk space -^ Fast access to files CS 537:Operating Systems file.fm.

File Operations

Create file

-^ Find space on disk -^ Give name to file

Write or Read from named file

-^ Find current location in file (track per-file & per-process) -^ Seek within file to desired location

Delete file

-^ Release disk space

Truncate

-^ Set size to 0, but keep other attributes

RenameChange access permissions

A.Arpaci-Dusseau CS 537:Operating Systems file.fm.

Meta-Data

Additional system information on disk associated with each file

-^ Name of file, type of file -^ Pointer to data on disk -^ File size -^ Most recent access and modification time -^ Owner and group id -^ Protection bits -^ Special file? Directory? Symbolic link?

UNIX Example: ls -lig midSol.ps

122945 -rw-r----- 1 dusseau cs140 2918 Nov 1 18:53 midSol.ps

Issue: How is meta-data stored on disk? (i-node in UNIX)

CS 537:Operating Systems file.fm.

Opening Files

Expensive to access file by symbolic nameOpen file before first access

-^ Search directories for file name and check permissions -^ Copy relevant meta-data to open file table in memory -^ Return index in open file table (“file descriptor”) -^ Application passes index to OS when accessing file

Per-process open file table

-^ Current position pointer -^ Index in system table

System open file table shared across processes

-^ File open count A.Arpaci-Dusseau CS 537:Operating Systems file.fm.

Directories

Organization technique

-^ How to map file name to location of file on disk? Index of meta-data in list

Single-Level directory

-^ Single directory for entire disk Each file must have a unique name -^ Special part of disk holds one directory Contains <file name, index> pairsFixed length name -^ Only appropriate for personal computers

Two-Level directory

-^ Directory for each user -^ Specify file with user and file name CS 537:Operating Systems file.fm.

Tree-Structured Directories

Directory stored on disk just like regular file

-^ Data consists of <file name, index> pairs File name can be another directory -^ Special bit set in meta-data User programs can read directoriesOnly special system programs can write directories -^ Reference by separating names with slashes

Special directories

-^ Root: Fixed index for meta-data (2) -^ . : This directory -^ .. : Parent directory

Example: mkdir /a/b/c

2: Find <“a”, 5>5: Find <“b”, 9>9: Verify no <“c”, X> previously; add “c” to directory