Download File System Ch. 10 - Fakultas Ilmu Komputer Universitas Indonesia

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
SISTIM OPERASI
(Operating System)
IKI-20230
File System
Ch. 10
Johny Moningka
([email protected])
Fakultas Ilmu Komputer
Universitas Indonesia
Semester 2000/2001
Ch. 10: File-System Interface





File Concept
Access :Methods
Directory Structure
Protection
Consistency Semantics
File System JM-2000/v1.1/2
File Concept


Contiguous logical address space
Types:

Data
• numeric
• character
• binary

Program
File System JM-2000/v1.1/3
Aspek Sudut Pandang User

Media penyimpanan data/informasi:


magnetic disk, magnetic tape, dan optical disk
Untuk kenyamanan user

OS menyediakan sudut pandang lojik yang sama bagi
semua media dengan abstraksi unit-unit storage lojik
yaitu file
File System JM-2000/v1.1/4
Aspek Isi dan Struktur

Isi File


Representasi program atau data yang terekam dalam
secondary storage
Struktur file


Bebas maupun berformat
Secara umum file merupakan deretan bit, byte, baris,
atau record yang artinya didefinisikan sendiri oleh user
perancangnya
File System JM-2000/v1.1/5
Atribut-atribut File



Atribut dari file yang berlaku bebas dari user,
proses maupun sistem
Minimal file memiliki atribut nama
Atribut-atribut lain:

type informasi yang tersimpan, lokasi dalam device,
ukuran dari data (byte, word, block), proteksi untuk
mengendalikan akses, waktu (create, modifikasi
terakhir, akses terakhir) dan identifikasi ownership
File System JM-2000/v1.1/6
File Structure


None - sequence of words, bytes
Simple record structure




Complex Structures




Lines
Fixed length
Variable length
Formatted document
Relocatable load file
Can simulate last two with first method by inserting
appropriate control characters.
Who decides:


Operating system
Program
File System JM-2000/v1.1/7
File Attributes







Name – only information kept in human-readable form.
Type – needed for systems that support different types.
Location – pointer to file location on device.
Size – current file size.
Protection – controls who can do reading, writing,
executing.
Time, date, and user identification – data for protection,
security, and usage monitoring.
Information about files are kept in the directory structure,
which is maintained on the disk.
File System JM-2000/v1.1/8
Operasi-operasi File

Enam operasi dasar yang berkaitan dengan
manajemen file sistem:






Create file
Write file
Read file
Reposition dalam file
Delete file
Truncate file
File System JM-2000/v1.1/9
Add. Operasi-operasi File

Create file:


(1) menemukan free space; (2) entry baru dibuat
dalam tabel direktori yang mencatat nama dan lokasi;
serta (3) ukuran yang diinisialisasi 0
Write file:

(1) OS melihat ke direktori untuk mencari lokasinya
dalam disk; (2) melakukan transfer dari memori ke
lokasi dalam disk (suatu pointer digunakan sebagai
penunjuk lokasi penulisan berikutnya); dan (3) entry
dalam direktori di update
File System JM-2000/v1.1/10
Add. Operasi-operasi File

Read file:


Reposition dalam file:


(1) OS melihat ke direktori untuk mencari entry yang dimaksud,
(2) pointer di set dengan harga (lokasi) tertentu yang diberikan
Delete file:


OS melakukan hal yang sama dengan penulisan file kecuali
operasinya membaca dari lokasi dalam disk ke dalam memori
(1) OS melihat ke direktori mencari entry dengan nama yang
dimaksud; (2) kemudian membebaskan space yang teralokasi;
(3) serta menghapus entry tsb
Truncate file:

sama dengan menghapus file kecuali entry tidak dihapuskan tapi
ukuran file diisi 0
File System JM-2000/v1.1/11
Operasi-operasi File Lain

Operasi-operasi lain pada dasarnya dilakukan
dengan kombinasi operasi-operasi dasar tadi,
contoh:




Append file
Rename file
Get atribut file
Set atribut file
File System JM-2000/v1.1/12
File Types – name, extension
File Type
Executable
Object
Source code
Usual extension
exe, com, bin or
none
obj, o
Function
ready-to-run machinelanguage program
complied, machine
language, not linked
source code in various
languages
commands to the
command interpreter
textual data documents
Batch
c, p, pas, 177,
asm, a
bat, sh
Text
txt, doc
Word processor
wp, tex, rrf, etc.
Library
lib, a
various word-processor
formats
libraries of routines
Print or view
ps, dvi, gif
ASCII or binary file
Archive
arc, zip, tar
related files grouped
into one file, sometimes
compressed.
File System JM-2000/v1.1/13
Open File Table


Status file open terjadi saat reference pertama
kali pada file dilakukan
OS memelihara suatu tabel mencatat sejumlah
informasi file-file yang open:



File pointer: offset pada file yang akan diakses
File open count: berapa banyak yang meng-open file
tsb
Disk location: lokasi blok pertama file dl disk
File System JM-2000/v1.1/14
Pemanggilan Open File Table


Beberapa sistem memungkinkan open & close
dilakukan secara implisit dari proses (artinya: OS
yang menangani sendiri)
Sebagian sistem mengharuskan proses melakukan pemanggilan system call open/ close
tersebut
File System JM-2000/v1.1/15
Proses Open File Table

Saat pemanggilan open, OS melakukan:



mencari dalam direktori entry yang sesuai dengan
nama yang diberikan
jika belum ada, OS membuat entry baru dalam open
file table dan menyalin informasi dalam directori entry
tsb ke dalam entry open file table yang baru dibuat
me-return ke proses pemaggil pointer entry dalam
open file table untuk digunakan sebagai file handler
dalam setiap operasi berikutnya
File System JM-2000/v1.1/16
Open File Table Dua Level


Dalam lingkungan multiuser operasi open/close
lebih rumit di mana beberapa user dapat mengopen file yang sama pada saat yang bersamaan
OS menggunakan dua level tabel internal


open file table per proses
open file table dari sistem
File System JM-2000/v1.1/17
Open File Table per Proses


Masing-masing proses memiliki tabel sendiri
yang menyimpan informasi dari file-file yang
dipakai
Tabel-tabel per proses ini memiliki pointer ke
open file table sistem
File System JM-2000/v1.1/18
Open File Table dari Sistem

Berisikan informasi yang independen terhadap
proses:


lokasi file dalam disk, tanggal akses, ukuran file
open count: jumlah proses yang sedang mengakses
file
File System JM-2000/v1.1/19
Mekanisme


Jika file sudah diopen oleh suatu proses, proses
lain yang meng-open dilakukan dengan
menambah entry baru pada tabel proses dengan
file pointer baru, dan pointer ke entry ybs dalam
tabel sistem dan open count bertambah satu
Saat eksekusi close, open count berkurang satu
dan bila menjadi 0 maka entry dihapus
File System JM-2000/v1.1/20
Metoda Akses

Sequential Access


Direct Access (random access)


Akses dilakukan dengan satu arah
pembacaan/penulisan (dari awal hingga akhir) jika
ingin mundur maka perlu dilakukan rewind
Akses dilakukan bisa pada posisi mana saja dalam file
Metoda lain


Abstraksi lebih tinggi dari direct access
Index file & relative file
• Tabel Informasi index: record dan pointer ke file direct access.
File System JM-2000/v1.1/21
Access Methods
 Sequential
Access
read next
write next
reset
no read after last write
(rewrite)
 Direct
Access
read n
write n
position to n
read next
write next
rewrite n
n = relative block number
File System JM-2000/v1.1/22
Directory Structure



Directory: A collection of nodes containing
information about all files.
Both the directory structure and the files
reside on disk.
Backups of these two structures are kept
on tapes.
File System JM-2000/v1.1/23
Structure
Directory
Files
F1
F2
F3
F4
Fn
File System JM-2000/v1.1/24
Information in a Device Directory









Name
Type
Address
Current length
Maximum length
Date last accessed (for archival)
Date last updated (for dump)
Owner ID (who pays)
Protection information (discuss later)
File System JM-2000/v1.1/25
Directory Operations






Search for a file
Create a file
Delete a file
List a directory
Rename a file
Traverse the file system
File System JM-2000/v1.1/26
Logical Organizations


Efficiency – locating a file quickly.
Naming – convenient to users.



Two users can have same name for different files.
The same file can have several different names.
Grouping – logical grouping of files by properties,
(e.g., all Pascal programs, all games, …)
File System JM-2000/v1.1/27
Single-Level Directory

A single directory for all users.

Naming problem
Grouping problem

File System JM-2000/v1.1/28
Two-Level Directory

Separate directory for each user.

Path name
Can have the saem file name for
different user
Efficient searching


File System JM-2000/v1.1/29
Tree-Structured Directories
File System JM-2000/v1.1/30
Tree-Structured Directories



Efficient searching
Grouping Capability
Current directory (working directory)


cd /spell/mail/prog
type list
File System JM-2000/v1.1/31
Tree-Structured Directories
 Absolute
or relative path name
 Creating a new file is done in current directory.
 Delete a file
rm <file-name>
 Creating a new subdirectory is done in current
directory.
mkdir <dir-name>
Example: if in current directory /spell/mail
mkdir count
File System JM-2000/v1.1/32
mail
prog
copy prt exp count
“mail”  deleting the entire
subtree rooted by “mail”.
 Deleting
File System JM-2000/v1.1/33
Acyclic-Graph Directories

Have shared subdirectories and files.
File System JM-2000/v1.1/34
Acyclic-Graph Directories (Cont.)


Two different names (aliasing)
If dict deletes list  dangling pointer.
Solutions:



Backpointers, so we can delete all pointers.
Variable size records a problem.
Backpointers using a daisy chain organization.
Entry-hold-count solution.
File System JM-2000/v1.1/35
General Graph Directory
File System JM-2000/v1.1/36
General Graph Directory (Cont.)

How do we guarantee no cycles?



Allow only links to file not subdirectories.
Garbage collection.
Every time a new link is added use a cycle detection
algorithm to determine whether it is OK.
File System JM-2000/v1.1/37
Protection

File owner/creator should be able to control:



what can be done
by whom
Types of access






Read
Write
Execute
Append
Delete
List
File System JM-2000/v1.1/38
UNIX: protection
 Mode
of access: read, write, execute
 Three classes of users
RWX
a) owner access 7
 111
RWX
b) groups access 6
 110
RWX
c) public access 1
 001
 Ask manager to create a group (unique name),
say G, and add some users to the group.
 For a particular file (say game) or subdirectory,
define an appropriate access.
File System JM-2000/v1.1/39
owner
chmod
 Attach
group
761
a group to a file
chgrp
public
game
G
game
File System JM-2000/v1.1/40