0% found this document useful (0 votes)
19 views18 pages

04 1 Ufs

Test

Uploaded by

JohnKevinStanley
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)
19 views18 pages

04 1 Ufs

Test

Uploaded by

JohnKevinStanley
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/ 18

Advanced Programming in

the UNIX Environment


Week 04, Segment 1: The Unix Filesystem

Department of Computer Science


Stevens Institute of Technology

Jan Schaumann
jschauma@stevens.edu
https://stevens.netmeister.org/631/
CS631 - Advanced Programming in the UNIX Environment

The Unix Filesystem

• a disk can be divided into logical partitions

2
Jan Schaumann 2020-09-17
CS631 - Advanced Programming in the UNIX Environment

The Unix Filesystem


physical blocksize

• a disk can be divided into logical partitions


first NetBSD partition
second NetBSD partition
NetBSD portion of disk
3 entire disk
Jan Schaumann 2020-09-17
CS631 - Advanced Programming in the UNIX Environment

The Unix Filesystem

• on each logical partition you may create a file system containing the cylinder groups

4
Jan Schaumann 2020-09-17
CS631 - Advanced Programming in the UNIX Environment

The Unix Filesystem

• each cylinder group contains a list of inodes (i-list) as well as the actual directory-
and data blocks

5
Jan Schaumann 2020-09-17
CS631 - Advanced Programming in the UNIX Environment

The Unix Filesystem

6
Jan Schaumann 2020-09-17
CS631 - Advanced Programming in the UNIX Environment

The Unix Filesystem

#123

• data blocks containing the actual data (i.e., contents of the file) are referenced from
the inode

7
Jan Schaumann 2020-09-17
CS631 - Advanced Programming in the UNIX Environment

The Unix Filesystem

#123

#123

• a directory entry is really just a hard link mapping a “filename” to an inode

8
Jan Schaumann 2020-09-17
CS631 - Advanced Programming in the UNIX Environment

The Unix Filesystem

#123

#123

#123

• a directory entry is really just a hard link mapping a “filename” to an inode

• you can have many such mappings to the same inode


9
Jan Schaumann 2020-09-17
CS631 - Advanced Programming in the UNIX Environment

The Unix Filesystem

• directories are special "files" containing a list of hard links

10
Jan Schaumann 2020-09-17
CS631 - Advanced Programming in the UNIX Environment

The Unix Filesystem

• each directory contains at least two entries:

• "." -- this directory

• ".." --
Jan Schaumann the parent directory 11
2020-09-17
CS631 - Advanced Programming in the UNIX Environment

The Unix Filesystem

12
Jan Schaumann 2020-09-17
CS631 - Advanced Programming in the UNIX Environment

Inodes

• The inode number in a directory entry must point to an inode on the same file system
(no hardlinks across filesystems).

13
Jan Schaumann 2020-09-17
CS631 - Advanced Programming in the UNIX Environment

Inodes

• The inode number in a directory entry must point to an inode on the same file system
(no hardlinks across filesystems).

• The inode contains most of the information found in the struct stat.

• Every inode has a link count (st_nlink): it shows how many “things” point to this
inode. Only if this link count is 0 (and no process has the file open) are the data
blocks freed.

14
Jan Schaumann 2020-09-17
CS631 - Advanced Programming in the UNIX Environment

Inodes

• To move a file within a single filesystem, we can just ”move” the directory entry
(actually done by creating a new entry, and deleting the old one).

15
Jan Schaumann 2020-09-17
CS631 - Advanced Programming in the UNIX Environment

Inodes

• To move a file within a single filesystem, we can just ”move” the directory entry
(actually done by creating a new entry, and deleting the old one).

16
Jan Schaumann 2020-09-17
CS631 - Advanced Programming in the UNIX Environment

Inodes

• To move a file within a single filesystem, we can just ”move” the directory entry
(actually done by creating a new entry, and deleting the old one).

17
Jan Schaumann 2020-09-17
CS631 - Advanced Programming in the UNIX Environment

The Unix Filesystem

Visualizing the Unix Filesystem helps us understand the concept of hard links, what
directories "look like", and how operations on a directory are independent of the files
and their data.

Coming up: creating, removing, and renaming links (hard and symbolic)

link(2) unlink(2) rename(2) symlink(2) / readlink(2)

18
Jan Schaumann 2020-09-17

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