8/9/2019 File system organization and implementation
1/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.1
REAL TIME OPERATING SYSTEMS
Lesson-7:
File System Organization and
Implementation
8/9/2019 File system organization and implementation
2/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.2
1. File1. File
8/9/2019 File system organization and implementation
3/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.3
FileFile
a named entity on a magnetic disc, or
optical disc, or system memory or
memory stick
contains has the data, characters and text
8/9/2019 File system organization and implementation
4/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.4
i) Afile may be a named entity that is a
structured record named entity as on a disk,
which has having random access in the
system.
ii) May be a structured record on a RAM
analogous to a disk and may also be either
called separately called as RAM disk orsimply ,simply, as a file itself (virtual
device).
OSes differing abstractions of a fileOSes differing abstractions of a file
8/9/2019 File system organization and implementation
5/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.5
(iii) May be an unstructured record of bits
or bytes.
(iv) Afile device may be a pipe -like device
OSes differing abstractions of a fileOSes differing abstractions of a file
8/9/2019 File system organization and implementation
6/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.6
2. File organization in a file system2. File organization in a file system
8/9/2019 File system organization and implementation
7/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.7
File is organized in a way according to a file
system, which has set of command
functions for operations on the file
File organization in a systemFile organization in a system
8/9/2019 File system organization and implementation
8/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
8
Standard set of interfacesStandard set of interfaces
Should a file having integers differ from a
file having bytes?
Should a file having bytes differ from file
having characters?
Due to the differing approaches to device
and file management interfaces, the
development of a set of standard interfacesmust.
Then only then can systems can be portable.
8/9/2019 File system organization and implementation
9/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
9
Two type of file systemsTwo type of file systemsBlock FileBlock File
SystemSystem
Block File System. Its application generates
records to be saved into the memory.
First structured into a suitable format and
then translated into block-streams.
A file pointer (record) points to a block
from the start to the end of the file.
8/9/2019 File system organization and implementation
10/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
10
Two type of file systemsTwo type of file systemsByte Stream FileByte Stream File
SystemSystem
Byte Stream File-System. Its application
generates record stream.
Stream are to be saved into the memory.
These are first structured into a suitable
format and then translated into byte-stream.
A file pointer (byte index) points to a byte
from the start index = 0 to N-1 in a file of Nbytes
8/9/2019 File system organization and implementation
11/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
11
POSIXPOSIX
A standard set of interfaces.
File operations are as the operations on a
linear sequence of bytes
8/9/2019 File system organization and implementation
12/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
12
POSIXPOSIX
POSIX stands for Portable Operating
System Interface IEEE standard for coding
the programs when using the multiple
threads.
The X after I is because of the interfaces
being similar to ones in UNIX like.
It is according to the definitions at A T & TUNIX System V Interface.
8/9/2019 File system organization and implementation
13/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
13
open ( )
write ( ) in the byte stream at the present
pointer position
read ( ) from the byte stream present pointer
position
lseek (List seek) or set the file pointer in the
byte stream
fcntl ( )
close ( )
Set of Command Functions in theSet of Command Functions in the
POSIX File SystemPOSIX File System
8/9/2019 File system organization and implementation
14/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
14
UNIX and LINUX File SystemsUNIX and LINUX File Systems
Unix has a structured file system with an
unstructured hardware interface.
Linux supports different standard file-
systems for the system
8/9/2019 File system organization and implementation
15/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
15
File DeviceFile Device
File devices are block devices in UNIX.
Linux permits the use of a block devices as
a char devices also. This is because between
block-device to char-device, Linux has an
additional interface.
Kernel interface is identical for the char and
block devices in Linux and not in UNIX.
8/9/2019 File system organization and implementation
16/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
16
RAM diskRAM disk
File on the RAM that is hierarchically
organized is is known as RAM disk.
RAM memory storage is analogous to that
on the disk and accessing is also analogous
to a disk.
For example, path for accessing a file is
directory, then subdirectory, then folder andthen subfolder. There is hierarchical tree
like filing organisation
8/9/2019 File system organization and implementation
17/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
17
3. File descriptor3. File descriptor
8/9/2019 File system organization and implementation
18/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
18
File descriptorFile descriptor fd fd
An integer, which returns on opening a file
and which points to a data structure.
8/9/2019 File system organization and implementation
19/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
19
File describing data structureFile describing data structure
Identity
Creator or Owner
State
Locks and Protection fields
file Info
Sharing Permission
Count
Storing Media Details
8/9/2019 File system organization and implementation
20/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
20
SummarySummary
8/9/2019 File system organization and implementation
21/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
21
We learntWe learnt
File Manager has functions to create, open,reads, seek a record, write, and close a file.
A file has a file descriptor.
8/9/2019 File system organization and implementation
22/22
2008 Chapter-8 L7: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
22
End of Lesson 7 of Chapter 8End of Lesson 7 of Chapter 8