Filing system (Explorer, graphic) 13: Files and Data CL1 2002/3-13 - - PDF document

filing system explorer graphic 13 files and data
SMART_READER_LITE
LIVE PREVIEW

Filing system (Explorer, graphic) 13: Files and Data CL1 2002/3-13 - - PDF document

Filing system (Explorer, graphic) 13: Files and Data CL1 2002/3-13 1 CL1 2002/3-13 2 Filing System (schematic) Filing System Sometimes necessary to give path C:\ A:\ Path is a full text name & address of item Item


slide-1
SLIDE 1

CL1 2002/3-13 1

13: Files and Data

CL1 2002/3-13 2

Filing system (Explorer, graphic)

CL1 2002/3-13 3

Filing System (schematic)

cl1\ lect1\ lect2\ lect3\ prac1\ slide1.ppt note1.doc PI\ A:\ Todays_lect.lnk C:\

CL1 2002/3-13 4

Filing System

  • Sometimes necessary to give path
  • Path is a full text ‘name & address’ of item
  • Item could be file, device, port …
  • Path may be absolute or relative
  • Path may start with machine or volume

name

  • Path separator will be operating system

specific ( \ or / most common)

CL1 2002/3-13 5

Paths

  • fred.doc
  • Cl1h/notes/term1/week4.doc
  • ../fred.doc
  • “C:\My Documents\slides1.ppt”
  • \\printserver\lj_towerlab
  • ~jhb/export/cs/index.txt
  • personal:downloads:demosingle.mp3
  • http://www.dcs.ed.ac.uk/teaching/cl1/www

CL1 2002/3-13 6

Storing Files: Filing systems

  • Data is stored in blocks of typically 512 bytes
  • Each is numbered; a file can occupy many blocks.
  • Each block leads on to the next one
  • A “Table of Contents” at the start of the disk

contains the name and 1st block of each file.

  • Windows stores files slightly differently but the

table of contents is called the FAT

  • (There are many ways of organising a filing system)
slide-2
SLIDE 2

CL1 2002/3-13 7

A basic filing system

File1 1 File2 4 File3 7 2 3 5 6 8 Block 1 2 3 4 5 6 7 8 … Table of contents

CL1 2002/3-13 8

Fragmentation

  • Moving a disk read head is (relatively) slow
  • Files are accessed fastest when the blocks are

contiguous (all together) and the head doesn’t have to move far

  • Fragmentation is a process where parts of files are

scattered over the disk and reduces efficiency and disk eventually needs defragmentation

– As follows…

CL1 2002/3-13 9

Fragmentation

File_a b file_c d file_e f file_g Delete b, d and f: Add new file h, length 3 blocks: Repeated deletion and addition of files leaves disk fragmented

CL1 2002/3-13 10

Filing system + free list

File1 1 File2 4 2 3 5 6 8 Block 1 2 3 4 5 6 7 8 … Free 7 Table of contents Delete File3

CL1 2002/3-13 11

Free block list and non-deletion

  • All blocks not in use are linked together in a

special file called the free block list.

  • To delete a file all you need to do is:

– Transfer the blocks to the free block list – Remove the file entry from the table of contents

  • This does not destroy the data in the file
  • Such files can easily be undeleted
  • Remember this when giving a disk to someone else

CL1 2002/3-13 12

Formatting disk for initial use

  • Low-level formatting writes empty blocks of the right

characteristics on the disk.

  • Partitioning designates areas for file systems
  • (High-level) formatting writes an empty filing

system on the disk partition, e.g.

  • Formatting a disk need not destroy files beyond

recovery either

Free 1 All blocks in the partition

slide-3
SLIDE 3

CL1 2002/3-13 13

The file locking problem

  • An update is a read then a write
  • “A” reads item
  • “B” reads item
  • “A” writes back updated item
  • “B” writes back differently updated item
  • “A”’s update is lost
  • Careful design of ‘atomic’ transactions

CL1 2002/3-13 14

Image files

  • Grid of pixels
  • Each has to represent a colour
  • Colour is defined by proportions of Red, Green

and Blue (RGB)

  • Describe each of R,G,B accurate to 1 part in 256
  • Each pixel needs 3 bytes = 24 bits
  • Full screen @ 800*600 requires 1.44 Mbytes
  • 3-5 minutes @ 56Kbits/sec (modem line)

CL1 2002/3-13 15

Colour maps and LUTs

  • A diagram or slide could have only a few colours
  • Rather than represent each pixel by 3 bytes, keep a

lookup-table (LUT) or colour map of colours and for each pixel store the index in that table

  • Similar process used in video cards and

applications; only so many colours can be displayed at once

  • (can get strange effects when different

applications are using different colour maps)

CL1 2002/3-13 16

Data Compression

  • Full-screen Web page

– PC screen: 800*600 * 3 = 1.44 Mbytes – @ 56 Kbit/sec modem = about 4 minutes.

  • Videoconference link (NetMeeting)

– Image: 160 * 128 * 1 = 20Kbytes – @ 56 Kbit modem = 1 frame / 3 secs

  • Doesn’t happen (!); what’s going on?
  • Data Compression

CL1 2002/3-13 17

Image: 11 * 11 = 121 pixels. Transmit (no encoding): width=11,height=11, data= 0,0,0, … 0,1,0 … 0,1,0 … 0,0,1,1,1,1,1,1,1,0,0 … = 123 pieces of real information (width, height, 121 pixel values) Transmit (with run-length encoding): width=11,height=11, 0(27),1(1), 0(10), 1(1), 0(10), … =32 pieces of real information (width, height, 15 * (value * length)) Simple run-length encoding

Run-length encoding

CL1 2002/3-13 18

File and Image Compression

  • (see Compression slide)
  • Run-length encoding
  • Inefficient if no runs, e.g.

– 1234 1234 1234 1234 …

  • Better techniques
slide-4
SLIDE 4

CL1 2002/3-13 19

Compression

  • Saves transmission time and space
  • Lossless: Can recover original data exactly

– Data, text, executable program – E.g. Lempel-Ziv (used by Zip programs)

  • Lossy: Information is lost

– Pictures of real world; video link; MP3 music – Only care that it is good enough. Specify quality – E.g. JPEG, MPEG

CL1 2002/3-13 20

BSTW Compression (lossless)

  • File is read word by word
  • Once read, words are put in a table
  • Words that repeat are referred to by their

position in the table

  • Table position is adjusted on-the-fly to put

frequent words at the top (shorter reference)

  • Compression & decompression programs

both know the rules by which this is done

CL1 2002/3-13 21

File and Image Compression

  • Simple run-length encoding

– Lossless; not very efficient for images (no runs)

  • GIF – Lempel-Ziv encoding

– Lossless; can be very efficient

  • JPEG

– Lossy (losses increase each time it is rewritten) – Have trade-off: quality v. compression

CL1 2002/3-13 22

Teddy bears

CL1 2002/3-13 23

Teddy Bears

CL1 2002/3-13 24

Choice of image formats

  • JPG

– Lossy; Ideal for real-world images, pictures

  • BMP

– Degree of compatibility with Windows

  • GIF

– Lossless; max 256 colours; Diagrams, clip art

  • TIFF

– Lossless; good colour rendition (24-bit) ‘reference’ format – browsers won’t handle it; large files

  • Kodak Photo-CD

– Filing system+format; picture stored at several resolutions

slide-5
SLIDE 5

CL1 2002/3-13 25

Other formats

  • MPEG, AVI, QuickTime – video
  • MP3, WAV – music and sound
  • DXF – AutoCAD drawing exchange
  • CSV – Comma Separated Variable

– spreadsheet, database, any simple tables

  • CODECS – on-the-fly coder/decoders for

real-time video

CL1 2002/3-13 26

Single (private) key encryption (DES)

Encrypt Original message … LòceŷeOjz91 … Send as attachment Decrypt Original message Sender’s Key

Key is weak spot – has to be sent to recipient somehow

Sender’s Key Sender Recipient

CL1 2002/3-13 27

Dual (public) key encryption (PGP)

Encrypt Original message … LòceŷeOjz91 … Send as attachment Decrypt Original message Recipient’s Public Key

Public key is weak point – could be compromised. Key- signing parties guard against this

Recipient’s Private Key (no contact) Sender Recipient

CL1 2002/3-13 28

Public Key encryption (e.g. PGP)

  • I publish public key that encrypts only
  • You use my public key to encrypt and send me

encrypted file

  • I use my associated private key to decrypt it
  • Limitation: Can’t publish a single encrypted

document for all to read

  • Key-signing parties: People get together and

validate each other’s keys; validation is part of key

CL1 2002/3-13 29

Key Points

  • Filing system – blocks; how they’re linked
  • Formatting, fragmentation, free list
  • Why deleting file doesn’t wipe data
  • Colours – RGB
  • Choice of image file formats
  • Lossy and lossless data compression
  • Encryption and vulnerability