Lecture 19 Linux/Unix – File System

Slides:



Advertisements
Similar presentations
Chapter 12: File System Implementation
Advertisements

File Management.
Operating Systems File Management.
Concepts about the file system 2. The disk structure 3. Files in disk – The ext2 FS 4. The Virtual File System (c) 2013, Prof. Jordi Garcia.
Chapter 4 : File Systems What is a file system?
File Systems.
Allocation Methods - Contiguous
Chapter 10: File-System Interface
File System Interface CSCI 444/544 Operating Systems Fall 2008.
Day 27 File System. UNIX File Management Types of files Ordinary – stream of bytes Directory – list of names plus pointers to attributes of the entry.
Operating Systems File Systems (in a Day) Ch
Lecture 10: The FAT, VFAT, and NTFS Filesystems 6/17/2003 CSCE 590 Summer 2003.
Ceng Operating Systems
6/24/2015B.RamamurthyPage 1 File System B. Ramamurthy.
1 File Management in Representative Operating Systems.
Chapter 12: File System Implementation
Operating Systems File Systems (Select parts of Ch 11-12)
7/15/2015B.RamamurthyPage 1 File System B. Ramamurthy.
Chapter 8 File Management
File Systems (1). Readings r Silbershatz et al: 10.1,10.2,
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
1Fall 2008, Chapter 11 Disk Hardware Arm can move in and out Read / write head can access a ring of data as the disk rotates Disk consists of one or more.
CSC 322 Operating Systems Concepts Lecture - 4: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
SIMULATED UNIX FILE SYSTEM Implementation in C Tarek Youssef Bipanjit Sihra.
File Systems Long-term Information Storage Store large amounts of information Information must survive the termination of the process using it Multiple.
File System Implementation Chapter 12. File system Organization Application programs Application programs Logical file system Logical file system manages.
NETW3005 File System Interface. Reading For this lecture, you should have read Chapter 10 (Sections 1-5) and Chapter 11 (Sections 1-4). NETW3005 (Operating.
Chapter 4. INTERNAL REPRESENTATION OF FILES
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials– 8 th Edition Chapter 10: File System Implementation.
File Systems CSCI What is a file? A file is information that is stored on disks or other external media.
Chapter 5 File Management File System Implementation.
File Management Chapter 12. File Management File management system is considered part of the operating system Input to applications is by means of a file.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 12: File System Implementation File System Structure File System Implementation.
File System Implementation
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 11: File System Implementation.
Module 4.0: File Systems File is a contiguous logical address space.
Chapter 4. INTERNAL REPRESENTATION OF FILES
CE Operating Systems Lecture 13 Linux/Unix interprocess communication.
Some basic concepts and information on file systems Portions taken and modified from books by ANDREW S. TANENBAUM.
Files & File system. A Possible File System Layout Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved
CE Operating Systems Lecture 17 File systems – interface and implementation.
1 Chapter 4. INTERNAL REPRESENTATION OF FILES THE DESIGN OF THE UNIX OPERATING SYSTEM Maurice J. bach Prentice Hall.
Unix File Access Unix file access is accomplished via a series of tables Process file table System file table v-nodes (sometimes i-nodes)
Lecture 18 Windows – NT File System (NTFS)
Jeff's Filesystem Papers Review Part I. Review of "Design and Implementation of The Second Extended Filesystem"
File Systems. 2 What is a file? A repository for data Is long lasting (until explicitly deleted).
Lecture 10 Page 1 CS 111 Summer 2013 File Systems Control Structures A file is a named collection of information Primary roles of file system: – To store.
Linux File system Implementations
Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID: Operating System Research Topic December, 2000.
THE FILE SYSTEM Files long-term storage RAM short-term storage Programs, data, and text are all stored in files, which is stored on.
Chapter 6 File Systems. Essential requirements 1. Store very large amount of information 2. Must survive the termination of processes persistent 3. Concurrent.
File system In computing, a file system is a method of storing and organizing computer files and the data they contain to make it easy to find and access.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 10 & 11: File-System Interface and Implementation.
Linux file systems Name: Peijun Li Student ID: Prof. Morteza Anvari.
FILE SYSTEM IMPLEMENTATION 1. 2 File-System Structure File structure Logical storage unit Collection of related information File system resides on secondary.
1 The File System. 2 Linux File System Linux supports 15 file systems –ext, ext2, xia, minix, umsdos, msdos, vfat, proc, smb, ncp, iso9660, sysv, hpfs,
W4118 Operating Systems Instructor: Junfeng Yang.
Day 28 File System.
Chapter 11: File System Implementation
Day 27 File System.
Chapter 11: File System Implementation
Chapter 11: File System Implementation
CS510 Operating System Foundations
An overview of the kernel structure
Chapter 11: File System Implementation
File System B. Ramamurthy B.Ramamurthy 11/27/2018.
Directory Structure A collection of nodes containing information about all files Directory Files F 1 F 2 F 3 F 4 F n Both the directory structure and the.
Chapter 11: File System Implementation
Internal Representation of Files
Chapter 5 File Systems -Compiled for MCA, PU
Presentation transcript:

Lecture 19 Linux/Unix – File System CE01000-3 Operating Systems Lecture 19 Linux/Unix – File System

Overview of lecture In this lecture we will look at: Files in Linux/Unix – Ordinary files, Directory files, Special files Virtual File System System V Free data blocks inode free lists inode disk location mapping Linux Second Extended File System (Ext2FS) Disk block groups

Overview of Unix/Linux approach Philosophy - attempt to treat all resources to which you can output and from which you can input like ordinary data files Unix/Linux has 3 types of files ordinary files - for ordinary user data/programs, etc directory files - to structure file system special files - for access to I/O and system devices these are all arranged in a single tree structured hierarchy

Tree structured hierarchy

Ordinary files Ordinary files contain a linear array of bytes - no structure is imposed on bytes by Unix/Linux reads and writes start at a file pointer file pointer can be moved anywhere multiple programs can read/write concurrently to one file (but order of access unpredictable)

Ordinary files (Cont.) although user gives names to ordinary files they are identified within system by inode numbers which index an array of data structures called inodes held on the disk inodes contain administrative information about file and location information for data of file where appropriate. Specifically it contains,

Ordinary files (Cont.) files device and inode numbers file type (ordinary, directory, special, etc.) link count file owner’s user and group ids file access permissions major and minor device numbers (for special files) time of last access/modification/status change pointers to disk blocks of file contents if data file

Directory files allow file access by name from directory table table provides logical grouping together of files as defined by user table provides translation between name and inode number inode number and file name constitute a link

Directory to inode mapping

Directory files (Cont.) directory is stored like ordinary files but have the directory type in the inode. This allows a link in one directory to refer to another allowing tree structures to be built inode numbers only unique to a given partition of a disk - each partition has its own inode array symbolic links permit references to files that cross partition boundaries - symbolic link is a special file type - consists of a simple text file that holds absolute pathname of linked file - access to file is indirect (via pathname in link) rather than direct to inode

Directory files (Cont.) each file has 2 types of path name - absolute (from root) and relative (from current directory) directory files can only be written to with special system calls multiple links to a file are allowed - number of links to file held in link count in inode when removing a link from a directory other links may still exist, link count just decremented. Only when link count falls to 0 is inode entry and file data blocks released back to system to reuse.

special files there are 3 main types character special files block special files FIFO special files (these are named pipes) the first 2 are primarily used to access input/output devices (disks, terminals, printers, etc.) some devices (disks for example) have both character and block special files

special files (Cont.) device files have inodes but these contain no reference to data blocks instead of data blocks major and minor device numbers are stored to access a device driver adding new device drivers is relatively easy it is a popular way of adding new facilities into the Unix/Linux kernel modern systems also support symbolic links to special files

File systems disks - in general are split into convenient sized partitions - each physical disk having one or more partitions each partition will have a Unix file system imprinted on it with a partition root directory and its own directory tree underneath Unix/Linux makes these individual file systems appear to be one directory hierarchy by mounting the root of one file system over a leaf directory in another and making the join appear seamless to user

Joined file systems /

File System Internals All the disk I/O we have looked at so far has been done via the kernel’s file system using abstractions like file, I-node and directory When a disk file system is mounted into the directory structure the disk has this abstract model built into it It is also possible to access the physical disks directly via a device special file in the /dev directory

File system internals (Cont.) This bypasses all the file abstractions and allows access to the underlying device itself. In practice most users are denied this low level access by the correct setting of the device special file permission bits. This is necessary to prevent unauthorised access to programs and data on the disk partitions.

Virtual File System

Virtual File System (Cont.) Linux can support a number of different file systems – Second/Third Extended Filesystem (Linux default filesystems), plus e.g. Network File System(NFS), MS-DOS, Unix System V, HPFS (O/S2/NT), Minix (original Linux filesystem),etc. it does this by using a virtual file system layer file system calls are passed onto the VFS which translates the call into the call appropriate to the underlying file system the VFS specifies a set of functions that every file system it can support, has to provide implementations for

Virtual File System (Cont.) VFS uses a table defined during kernel configuration. Each table entry defines a file system type - file system type name and pointer to function called to mount that type of file system When file system is mounted, table is looked up and appropriate function called to mount the file system this function returns a mounted file system descriptor to VFS

Virtual File System (Cont.) a mounted file system descriptor includes pointers to functions provided by physical file system kernel code the VFS then uses descriptor to access the file system internal routines The VFS also maintains 2 other types of descriptors - inode descriptors and open file descriptors

Virtual File System (Cont.) each descriptor contains info about files in use and the set of operations provided by physical file system code inode descriptor contains pointers to functions that act on any file (e.g. creat(), unlink()) the file descriptor contains pointers to functions that can only act on an open file (e.g. read(), write())

Unix System V System V filesystem is the classic early Unix filesystem on a System V filesystem disk partition, the disk blocks would have the following layout:

Unix System V (Cont.) boot block (block 0) - holds boot up code if bootable partition, if not then left unused super block (block 1) - contains information about the file system as a whole, especially: the free block list (a list of all the data blocks that are free for use) a free inode list - for rapid allocation of inodes

Unix System V (Cont.) inodes (block 2 to n) - disk blocks that hold inodes for filesystem - number of disk blocks allocated to inodes is fixed when filesystem created (hence max number of inodes fixed for given partition) data blocks (blocks n+1 to end) - disk blocks for actual file/directory data

Free data block list initially list of free data blocks fills space in super block, then overflow is held in free data blocks with last block number in super block or each subsequent data block giving a linked list

Free data block list (Cont.) allocation of free blocks proceeds from the first free block entry - this repeated until only one free block entry left in super block prior to allocation of that data block it’s contents are copied into super block when data blocks become free they are added to list in super block, but if super block is full then super block entries are copied to newly freed data block and replaced by a single entry in super block to new data block

Free inode list A free inode will have a flag set within struct to indicate whether or not it is free so could conduct a simple linear search through inodes to find free inodes - but inefficient super block contains a list of free inodes - these are allocated from first to last until list is empty the inodes are then searched from number of last free inode in list refilling inode list in super block when inode freed that is lower number than those in free list then replace last inode number with this new number so the next search through inodes will start from new location

Free inode list (Cont.)

inode data block pointers

inode data block pointers (Cont.) Mechanism for locating file data blocks from inode for file. system V inode contains 13 pointers: the first 10 point directly at file data blocks, the 11th pointer (single indirect) points at a data block that contains pointers to file data blocks (typically 256 pointers) the 12th pointer (double indirect) points at a data block that contains pointers to data blocks that contain pointers to file data blocks

inode data block pointers (Cont.) the 13th pointer (triple indirect) points at a data block that contains pointers to data blocks that contain pointers to data blocks that contain pointers to file data blocks this arrangement means that small files (the majority of files) can be accessed very rapidly, whereas larger files may take a larger number of disk accesses to locate their blocks.

Second extended filesystem Ext2fs has 15 pointers in the inode - 12 direct, 1 indirect, 1 double indirect and 1 triple indirect Ext2fs does not have fixed size records for file names, but variable length records permitting long file names (max 255 chars) without wasting space

Second extended filesystem (Cont.) disk partition structure changed - to consist in boot block followed by several block groups

Disk block groups each block group contains duplicates of critical info especially super block and the file system descriptors - improves reliability

Disk block groups (Cont.) each block group holds some of the inodes and file data blocks (attempts to keep inodes and their data blocks in close proximity) Also free inode list and free data block list replaced by an inode bitmap and block bitmap

Disk block groups (Cont.) bitmap has a single bit for each inode or block in the block group. If bit is set to 1 then inode or block is free, if set to 0 then inode/block is in use. Allocation/deallocation consists in searching through a bit list setting values appropriately. Bitmaps are small and can thus be held in memory during mounting of filesystem - very fast to search.

Third Extended File System Ext3fs replaces Ext2fs – major improvements over Ext2fs Provides ability to log intended changes to filesystem – makes recovery from crashes/failures easier Allows Htree indexing of large directories Htree is a form of binary tree which allows very quick searching

References Operating System Concepts. Chapter 22 & Appendix C.