0% found this document useful (0 votes)
6 views10 pages

MTech AOSC PPT 13

The document provides an overview of file system interfaces and implementations, detailing commands and system calls used for file operations. It discusses the structure and organization of file systems, including types of files, file attributes, and directory operations, particularly in Unix/Linux systems. Additionally, it covers the Linux Virtual File System (VFS), file protection mechanisms, and the Ext2 file system design, emphasizing the importance of efficient file management and data access.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
6 views10 pages

MTech AOSC PPT 13

The document provides an overview of file system interfaces and implementations, detailing commands and system calls used for file operations. It discusses the structure and organization of file systems, including types of files, file attributes, and directory operations, particularly in Unix/Linux systems. Additionally, it covers the Linux Virtual File System (VFS), file protection mechanisms, and the Ext2 file system design, emphasizing the importance of efficient file management and data access.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 10
File system interface and implementation Harshad B. Prajapati Associate Professor information Technology Departmen Dharmsinh Desai University, Nadiad File system interface + Through commands Eg, Is dir, my rmdir, + Through system calls/functions open, close, read, write, File system + The file system is part of an operating system that provides the abstractions of the resources associated with secondary storage + The Unix/Linux system provides abstraction of different devices in form of file. — le, you treat all devices as files and perform ‘operations on them as if you are doing operations ona file, 2012-05-01 Topics File system interface = command interface = System cllinterface ~ Fle for long term storage = File naming = Fle structure ~ Fle attributes = File operations = Directory operations Long-term storage of information (asa file) When we want to store large amounts of data (E.g., not restricted by size of main memory) ‘When information must survive the termination of the process/system. Multiple processes must be able to access the Information concurrently Types of files and naming of files Types of files = Regular or ordinary = hector) Ne = Special = = Named pipes = a Fretenaactr nates Naming of file ‘ype = File name and fle extension (E~, matric) Path of a file ~ act location ofa file stating from root dtectory. £8, Prome/usert/programs/matrice File access operation + Sequential access ~ read all byts/record rom the begining ~ Cannot move rea pointer) jump back nd forthinafile = Useful when datais coming as stream of bytesinetwork, Pipe, fifo, ete) or we need dataas stream of bytes (audio/video) + Random access ~ bytes/recordsread in any order ~ We an move ile ead pointer a random ~ essential for data base systems File attributes a Terponeytig Ofer nm fr (es. the ngs state waa fru and or otra ‘eatin hangout te ews et mefchargnd iret Manertopesinae Protection + Typeotaccess ~ head wite, nete,spen, delet it + How can itbe implemented? 1, Access contra ist = sect Ito are wth aces ght fr vy fle "Teo to const st yn be aon in ane fra on) 2. Classiyusers = aarartage caer timploment 2012-05-01 File attributes Felon Wincnace va ‘mofo essen fag Hg vette reas ssig——_Clrromaand tore ‘syaomtg fernandez e santas Ofer Aso e sn tray File operations coe cone ose anopentle seo eat Move ptr File protection “root | ‘Garecan es ard wie group cn 8 ‘oror00- ‘arorsnesd rd wrt ster saad 470110" | rar | Owner ea een, et on ad 3nd 858 Some examples of file protection modes System calls for protection nod Garg peton mote eid eters rid ws Seunerea oun eels Getta rau oa Cargette nner oop se Senecio Directory organization 3. Tree-structured directory = Directory stored on clk ust ke files = Data consists of cname,index> pairs + Special directories ~ Root (/):fxed index fr metadata = this directory = «parent directory Path names * Absolute path name (full path name) Start at root directory Eg, fhome/useri/mtech txt * Relative path name — Full path is lengthy and inflexible ~ Give each process current working directory —Itassumes a file in current directory 2012-05-01 Directory organization + Organization technique ~ itis used to map a filename to location on ck = tie stored on disk 1. Single-Level directory ~ Single clvectory for entire disk = Each le must have unique name = Not very usable 2. Twolevel directory ~ pikectoryfor each user = sullnot very usable Directory organization (Acyclic graph directories) + Directories can share fies ~crestetinis fom nee + Two types oftinks varie ~ symboteine special le, eogrted btn meta ta Main directories in Unix file system, + Some important directories found in most UNIX systems Directory Contents bin Binary (executable) programs dev ‘Special fes for UO devices atc Miscellaneaus system files rm Libraries [usr | User directories 2012-05-01 Directory operations Topics ese vee ‘ewe anew decry > "Peta an aa TT 7 une [Ese ceo Comair oer Opacity ren Serine dincoy coor downarecay mnie Freed ja a acon a reer Disk block allocation Contiguous Disk block allocation + Aspe set comauous + onside eny inthe + Indexed allocation ‘elocabon tse Tenghot he fe + Dinchetge Protem fener + Contiguous allocation * Linked allocation ~ chang te se of coins Linked Disk block allocation Indexed Disk block allocation + Aserstnuditete — [———] [eat + ade spend Bis cogeosa| Lee ‘leper “mcconeaa | OFD7O cme + rece aryreetonty | ace ~ eset oaadal acl + rea ern consis Steraltagrerttion | wthrcykcowcy yeah aan * eager: Net ae ren po + fom neo Bone . lacadlacarc) + Noster tepneaton toners teontent [acaCuCC Ieaton tered tom Ss pay yn Gy ten, sta bees) area cea, Unix File system + 800k block ~ heislozated at the being fhe le ster (ron ~ hcotaie he cadence futher tile the operating sem + Super block hese the state ofa stem wit flowing lormatin + tof stor oes + ideo terest ee Boca the ee Bock st Disk block allocation to a regular file in Linux/Unix Ext2 file system + LayoutofBet2 filesystem + Ext2 was devised (by Rémy Card) asan extensible and ‘oweful filesystem for Linux + Each lock group duplicates information critical tothe Integrity ofthe le system, + Each block group als hols teal les and dretovies. 2012-05-01 Unix File system LF sins ome ba + nade is (table) ~ Test sable mote ep reserve for casing the ot deetony Data blocks Maximum file size ‘Assume block siz is 4KB, and isk block addressis of byes. ‘Addressable size using ect pointers + Addressable file sie using one singe indirect pointer ~ (raya) = + Addressable fil sie using one double indirect pointer 8) x14 /08) 448 4.68 + Addressable file sie using one triple indirect pointer ~ (ena) x nna) x(a xa = Te + Total addeessable file site = AT8+46B+4M0+ 4048 Ext2 file system Design Philosophy ‘The data held in files is kept in data blocks ‘These data blocks are allof the same length very file's siz is rounded up to an integral number of blocs. Ext2 describes each fein the system with an inode data + EXT drectrios are simply special files (directories ‘themselves are deseribed by rnodes) + Acdirectory contains pointrsto the inodes ofits directory + The filesystem s divided inte number of block groups ~ fiesin the same rectory ate staredin he same Bc ou fein tern rector ar spread smog te oc roups Ext2 I-node information + Made (2 8 Fey protection Bs st stlits + ins (2 ots number of drecery ents ong ths nee ~ Ud (ts: UD fe owner = Git: to ff cuner + sin tots le sein yes 1 hate Orc ange nec, colnet, a tenet poet + can(t bk ateraton number nde Row many tines dere EXT2 Group Descriptor + Each Group Descriptor contains thefolowinginformaion: ‘hs los Graun Thies during ack alleston and ~ age able: The lee rumber ofthe rng corn nods able forts ow Group ach node epee by Oe ET? node aa Ext2 Directory Implementation + Directories are managed as linked lists of variable length entries + Each entry contains ~ theinode number, = the entry length, = thefilename and ~ its length + Itis possible to implement long file names without wasting disk space in directories. ~ Possible as rectoryentries are of variable length 2012-05-01 EXT2 Superblock + tecontainsa description of basic size and shape ofthis fle ‘system, Major information's as flows Biock ize: The size ofthe block fr thse system in bytes, for example 1024 bytes, + Blocks per Group: The umber of blcksin a group. Like the bockstae this is xed when the fle system i created + Free Blocks: The number of tree blocksin the filesystem, Free nodes: The numberof free nodesin the filesystem, + First node: This is the -nade number ofthe fst -node in the file sytem, “Th et noe nan 72 rot stom wo be the ractoy etry forte erectory EXT2 Group Descriptor +All the group descriptors for all ofthe Block Groups ‘are duplicated in each Black Group to handle file system corruption, ~ The group descriptorsae placed one after another ~The group descriptors ofall block groupe together make the group descriptor table ~ kach Boks Group contains the ene table of group Gescriptorsaterits copy of the Superblock ~ However only the fist copy of group descriptor table in lock Group) is actually used bythe EX fle system. = The other copie are ther, ike the copes ofthe Superbiock incase the main copy i corrupted, Ext2 Directory Implementation a} Adirectory with thre files b}_ The rectory with the file voluminous removed. Seure:Tnenboum, Modern Operating Sues 36, 2008 Pesce Finding a file in Ext2 file system + Traversal starts from the root directory + Itinvolves following operation — Locate inode of the directory Fetch data block associated with the inode — Search for sub-directory entry and find out associated inode — Repeat the procedure unti the inode for the desired file is found. (Ex, for Jroot/usert/mtech.tt, inode of mtech.txt) File system data structure after a file is opened in Unix/Linux ‘Therlaton beenen thee desrtoral,the open le destin Linux Virtual File System (VES) + wen a proces calle Soran a are 7 impos rears by Simei en + inatrycting device drvw co | ===] Z sie cs 2012-05-01 Handling open files + becomes expensive to resolve name to identifier an each + InUnb/tinu, le is opened before access = fangreleat nemton open fl tbe = Ratan amino open fle le ezrin tothe proses = Theres pests tha del ute fe oertion, + system wide apen tables + Perprocess open fil tables * Mantas cuter pote potion an index stem wide open The Linux Virtual File System (VFS) + provides common interface to several kinds of filesystems touser processes + AVSisa keene software layer tha handles al system-cals related toa standard Unix filesystem interface, + This allows Linuxta acces files rom disks in other file formats (FAT, NTE, using 2 common set of stem calls. + Supported le systems by VES = ai 5 5, = Necross: MS DOS, EA (Wan an ter else) ~ co/ove: 09660 €0-40M flee and ies Disk Format [OOF ovo eaptem ~ fed many other rarer fe sete 10M, Ale.) Linux Virtual File System (VFS) + VFS uses following four primary object types to {generate common file model: ~ Superblock object sero of mounts tasytom = Inode object, = Dentry object (directory entry) = File object * lees avert oto fl pit) Inode cache and directory cache + Inode cache = Inodes that are use repeatedly ara kept in inode cacheto reduce overhead of losing every time, ~ When an inode snot nthe inode cache, a fle ystem Specie routines sled * Directory cache ~ Directory entries that are repeatedly used are kept in directory cache. ~ The directory ache does no store the inode forthe Arectoies sel but store the mappingboetween the fll, ‘rectory names and ther inode numbers = Inodes are keptim inode cache Preparing Filesystem for use + Before using a filesystem, there are two basic operations that must be performed = Registration * Done when you buld the kernel Mounting + For oot filesystem done ot system initiation + For other ilesystems—done at any time Mounting + Allfiles accessible in a UNIX system are arranged in one big tree, =the file hierarchy, rooted at / + These files can be spread out over several devices + The mount command serves to attach the file system found on some device to the big file tree, 2012-05-01 Buffer Cache Butfer cache a common bulfer cache is used to cache data butlers trom the underlying devices ~ This bufereaeneisindapendent ofthe supported fle systems. ~ The globalbutfer cache i shared by all ofthe file systems and the Linux kernel, ~ Buffers within bufer cache ae identified by their block umber anda unique identiter"or the device which read ~ So, lfthe same datas needed frequent, t willbe Selivered from the butter cache rather tan reading i fom the actual physical dis Registering the File Systems + whan le syste init sal wth be St Frelenytans + Theacual fl ytems te ther alt reo te ral or are 3 ple str moles are lode hey ar needed by he sam, hel orem meena est wh he + when youbulé the Unixlrnl your aed you want sch the + ads spertock anaes norman and punters torownes Hat Mount command Focexample to "mount the DUD-OM drive before you can acest ‘mount -is08660 /dew/hde fedrom T “None spec te fra te lo ste ig mounted Thebes rater ts ns debate ath tthe DYOAOM d's device ve fe fer she decor map" the dee tn the le pte 208 Mounting + The "mount_root()" function takes care of mounting the first file system. *+ Every mounted file system is then represented by super_block structure, + The function read_super() of the virtual file system is used to initialize the superblock. Network File System, (NFS) <% | coal + Examples of remote mounted fle ystems + ieectoriesare shown as squares, esas ccs The /proc file system + The /roc filesystem ike areal ile system, registersitself ith the Virtua Fle System to allow acces of keene data in formof file to the user + edoes not really exist onthe storage device. + Itstoresinformation present in kernels data structures, +The proc flesystem provides a mechanism of accessing kere! space information and data structure in userspace 2012-05-01 The UNIX File System mounting dod dod @® © © © (a) Before mounting. (b) After mounting. Network File System (NFS) implementation structure | Bt | Be Hg The /proc file system Few subdirectory names and their content rte Tneinseeh see brant ised sess emi Thenunberof taal anda eer nna) esr Grtentevef ekerl drain pune Recaps carports jet ret ocpation tis, et Deeiptoractet teneteree ‘masts abo eterlmodules urea Device special files ‘The Unia/Linux presents its hardware devices as special les. device file doesnot use any data space inthe filesystem it Isenly an access point tothe devie diver vice fle is implemented a a special typeof nade, ‘There ae two types of device fle \when an /0 request comes to device fie the requestis forwardedto the appropriate device driver within the system Device fies are referenced by a major number, and minor umber ~ and minor unr eoties the ur itanes oF hat mee. 2012-05-01 References David A Rusting, Chapter 9 The Filesystem, htp:/feldp.or/LOP//eflesyster.tm Tanenbaum, Modern Operating Systems 3¢, 2008 Prentice- all course: Operating Systems, online] Irtp:/ few. columblau/unteng/0sp- w4138/5labus ht Operating ystems by Willam Stallings, Pearson Education “The Design OFThe UNDKO/S", Maurie Bach, PHI publication Operating System Concepts by Slberschatz, Galvin, and ‘Gagne,John Wiley & Sons 10

You might also like