1 file processing : file organization and file systems 2015, spring pusan national university...
TRANSCRIPT
![Page 1: 1 File Processing : File Organization and File Systems 2015, Spring Pusan National University Ki-Joune Li](https://reader035.vdocuments.us/reader035/viewer/2022062519/5697bff11a28abf838cbb30c/html5/thumbnails/1.jpg)
1
File Processing : File Organization and File Systems
2015, Spring
Pusan National University
Ki-Joune Li
![Page 2: 1 File Processing : File Organization and File Systems 2015, Spring Pusan National University Ki-Joune Li](https://reader035.vdocuments.us/reader035/viewer/2022062519/5697bff11a28abf838cbb30c/html5/thumbnails/2.jpg)
STEMPNU
2
Logical Structure of File
FileFile
FieldField FieldField FieldField
Record (Tuple)Record (Tuple)
RecordRecord
RecordRecord
BlockBlock
Fixed Size RecordFixed Size Record
Variable Size RecordVariable Size Record
![Page 3: 1 File Processing : File Organization and File Systems 2015, Spring Pusan National University Ki-Joune Li](https://reader035.vdocuments.us/reader035/viewer/2022062519/5697bff11a28abf838cbb30c/html5/thumbnails/3.jpg)
STEMPNU
3
Fixed 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
![Page 4: 1 File Processing : File Organization and File Systems 2015, Spring Pusan National University Ki-Joune Li](https://reader035.vdocuments.us/reader035/viewer/2022062519/5697bff11a28abf838cbb30c/html5/thumbnails/4.jpg)
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
![Page 5: 1 File Processing : File Organization and File Systems 2015, Spring Pusan National University Ki-Joune Li](https://reader035.vdocuments.us/reader035/viewer/2022062519/5697bff11a28abf838cbb30c/html5/thumbnails/5.jpg)
STEMPNU
5
Delimiters
RecordRecord RecordRecord …… RecordRecord
DelimitersDelimiters
RecordRecord RecordRecord …… RecordRecord
Pointer/SizePointer/Size
• Difficult to handle deletions and insertions
![Page 6: 1 File Processing : File Organization and File Systems 2015, Spring Pusan National University Ki-Joune Li](https://reader035.vdocuments.us/reader035/viewer/2022062519/5697bff11a28abf838cbb30c/html5/thumbnails/6.jpg)
STEMPNU
6
Slotted 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.
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.
Pointers should not point directly to record
But to the entry for the record in header.
Pointer to Record Pointer to Record
![Page 7: 1 File Processing : File Organization and File Systems 2015, Spring Pusan National University Ki-Joune Li](https://reader035.vdocuments.us/reader035/viewer/2022062519/5697bff11a28abf838cbb30c/html5/thumbnails/7.jpg)
STEMPNU
7
Reserved Space
Maximum # of FieldsMaximum # of Fields
![Page 8: 1 File Processing : File Organization and File Systems 2015, Spring Pusan National University Ki-Joune Li](https://reader035.vdocuments.us/reader035/viewer/2022062519/5697bff11a28abf838cbb30c/html5/thumbnails/8.jpg)
STEMPNU
8
Overflow Area
First field of recordFirst field of record
Rest recordsRest records
![Page 9: 1 File Processing : File Organization and File Systems 2015, Spring Pusan National University Ki-Joune Li](https://reader035.vdocuments.us/reader035/viewer/2022062519/5697bff11a28abf838cbb30c/html5/thumbnails/9.jpg)
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
NameName ID#ID# Photo Photo
Block sizeBlock size
NameName ID#ID#Contiguous Reserved
Block for BLOBContiguous Reserved
Block for BLOB
![Page 10: 1 File Processing : File Organization and File Systems 2015, Spring Pusan National University Ki-Joune Li](https://reader035.vdocuments.us/reader035/viewer/2022062519/5697bff11a28abf838cbb30c/html5/thumbnails/10.jpg)
STEMPNU
10
File System
Example fd=open(”data.txt”,O_RDONLY,0);
Nbytes=read(fd,buf,100);
How to process these functions in OS ?
![Page 11: 1 File Processing : File Organization and File Systems 2015, Spring Pusan National University Ki-Joune Li](https://reader035.vdocuments.us/reader035/viewer/2022062519/5697bff11a28abf838cbb30c/html5/thumbnails/11.jpg)
STEMPNU
11
i (index)–node : information about file
AttributesAttributesPointers to data blockPointers to data block
i-node
Data BlockData Block
NameName
PermissionPermissionOwnershipOwnershipLast updated date/timeLast updated date/timeCreated date/timeCreated date/time
Type : directory, data, specialType : directory, data, special
![Page 12: 1 File Processing : File Organization and File Systems 2015, Spring Pusan National University Ki-Joune Li](https://reader035.vdocuments.us/reader035/viewer/2022062519/5697bff11a28abf838cbb30c/html5/thumbnails/12.jpg)
STEMPNU
12
i-node : Pointer to data block
AttributesAttributes
Pointers to data block(0-9: up to 40K bytes)Pointers to data block(0-9: up to 40K bytes)
Single direct PointerSingle direct Pointer
Data BlockData Block
. . .. . .
Data BlockData Block
Data BlockData Block
. . .. . .
Data BlockData Block
Pointer Block(1024 blocks)Pointer Block(1024 blocks)
Double direct PointerDouble direct Pointer
![Page 13: 1 File Processing : File Organization and File Systems 2015, Spring Pusan National University Ki-Joune Li](https://reader035.vdocuments.us/reader035/viewer/2022062519/5697bff11a28abf838cbb30c/html5/thumbnails/13.jpg)
STEMPNU
13
Block configuration for i-node
Boot BlockBoot BlockSuper BlockSuper Block
0
1
i-node 1 ~ 40i-node 1 ~ 40i-node 41 ~ 80i-node 41 ~ 80……
2
3
Data blockData blockData blockData block……Data blockData block
Reserved Block
Given by formatting
User space
![Page 14: 1 File Processing : File Organization and File Systems 2015, Spring Pusan National University Ki-Joune Li](https://reader035.vdocuments.us/reader035/viewer/2022062519/5697bff11a28abf838cbb30c/html5/thumbnails/14.jpg)
STEMPNU
14
Implementation of File Hierarchy
AttributesAttributes
i-node 6
AttributesAttributes
i-node 1
i-node for root directory
i-node for /usr
AttributesAttributes
i-node 19
11
11
44
77
1414
Root directoryblock
99
66
88
..
....
binbin
devdev
liblib
etcetc
usrusr
tmptmp
66
11
1919
3030
5454
Directory block for /usr
..
....
liklik
kimmkkimmk
parkshparksh
i-node for /usr/lik
1919
66
107107
Directory block for /usr/lik
..
....
data.txtdata.txt
Data block for /usr/lik/data.txt
AttributesAttributes
i-node 107
i-node for /usr/lik/data.txt
![Page 15: 1 File Processing : File Organization and File Systems 2015, Spring Pusan National University Ki-Joune Li](https://reader035.vdocuments.us/reader035/viewer/2022062519/5697bff11a28abf838cbb30c/html5/thumbnails/15.jpg)
STEMPNU
15
FAT (File Allocation Table)
DOS or MS-Windows 98 Same purpose of i-node in UNIX
![Page 16: 1 File Processing : File Organization and File Systems 2015, Spring Pusan National University Ki-Joune Li](https://reader035.vdocuments.us/reader035/viewer/2022062519/5697bff11a28abf838cbb30c/html5/thumbnails/16.jpg)
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