~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File...

33
~FILE SYSTEM~ SUNU WIBIRAMA

Transcript of ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File...

Page 1: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

~FILE SYSTEM~SUNU WIBIRAMA

Page 2: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

OUTLINE

FILE SYSTEM

ACCESS METHODS

DIRECTORY STRUCTURE

FILE SYSTEM MOUNTING

PROTECTION

Page 3: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

EXTERNAL VIEW OF THE FILE MANAGER

Page 4: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

FILE MANAGEMENT

FILE, IS A NAMED AND ORDERED COLLECTION OF INFORMATION

COMPUTER SHOULD BE CONVENIENT TO BE USED

OPERATING SYSTEM HANDLES IT WITH ITS FILE MANAGEMENT FUNCTION

FILE MANAGER’S JOB:- STORING THE INFORMATION ON A DEVICE- MAPPING THE BLOCK STORAGE TO LOGICAL VIEW- ALLOCATING /DEALLOCATING STORAGE- ORGANIZING FILE EFFICIENTLY

Page 5: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

FILE STRUCTURE

File represents program (source and object forms) and data

General file structure: sequence of bits, bytes, lines, or records

Simple record structure:

Lines

Fixed length

Variable length

Complex Structures:

Formatted document

Relocatable load file!

Who decides:

Operating system

Program

Page 6: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

FILE ATTRIBUTES

NAME – ONLY INFORMATION KEPT IN HUMAN-READABLE FORM

IDENTIFIER – UNIQUE TAG (NUMBER) IDENTIFIES FILE WITHIN FILE SYSTEM

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

Page 7: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

FILE OPERATIONS

File is an abstract data type

Create

Write

Read

Reposition within file (FILE SEEK)

Delete

Truncate

Page 8: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

OPEN AND CLOSE FILE

Open(Fi) – search the directory structure on disk for entry Fi,

and move the content of entry to memory. OS provides open-file table to containing information about all open files (no need to search directory structures when a file operation is requested)

Close (Fi) – move the content of entry Fi in memory to directory

structure on disk. Erase the entry in open-file table related to the closed file.

Page 9: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

FILE TYPES

Operating System must recognize the file type in order to operate on the file in reasonable ways.

File types are recognized as an extension : *.exe, *.doc, *.psd, etc.

Page 10: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

ACCESS METHOD (1)

Sequential Access:! - read next! - write next ! - reset! - no read after last write! - rewrite

Page 11: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

ACCESS METHOD (2)

Direct Access (Relative Access):! - no restrictions on the order of read or write

- read n! - write n! - position to n! - read next! - write next ! - rewrite n

! n = relative block number

HOW TO TRANSLATE SEQUENTIAL-ACCESS

ON A DIRECT-ACCESS FILE

Page 12: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

BASIC DISK STRUCTURES

DISK CAN BE SUBDIVIDED INTO PARTITIONS

ENTITY CONTAINING FILE SYSTEM ALSO KNOWN AS VOLUME

DIRECTORY IS LIKE A TABLE OF CONTENTS - RECORDS INFORMATION, SUCH AS NAME, LOCATION, SIZE, TYPE OF ALL FILES IN A VOLUME

Page 13: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

DIRECTORY

SET OF FILES

USED TO ORGANIZE FILES

TREATED AS A FILE, BUT WITH SPECIAL OPERATIONS ON IT:- CREATE A FILE- DELETE A FILE- SEARCH A FILE- LIST A DIRECTORY- RENAME A FILE

Page 14: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

SINGLE-LEVEL DIRECTORY

SINGLE DIRECTORY FOR ALL USERS

IF THE NUMBER OF FILES INCREASES OR MORE THAN ONE USERS --> PROBLEM OCCURES

LENGTH OF FILE NAME LIMITATION: MS-DOS (11) DIFFERS WITH UNIX (255)

Page 15: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

TWO-LEVEL DIRECTORY

SEPARATE DIRECTORY FOR EACH USER

CAN HAVE THE SAME FILE NAME FOR DIFFERENT USER

ISOLATES ONE USER TO THE OTHERS

Page 16: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

TREE-STRUCTURED DIRECTORY

TREE: THE MOST COMMON STRUCTURES

Page 17: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

TREE-STRUCTURED DIRECTORY

Efficient searching

Grouping Capability

Current directory (working directory)

Absolute or relative path name

CURRENT DIRECTORY

ABSOLUTE PATH

RELATIVE PATH

Page 18: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

TREE-STRUCTURED DIRECTORY

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 /mail

! ! mkdir count mail

copy prt exp count

Page 19: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

TREE-STRUCTURED DIRECTORY

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 /mail

! ! mkdir count mail

copy prt exp count

what’s happened, if i execute rm -rf /home?

Page 20: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

ACYCLIC-GRAPH DIRECTORIES

HAVE SHARED SUBDIRECTORIES AND FILES

SHARED FILE

SHAREDSUBDIRECTORY

Page 21: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

ACYCLIC-GRAPH DIRECTORIES

ALIASING: DIFFERENT FILE NAMES FOR SAME FILE

A POINTER TO SHARED FILE IS NAMED LINK

DELETION PROBLEM, IF THE SHARED SUBDIRECTORY “LIST” IS DELETED, WE HAVE DANGLING POINTER

SYMBOLIC LINKS: - IF LINK IS DELETED, PRESERVE THE ORIGINAL FILE- IF ORIGINAL FILE IS DELETED, ACCESS TO THE DELETED FILE USING LINKS IS TREATED AS ILLEGAL ACCESS.

NON-SYMBOLIC LINKS (HARD LINKS):- PRESERVE THE FILE UNTIL ALL REFERENCES TO IT ARE DELETED- KEEP ONLY A COUNT OF THE NUMBER OF REFERENCES. WHEN THE COUNT = 0, FILE CAN BE DELETED BECAUSE NO REFERENCE TO IT.

Page 22: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

GENERAL GRAPH DIRECTORY

How do we guarantee no cycles?

Allow only links to file not subdirectories

Garbage collection: detect when the last reference has been deleted

Every time a new link is added use a cycle detection algorithm to determine whether it is OK, but it’s computationally expensive

Page 23: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

ACYCLIC-GRAPH DIRECTORIES

LINK IN UBUNTU LINUX 10.10

Page 24: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

FILE SYSTEM MOUNTING

(A) MOUNTED (B) UNMOUNTED MOUNTED

you can see how it works on unix, instead of windows

Page 25: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

FILE SYSTEM MOUNTING

SOMETIMEYOU SHOULD

DEFINE THE TYPE OF YOUR MOUNTED FILE SYSTEM

BEFORE MOUNTING

Mount point: /mnt/public

AFTERMOUNTING

Page 26: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

FILE SYSTEM MOUNTING

Automatic mounting on booting: /etc/fstab

mounted file mount point file system type

Page 27: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

FILE SHARING

Multiple users: problem arises on file sharing, file naming, and file protection

Add more attributes to file and directory

Most systems use concept of OWNER and GROUP

User IDs identify users, allowing permissions and protections to be per-user

Group IDs allow users to be in groups, permitting group access rights

We will elaborate on the last section : PROTECTION

Page 28: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

REMOTE FILE SHARING

Uses networking to allow file system access between systems

Manually via programs like FTP

Automatically, seamlessly using distributed file systems

Semi automatically via the world wide web

Client-server model allows clients to mount remote file systems from servers

Server can serve multiple clients

Client and user-on-client identification is insecure or complicated

NFS is standard UNIX client-server file sharing protocol

CIFS is standard Windows protocol

Standard operating system file calls are translated into remote calls

Distributed Information Systems (distributed naming services) such as LDAP, DNS, NIS, Active Directory implement unified access to information needed for remote computing

Page 29: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

PROTECTION

Keep the file safe from physical damage (reliability) and improper access (protection)

File owner/creator should be able to control:

what can be done

by whom

Types of access

Read

Write

Execute

Append

Delete

List

Page 30: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

PROTECTION

Field Meaning

- File type / directory

rw-r--r-- Permission

1 Hard link number to file

sunu owner of file

sunu group of file

323 file size in byte

2010-11-18 13:55 modification date

execute.txt file name

Owner (o)Group (g)

Public/Universe (p)

-rwxr-x---

file [o] [g] [p]

Page 31: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

PROTECTION

Mode of access and octal: read (r = 4), write (w = 2), execute (x = 1)

Three classes of users! ! ! ! ! RWX! ! a) owner access ! 7! ⇒! 1 1 1

! ! ! ! RWX! ! b) group access ! 6! ⇒! 1 1 0! ! ! ! ! RWX! ! c) public access ! 1! ⇒! 0 0 1

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.

owner group public

chmod 761 game

Attach a group to a file: chgrp G game

Page 32: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

PROTECTION

ACCESS CONTROL LIST IN WINDOWS XP

ADMIN USERS

Page 33: ~FILE SYSTEM~te.ugm.ac.id/~wibirama/tif206/01/ch11/ch11-presentation.pdf · FILE STRUCTURE File represents program (source and object forms) and data General file structure: sequence

/EOFend of file