ENGR 3950U / CSCI 3020U (Operating Systems) Simulated UNIX File System Project Instructor: Dr. Kamran Sartipi

Similar documents
ENGR 3950U / CSCI 3020U Midterm Exam SOLUTIONS, Fall 2012 SOLUTIONS

Chapter 11: File System Implementation

Lab 03 - x86-64: atoi

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

Project #1 Exceptions and Simple System Calls

COMP SCI 3SH3: Operating System Concepts (Term 2 Winter 2006) Test 2 February 27, 2006; Time: 50 Minutes ;. Questions Instructor: Dr.

ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University

Programming Standards: You must conform to good programming/documentation standards. Some specifics:

File. File System Implementation. File Metadata. File System Implementation. Direct Memory Access Cont. Hardware background: Direct Memory Access

CS261: HOMEWORK 2 Due 04/13/2012, at 2pm

File Systems 1. File Systems

File Systems 1. File Systems

Data and File Structures Chapter 2. Basic File Processing Operations

Homework 3 Grade Database Management Due Date

we are here Page 1 Recall: How do we Hide I/O Latency? I/O & Storage Layers Recall: C Low level I/O

Compiling Your Code and Running the Tests

Project 2: Shell with History1

File. File System Implementation. Operations. Permissions and Data Layout. Storing and Accessing File Data. Opening a File

Files and File Systems

CS3114 (Fall 2013) PROGRAMMING ASSIGNMENT #2 Due Tuesday, October 11:00 PM for 100 points Due Monday, October 11:00 PM for 10 point bonus

(In columns, of course.)

Files and File Systems

Project 2 - Kernel Memory Allocation

Programming Assignment 3

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes

we are here I/O & Storage Layers Recall: C Low level I/O Recall: C Low Level Operations CS162 Operating Systems and Systems Programming Lecture 18

CS164: Programming Assignment 5 Decaf Semantic Analysis and Code Generation

CS 385 Operating Systems Fall 2011 Homework Assignment 5 Process Synchronization and Communications

UNIX Kernel. UNIX History

Part 1. Introduction to File Organization

CSI 402 Systems Programming LECTURE 4 FILES AND FILE OPERATIONS

University of Toronto

Lab 09 - Virtual Memory

CSC 553 Operating Systems

Basic filesystem concepts. Tuesday, November 22, 2011

Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

CS354/CS350 Operating Systems Winter 2004

CS Fundamentals of Programming II Fall Very Basic UNIX

Due: February 26, 2014, 7.30 PM

Principles of Bioinformatics. BIO540/STA569/CSI660 Fall 2010

CS 2505 Fall 2013 Data Lab: Manipulating Bits Assigned: November 20 Due: Friday December 13, 11:59PM Ends: Friday December 13, 11:59PM

Segmentation with Paging. Review. Segmentation with Page (MULTICS) Segmentation with Page (MULTICS) Segmentation with Page (MULTICS)

UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4500/8506 Operating Systems Fall Programming Assignment 1 (updated 9/16/2017)

ADVANCED OPERATING SYSTEMS

OPERATING SYSTEMS, ASSIGNMENT 4 FILE SYSTEM

CS 0449 Intro to Systems Software Fall Term: 2181

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

CMSC 412 Project 1: Keyboard and Screen Drivers

Project 4: File System Implementation 1

Announcements. 1. Forms to return today after class:

Directory. File. Chunk. Disk

UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4500/8506 Operating Systems Summer 2016 Programming Assignment 1 Introduction The purpose of this

Programming Assignment #4

Introduction to OS. File Management. MOS Ch. 4. Mahmoud El-Gayyar. Mahmoud El-Gayyar / Introduction to OS 1

How do we define pointers? Memory allocation. Syntax. Notes. Pointers to variables. Pointers to structures. Pointers to functions. Notes.

File System Definition: file. File management: File attributes: Name: Type: Location: Size: Protection: Time, date and user identification:

1 PROJECT OVERVIEW This project develops a simple file system using an emulated I/O system. The following diagram shows the basic organization:

CS 1550 Project 3: File Systems Directories Due: Sunday, July 22, 2012, 11:59pm Completed Due: Sunday, July 29, 2012, 11:59pm

3. When you process a largest recent earthquake query, you should print out:

Computer 2 App1. App3 API Library. App3. API Library. Local Clipboard

File System Interface and Implementation

5/8/2012. Creating and Changing Directories Chapter 7

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: C and Unix Overview

1. Introduction. 2. Deliverables

CSCI-1200 Data Structures Spring 2014 Lecture 5 Pointers, Arrays, Pointer Arithmetic

Programming Assignment #4 Arrays and Pointers

Operating Systems. Project #2: System Calls

Out: April 19, 2017 Due: April 26, 2017 (Wednesday, Reading/Study Day, no late work accepted after Friday)

File Systems. What do we need to know?

File Organization Sheet

Summer June 15, 2010

***PRACTICE EXAM 02 for*** CS16 Midterm Exam 2 E02, 09F, Phill Conrad, UC Santa Barbara Actual exam scheduled for: 11/18/2009

Lecture 3. Introduction to Unix Systems Programming: Unix File I/O System Calls

CS6401- Operating System QUESTION BANK UNIT-IV

CSCI Compiler Design

CMSC 313 Lecture 13 Project 4 Questions Reminder: Midterm Exam next Thursday 10/16 Virtual Memory

Today. Review. Unix as an OS case study Intro to Shell Scripting. What is an Operating System? What are its goals? How do we evaluate it?

CSC209. Software Tools and Systems Programming.

Week 10 Project 3: An Introduction to File Systems. Classes COP4610 / CGS5765 Florida State University

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

Incoming Exam. CS 201 Introduction to Pointers. What is a Pointer? Pointers and Addresses. High Speed Memory (RAM) Size of Variable Types.

CSCE 455/855 Distributed Operating Systems

CSC116: Introduction to Computing - Java

CS4411 Intro. to Operating Systems Final Fall points 10 pages

CST8207: GNU/Linux Operating Systems I Lab Ten Boot Process and GRUB. Boot Process and GRUB

CSC 112 Lab 1: Introduction to Unix and C++ Fall 2009

CS 314 Principles of Programming Languages Fall 2017 A Compiler and Optimizer for tinyl Due date: Monday, October 23, 11:59pm

Project 3: An Introduction to File Systems. COP4610 Florida State University

CSCI-1200 Data Structures Spring 2017 Lecture 5 Pointers, Arrays, Pointer Arithmetic

Physical Files and Logical Files. Opening Files. Chap 2. Fundamental File Processing Operations. File Structures. Physical file.

SMD149 - Operating Systems - File systems

Assignment 3: Inheritance

Target Definition Builder. Software release 4.20

CpSc 1111 Lab 6 Conditional Statements, Loops, the Math Library, and Random Numbers What s the Point?

Basic Tiger File System for SmartMedia. Version 1.04

! Determine if a number is odd or even. ! Determine if a number/character is in a range. - 1 to 10 (inclusive) - between a and z (inclusive)

UNIX File System. UNIX File System. The UNIX file system has a hierarchical tree structure with the top in root.

PESIT Bangalore South Campus

File Systems. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

The UNIX File System

Transcription:

ENGR 3950U / CSCI 3020U (Operating Systems) Simulated UNIX File System Project Instructor: Dr. Kamran Sartipi Your project is to implement a simple file system using C language. The final version of your program must compile and execute in the Linux environment. Develop your project using Eclipse IDE. You will be given code to simulate access to a block-oriented storage device. You are to implement a file system that will reside on the simulated device. The interface and functionality of the file system are described later in this document. Your grade will be based on correctness of execution and on the quality and style of your code and documentation. At the end of this project, you will find a list of items you are expected to submit for grading. The Block I/O System Two routines are available to simulate access to a block-oriented storage device, e.g., a disk. The simulated device holds 512 blocks, numbered from 0 to 511. Each block holds 128 bytes. A routine called put_block copies 128 bytes of data from memory to one of the device blocks. The first argument to put_block specifies which device block to copy to. The second is a pointer to the data in memory. A routine called get_block copies the contents of a specified device block into memory at a specified address. Like put-block, it takes two arguments, one to specify the disk block and the second to specify a memory address. The get_block routine does not allocate memory, so the memory pointer that it is passed should point to a least 128 bytes of space that your program has allocated. Code for the get_block and put_block routines is available in the file blockio.c, which you should compile and link with your file system code. There is also a file blockio.h containing function declarations that can be included in your programs that use the block I/O functions. You will find that these functions store the simulated device's data in a file called "simdisk.data". If a file with that name exists in the current directory (from a previous run of your program), the functions will use it. Otherwise, a new one will be created. When a simulated disk is first created, all of the bytes of all of the blocks of the disk are initialized to zero. You must use these functions as given with no modifications. Furthermore, your file system should use only these functions to store and retrieve data. You should not use any Linux file system calls (e.g., read(), write(), open()) in your project. The File System You are to implement a file system with a UNIX-like hierarchical directory structure. When a file is opened, your system should return a file descriptor to its caller. The file descriptor will be used, as discussed in class, to identify the open file during any subsequent operations on it. Each sfs_open() call should result in a new file descriptor, even if the file is already opened. File Types Your system should support two types of files: regular files and directories. As discussed in class, directories are used to implement hierarchical file names. Your system should not allow the sfs_writer() or sfs_read() functions to be used on directory files. Directories are updated by the file system as necessary, e.g., when a new file is created within the directory. Directories are read using the special sfs_readdir() function. File Names Your system should implement a hierarchical UNIX-like file-naming scheme. The pathname "/" should refer to the root directory of the file system, and " /" should also be used to separate the components of a path name. All pathnames used as arguments to file system calls must be absolute, i.e., they must be specified Page 1 of 5

from the root directory. Thus, "/foo/bar/zam" is a legitimate pathname, but "bar/zam" is not. Each component of a pathname, e.g., "foo" or "zam", must be limited by your system to at most six characters. Implementation Requirements Each file must be assigned a unique internal identification number, like a UNIX i-number. Your system should use a hierarchical directory scheme for pathname-to-file-number translation. Each directory file should consist of a number of directory entries. Each directory entry should include a pathname component. Users can read the pathname components from a directory using the sfs_readdir function defined below. File System Limits Your file system must meet the following criteria. It must be capable of supporting at least 4 open files at one time. It must support individual files (including directories) that are up to 512 bytes long. It must allow at least 64 files to exist in the file system at one time (provided that they all fit on the disk). These are minimum requirements. Your system may be less restrictive, e.g., it may permit files to grow larger than 512 bytes. It may not be more restrictive. As noted above, the length of a pathname component must be limited to six characters. This is not a flexible criterion. Do not allow pathname components longer than six characters. This restriction is necessary so that the amount of data returned by sfs_readdir can be defined in the file system interface. File System Interface Your file system's interface should include the functions described below. In these descriptions, the fd argument is a file descriptor, returned by a previous call to sfs_open. sfs_open(char *pathname): Open the file specified by pathname. It is an error for the file not to exist. If a file is successfully opened, a file descriptor should be returned to the caller. A file descriptor is a nonnegative integer value. sfs_read(int fd, int start, int length, char *mem_pointer): Copy length bytes of data from a regular file to the memory location specified by mem_pointer. The parameter start gives the offset of the first byte in the file that should be copied. So, if start is 10 and length is 5, then bytes 10 through 14 of the file should be copied into memory. (Assume a zero-based count, i.e., the first byte in a file is called byte 0). If a read request cannot be fully satisfied because the file is not long enough, no data should be copied from the file, and an error value should be returned. sfs_write(int fd, int start, int length, char *mem_pointer): Copy length bytes of data from the memory location specified by mem_pointer to the specified file. The parameter start gives the offset of the first byte in the file that should be copied to. So, if start is 10 and length is 5, then five bytes from memory should be used to overwrite bytes 10 through 14 in the file. Alternatively, the value of start may be set to -1. This indicates that the specified number of bytes should be appended to (added to the end of) the file. Appending (setting start to -1) is the only allowable way to increase the length of a file. This means that if start is not -1, then it is an error for (start + length -1) to be greater than the current length of the file. sfs_readdir(int fd, char *mem_pointer): This call is used to read the file name components from a directory file. The first time sfs_readdir is called, the first file name component (a string) in the directory should be placed into memory at the location pointed to by mem_pointer. The function should return a positive value to indicate that a name component has been retrieved. Each successive call to sfs_readdir should place the next name component from the directory into the buffer, and should return a positive value. When all names have been returned, sfs_readdir should place nothing in the buffer, and should return a value of zero to indicate that the directory has been completely scanned. sfs_close(int fd): Indicates that the specified file descriptor is no longer needed. Page 2 of 5

sfs_create(char *pathname, int type): If there is not already a file with name pathname, create one. If the specified name is already in use, return an error. The parameter type is an integer which should have value zero or one. If zero, a regular file should be created. If one, a directory file should be created. All components of pathname (except the last) must already exist, i.e., the total number of files in the file system should increase by exactly one when this command is executed without error. sfs_delete(char *pathname): Delete the specified file or directory, if it exists. Directories must be empty to be deleted, i.e., the total number of files in the file system should decrease by exactly one when this command is executed without error. This call should return an error if pathname specifies a directory that is not empty. sfs_getsize(char *pathname): If the specified file is a regular file, this function should return the number of bytes in the file. If it is a directory file, this function should return the number of directory entries in the file. sfs_gettype(char *pathname): This function should return the value zero if the specified file is a regular file. It should return the value one if the file is a directory. sfs_initialize(int erase): The sfs_initialize function must be called before any other file system functions are called. (In addition, it may be called at any other time.) This function may be used to perform any initialization required by your file system. (See "Simulating Failures", below.) Normally, the value of erase will be zero. If the value of erase is one, this indicates that any existing file system on the simulated disk is to be destroyed, and that a brand new file system should be created. Any existing files on the device are destroyed by this call if the value of erase is set to one. A new file system should consist of a single, empty root directory and no other directories or regular files. To simplify your implementation, you may assume that the value of the length and start parameters to the sfs_read and sfs_write calls will always satisfy the following formula: In other words, no read or write operation will use data more than one device block. All of the file system calls should return an integer value. In all cases, a negative value should be used to indicate an error. Unless otherwise specified, a strictly positive value should be used to indicate successful execution. You should define a set of (negative) error codes to be used by functions that cannot execute properly. The return code should indicate the source of the problem. For example, the sfs_create function may fail because the specified file name is already in use, or because there is no room on the simulated disk for additional files. Each type of error should have its own return code. Testing Your File System This project requires you to implement a set of file system interface functions. To test your code, you must also write one or more test programs. Such programs provide a main() routine and call the file system functions. Do not submit your test programs along with your file system implementation. To get you started with this, and to provide you with an illustration of how the file system functions may be used, a simple interactive test program will be made available to you in the file sfstest.c that you should put it into your working directory. To use the interactive test program, you will need to compile and link it with your file system implementation. You may use a command similar to the following one to do this: gcc -o sfstest sfstest.c your-source-files-here blockio.c Page 3 of 5

This should produce an executable file called "sfstest" which you may use to test your file system code. Look at sfstest.c to get an idea of how to use the interactive test program. Simulating Failures File system data resides permanently on disk because disk-resident data survives failures such as power outages. We will simulate failures by terminating the process in which your file system is running. The easiest way to terminate a process is to interrupt it, e.g., to type "control-c" at the keyboard. Your file system should be able to survive any failure that occurs while there is no file system function executing. Survival means that any changes that have been made to the file system should not be lost because of the failure. In particular when running the interactive test program, it should be possible to interrupt the program any time it prompts for a new file system request to execute. If the program is then restarted, the file system should include all changes (new files, deleted files, written data, etc.) that were made before the program was interrupted. Files should never be lost unless sfs_initialize is used to start a new file system on the simulated disk. After the program is restarted, sfs_initialize will be called before any other file system functions. When sfs_initialize is called, your code must determine whether a file system already exists on the simulated disk from a previous run of the program. You must determine how to do this. You should take advantage of the fact that the entire disk is initialized to Zero when it is first created. If no file system exists on the disk, or if one already exists but the erase parameter is set to one, your code should create a new, empty file system on the disk, as was described for sfs_initialize. Deliverables You should submit the following items (as a single zipped file) through Blackboard System by the project due dates. 1) File System Design Document: DUE Friday October 26, 2012 at 11:59pm. [30 Marks]. This document provides an overview of the design of your file system including: Definitions of major data structures in your simulated Unix File System, with description of how they are used to implement the required file operations (e.g., sfs-create( )). Description of how file system information is laid out on the simulated disk. Design of algorithms (in Pseudocode) of the above file operations. 2) Source Code and Test Suite: DUE Monday November 26, 2012, at 11:59pm. [50 Marks] Submit source code for your file system. Your code should be neat, clear and well documented. A makefile will be available for you to compile your code. It is important that your file system interface conform exactly to the project specifications. 3) Project Presentation: Monday (November 26 th & December 3 rd ) 2012 during the lab: [20 Marks] Each group will present different features of their simulated Unix File System to the course TAs in the lab. The TAs will ask questions about the design document, source code, and the implemented system. The mark is based on the participation in the discussions, logic for the design, and the correctness of the simulated file system. Page 4 of 5

NOTE: Cheating Policy The work submitted by each group must be the work of that group only. It is not permissible to share code, documentation, or design effort. You may discuss the project in general terms and may discuss the public aspects of the project (such as this handout). However, the projects must be designed, implemented and documented independently by each group. Note that it is the responsibility of each student to ensure that his or her on-line code and documentation are protected from general access. The Linux command chmod 600 filename (use 700 for executable files or directories) will set a file's access permissions so that only the owner of the file may read or write (or execute) it. The penalty for cheating is a grade of -100% on the project or exam. Acknowledgement: this project was originally designed at the University of Waterloo. Page 5 of 5