Title: File Processing : File Organization and File Systems
1File Processing File Organization and File
Systems
- 2008, Spring
- Pusan National University
- Ki-Joune Li
2Logical Structure of File
File
Field
Field
Field
Record (Tuple)
Record
Record
Block
3Fixed Size Record
- Fixed Size
- Fixed Number of Fields, and
- Fixed Size of each Field
- Easy to implement
- Disk Address
- (n-1)srecord
- Deletion of a record
- Like Array but no movement
- Free Record List or
- Pointer to Next Record
4Variable 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
5Delimiters
Record
Record
Record
Record
Record
Record
- Difficult to handle deletions and insertions
6Slotted Page
- 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.
- Pointers should not point directly to record
- But to the entry for the record in header.
7Reserved Space
8Overflow Area
9Binary Large Object Block (BLOB)
- If size (field) gt 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
10File System
- Example
- fdopen(data.txt,O_RDONLY,0)
- Nbytesread(fd,buf,100)
- ? How to process these functions in OS ?
11i (index)node information about file
Name
Type directory, data, special
Permission
Ownership
Last updated date/time
Created date/time
12i-node Pointer to data block
Attributes
Pointers to data block (0-9 up to 40K bytes)
Single direct Pointer
Double direct Pointer
13Block configuration for i-node
Boot Block
0
Reserved Block
Super Block
1
User space
14Implementation of File Hierarchy
i-node for root directory
i-node for /usr
i-node for /usr/lik
15FAT (File Allocation Table)
- DOS or MS-Windows 98
- Same purpose of i-node in UNIX
16fdopen(data.txt,O_RDONLY,0)Nbytesread(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 OpenFileTablefd.offset
- OpenFileTablefd.offset 100