Lecture 44 Syed Mansoor Sarwar Operating Systems Lecture 44 Syed Mansoor Sarwar
© Copyright Virtual University of Pakistan Agenda for Today Review of the previous lecture File Sharing File Protection In-Memory Data Structures Space Allocation Techniques Contiguous, Linked, Index UNIX Allocation File Allocation Table (FAT) 19 November 2018 © Copyright Virtual University of Pakistan
© Copyright Virtual University of Pakistan Review of Lecture 43 Directory Structures Links in UNIX/Linux File System Mounting 19 November 2018 © Copyright Virtual University of Pakistan
© Copyright Virtual University of Pakistan File Sharing Sharing of files on multi-user systems is desirable. Sharing may be done through Duplicating files Common login for members of a team Setting appropriate access permissions Common groups for members of a team Links 19 November 2018 © Copyright Virtual University of Pakistan
© Copyright Virtual University of Pakistan Protection File owner/creator should be able to control What can be done By whom Types of access Read Write Execute Append Delete List 19 November 2018 © Copyright Virtual University of Pakistan
© Copyright Virtual University of Pakistan UNIX Protection Mode of access: read, write, and execute (r, w, x) Three classes of users: owner, group, and others r w x a) Owner access: 7 1 1 1 b) Group access: 6 1 1 0 c) Public access: 1 0 0 1 19 November 2018 © Copyright Virtual University of Pakistan
© Copyright Virtual University of Pakistan UNIX Protection Ask system administrator to create a group and add some users to the group For a particular file or subdirectory, set appropriate access permissions for proper protection 19 November 2018 © Copyright Virtual University of Pakistan
© Copyright Virtual University of Pakistan Default Permissions 777 for executable files and directories 666 for text files Can be changed with the umask command 19 November 2018 © Copyright Virtual University of Pakistan
© Copyright Virtual University of Pakistan UNIX Protection chmod 761 game1 owner group others Read Write Execute Read Write Execute 19 November 2018 © Copyright Virtual University of Pakistan
© Copyright Virtual University of Pakistan UNIX Protection chmod 755 projectAthena owner group others Read Write Search Read Search Read Search 19 November 2018 © Copyright Virtual University of Pakistan
© Copyright Virtual University of Pakistan UNIX Protection Sample commands chmod 700 ~ chmod 744 ~/file chmod 755 ~/directory ls –l ~ ls –ld ~ ls –l prog1.c ls –ld ~/courses 19 November 2018 © Copyright Virtual University of Pakistan
© Copyright Virtual University of Pakistan UNIX Protection The umask Command Sets default permissions on newly created files and directories as (default permissions – mask value) umask umask 022 touch temp1 ls –l temp1 19 November 2018 © Copyright Virtual University of Pakistan
© Copyright Virtual University of Pakistan File Control Block UNIX inode 19 November 2018 © Copyright Virtual University of Pakistan
In-Memory Data Structures The following upper-level data structures needed for file system support. Mapping directory entry for the file to the file control block at the time of opening a file. Mapping used while reading or writing a file. 19 November 2018 © Copyright Virtual University of Pakistan
In-Memory Data Structures 19 November 2018 © Copyright Virtual University of Pakistan
Per Process File Descriptor Table File Descriptor to File Contents Per Process File Descriptor Table File Table Inode Table File Descriptor 1 2 3 4 OPEN_MAX — 1 File’s contents … … … … … 19 November 2018 © Copyright Virtual University of Pakistan
Space Allocation Methods Contiguous allocation Linked allocation Indexed allocation 19 November 2018 © Copyright Virtual University of Pakistan
Contiguous Allocation Each file occupies a set of contiguous blocks on the disk Best-fit, first-fit, or worst-fit algorithm Directory entry contains starting block number and file size (in blocks) Good sequential and random access External fragmentation User needs to declare file size Expensive file growth 19 November 2018 © Copyright Virtual University of Pakistan
Contiguous Allocation 19 November 2018 © Copyright Virtual University of Pakistan
© Copyright Virtual University of Pakistan Linked Allocation Each file is a linked list of disk blocks: blocks may be scattered anywhere on the disk. Simple – need only starting address No wastage of space No random access 19 November 2018 © Copyright Virtual University of Pakistan
© Copyright Virtual University of Pakistan Linked Allocation 19 November 2018 © Copyright Virtual University of Pakistan
© Copyright Virtual University of Pakistan Index Allocation Brings all pointers together into the index block Logical view Index table Data blocks 19 November 2018 © Copyright Virtual University of Pakistan
© Copyright Virtual University of Pakistan Index Allocation 19 November 2018 © Copyright Virtual University of Pakistan
© Copyright Virtual University of Pakistan Recap of Lecture File Sharing File Protection In-Memory Data Structures Space Allocation Techniques Contiguous, Linked, Index 19 November 2018 © Copyright Virtual University of Pakistan
© Copyright Virtual University of Pakistan Operating Systems Lecture 44 Syed Mansoor Sarwar 19 November 2018 © Copyright Virtual University of Pakistan