Download as pdf
Download as pdf
You are on page 1of 17
UNIT - 2 Introduction to File _ System and File Management 2.1. Fi cept > Bs Operations on File : “Zlt-2 Introduction to File System and File Management 2.3. File Access Methods (Sequential Access and Direct Access) 2.4. Directory Systems File Management Functions. 2.5. File System and Directory Structure organization.’ 2.6. File Protection.” Scanned with CamScanner 4 File Concept hat is File? , A file a container in a computer system that stores data, Feed wil a computar Sheesh , information, settings, or commands, Afile isa named collection of related information that Is e recorded on second » as magneti ictay ical disks. - so sores such > Files are mapped by the operating system on the physical devices, These devices are usually ni remote. ( eH i due opical dice, oe) A file is logical storage unit of secondary, storage. In f general, Tines or. seco w eaningis defined afile is a sequence of bits, bytes, in a fie system, ‘whlch may exist on aidisk or inl ‘the. mainimem Pept pee ~ Tent] or complex (specially-formatted). memen ris ee © The-collection of files is known as Directory. The cole ‘3 ction of di Tecoleclen ectories at the different levels,- Scanned with CamScanner “File Attributes "Ales named, for the conventence ofits human users, and is referred to by its name. A name is \sualy a string of characters, such as example.c, Some systems differentiate between uppercase and lowercase characters In names, Whercas other systems do not. When a file is named, 1” becomes independent of the process, the user, and even the system that created It. For instance, ‘one user night create the file example.c, and another user might edit that file by specifying its name, The file's owner might write the file to a floppy disk, send It In an e-mail, or copy it across a network, and it could still be called example.c on the destination system. A file's attributes vary from one operating system to another but typically consis of these: Name: The symbolic file name-is the only int mation kept In hhiiman readable form. . Wdentifler : This unique tag, usually’a number Vdenties the file within the file system; itis the non-human-readable'name for the file. Type t This information Is heeded for systems that support different types of files. Locations ‘This information isa pointer to a device and to the location of the file on that { Size: The current size of the file (ln bytes, words, orb) and possibly the maximum allowed dize are included in this attribute. = 2X Protection: Access-control inferiniation devetmines ‘who ¢an do reailing, writing, executing, and so on. : Time, date, and user Identification : This Information ay be kept for creation, last modification, and last use. These data can be useful for protection, security, and usage monitoring. i “Rai , storage. Typically, a directory-entry consists of the file's name and its unique identifier. The Identifier in turn locates the other file attributes. Be LAT Creating File Two steps are necessary to create File @ First, as fem must be found for the file, ® Second, an entry for the new file must be made in the directory. The directory entry records the name of the file and the location in the file system, : +2 Writing File Scanned with CamScanner The information about all files is kept in the directory structure, which also’ resides on secondary” ( @ To write.a file, a system call is made that specifying the name of the file and the information to be written to the file, © Given the name of the file, the system searches the directory to find the location of fhe file. @ The directory entry will need to store a pointer to the current block of the file sie the beginning of the file). Using this pointer, the address of the next ‘block can be computed where the Information will be written,” @ The write pointer must be updated ~ in this ay; successive vires can nbe used to write ( Ee a sequence of blocks to the file Reading File z @ To read a file, a cities ithe hameof the file and where (in memory) the next block of the file should be put iE ‘Again, the, directory Is Searched for. the associated directory entry,-and the directory will ne '@ pointerito'the ne Once the block is fead, the pointer oy = é is ea file, the director ® Having fou sociated directory entry, the spz itcan be reused ae ‘Truncating File: ® The user wants to erase contentiof file for that its attribute uinchanged’ ® Rather than forcing the user to delete file and then recreate it, this function allows all allocated to the ile is released” and remove from the directory entry => File Types 2 = yes i : The File name Is split Into two parts-a name and an extension, usually separated by a perlod .) Shatacter (dot)-In this way, the user and the operating system can tell from the name alone Raracter (dot). ‘what the type of a file is, For example, most operating systems allow users to specify a file Name as a sequence of characters followed by a period and terminated by an extension of Sranned with CamGranner Scanned with CamScanner » ,dditional characters. File name examples ing rext file : sequence of character formed as tine Extension .txt, doc ‘source File : * sequence of subroutine and functions Extension .c, . & Similar : Write: operation call “write next” j pointer at end of newly written material: i.e. it appends to the end of ednd set file ( @ Reset to the beginning. ; + ; SS Reset to the beginning. : Figure 2.3: sequential ‘access method ® Here record maintain sequence 0 If we want to find specific record, we can find it easily, ADissdvantage ' © Itis time consuming because tofi find specific record, whole file have to scan from beginning tomatching record ar end of file. Seanned with CamSranner Scanned with CamScanner nd File Manageme 22. Direct access or random acces, P Z @ A file made_up_of fixed | : Flas Alte mate records. 0 eal estonia q os Santee ee @ itis based on the disk model of fi @ Each record has its own a ‘writing. efile viewed as a Roendls en : sequence of. ‘blocks oF record: block 14 then block 53 then Biosk Taha mea the snd resiction on re am ion on reading or writing - @ Direct access files are “used inet Databases are often using this type. @ Easy to read write and delete arecord @ The file operation must be modified to include the bloék niimber as | parameter ‘Thus we & Soaddress of N record is L*(N-1) Sige rt al doce 3 ' “eC a n fsadvantage 6 itis very difficult to fin id articular reco ie > >) 3. Index sequential access” & This method generally Involves construct ycks. © The index contain pointer to the various blot jon af an index of file. _ nad with CamSranner Scanned with CamScanner last namo ‘opie reco [Adams [ae ‘Arthur [Asher }—sher_| directly and to find a desire reco © With large file the index may becoit The large to kdep dex for thé index file n file whi Of sequential an = oy pointer tothe secon & itis the combination Advantage tle ; a4 ® Wecan get accurate Tesult, ee : ‘ ribadtanage of ge AOE eee iS & Tofind a particular item, we frst make a binary Search of master index which, rovides the bl ber of secondary index. The block is Fead and again binary search is used to find the block containing desire records. Finally this block search Sequentially, “2.4 Directory System File Management Functions Information about files is maintained by BI actorles. A directory can contain multiple files. It eh even haye directories:insid mein “ we also:call these jrectories as folders. i The decor cdf be}view):as symbol t iF that! transiftesafile namelint thet rectory cettiess. ie Le if —*Search for a file i aa i & We need to be able to search'a directory structure to find the entry for a particular idle, 2 Createafile 4 , © New file need to be created and added to the directory Scanned with CamScanner File § ile Management 7 pelete a ! m director ena file no longer nee ded, we want able to t os ‘emove it from directory. les ina di * each file in the list, "ectory and contents of the directory entry for 5, Rename a file gecause the name of 4 cable whi Me represents ts content ; chang’ en the content or use oft i 'o its user, the name must, be @ Renaming a file may also allo le changes. 7 changed. ts" position ‘withia-the directory structure to be ¢, Traverse file % : s / @ It is useful to. be, structure. mn aid Directory Striictur Org “sen: : ‘fle is saving on secondary storage to tmaragsalthese data so we fibea to organize them. This tis svery common on single user operating aisen Be step le of all directoiy, rs, the user toirehyetnberall the “AINES ee ® If there is more than one user then this problem occurs. © Allfiles must have unique names and it may quite possible that different users give Same file name, and then the problem of name collision occurs. ® We can’t give descriptive name to the file because the Identifiers length is limited. Sa Two level directory, Pa Scanned with CamScanner OF single tey, 22 of this we can create a separa te OFY is na Sir cachass ame collision so to overcome from Master file “using 2 level directory structures. directory el directo, directory searched. MFO is indexed ; 5 FD to check: whether another file of that name exists or not. : = ® To ‘delete a file, operating system limits its seach to'the, local UUFD 50 that it cam * accidently delete another user's file s ® Every file in system has a path which is combinatio er name and file name. Advantages: Itsolves the problem of! ision at user level. ® Isolates one user from another, when user's creating or naming a file. (8 Toname asileuntayely, Nsey ¢ er nN | Whe feta thar t } 2) 3. tree level directory 's is |-DOS (Micro Soft Disk. “® The Most common example of ee ove direct Ms Operating System) id files. 2 Thos ot direetary which cntaring subdirectories 225 Scanned with CamScanner Wsolves the problem of name collision, ae Disadvantages: « PREAL : “ rd © Ifwe delete ardirectory then’ a idrectory should be empty. : 4 ® We cannot share file and directories. Scanned with CamScanner 4, Acyclic graph directory st > ! z ructure @ Itisa generalization fo, . tories of exists more than one place,» @ ‘Atree structure does pop icture does not Provide : Figure 2.9: A the Same 2 différent directories: ‘> Each‘user view only copy, not original “ . > "Ifa user changes the fl, the changes wl not ap ® With share File : “FREY * > Only oneactual file Exists” a > If user changes the file, nother user immediately visible that changes.’ ® Acommion way to create a calls Link. ® Alinkis effectively a pointer to an sub directory. ‘seach the, mejor 1c dltettory.cfitry is in thé}takeinformatign. t 1 atl Mimesto Tocate theiredl fldllinks are easily In the directory entry and are effectively named indirect Pointers, © Another common approach to Implementing a share file to duplicate all the Information about thelr in both sharing directories thus both entries are identical and equal. 4 ; ® Alink is clearly différent from original directory entry. Thus two are not equal, Scanned with CamScanner @ Armalor problem wi ae is modified. - reg & Through this appro roach, iti hen one ONY ent les is Malntaining Consistency when a file> a chit: ‘f tS 8 Zz 2 z. oe ee a symbolic Me » lative path name (a. -* © When'a shared! a a pe : bsiertohandle imber Gf link or : © gure 2.10: General graph ‘directory how fo ensure that there lem: with vsiag a an acyclic graph structure ~how Ore seridus problem ! a samo ades ii Scanned with CamScanner @ Weydles are allowed to exis use acyl + We want to avoid searchin, e-nroblems accut_ ving any ¢o ae + A poorly designed algorithn, no Mone twice for cofrection and performance: mM might through the cycle and never tarsi a ult In-an infin rm sail = Itis more costly and neéd a wiser @ Orie sglution Is to li 7 os Be Colle ® Garbage collector Invi will be access during a search.» System: Mi p26 ile Protection : FESS 4 : © {When information is kept in a computer system, a major c Physical damay 3 ® In multiuser system, there are 3 ways of prot .® The need for protection a file Is a direct result of the abil ® Protection mechanism provides control access by limiting the types of file access that can be made. “ ® Access is permitted or denied dependi | ® Several different types of operatidns 4-—Append: write new information at the end of file. Sy Delete: Delete the file and free Its space for reuse. 6." Ust: List the name and attributes of the file. ’ Other operations can be renaming, copying, editing the file may also be controlled. Protection is provided at only lower level (system level). Scanned with CamScanner te loop continually searching ~ It-2 Introduction to Fil se warar 1 2-cAccess List and Groups . ® The most common. _Onthe Identity of the user, ® ‘Varlous users may need different types of access to a file or directory. ® To implement this mechanism is to associate with each file and directory access fist, specifying the user name and types of access allowed for each user. ® When user request access to a particular file the operating system checks the access fist associate with that file. tection problem is to make access dependent * we mustlist all the users with read access. G, To solve the length of access Ist ‘many syste 1. Owner: the user who creates a file is owner. ; Seo Asset of users who are Sane je file Other Protection Approach Fy There is another approach to the protection problem which isto associate with 3 password to cathe To access a computer system itself often controlled by a = to cach filecan be controlled by a password. > ie are several Disadvantages for this schemas if we associated a separate passvord with each file, the number of passwords that dt a ser needs to toremember mov betaine large. tf AT ed ny theyfont ‘LL. ifilestare atressible. f : ime system all 6r to uissoclate & passwort ith a subdirectory rather than * ith an individual did deal with this problem. . Geanned with CamSeanner Scanned with CamScanner sequent ace; begin at the beginni ne oi access -each elem, : “Aah og Lu ee Index Sequential e | Access of fir ent if ak of any record first order, one after the other. In gent nie ere Search a record in index and [x [Duplicate Data is aliowen “aires. | then use pointer to access -| Duplicate Data; record directly. [ [Record isnot someq > plowed “Snot [Duplicate ata isnot order ‘ in Reeord ie in is i =~+__| allowed in index +> access is slow | basea ch Ret Record is in. sorted order 7 | Access is slow : elativ Tse, sed on k Lt. «| eneey HE thn ney Paes ee bat sow i a 5 . ‘sar 6 | ThisSmethod is useg 0) Th seeSidatafrom Tap at faa Co-Dvo | 3 cess: data/from DBMS x fem. : + Differentiate betwieen Allo cae bet cation Method : No. + Contiguous: Linked Toe nde 1 | All blocks:-of the file are | Linked list of file Blocks => =] File block: areas are consecutive on disk 26 « ¥ storéd in anarray which is Sats ee A stored in.a disk block 2 | Sequential and direct access | Effective for sequential:| Sequential and direct access ‘access but Problematic with | methods well supported but random access Much more effective for sequential access direct access 3, | External” Fragmentation | External__ Fragmentation | External Fragmentation {| Problem Occur. | Problém Resolve! Problem Resolve rt! ae ei field pe for each file ent! Easily File'Gan bélexpanded Tei can be Sparded eer haa | ize of index |}. Pestatt=and “Ends| field store for cach file entry mame and Index block field store for each file entry Major problem For creating file, How much space allocate to file No need to declare the size of file when file create: but each block occupy pointer reference of next block Major problem with how long index block when file create. Inefficient for small file | LZ [Efficient for small file Efficient for any size of file Scanned with CamScanner OE vd a Scanned with CamScanner

You might also like