1 File Processing : File Organization and File Systems 2015, Spring Pusan National University Ki-Joune Li
STEMPNU 2 Logical Structure of File File Field Record (Tuple) Record Block Fixed Size Record Variable Size Record
STEMPNU 3 Fixed Size Record Fixed Size Fixed Number of Fields, and Fixed Size of each Field Easy to implement Disk Address (n-1)*s record Deletion of a record Like Array but no movement Free Record List or Pointer to Next Record
STEMPNU 4 Variable Length Record Variable Length due to Variable Number of Fields, or Variable Size of each Field Complicated to implement Implementation Delimiter (, size, or pointer) Slotted Page Fixed Length Overflow Area Reserved Space
STEMPNU 5 Delimiters Record … … Delimiters Record … … Pointer/Size Difficult to handle deletions and insertions
STEMPNU 6 Slotted Page n Records can be moved around within a page to keep them contiguous with no empty space between them entry in the header must be updated. n Records can be moved around within a page to keep them contiguous with no empty space between them entry in the header must be updated. n Pointers should not point directly to record But to the entry for the record in header. n Pointers should not point directly to record But to the entry for the record in header. Pointer to Record
STEMPNU 7 Reserved Space Maximum # of Fields
STEMPNU 8 Overflow Area First field of record Rest records
STEMPNU 9 Binary Large Object Block (BLOB) If size (field) > size (block) e.g. Image or Video BLOB : Type of field where its size is greater than block size cf. CLOB : Text rather than binary Name ID# Photo Block size Name ID# Contiguous Reserved Block for BLOB
STEMPNU 10 File System Example fd=open(”data.txt”,O_RDONLY,0); Nbytes=read(fd,buf,100); How to process these functions in OS ?
STEMPNU 11 i (index)–node : information about file Attributes Pointers to data block i-node Data Block Name Permission Ownership Last updated date/time Created date/time Type : directory, data, special
STEMPNU 12 i-node : Pointer to data block Attributes Pointers to data block (0-9: up to 40K bytes) Pointers to data block (0-9: up to 40K bytes) Single direct Pointer Data Block... Data Block... Data Block Pointer Block (1024 blocks) Pointer Block (1024 blocks) Double direct Pointer
STEMPNU 13 Block configuration for i-node Boot Block Super Block 0 1 i-node 1 ~ 40 i-node 41 ~ 80 … … 2 3 Data block … … Reserved Block Given by formatting User space
STEMPNU 14 Implementation of File Hierarchy Attributes i-node 6 Attributes i-node 1 i-node for root directory i-node for /usr Attributes i-node Root directory block bin dev lib etc usr tmp Directory block for /usr.... lik kimmk parksh i-node for /usr/lik Directory block for /usr/lik.... data.txt Data block for /usr/lik/data.txt Attributes i-node 107 i-node for /usr/lik/data.txt
STEMPNU 15 FAT (File Allocation Table) DOS or MS-Windows 98 Same purpose of i-node in UNIX
STEMPNU 16 fd=open(”data.txt”,O_RDONLY,0); Nbytes=read(fd,buf,100); Step 1 : Find i-node for “data.txt” via i-node from root or current directory Step 2 : Check owner and access right Step 3 : Register it to OpenFileTable Initialize entry values : e.g. offset, mode fd : array index of this table Some entries : reserved for stdio, stderr, etc.. Step 4 : Check ownership and right Step 5 : Read 100 bytes to buf Read 100 bytes from the OpenFileTable[fd].offset OpenFileTable[fd].offset += 100; open write