1 Week 13 FAT32 Utility Operations Guide: rm and rmdir Classes COP4610 / CGS5765 Florida State University.

Slides:



Advertisements
Similar presentations
Chapter 4 : File Systems What is a file system?
Advertisements

Operating Systems Lecture 10 Issues in Paging and Virtual Memory Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing.
1 Week 11 FAT32 Boot Sector, Locating Files and Dirs Classes COP4610 / CGS5765 Florida State University.
Free Space and Allocation Issues
Text Searches Slack Space Unallocated Space
Recap – Intro to Project 3 and FAT32
1 Week 12 FAT32 Utility Operations Guide Classes COP4610 / CGS5765 Florida State University.
Ext2/Ext3 Linux File System Reporter: Po-Liang, Wu.
In this assignment you are going to read floppy disk. You can run ‘mdir’ Unix function to see what output your program should give. FAT-12 MS-DOS file.
When you log into unix you are in the root directory Root directory To create a new directory you must type: mkdir newdirectory This will create a new.
CS 333 Introduction to Operating Systems Class 18 - File System Performance Jonathan Walpole Computer Science Portland State University.
Cse Feb-001 CSE 451 Section February 24, 2000 Project 3 – VM.
Ext3 Journaling File System “absolute consistency of the filesystem in every respect after a reboot, with no loss of existing functionality” chadd williams.
File Management System The way a user or application may access files Programmer does not need to develop file management software You take files for granted.
7/15/2015B.RamamurthyPage 1 File System B. Ramamurthy.
Backup and Recovery Part 1.
Week 10 Project 3: An Introduction to File Systems
Transactions and Reliability. File system components Disk management Naming Reliability  What are the reliability issues in file systems? Security.
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
1 THE UNIX FILE SYSTEM By Chokechai Chuensukanant ID COSC 513 Operating System.
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
1 Project Information and Acceptance Testing Integrating Your Code Final Code Submission Acceptance Testing Other Advice and Reminders.
CPSC 217 T03 Week I Part #1: Unix and HELLO WORLD Hubert (Sathaporn) Hu.
The Design and Implementation of Log-Structure File System M. Rosenblum and J. Ousterhout.
26-Oct-15CSE 542: Operating Systems1 File system trace papers The Design and Implementation of a Log- Structured File System. M. Rosenblum, and J.K. Ousterhout.
10/28/20151 Operating Systems Design (CS 423) Elsa L Gunter 2112 SC, UIUC Based on slides by Roy Campbell, Sam.
SOCSAMS e-learning Dept. of Computer Applications, MES College Marampally VIRTUALMEMORY.
File Systems in Real-Time Embedded Applications March 6th Eric Julien Balancing Performance, Safety and Resource Usage in an Embedded File System 1.
Project 6 Unix File System. Administrative No Design Review – A design document instead 2-3 pages max No collaboration with peers – Piazza is for clarifications.
Solutions for the First Quiz COSC 6360 Spring 2014.
File Systems Operating Systems 1 Computer Science Dept Va Tech August 2007 ©2007 Back File Systems & Fault Tolerance Failure Model – Define acceptable.
CS333 Intro to Operating Systems Jonathan Walpole.
Lecture 21 LFS. VSFS FFS fsck journaling SBDISBDISBDI Group 1Group 2Group N…Journal.
File Systems. 2 What is a file? A repository for data Is long lasting (until explicitly deleted).
File Systems cs550 Operating Systems David Monismith.
Operating System Concepts and Techniques Lecture 15 Deadlock and starvation-1 M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and Techniques,
11.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles 11.5 Free-Space Management Bit vector (n blocks) … 012n-1 bit[i] =  1  block[i]
Transactions and Reliability Andy Wang Operating Systems COP 4610 / CGS 5765.
Lecture 20 FSCK & Journaling. FFS Review A few contributions: hybrid block size groups smart allocation.
File Systems - Part I CS Introduction to Operating Systems.
Details of Final Exam Format will be similar to the midterm, however, there will be more emphasis on longer written answers, less on multiple choice and.
Chapter 8 File Systems FAT 12/16/32. Defragmentation Defrag a hard drive – Control Panel  System and Security  Administration tools  Defrag hard drive.
Operating Systems, Winter Semester 2011 Practical Session 11 File Systems, part 1 1.
Database Applications (15-415) DBMS Internals- Part III Lecture 13, March 06, 2016 Mohammad Hammoud.
File-System Management
File System Consistency
Jonathan Walpole Computer Science Portland State University
Transactions and Reliability
The Buffer Cache.
FAT32 Directory Entries and Operations Guide
Useful Linux Commands.
FAT32 Directory Entries and Operations Guide
Chapter 11: File System Implementation
Hash-Based Indexes Chapter 11
Project 3: An Introduction to File Systems
File Management.
Database Applications (15-415) DBMS Internals- Part III Lecture 15, March 11, 2018 Mohammad Hammoud.
Operation System Program 4
Chapter 11: File System Implementation
File Systems Implementation
Lecture 20 LFS.
File System B. Ramamurthy B.Ramamurthy 11/27/2018.
Normal deletion Shift deletion
Hash-Based Indexes Chapter 10
FAT32 Directory Entries and Operations Guide
Disk Structure Analysis
CSE 451 Fall 2003 Section 11/20/2003.
Lecture 11: Flash Memory and File System Abstraction
Module 6 Working with Files and Directories
Chapter 11 Instructor: Xin Zhang
Presentation transcript:

1 Week 13 FAT32 Utility Operations Guide: rm and rmdir Classes COP4610 / CGS5765 Florida State University

Outline Problem of orphaned data File removal walkthrough Directory removal walkthrough 2

Orphans 3

What is orphaned data? Orphaned data – data marked as valid in the file system that cannot be reached through the file system mechanisms How could this ever happen? 4

Orphan Example Suppose we want to delete a file It has  A directory entry with a first cluster number  Data clusters  Entries in the FAT 5

DATA Orphan Example 6 FAT Dir Entry: First Cluster # EoC Index Next Cluster Cluster numbers Our sample file starts at cluster 3 and continues to cluster 4.

Orphan Example Normally when we want to find a file’s contents, we start by reading its directory entry contents  What if we start deleting there? 7

DATA Orphan Example 8 FAT Dir Entry: First Cluster # EoC Index Next Cluster Cluster numbers Step 1: Read the file’s first cluster number into memory.

DATA Orphan Example 9 FAT EoC Index Next Cluster Cluster numbers Step 2: Delete the file’s directory entry.

DATA Orphan Example 10 FAT EoC Index Next Cluster Cluster numbers Step 3: Look up cluster 3 in the FAT.

DATA Orphan Example 11 FAT EoC Index Next Cluster Cluster numbers Step 4: Read the file’s next cluster number into memory (4).

DATA Orphan Example 12 FAT EoC Index Next Cluster Cluster numbers Crash!

Orphan Example We just crashed and have to reboot the system Can the file system get to the data we were deleting? 13

DATA Orphan Example 14 FAT EoC Index Next Cluster Cluster numbers We are now in trouble. Since we deleted the file’s directory entry, we don’t know where the file started…

DATA Orphan Example 15 FAT EoC Index Next Cluster Cluster numbers Leftover entries in the FAT that we can never reclaim… Allocated disk space we can never clean up…

Preventing Orphans How can we avoid the chance of orphans while we delete? Answer: delete backwards! 16

DATA Preventing Orphans 17 FAT Dir Entry: First Cluster # EoC Index Next Cluster Cluster numbers Step 1: Read through entire file until we find the last cluster entry for the file in the FAT

DATA Preventing Orphans 18 FAT Dir Entry: First Cluster # Index Next Cluster Cluster numbers Step 2: Mark the last cluster as free. What happens if we crash here?

DATA Preventing Orphans 19 FAT Dir Entry: First Cluster # Index Next Cluster Cluster numbers Step 3: Find the new last file cluster in the FAT.

DATA Preventing Orphans 20 FAT Dir Entry: First Cluster # Index Next Cluster Cluster numbers Step 4: Mark the last cluster as free.

DATA Preventing Orphans 21 FAT Index Next Cluster Cluster numbers Step 5: Finally, if all the FAT entries for the file are marked free, delete the directory entry.

DATA Preventing Orphans 22 FAT Index Next Cluster Cluster numbers Why don’t we zero out the file’s data?

File Data Leftovers Most file systems only update metadata upon deletion and leave old data as it was. Why?  Old data will just be overwritten later anyway by new, valid data  File system will never display old data to the user because it is no longer part of a file  It can take a significant amount of time to zero over large amounts of file data  Zeroing the data can cause extra wear on the device 23

File Data Leftovers File recovery utilities leverage this situation  Scans the file system for data clusters that are not currently allocated 24

File Deletion rm operation 25

File Deletion : rm 1. Check that the file to removed is a file and does exist  Cannot use this utility command to delete a directory 2. Seek to the last cluster entry in the FAT 3. Mark the last cluster entry in the FAT with the free mark of 0x Repeat 2 and 3 until there are no more cluster entries in the FAT 5. Delete the file’s directory entry 26

Deleting a Directory Entry Can just mark the first byte in the directory entry to symbolize deletion  If DIR_Name[0] == 0xE5, then the directory entry is free (no file or directory name in this entry)  If DIR_Name[0] == 0x00, then the directory entry is free (same as for 0xE5), and there are no allocated directory entries after this one 27

Deleting a Directory Entry 28 Deleted directory entry staring with 0xE5

Deleting a Directory Entry 29 Starts with 0x00, so no more directory entries in this cluster

rm Use Cases Successful rm /FILES/] ls... CONST.TXT EMPTY.TXT HELLO.TXT /FILES/] rm HELLO.TXT /FILES/] Unsuccessful rm /FILES/] rm NOTHERE.TXT Error: does not exist /FILES/] 30

Directory Deletion rmdir 31

Directory Deletion: rmdir 1. Check that directory to be removed is empty and is actually a directory 2. Go to step #2 for rm  Rest of directions just like deleting a file! 32

rmdir Use Cases Successful rmdir /DIRS/] rmdir A /DIRS/] Unsuccessful rmdir /DIRS/] rmdir B Error: directory not empty /DIRS/] 33

rmdir Use Cases Unsuccessful rmdir /DIRS/] cd.. /] rmdir FATINFO.TXT Error: not a directory /] 34

Next Time Today’s lecture is last recitation lecture Next recitation will be office hours 35

Project 3 Submission Hints Make sure everything is included!  Points will be taken off if things are missing Make sure the project at least compiles  If it doesn’t, it will get a 0. Please remove all executables and *.o files before ing submissions Please submission to TA address 36

Questions? Good luck with project 3 and finals! 37