Operating Systems 142 Practical Session 12 File Systems
- Slides: 40
Operating Systems, 142 Practical Session 12 File Systems, part 2 1
File system layout (Tanenbaum) 2
Quick recap: i-Nodes • An i-node (index node) is a data structure containing pointers to the disk blocks that contain the actual file contents. • Every i-node object represents a single file. • An i-node needs to be in Main Memory only if the correspondent file is open. 3
Quick recap: FAT • A FAT (File allocation table) contains the chains of disk blocks. Each chain defines a different file. • Every entry in the FAT points to the next disk block of the file. • Chains of blocks are terminated by a special marker – end_of_file character. • Directory entry points to first block in a file (i. e. specifies the block number). • The FAT is held in Main Memory and its size is proportional to the disk size.
Recap: MS-DOS directory entry • Tree structure (no links) • directories provide information about location of file blocks (directly or indirectly. . ) • Both names and attributes are IN the directory • read-only • hidden • system • archive An index into the 64 K –entry FAT MS-DOS uses fixed size 32 -byte directory entries 5
NTFS • Each file is represented by a record in a special file called the master file table (MFT). • Directories are also files. • The first 16 records of the table are reserved for special information and the first record of this table describes the master file table itself, followed by a MFT mirror record. • The seventeenth and following records of the master file table are for user files and directories. • The master file table allocates a certain amount of space for each file record (for attributes and initial data). • Small files can be entirely contained within the master file table record in this case file access is very fast.
MFT records
The MFT record of a long file A file that requires three MFT records to store its runs Ben-Gurion University Operating Systems, Semester B 2008, Danny Hendler 8
NFS – Network File System • • Allows sharing of file Systems. A server exports part of its file system. A client can mount an exported file system. A stateless protocol. The server remembers nothing about previous requests from a client.
Design compare EXT 4 NTFS 6 FAT 32 Indexed, by “runs” Linked i-node (default size 256 KB) MFT record (default size 1 Kb) Chain of clusters pointed from a Directory entry Location of filename Directory entry, MFT record Directory entry Location of attributes i-node MFT record Directory entry Allocation method File representation Data access Location of index table For small files- the contents inside the MFT i-node contain pointers record, for larger- with different levels of organized as 'runs' indirection which may span multiple MFT records i-nodes table immediately after the superblock MFT anywhere, pointed by MBR Directory entry Points to 1 st link in chain FAT anywhere, pointed by MBR 10
Features compare EXT 4 NTFS 6 FAT 32 Built in security Yes No Recoverability Yes, via data and metadata journaling Yes, via metadata journaling No Efficient disk usage Yes, via sparse files Yes, via compression, sparse files No No Some, tries to store files sequentially Yes 16 TB (for 4 k block) 16 EB by design, 16 TB by implementation 4 GB 1 EB (1 EB=1, 000 TB) 16 EB 2 TB 255 chars (case sensitive) Originally 8+3, extended to 255 (not case sensitive) Hard links Yes No Soft links Yes No Fragmentation problem Max file size Max volume size Max filename length 11
Pros & Cons Pros Cons EXT 4 NTFS 6 FAT 32 • Supports large volumes and files • Built in security and permissions • Recoverability • Unicode file names • Extended file attributes • No fragmentation problems, no maintenance needed • Small memory footprint • Modern • Supports large volumes and files • Built in security and permissions • Recoverability • Unicode file names • Extended file attributes • High performance on large directories and files • Simple • Widely supported • Efficient for small files on small volumes and sequential access • Compatibility issues with • Fragmentation problem other OS • Inefficient on small • Larger disk footprint volumes than NTFS • Performance degrades when disk is almost full • Size of MFT grows with usage • Obsolete • Not suitable for large volumes and files • No recoverability • No security • No user permissions • Fragmentation 12 reduce performance
Question 1: FAT A FAT starts with the following values: Assuming that slots with -1 indicates an end of file and slots with 0 indicates a free slot: 1. If the directory containing a certain file has 7 as the starting block, how many blocks does that file contain? 2. The owner of the file has written two more blocks to the file. Adjust the FAT to the change.
Question 1: FAT 1. 4 2. 14 , 19 , 8 , -1 , 9 , 3 , 2 , 5 , 10 , -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 X X EOF 13 2 9 8 Free Y 12 3 FREE EOF FREE BAD Not allocated End of file Marked as a bad block File A: 6 8 4 File B: 5 9 12 File C: 10 3 13 2
Question 2: FAT (2007 a) קוד המתאר את פעולתה של פרוצדורה - ( כתבו פסאודו b soft-link(old-path, new-path). soft-link המממשת את הפקודה Procedure soft-link(old-path, new-path) { // get directory-name and entry-name Convert new-path to <dir. Name, entry. Name> // allocate a new directory entry in directory dir. Name new-entry ← allocate-new-entry(dir. Name) new-entry. filename ← entry. Name new-entry. link ← true // indicate that this is a symbolic link allocate a single block, initialize with old-path, set it as new-entry's single block new-entry. data ← old-path }
Question 2: FAT (2007 a)
Question 2: FAT (2007 a) , hard-link(old-path, new-path) קוד המתאר אל פעולתה של פרוצדורה - ( כתבו פסאודו b. hard-link המממשת את הפקודה Procedure hard-link(old-path, new-path) { // get directory-name and entry-name Convert new-path to <dname, ename> // allocate a new directory entry in directory dname new-entry ← allocate-new-entry(dname) new-entry. filename ← ename // locate old-path dnote entry dnode-entry-num ← locate-dnote-entry(old-path) // point from directory entry to dnode entry new-entry. dnode ← dnode-entry-num // Increment links number dnodes[dnodes-entry-num]. links++ }
Question 3 a (Moed b, 2007) Client kernel Server kernel System call layer v-nodes Virtual file system layer i-nodes Local FS 1 Local FS 2 Virtual file system layer NFS server Local FS 1 Local FS 2 r-nodes Buffer cache Message to server Message from client 25
Question 4 (Moed b 2006) 1. I was here first. I was here second 2. int fd 2=open (“dugma 1. txt”, O_WRONLY, 0666); output is : I was here second Why?
Open File Description Table & File Descriptor Table Parent’s file descriptors table Child’s file descriptors table Unrelated process’s file descriptors table Open files description table File position RW pointer to i-nodes table
Locking Files • Two or more processes accessing a file together can cause race conditions. • Ability to lock any number of bytes of a file. • Two kinds of locks shared locks, exclusive locks • C Function is int flock(int fd, int operation); • flock is an advisory lock
Locking Files • flock doesn’t work over NFS • Locking a whole file is wasteful. • lockf(int fd, int cmd, off_t len) – Allows locking over NFS by implementing another protocol (Network Lock Manager) L – No shared locking – Also an advisory lock – Commands: F_ULOCK (unlock), F_LOCK (lock (unlock) [blocking]), F_TLOCK (test & lock [non-blocking]), [blocking]) (test & lock [non-blocking]) F_TEST (test)
Question 4 (Moed b 2006) [revised] int main(char ** argv, int argc){ int stat; int fd=open("dugma 1. txt", O_WRONLY, 0666); if (fork()==0){ int fd 2=open("dugma 1. txt", O_WRONLY, 0666); sleep(10); if (lockf(fd 2, F_TLOCK, 17)>=0){ write (fd 2, "I was here second", 17); } }//if else{ lockf(fd, F_TLOCK, 16); write (fd, "I was here first", 16); wait(&stat); } } . הקוד את שינו ? עכשיו הפלט יהיה מה . הסבר
- File-file yang dibuat oleh user pada jenis file di linux
- Module 4 operating systems and file management
- Practical session definition
- Practical session definition
- Practical session meaning
- Multipicand
- Management files for
- File management in android operating system
- What are the main components of file management
- File system in operating system
- File system in operating system
- File system in operating system
- Difference between logical file and physical file
- Fungsi sistem file
- Distributed file system definition
- What does a markup tag tells the web browser
- In a file-oriented information system, a transaction file
- 1 to 200 prime numbers
- Pl-94-142
- Pl-94-142
- 18 numero romano
- Cs 142 stanford
- Psalms 142:4
- Mat 142
- 142 984 in scientific notation
- Phm 142
- Superget move 5000 essential
- Generel helbredsattest
- Stanford cs 142
- Convenio 140 oit
- Intangible inputs
- Sfas 142
- Physics 142
- Dicom supplement 142
- Phys 142
- 12 742 km in miles
- 142 cooper river drive
- 100000/142
- Operating software example
- Evolution of operating systems
- Components of an operating system