Files. File Structure. File Systems. Structure Terms. File Management System. Chapter 12 File Management 12/6/2018

Similar documents
CSC 553 Operating Systems

Chapter 12. File Management

File Management. Chapter 12

Table 12.2 Information Elements of a File Directory

DATA STRUCTURES USING C

File Management. Ezio Bartocci.

File Management. Marc s s first try, Please don t t sue me.

Introduction to OS. File Management. MOS Ch. 4. Mahmoud El-Gayyar. Mahmoud El-Gayyar / Introduction to OS 1

Chapter 11. I/O Management and Disk Scheduling

File Management. COMP3231 Operating Systems

OPERATING SYSTEM. Chapter 12: File System Implementation

Chapter 11: Implementing File Systems

makes floppy bootable o next comes root directory file information ATTRIB command used to modify name

Introduction. Secondary Storage. File concept. File attributes

Chapter 11: Implementing File-Systems

Secondary Storage (Chp. 5.4 disk hardware, Chp. 6 File Systems, Tanenbaum)

File Management. COMP3231 Operating Systems

CHAPTER 11: IMPLEMENTING FILE SYSTEMS (COMPACT) By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

CS370 Operating Systems

File System CS170 Discussion Week 9. *Some slides taken from TextBook Author s Presentation

Chapter 11: Implementing File

Chapter 12: File System Implementation

Advanced Operating Systems

Chapter 11: Implementing File Systems. Operating System Concepts 9 9h Edition

File Systems. What do we need to know?

Chapter 10: File System Implementation

Chapter 11: File System Implementation. Objectives

File Systems. File system interface (logical view) File system implementation (physical view)

Example Implementations of File Systems

File System Implementation

Operating Systems. Lecture File system implementation. Master of Computer Science PUF - Hồ Chí Minh 2016/2017

File System Internals. Jo, Heeseung

OPERATING SYSTEMS II DPL. ING. CIPRIAN PUNGILĂ, PHD.

Chapter 12 File-System Implementation

UNIX File Systems. How UNIX Organizes and Accesses Files on Disk

CS370 Operating Systems

Chapter 12: File System Implementation. Operating System Concepts 9 th Edition

Typical File Extensions File Structure

Windows File System. File allocation table (FAT) NTFS - New Technology File System. used in Windows 95, and MS-DOS

CS3600 SYSTEMS AND NETWORKS

Chapter 11: Implementing File Systems. Operating System Concepts 8 th Edition,

Chapter 12: File System Implementation

FILE SYSTEMS. CS124 Operating Systems Winter , Lecture 23

SMD149 - Operating Systems - File systems

Da-Wei Chang CSIE.NCKU. Professor Hao-Ren Ke, National Chiao Tung University Professor Hsung-Pin Chang, National Chung Hsing University

File System Concepts File Allocation Table (FAT) New Technology File System (NTFS) Extended File System (EXT) Master File Table (MFT)

NTFS Recoverability. CS 537 Lecture 17 NTFS internals. NTFS On-Disk Structure

Chapter 11: Implementing File Systems

File System Case Studies. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Chapter 12: File System Implementation

File System: Interface and Implmentation

Motivation. Operating Systems. File Systems. Outline. Files: The User s Point of View. File System Concepts. Solution? Files!

Chapter 4 File Systems. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

Disks and I/O Hakan Uraz - File Organization 1

File System Internals. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

File System Implementation. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

There is a general need for long-term and shared data storage: Files meet these requirements The file manager or file system within the OS

V. File System. SGG9: chapter 11. Files, directories, sharing FS layers, partitions, allocations, free space. TDIU11: Operating Systems

ECE 598 Advanced Operating Systems Lecture 18

Lecture 19: File System Implementation. Mythili Vutukuru IIT Bombay

Disk divided into one or more partitions

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

COMP 530: Operating Systems File Systems: Fundamentals

Filesystem. Disclaimer: some slides are adopted from book authors slides with permission 1

Chapter 8 Virtual Memory

Week 12: File System Implementation

MEMORY MANAGEMENT/1 CS 409, FALL 2013

Operating Systems. Week 9 Recitation: Exam 2 Preview Review of Exam 2, Spring Paul Krzyzanowski. Rutgers University.

Long-term Information Storage Must store large amounts of data Information stored must survive the termination of the process using it Multiple proces

Chapter 11: Implementing File Systems

CS370 Operating Systems

Filesystem. Disclaimer: some slides are adopted from book authors slides with permission

Computer Systems Laboratory Sungkyunkwan University

Outlook. File-System Interface Allocation-Methods Free Space Management

EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)

Chapter 11: File System Implementation

File System Implementation

Operating Systems 2010/2011

Glossary. The target of keyboard input in a

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

File System Code Walkthrough

Chapter 11: File System Implementation

UNIX File System. UNIX File System. The UNIX file system has a hierarchical tree structure with the top in root.

File Systems: Fundamentals

CS307: Operating Systems

Chapter 11: Implementing File Systems

File System Interface: Overview. Objective. File Concept UNIT-IV FILE SYSTEMS

Segmentation with Paging. Review. Segmentation with Page (MULTICS) Segmentation with Page (MULTICS) Segmentation with Page (MULTICS)

OPERATING SYSTEMS CS136

Chapter 11: File System Implementation

Chapter 10: Case Studies. So what happens in a real operating system?

File Systems: Fundamentals

ELEC 377 Operating Systems. Week 8 Class 1

Operating Systems. Operating Systems Professor Sina Meraji U of T

Sistemas Operacionais I. Valeria Menezes Bastos

File System Case Studies. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Chapter 7: File-System

File System Implementation. Sunu Wibirama

File Management By : Kaushik Vaghani

Local File Stores. Job of a File Store. Physical Disk Layout CIS657

Transcription:

Operating Systems: Internals and Design Principles Chapter 2 Management Ninth Edition By William Stallings s collections created by users The System is one of the most important parts of the OS to a user Desirable properties of files: Long-term existence s are stored on disk or other secondary storage and do not disappear when a user logs off Sharable between processes s have names and can have associated access permissions that permit controlled sharing Structure s can be organized into hierarchical or more complex structure to reflect the relationships among files Systems Structure Provide a means to store data organized as files as well as a collection of functions that can be performed on files Maintain a set of attributes associated with the file Typical operations include: Create Delete Open Close Read Write Four terms are commonly used when discussing files: Field Record base Structure Terms Management System Field Basic element of data Contains a single value Fixed or variable length base Collection of related data Relationships among elements of data are explicit Designed for use by a number of different applications Consists of one or more types of files Collection of similar records Treated as a single entity May be referenced by name Access control restrictions usually apply at the file level Record Collection of related fields that can be treated as a unit by some application program Fixed or variable length Meet the data management needs of the user Guarantee that the data in the file are valid Optimize performance Provide I/O support for a variety of storage device types Minimize the potential for lost or destroyed data Provide a standardized set of I/O interface routines to user processes Provide I/O support for multiple users in the case of multipleuser systems

Minimal User Requirements Each user: User Program 2 Should be able to create, delete, read, write and modify files May have controlled access to other users files Pile Sequential Indexed Sequential Logical I/O Indexed Hashed 4 5 6 May control what type of accesses are allowed to the users files Should be able to move data between files Should be able to back up and recover files in case of damage Should be able to access his or her files by name rather than by numeric identifier Basic I/O Supervisor Basic System Disk Device Driver Tape Device Driver Figure 2. System Software Architecture Device Drivers Lowest level Communicates directly with peripheral devices Responsible for starting I/O operations on a device Processes the completion of an I/O request Considered to be part of the operating system Also referred to as the physical I/O level Basic System Primary interface with the environment outside the computer system Deals with blocks of data that are exchanged with disk or tape systems Concerned with the placement of blocks on the secondary storage device Concerned with buffering blocks in main memory Does not understand the content of the data or the structure of the files involved Considered part of the operating system Basic I/O Supervisor Logical I/O Responsible for all file I/O initiation and termination At this level, control structures are maintained that deal with device I/O, scheduling, and file status Selects the device on which I/O is to be performed Concerned with scheduling disk and tape accesses to optimize performance I/O buffers are assigned and secondary memory is allocated at this level Enables users and applications to access records Provides generalpurpose record I/O capability Maintains basic data about file Part of the operating system 2

Access Method Level of the file system closest to the user Provides a standard interface between applications and the file systems and devices that hold the data Structure Directory Access management method User & program comands Operation, name manipulation functions Records Physical blocks Physical blocks in main memory in secondary buffers storage (disk) Disk Blocking scheduling I/O Free storage management Different access methods reflect different file structures and different ways of accessing and processing the data User access control allocation management concerns Operating system concerns Figure 2.2 Elements of Management Organization and Access Organization Types The pile organization is the logical structuring of the records as determined by the way in which they are accessed In choosing a file organization, several criteria are important: Short access time Ease of update The direct, or hashed, file The sequential file Economy of storage Simple maintenance Reliability Priority of criteria depends on the application that will use the file The indexed file Five of the common file organizations are: The indexed sequential file The Pile Variable-length records Variable set of fields Chronological order (a) Pile n Index Main levels Index 2 Fixed-length records Fixed set of fields in fixed order Sequential order based on key field (b) Sequential Exhaustive Exhaustive Partial index index index Least complicated form of file organization are collected in the order they arrive Each record consists of one burst of data Overflow (c) Indexed Sequential Primary (variable-length records) (d) Indexed Figure 2. Common Organizations Purpose is simply to accumulate the mass of data and save it Record access is by exhaustive search Variable-length records Variable set of fields Chronological order (a) Pile E

The Sequential Most common form of file structure A fixed format is used for records Key field uniquely identifies the record ble-length Typically records used in batch ble set of applications fields nological order Only organization that is easily stored on tape as well (a) as Pile disk Fixed-length records Fixed set of fields in fixed order Sequential order based on key field (b) Sequential Exhaustive Exhaustive Partial Indexed Sequential Adds an index to the file to support random access Adds an overflow file Greatly reduces the time required to access a single record Multiple levels of indexing can be used to provide greater efficiency in access n Index levels Index 2 (a) Pile Main Overflow (c) Indexed Sequential (a) Pile Indexed Records n are accessed only through Indextheir indexes Main levels Index 2Variable-length records can be employed Exhaustive index contains one entry for every record in the main file Overflow Partial index contains entries to records where the field of interest exists Used (c) Indexed mostly in Sequential applications where timeliness of information is critical Examples would be airline reservation systems and inventory control systems Exhaustive index (b) Sequential Exhaustive index Partial index Primary (variable-length records) (d) Indexed Direct or Hashed Access directly any block of a known address Makes use of hashing on the key value Often used where: Very rapid access is required Fixed-length records are used Records are always accessed one at a time Examples are: Directories Pricing tables Schedules Name lists B-Trees A balanced tree structure with all branches of equal length Standard method of organizing indexes for databases Key Key 2 Key k Commonly used in OS file systems Provides for efficient searching, adding, and deleting of items Subtree Subtree 2 Subtree Subtree k Subtree k Figure 2.4 A B-tree Node with k Children 4

B-Tree Characteristics A B-tree is characterized by its minimum degree d and satisfies the following properties: Every node has at most 2d keys and 2d children or, equivalently, 2d pointers Every node, except for the root, has at least d keys and d pointers, as a result, each internal node, except the root, is at least half full and has at least d children The root has at least key and 2 children All leaves appear on the same level and contain no information. This is a logical construct to terminate the tree; the actual implementation may differ A nonleaf node with k pointers contains k keys 2 5 6 7 2 0 0 2 9 4 44 52 59 60 67 68 7 85 88 96 (a) B-tree of minimum degree d =. 2 5 6 7 2 0 0 2 9 4 44 52 59 60 67 68 7 85 88 90 96 (b) Key = 90 inserted. This is a simple insertion into a node. 2 9 5 6 7 2 0 0 2 4 44 45 52 59 60 67 68 7 85 88 90 96 (c) Key = 45 inserted. This requires splitting a node into two parts and promoting one key to the root node. 5 2 9 6 7 88 2 0 0 2 4 44 45 52 59 60 67 68 7 84 85 90 96 (d) Key = 84 inserted. This requires splitting a node into two parts and promoting one key to the root node This then requires the root node to be split and a new root created. Figure 2.5 Inserting Nodes into a B-tree Table 2. Name Type Organization Basic Information Name as chosen by creator (user or program). Must be unique within a specific directory. For example: text, binary, load module, etc. For systems that support different organizations Operations Performed on a Directory Address Information Information Elements of a Volume Starting Address Size Used Size Allocated Indicates device on which file is stored Starting physical address on secondary storage (e.g., cylinder, track, and block number on disk) Current size of the file in bytes, words, or blocks The maximum size of the file Access Control Information To understand the requirements for a file structure, it is helpful to consider the types of operations that may be performed on the directory: Directory Owner Access Information Permitted Actions User who is assigned control of this file. The owner may be able to grant/deny access to other users and to change these privileges. A simple version of this element would include the user's name and password for each authorized user. Controls reading, writing, executing, transmitting over a network Usage Information Search Create files Delete files List directory Update directory Date Created When file was first placed in directory Identity of Creator Usually but not necessarily the current owner Date Last Read Access Date of the last time a record was read Identity of Last Reader User who did the reading Date Last Modified Date of the last update, insertion, or deletion Identity of Last Modifier User who did the modifying Date of Last Backup Date of the last time the file was backed up on another storage medium (Table can be found on page 57 in textbook) Current Usage Information about current activity on the file, such as process or processes that have the file open, whether it is locked by a process, and whether the file has been updated in main memory but not yet on disk Two-Level Scheme Master Directory There is one directory for each user and a master directory Master directory has an entry for each user directory providing address and access control information Each user directory is a simple list of the files of that user Subirectory Subirectory Subirectory Subirectory Subirectory Names must be unique only within the collection of files of a single user system can easily enforce access restriction on directories Figure 2.6 Tree-Structured Directory 5

Master Directory System User_A User_B User_C Sharing Directory "User_C" Directory "User_B" Directory "User_A" Directory "Word" Unit_A Draw Word Directory "Draw" ABC Two issues arise when allowing files to be shared among a number of users: Directory "Unit_A" ABC "ABC" Pathname: /User_B/Word/Unit_A/ABC "ABC" Pathname: /User_B/Draw/ABC Access rights Management of simultaneous access Figure 2.7 Example of Tree-Structured Directory Access Rights User Access Rights None The user would not be allowed to read the user directory that includes the file Knowledge The user can determine that the file exists and who its owner is and can then petition the owner for additional access rights Execution The user can load and execute a program but cannot copy it Reading The user can read the file for any purpose, including copying and execution Appending The user can add data to the file but cannot modify or delete any of the file s contents Updating The user can modify, delete, and add to the file s data Changing protection The user can change the access rights granted to other users Deletion The user can delete the file from the file system Owner Usually the initial creator of the file Has full rights May grant rights to others Specific Users Individual users who are designated by user ID User Groups A set of users who are not individually defined All All users who have access to this system These are public files Record Blocking Record Record 2 Record Record 4 Record 5 Record 6 Record 7 Record 8 Track Track 2 Blocks are the unit of I/O with secondary storage For I/O to be performed records must be organized as blocks Given the size of a block, three methods of blocking can be used: ) Fixed-Length Blocking fixedlength records are used, and an integral number of records are stored in a block Internal fragmentation unused space at the end of each block 2) Variable-Length Spanned Blocking variable-length records are used and are packed into blocks with no unused space ) Variable-Length Unspanned Blocking variable-length records are used, but spanning is not employed (a) Fixed Blocking Record Record 2 Record Record 4 Ptr Track Record 4 (rest) Record 5 Record 6 Record Ptr Track 2 (b) Variable Blocking: Spanned Record Record 2 Record Track Record 4 Record 5 Record 6 Track 2 (c) Variable Blocking: Unspanned Figure 2.8 Record Blocking Methods 6

Allocation Preallocation vs Dynamic Allocation On secondary storage, a file consists of a collection of blocks The operating system or file management system is responsible for allocating blocks to files The approach taken for file allocation may influence the approach taken for free space management Space is allocated to a file as one or more portions (contiguous set of allocated blocks) A preallocation policy requires that the maximum size of a file be declared at the time of the file creation request For many applications it is difficult to estimate reliably the maximum potential size of the file Tends to be wasteful because users and application programmers tend to overestimate size Dynamic allocation allocates space to a file in portions as needed allocation table (FAT) structure used to keep track of the portions assigned to a file Portion Size In choosing a portion size there is a trade-off between efficiency from the point of view of a single file versus overall system efficiency Alternatives Two major alternatives: Items to be considered: ) Contiguity of space increases performance, especially for Retrieve_Next operations, and greatly for transactions running in a transaction-oriented operating system 2) Having a large number of small portions increases the size of tables needed to manage the allocation information ) Having fixed-size portions simplifies the reallocation of space 4) Having variable-size or small fixed-size portions minimizes waste of unused storage due to overallocation Variable, large contiguous portions Provides better performance The variable size avoids waste The file allocation tables are small Blocks Small fixed portions provide greater flexibility They may require large tables or complex structures for their allocation Contiguity has been abandoned as a primary goal Blocks are allocated as needed Contiguous Chained Indexed Preallocation? Necessary Possible Possible Fixed or variable size portions? Variable Fixed blocks Fixed blocks Variable Portion size Large Small Small Medium Allocation frequency Once Low to high High Low Time to allocate Medium Long Short Medium allocation table size Table 2.2 Allocation Methods One entry One entry Large Medium A 0 2 4 5 6 7 8 9 B 0 2 4 5 6 7 8 9 C 20 2 22 2 24 E 25 26 27 28 29 D 0 2 4 Allocation Table Name Start Block Length A 2 B 9 5 C 8 8 D 0 2 E 26 Figure 2.9 Contiguous Allocation 7

Allocation Table Allocation Table A 0 2 4 B 5 6 7 8 9 C 0 2 4 E D 5 6 7 8 9 Name A B C D E Start Block 0 8 9 6 Length 5 8 2 B 0 2 4 5 6 7 8 9 0 2 4 5 6 7 8 9 Name Start Block Length B 5 20 2 22 2 24 20 2 22 2 24 25 26 27 28 29 25 26 27 28 29 0 2 4 0 2 4 Figure 2.0 Contiguous Allocation (After Compaction) Figure 2. Chained Allocation B 0 2 4 5 6 7 8 9 Allocation Table Name Start Block Length B 0 5 B 0 2 4 5 6 7 8 9 Allocation Table Name Index Block B 24 0 2 4 0 2 4 5 6 7 8 9 20 2 22 2 24 25 26 27 28 29 5 6 7 8 9 20 2 22 2 24 25 26 27 28 29 8 4 28 0 2 4 0 2 4 Figure 2.2 Chained Allocation (After Consolidation) Figure 2. Indexed Allocation with Block Portions B 0 2 4 5 6 7 8 9 0 2 4 Allocation Table Name Index Block B 24 Free Space Management Just as allocated space must be managed, so must the unallocated space 5 6 7 8 9 20 2 22 2 24 25 26 27 28 29 Start Block 28 4 Length 4 To perform file allocation, it is necessary to know which blocks are available A disk allocation table is needed in addition to a file allocation table 0 2 4 Figure 2.4 Indexed Allocation with Variable-Length Portions 8

Bit Tables Chained Free Portions This method uses a vector containing one bit for each block on the disk Each entry of a 0 corresponds to a free block, and each corresponds to a block in use Advantages: Works well with any file allocation method It is as small as possible The free portions may be chained together by using a pointer and length value in each free portion Negligible space overhead because there is no need for a disk allocation table Suited to all file allocation methods Disadvantages: Leads to fragmentation Every time you allocate a block you need to read the block first to recover the pointer to the new first free block before writing data to that block Indexing Free Block List Treats free space as a file and uses an index table as it would for file allocation For efficiency, the index should be on the basis of variable-size portions rather than blocks Each block is assigned a number sequentially Depending on the size of the disk, either 24 or 2 bits will be needed to store a single block number There are two effective techniques for storing a small part of the free block list in main memory: This approach provides efficient support for all of the file allocation methods The list of the numbers of all free blocks is maintained in a reserved portion of the disk The size of the free block list is 24 or 2 times the size of the corresponding bit table and must be stored on disk The list can be treated as a push-down stack with the first few thousand elements of the stack kept in main memory The list can be treated as a FIFO queue, with a few thousand entries from both the head and the tail of the queue in main memory Volumes UNIX Management In the UNIX file system, six types of files are distinguished: A collection of addressable sectors in secondary memory that an OS or application can use for data storage The sectors in a volume need not be consecutive on a physical storage device They need only appear that way to the OS or application A volume may be the result of assembling and merging smaller volumes Regular, or ordinary Contains arbitrary data in zero or more data blocks Directory Contains a list of file names plus pointers to associated inodes (index nodes) Special Contains no data but provides a mechanism to map physical devices to file names Named pipes An interprocess communications facility Links An alternative file name for an existing file Symbolic links A data file that contains the name of the file to which it is linked 9

Inodes mode owners (2) timestamps (4) size direct(0) direct () All types of UNIX files are administered by the OS by means of inodes direct(2) An inode (index node) is a control structure that contains the key information needed by the operating system for a particular file single indirect double indirect triple indirect block count Several file names may be associated with a single inode An active inode is associated with exactly one file reference count flags (2) generation number Each file is controlled by exactly one inode blocksize extended attr size extended attribute blocks Inode Figure 2.5 Structure of FreeBSD inode and Allocation Table 2. Capacity of a FreeBSD with 4-Kbyte Block Size allocation is done on a block basis Allocation is dynamic, as needed, rather than using preallocation An indexed method is used to keep track of each file, with part of the index stored in the inode for the file In all UNIX implementations the inode includes a number of direct pointers and three indirect pointers (single, double, triple) Level Number of Blocks Number of Bytes Direct 2 48K Single Indirect 52 2M Double Indirect 52 52 = 256K G Triple Indirect 52 256K = 28M 52G Inode table i i2 Directory Name Name2 Volume Structure i Name i4 Name4 A UNIX file system resides on a single logical disk or disk partition and is laid out with the following elements: Boot block Contains code required to boot the operating system Superblock Contains attributes and information about the file system Inode table Collection of inodes for each file blocks Storage space available for data files and subdirectories Figure 2.6 UNIX Directories and Inodes 0

User applications GNU C library User space system Inode cache System call interface Virtual System (VFS) Individual Systems Directory cache Kernel space System calls using VFS user interface User Process Linux Virtual System VFS system calls Mapping function to file system X System calls using file system X interface System X Disk I/O calls Buffer cache s on secondary storage maintained by file system X Device drivers Figure 2.7 Linux Virtual System Context Figure 2.8 Linux Virtual System Concept Primary Object Types in VFS The Superblock Object Superblock Object Represents a specific mounted file system Inode Object Represents a specific file Dentry Object Represents a specific directory entry Object Represents an open file associated with a process Stores information describing a specific file system Typically, the superblock corresponds to the file system superblock or file system control block, which is stored in a special sector on disk The superblock object consists of a number of data items Examples include: The device this file system is mounted on The basic block size of the file system Dirty flag, to indicate that the superblock has been changed but not written back to disk system type Flags, such as a read-only flag Pointer to the root of the file system directory List of open files Semaphore for controlling access to the file system List of superblock operations The Inode Object The Dentry Object An inode is associated with each file A dentry (directory entry) is a specific component in a path The inode object holds all the information about a named file except its name and the actual data contents of the file Items contained in an inode object include owner, group, permissions, access times for a file, size of data it holds, and number of links The inode object also includes an inode operations object that describes the file system s implemented functions that the VFS can invoke on an inode The component may be either a directory name or a file name Dentry objects facilitate quick lookups to files and directories, and are used in a dentry cache for that purpose The dentry object includes a pointer to the inode and superblock It also includes a pointer to the parent dentry and pointers to any subordinate dentrys

The Object Caches The file object is used to represent a file opened by a process The object is created in response to the open() system call, and destroyed in response to the close () system call The file object also includes an inode operations object that describes the file system s implemented functions that the VFS can invoke on a file object The methods defined for the file object include read, write, open, release, and lock The file object consists of a number of items, including: Dentry object associated with the file system containing the file objects usage counter User s user ID User s group ID pointer, which is the current position in the file from which the next operation will take place The VFS employs three caches to improve performance: Inode cache Because every file and directory is represented by a VFS inode, a directory listing command or a file access command causes a number of inodes to be accessed The inode cache stores recently visited inodes to make access quicker Directory cache The directory cache stores the mapping between the full directory names and their inode numbers This speeds up the process of listing a directory Buffer cache The buffer cache is independent of the file systems and is integrated into the mechanisms that the Linux kernel uses to allocate and read and write data buffers As the real file systems read data from the underlying physical disks, this results in requests to the block device drivers to read physical blocks from the device that they control If the same data is needed often, it will be retrieved from the buffer cache rather than read from the disk Windows System The developers of Windows NT designed a new file system, the New Technology System (NTFS) which is intended to meet high-end requirements for workstations and servers Key features of NTFS: Recoverability Security Large disks and large files Multiple data streams Journaling Compression and encryption Hard and symbolic links NTFS Volume and Structure NTFS makes use of the following disk storage concepts: Sector Cluster Volume The smallest physical storage unit on the disk The data size in bytes is a power of 2 and is almost always 52 bytes One or more contiguous sectors The cluster size in sectors is a power of 2 A logical partition on a disk, consisting of one or more clusters and used by a file system to allocate space Can be all or a portion of a single disk or it can extend across multiple disks The maximum volume size for NTFS is 2 64 clusters Table 2.4 Windows NTFS Partition and Cluster Sizes Volume Size Sectors per Cluster Cluster Size 52 Mbyte 52 bytes partition boot sector Master Table System s Area 52 Mbyte - Gbyte 2 K Gbyte - 2 Gbyte 4 2K 2 Gbyte - 4 Gbyte 8 4K 4 Gbyte - 8 Gbyte 6 8K 8 Gbyte - 6 Gbyte 2 6K 6 Gbyte - 2 Gbyte 64 2K > 2 Gbyte 28 64K Figure 2.9 NTFS Volume Layout 2

Master Table (MFT) The heart of the Windows file system is the MFT The MFT is organized as a table of,024-byte rows, called records Each row describes a file on this volume, including the MFT itself, which is treated as a file Each record in the MFT consists of a set of attributes that serve to define the file (or folder) characteristics and the file contents Table 2.5 Windows NTFS and Directory Attribute Types Attribute Type Standard information Attribute list name Security descriptor Index root Index allocation Volume information Bitmap Description Includes access attributes (read-only, read/write, etc.); time stamps, including when the file was created or last modified; and how many directories point to the file (link count). A list of attributes that make up the file and the file reference of the MFT file record in which each attribute is located. Used when all attributes do not fit into a single MFT file record. A file or directory must have one or more names. Specifies who owns the file and who can access it. The contents of the file. A file has one default unnamed data attribute and may have one or more named data attributes. Used to implement folders. Used to implement folders. Includes volume-related information, such as the version and name of the volume. Provides a map representing records in use on the MFT or folder. Note: Colored rows refer to required file attributes; the other attributes are optional. Flush the log file Log Service Write the cache Cache Manager Log the transaction Read/write the file Access the mapped file or flush the cache Load data from disk into memory I/O Manager NTFS Driver Fault Tolerant Driver Disk Driver Read/write a mirrored or striped volume Read/write the disk /(root) /system /data /cache (ro) (rw) (rw) bin etc lib usr Virtual Memory Manager /mnt/sdcard ro: mounted as read only rw: mounted as read and write removable storage (rw) Figure 2.20 Windows NTFS Components Figure 2.2 Typical Directory Tree of Android SQLite Summary Most widely deployed SQL database engine in the world Based on the Structured Query Language (SQL) Designed to provide a streamlined SQL-based database management system suitable for embedded systems and other limited memory systems The full SQLite library can be implemented in under 400 KB In contrast to other database management systems, SQLite is not a separate process that is accessed from the client application The SQLite library is linked in, and thus becomes an integral part of the application program structure management systems organization and access The pile The sequential file The indexed sequential file The indexed file The direct or hashed file B-Trees directories Contents Structure Naming sharing Access rights Simultaneous access Record blocking Android file management system SQLite Secondary storage management allocation Free space management Volumes Reliability UNIX file management Inodes allocation Directories Volume structure Linux virtual file system Superblock object Inode object Dentry object object Caches Windows file system Key features of NTFS NTFS volume and file structure Recoverability