0% found this document useful (0 votes)
30 views

File Systems Inodes: - Abstraction - Which Disk Blocks Go With Which File. - Inode: Data Structure For Bookkeeping

The document summarizes key concepts related to implementing a simple UNIX-like file system, including inodes, directories, superblocks, and the disk layout. It describes how inodes are used to link files to disk blocks and store metadata. Directories are like files that contain name and inode number pairs. The superblock stores metadata about the disk. System calls like open, read, write, and mkdir are used to access and modify the file system. Formatting with mkfs initializes the data structures and free space management.

Uploaded by

MCA sharan 2118
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

File Systems Inodes: - Abstraction - Which Disk Blocks Go With Which File. - Inode: Data Structure For Bookkeeping

The document summarizes key concepts related to implementing a simple UNIX-like file system, including inodes, directories, superblocks, and the disk layout. It describes how inodes are used to link files to disk blocks and store metadata. Directories are like files that contain name and inode number pairs. The superblock stores metadata about the disk. System calls like open, read, write, and mkdir are used to access and modify the file system. Formatting with mkfs initializes the data structures and free space management.

Uploaded by

MCA sharan 2118
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

File Systems Inodes

• Abstraction • Which disk blocks go with which file.


– Directories and Files instead of disks • Inode: Data structure for bookkeeping
• Protection – List of Blocks
– File or Directory
• Project: Simple UNIX-like File system – Link Count
– Other information…owner/permissions

Inode Structure
• Direct and Indirect Blocks Inodes
• Advantages:
– Fast access for small files (majority)
– Supports large files
– Supports sparse files
Directories Super Block
• Like a file: List of files and directories • Contains the layout of the Disk
– name – Size of Disk
– inode number – Number of Inodes
• Can read it like a file – Number of Data Blocks
• Always has at least 2 entries: – Where inodes start, where data blocks start,
etc….
– “.” current directory
– “..” parent directory

Disk Layout
Super blocks (cont.)
• typedef struct {
Boot Block (Our OS == entire image)
• char signature[SIGN_SIZE]; /* Signature */
Super Block
• int size; /* Size of file system in blocks */
• int root_inode; /* Inode no. of root directory */ Inode Blocks
• int inode_start; /* First block for inodes */ Allocation Bitmap
• int inode_blocks; /* Number of inode blocks */ Allocation data Blocks

• int bitmap_start; /* First block for bitmap */


• int bitmap_blocks; /* Number of blocks used to store the bitmap */
• int alloc_start; /* First block managed by the allocater */
• int num_blocks; /* Number of blocks for allocation */
• int free_blocks; /* Number of free blocks: Note: IGNORE this
since we do not want to update superblock frequently. */
• } superblock;
Project Formatting(mkfs)
• System calls to access file system • Make a file system:
– mkfs: Formatting – Write superblock
– link, unlink: – Mark inodes and data blocks to be free
– open: file creation – Create root directory
– close, read, write, lseek: file access – initialize user file descriptor table
– mkdir, chdir, rmdir: directory stuff
– stat: information about a file or directory • fsck: Check integrity of file system
– provided

File Creation / Deletion File Access


• link: Hard link to a file • open: create file if it does not exist
– create a link to an existing file • read:
– hard vs soft link • write:
• unlink: Delete a file if link count == 0 • lseek: position in file
– delete directory entry
• close: free file descriptor
Example: mkdir()
Directories
int fs_mkdir(char *file_name) {
• Mkdir: make a directory if (file_name exists) return ERROR;

– create an entry in parent directory /* allocate data block */


/* allocate inode */
– create two directories: “.”, “..”
/* set directory entries for ‘.’, ‘..’ */
• rmdir: remove directory if empty /* set inode entries appropriately *
/* update parent */
• chdir: change the current directory
return SUCCESS
– For relative path names }

Doing the Assignment


• Most under Linux environment
– Use a file to simulate a disk (make lnxsh)
– code is provided (*Fake files)
• Should be able to move right over to our
OS.
• Shell supports
– System calls for File System
– Commands like “ls”, “cat”, “create” (create foo
200)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy