Operating Systems II Unit OS8: File System 8.1. Background: File - - PowerPoint PPT Presentation

operating systems ii unit os8 file system 8 1 background
SMART_READER_LITE
LIVE PREVIEW

Operating Systems II Unit OS8: File System 8.1. Background: File - - PowerPoint PPT Presentation

Operating Systems II Unit OS8: File System 8.1. Background: File System Concepts Prof. Dr. Andreas Polze, Andreas Grapentin, Bernhard Rabe Roadmap for Sec.on 8.1 General Concepts - Files and File


slide-1
SLIDE 1

Operating Systems II Unit OS8: File System 8.1. Background: File System Concepts

  • Prof. Dr. Andreas Polze,

Andreas Grapentin, Bernhard Rabe

slide-2
SLIDE 2

2 ¡

Roadmap ¡for ¡Sec.on ¡8.1 ¡

¡

  • General ¡Concepts ¡-­‑ ¡Files ¡and ¡File ¡A<ributes ¡
  • File ¡Opera.ons ¡
  • Directories ¡
  • Linking ¡File ¡Names ¡and ¡File ¡Content ¡
  • File ¡Protec.on ¡
  • Network ¡File ¡Systems ¡
slide-3
SLIDE 3

Registers ¡ Caches ¡ ¡ (L1, ¡L2, ¡L3) ¡ Main ¡Memory ¡ Solid ¡State ¡Disk ¡(+Cache) ¡ Hard ¡Disk ¡Drive ¡(+Cache) ¡ Op.cal ¡Disc ¡ Magne.c ¡Tape ¡(Robot ¡Library) ¡

Memory ¡Hierarchy ¡

Less ¡ More ¡ More ¡ Less ¡ ¡ Vola.le ¡ Non ¡ Vola.le ¡

slide-4
SLIDE 4

Hard ¡Disk ¡

  • Disks, ¡Sides, ¡Tracks, ¡Sectors, ¡Arm ¡with ¡Heads ¡
  • Sectors: ¡ ¡

– hardware-­‑addressable ¡blocks ¡on ¡a ¡storage ¡medium ¡ – Typical ¡sector ¡size ¡on ¡hard ¡disks ¡for ¡x86-­‑based ¡systems ¡is ¡512 ¡bytes ¡

  • Mo.on ¡of ¡disk ¡and ¡arm ¡(to ¡move ¡head) ¡
slide-5
SLIDE 5

File ¡System ¡History ¡

Amiga ¡FFS ¡(1987) ¡ XFS ¡(1994) ¡ HPFS ¡(1988) ¡ ZFS ¡(2004) ¡ CP/M ¡(1973) ¡ QDOS ¡(1977) ¡ FAT12 ¡(1980) ¡ FAT16 ¡(1984) ¡ FAT32 ¡(1996) ¡ + ¡VFAT ¡ MFS ¡(1984) ¡ HFS ¡(1985) ¡ HFS+ ¡(1998) ¡ Berkely ¡FFS ¡(1983) ¡ „UFS“ ¡ ext2 ¡(1993) ¡ ReiserFS ¡(2001) ¡ ext3 ¡(1999) ¡ JFS ¡(1999) ¡ NTFS ¡(1993) ¡ ReFS ¡(2012) ¡

„From ¡BFS ¡to ¡ZFS: ¡past, ¡present, ¡and ¡ ¡ the ¡future ¡of ¡file ¡systems“ ¡by ¡Jeremy ¡Reimer ¡

exFAT ¡(2006) ¡ Files-­‑11-­‑based ¡ ¡ ¡ (ODS-­‑1 ¡1972, ¡ODS-­‑2 ¡ 1979, ¡ODS-­‑5 ¡1998) ¡

slide-6
SLIDE 6

6 ¡

Background: ¡UNIX ¡File ¡Systems ¡

File: ¡

  • Logical ¡storage ¡unit ¡ ¡
  • Unit ¡of ¡abstrac.on: ¡

– Physical ¡proper.es ¡of ¡storage ¡devices ¡are ¡abstracted ¡away ¡ ¡

  • Nonvola.le ¡memory ¡ ¡
  • UNIX ¡files ¡are ¡unstructured ¡text ¡files ¡

– Organized ¡in ¡a ¡directory ¡structure ¡

  • Programs, ¡commands: ¡executable ¡files ¡
slide-7
SLIDE 7

7 ¡

File ¡A<ributes ¡

  • Files ¡are ¡named ¡ ¡

– For ¡the ¡convenience ¡of ¡the ¡human ¡user ¡ – File ¡names ¡are ¡case-­‑sensi.ve ¡

  • File ¡a<ributes ¡typically ¡consist ¡of: ¡

– Name ¡ ¡ – Type ¡(may ¡be ¡used ¡by ¡OS; ¡UNIX ¡does ¡not ¡dis.nguish ¡file ¡types) ¡ ¡ – Loca.on ¡(pointer ¡to ¡device, ¡loca.on ¡on ¡device) ¡ ¡ – Size ¡(current ¡size, ¡possibly ¡maximum ¡size) ¡ – Protec.on ¡(read/write/execute ¡(rwx) ¡rights ¡for ¡users/groups/others) ¡ – Time, ¡date, ¡user ¡id ¡for ¡crea.on/modifica.on/last ¡access ¡ – Owner ¡of ¡a ¡file ¡ ¡

slide-8
SLIDE 8

8 ¡

File ¡Opera.ons ¡

A ¡file ¡is ¡an ¡abstract ¡data ¡type ¡

– Values ¡+ ¡set ¡of ¡applicable ¡opera.ons ¡ – A ¡set ¡of ¡ ¡basic ¡file ¡opera.ons ¡has ¡to ¡be ¡supported ¡by ¡the ¡OS ¡

  • Crea.ng ¡a ¡file ¡

– ¡Allocate ¡space ¡in ¡the ¡file ¡system, ¡generate ¡directory ¡entry ¡

  • Wri.ng ¡a ¡file ¡

– Name ¡of ¡the ¡file ¡and ¡informa.on ¡to ¡be ¡wri<en ¡has ¡to ¡be ¡specified ¡ – System ¡hast ¡to ¡maintain ¡a ¡write ¡pointer ¡for ¡the ¡file ¡

  • Reading ¡a ¡file ¡

– File ¡name ¡and ¡a ¡pointer ¡to ¡memory ¡to ¡receive ¡data ¡has ¡to ¡be ¡specified ¡ – System ¡maintains ¡a ¡read ¡pointer ¡for ¡the ¡file ¡

slide-9
SLIDE 9

9 ¡

File ¡Opera.ons ¡(contd.) ¡

  • Reposi.oning ¡within ¡a ¡file ¡(file ¡seek) ¡

– Directory ¡is ¡searched ¡for ¡the ¡appropriate ¡entry ¡ – Read/write ¡pointers ¡for ¡the ¡file ¡are ¡set ¡to ¡a ¡given ¡value ¡

  • Dele.ng ¡a ¡file ¡

– Release ¡all ¡file ¡space; ¡erase ¡directory ¡entry ¡ – Instead ¡of ¡dele.ng ¡a ¡file, ¡UNIX ¡allows ¡to ¡unlink() ¡files ¡– ¡file ¡is ¡deleted ¡by ¡the ¡ OS ¡if ¡the ¡last ¡link ¡to ¡a ¡file ¡disappears ¡

  • TruncaLng ¡a ¡file ¡

– File ¡a<ributes ¡remain ¡unchanged ¡ – File ¡length ¡is ¡set ¡to ¡zero ¡(or ¡to ¡some ¡specified ¡value) ¡

Read ¡pointer ¡ Write ¡pointer ¡ UNIX ¡supports ¡the ¡„trunca.on-­‑on-­‑close“ ¡ flag ¡to ¡truncate ¡files ¡

Additional ops:

  • Append
  • Rename
  • Set attributes
  • ...
slide-10
SLIDE 10

10 ¡

Obtaining ¡Access ¡to ¡a ¡File ¡

  • Open() ¡system ¡call ¡

– Takes ¡a ¡file ¡name, ¡searches ¡the ¡directory, ¡checks ¡file ¡protec.on ¡ – Copies ¡directory ¡entry ¡into ¡open-­‑file ¡table ¡ – Returns ¡a ¡pointer ¡to ¡the ¡entry ¡in ¡open-­‑file ¡table ¡for ¡subsequent ¡use ¡

  • Close() ¡system ¡call ¡

– Flushes ¡cached ¡file ¡data ¡back ¡to ¡the ¡storage ¡device ¡ – Deletes ¡entry ¡from ¡open-­‑file ¡table ¡ – Frees ¡system ¡resources ¡

  • Opera.on ¡in ¡a ¡mul.user ¡environment ¡

– Per-­‑process ¡and ¡global ¡open-­‑file ¡tables ¡ – System ¡maintains ¡reference ¡counts ¡for ¡opened ¡files ¡

slide-11
SLIDE 11

11 ¡

Directories ¡

  • Record ¡informa.on ¡about ¡groups ¡of ¡files ¡
  • Management ¡of ¡files ¡

– Single-­‑Level ¡directory: ¡most ¡simple; ¡all ¡files ¡in ¡the ¡same ¡directory ¡ – Two-­‑Level ¡directory: ¡separate ¡directory ¡for ¡each ¡user ¡ – Tree-­‑Structured ¡(hierarchical) ¡directories: ¡most ¡common ¡

  • Opera.ons ¡on ¡directories: ¡

– Search ¡for ¡a ¡file ¡ ¡ – Create ¡a ¡file ¡(directory ¡entry) ¡ ¡ – Delete ¡a ¡file ¡(directory ¡entry) ¡ ¡ – List ¡a ¡directory ¡ ¡ – Rename ¡a ¡file ¡ ¡ – Traverse ¡the ¡file ¡system ¡(recursive) ¡ ¡

slide-12
SLIDE 12

12 ¡

UNIX ¡Directories ¡

  • Fully ¡hierarchical, ¡tree-­‑structured ¡
  • Directories ¡are ¡represented ¡as ¡files ¡ ¡

– Problem: ¡Trunca.on ¡ ¡

  • Processes ¡have ¡a ¡current ¡working ¡directory ¡ ¡

– pwd ¡command ¡

  • Each ¡user ¡has ¡a ¡home ¡directory ¡ ¡

– cd; ¡echo ¡$HOME ¡– ¡commands ¡to ¡obtain ¡info ¡about ¡the ¡home ¡dir. ¡

  • The ¡file ¡system ¡has ¡a ¡single ¡root ¡directory ¡ ¡

– cd ¡/ ¡-­‑ ¡command ¡changes ¡working ¡directory ¡to ¡root ¡directory ¡

  • Special ¡names ¡iden.fy ¡neighbors ¡in ¡the ¡directory ¡tree ¡

– ./ ¡-­‑ ¡the ¡current ¡directory ¡ – ../ ¡-­‑ ¡the ¡directory ¡one ¡level ¡above ¡the ¡current ¡directory ¡

slide-13
SLIDE 13

13 ¡

Linking ¡Names ¡and ¡File ¡Content ¡

  • UNIX ¡separates ¡file ¡names ¡and ¡file ¡

content ¡ – file ¡content ¡may ¡have ¡mul.ple ¡ (different) ¡names ¡ – ln ¡command ¡associates ¡new ¡ name ¡with ¡exis.ng ¡file ¡ ¡

  • File ¡content ¡iden.fied ¡by: ¡

– (Device, ¡File ¡system ¡on ¡device, ¡ i-­‑node) ¡ – i-­‑node ¡contains ¡references ¡to ¡all ¡ blocks ¡making ¡up ¡a ¡file ¡ – a ¡free-­‑node ¡list ¡is ¡maintained ¡ for ¡each ¡file ¡system ¡ Informa.on ¡contained ¡in ¡a ¡UNIX ¡i-­‑node ¡

slide-14
SLIDE 14

14 ¡

File ¡Protec.on ¡

  • Access ¡rights ¡can ¡be ¡independently ¡defined ¡for: ¡

– (u) ¡user ¡ ¡– ¡Owner ¡(creator) ¡of ¡a ¡file ¡ ¡ – (g) ¡group ¡ ¡– ¡Group ¡ – (o) ¡other ¡ ¡– ¡all ¡other ¡users ¡of ¡the ¡UNIX ¡system ¡ ¡

  • Example: ¡

luna ¡test ¡( ¡48 ¡)-­‑% ¡ls ¡-­‑lisa ¡ total ¡2 ¡ 421908 ¡ ¡ ¡ ¡1 ¡drwxr-­‑xr-­‑x ¡ ¡ ¡2 ¡ ¡apolze ¡ ¡ ¡ ¡ ¡ ¡1024 ¡ ¡Jan ¡ ¡7 ¡15:06 ¡. ¡ 116884 ¡ ¡ ¡ ¡1 ¡drwxr-­‑xr-­‑x ¡ ¡13 ¡ ¡apolze ¡ ¡ ¡ ¡ ¡ ¡2048 ¡ ¡Jan ¡ ¡7 ¡15:06 ¡.. ¡ 116992 ¡ ¡ ¡ ¡0 ¡-­‑rw-­‑-­‑-­‑-­‑-­‑-­‑-­‑ ¡ ¡ ¡1 ¡ ¡apolze ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡0 ¡ ¡Jan ¡ ¡7 ¡15:05 ¡Mail.txt ¡ 116991 ¡ ¡ ¡ ¡0 ¡-­‑rw-­‑rw-­‑rw-­‑ ¡ ¡ ¡1 ¡ ¡apolze ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡0 ¡ ¡Jan ¡ ¡7 ¡15:05 ¡test.c ¡

slide-15
SLIDE 15

15 ¡

File ¡Protec.on ¡(contd.) ¡

  • Access ¡rights ¡for ¡a ¡file: ¡

– (r) ¡ ¡Read ¡access ¡right; ¡List ¡right ¡for ¡directorisy ¡ – (w) ¡ ¡Write ¡access ¡right; ¡includes ¡delete/append ¡rights ¡ ¡ – (x) ¡ ¡Execute ¡access ¡right; ¡Traverse ¡right ¡for ¡directories ¡

  • Binary ¡representa.on: ¡

– (x): ¡ ¡ ¡Bit ¡0 ¡(+1) ¡ ¡ – (w): ¡ ¡Bit ¡1 ¡(+2) ¡ ¡ – (r): ¡ ¡ ¡Bit ¡2 ¡(+4) ¡ ¡

  • Rights ¡can ¡be ¡combined ¡

– Read+Write ¡access ¡right: ¡6 ¡ ¡ – Read+Execute ¡access ¡right: ¡3 ¡ ¡ – Read-­‑only: ¡2 ¡ ¡

slide-16
SLIDE 16

16 ¡

Distribu.on ¡– ¡Network ¡File ¡Systems ¡

  • Various ¡approaches ¡towards ¡distributed ¡file ¡systems: ¡

– SUN ¡Network ¡File ¡System ¡(Standard) ¡ ¡ – UNIX ¡United ¡ ¡ – Andrew ¡File ¡System ¡ ¡ – Sprite ¡ ¡ – Locus ¡ ¡

  • SUN ¡NFS ¡

– Client/Server-­‑System ¡(based ¡on ¡remote ¡procedure ¡call ¡(RPC)) ¡ – File ¡system ¡opera.ons ¡are ¡forwarded ¡from ¡client ¡to ¡server ¡ ¡ – Server ¡executes ¡actual ¡file ¡system ¡opera.ons, ¡returns ¡results ¡ ¡ – Client ¡has ¡access ¡to ¡remote ¡resources ¡ – Stateless ¡opera.on ¡(Reliability ¡!) ¡

slide-17
SLIDE 17

17 ¡

Opera.on ¡of ¡a ¡Network ¡File ¡System ¡

  • A ¡set ¡of ¡opera.ons ¡is ¡implemented ¡as ¡RPC-­‑callable ¡func.ons: ¡

– Searching ¡for ¡a ¡file ¡in ¡a ¡directory ¡ ¡ – Reading ¡a ¡set ¡of ¡directory ¡entries ¡ ¡ – Manipula.ng ¡links ¡and ¡directories ¡ ¡ – Accessing ¡file ¡a<ributes ¡ ¡ – Reading ¡and ¡wri.ng ¡files ¡ ¡

  • Logical ¡connec.on ¡between ¡client ¡and ¡server ¡has ¡to ¡be ¡established ¡

– mount ¡protocol ¡

  • NFS ¡works ¡in ¡heterogeneous ¡environments ¡

– Machine-­‑independent ¡protocol ¡for ¡data ¡representa.on ¡(XDR) ¡ ¡

  • Stateless ¡protocol ¡

– Network ¡file ¡system ¡may ¡tolerate ¡client ¡crashes ¡(reboots) ¡

slide-18
SLIDE 18

18 ¡

Moun.ng ¡a ¡Remote ¡File ¡System ¡

  • Computer ¡"sun" ¡exports ¡the ¡"/local"-­‑file ¡system ¡to ¡computer ¡"moon" ¡ ¡

Exported ¡to ¡moon ¡ Exported ¡to ¡all ¡computers ¡on ¡the ¡net ¡

slide-19
SLIDE 19

19 ¡

Windows ¡– ¡UNIX ¡File ¡System ¡Interoperability ¡

Windows ¡uses ¡per ¡default ¡the ¡Server ¡Message ¡Block ¡(SMB) ¡protocol ¡to ¡ implement ¡distributed ¡file ¡systems ¡ ¡ SMB/CIFS ¡(remote) ¡resource ¡sharing: ¡

  • Samba ¡– ¡de.samba.org ¡

POSIX ¡libraries/tool ¡chains ¡for ¡Windows ¡API: ¡

  • Cygwin ¡– ¡sources.redhat.com/cygwin/ ¡
  • U/WIN ¡– ¡www. ¡research.a<.com/sw/tools/uwin/ ¡
  • NuTCracker ¡/ ¡MKS ¡Toolkit ¡– ¡www.datafocus.com ¡
  • Interix, ¡SFU ¡– ¡ ¡www.microsor.com/windowsserversystem/sfu/ ¡
slide-20
SLIDE 20

20 ¡

What's ¡Samba ¡all ¡ about? ¡

  • Free SMB and CIFS client/server for UNIX & other OS
  • Func.onality: ¡

– a SMB server, to provide Windows NT and LAN Manager-style file and print services to SMB clients such as Windows, Warp Server, smbfs and others. – a NetBIOS (rfc1001/1002) nameserver, which amongst other things gives browsing support. Samba can be the master browser on your LAN if you wish. – a ftp-like SMB client so you can access PC resources (disks and printers) from UNIX, Netware and other operating systems

slide-21
SLIDE 21

21 ¡

Further ¡Reading ¡

  • Mark ¡E. ¡Russinovich ¡and ¡David ¡A. ¡Solomon, ¡ ¡

Microsor ¡Windows ¡Internals, ¡4th ¡Edi.on, ¡Microsor ¡

Press, ¡2004. ¡

– File ¡System ¡Formats ¡(from ¡pp. ¡689) ¡

¡

  • Abraham ¡Silberschatz, ¡Peter ¡B. ¡Galvin, ¡Opera.ng ¡System ¡

Concepts, ¡John ¡Wiley ¡& ¡Sons, ¡6th ¡Ed., ¡2003; ¡

– Chapter ¡11 ¡-­‑ ¡File-­‑System ¡Interface ¡ – Chapter ¡12 ¡-­‑ ¡File-­‑System ¡Implementa.on ¡ – Chapter ¡16 ¡-­‑ ¡Distributed ¡File ¡Systems ¡