CSE506-Project 5- s2fs (Super Simple File System) Solved

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

Rate this product

 

  • Introduction

The goal of this project is to implement a simple pseudo file system called name s2fs. A pseudo file system is not backed by disk but resides in memory and is usually used to provide information regarding the kernel to the user (e.g., proc file system).

Please read the following articles and sample codes to understand how to write a simple file system using libfs. Note that these articles are written for older Linux versions, and thus some APIs might have been renamed/removed.

Program your module in s2fs.c and s2fs.h (as needed). Create Makefile that support all, clean, install and uninstall rules (and more as needed), similar to that of project 2.

Recommended Background Reading

Part 1: Create a Pseudo File System

Design a kernel module called s2fs, a mountable pseudo file system.

Tasks:

struct file_system_type s2fs_type
  • Define .
  • Use mount_nodev to mount a pseudo file system.
  • Define a function named int s2fs_fill_super(…) to fill a superblock and pass it as an argument for mount_nodev.
  • During the module init, register the s2fs_type During the module exit, unregister the file system.

Deliverables:

  • Run the following commands and take a screenshot of the output. Name your screenshot as png

$ mkdir mnt

$ sudo insmod s2fs.ko # Inserting the filesystem kernel module

$ sudo mount -t s2fs nodev mnt # Mount at dir mnt with option nodev

$ mount # Print out all mounted file systems

$ sudo umount ./mnt # Unmount the file system

$ sudo rmmod s2fs.ko # Remove the kernel module

Part 2: Implement File Operations

Now we will add inode and file operations to s2fs.

Part 2.1: Create an inode

Write    a    function    to    create    an    inode,              called static struct inode

*s2fs_make_inode(struct super_block *sb, int mode)

. The function accepts two inputs, the

superblock of the filesystem and the mode which decides the type (a directory vs a file) and the permission. Make sure you set the i_ino field of inode with get_next_ino().

Part 2.2: Create a directory

Write a function to create a directory, called static struct dentry *s2fs_create_dir

(struct super_block *sb, struct dentry

*parent, const char *dir_name);

Part 2.3: File operations

To handle a file, the filesystem needs to know how to open, read and write a file. Write three functions, s2fs_open, s2fs_read_file, and s2fs_write_file. In this project we will not use the open and the write fuctions so they will simply return 0. The read function should return “Hello World!” string to the user.

Create a s2fs_fops of type file_operations and assign .read, .write and .open with the functions you wrote here.

Part 2.4: Create a file

Write a function to create a file, called static struct dentry *s2fs_create_file(st ruct super_block *sb, struct dentry *dir, const char *file_name). The funcion should create a file with the name stored in file_name inside directory pointed by dir dentry. Set s2fs_fops as file_operations.

Part 2.5: Putting it all together

Update s2fs_fill_super() function (Part 1) so that after mounting, s2fs creates (1) a directory named foo in the root directory, and (2) a file named bar inside the subdirectory foo. Use the s2fs_create_dir and s2fs_create_file functions, defined in Parts 2.2 and 2.4.

 

  • Assignment-5-Super-Simple-File-System-yxpdjr.zip