4061 session 12 (2/22). today files and directories

16
4061 Session 12 (2/22)

Upload: dylan-wilkinson

Post on 03-Jan-2016

225 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: 4061 Session 12 (2/22). Today Files and Directories

4061 Session 12 (2/22)

Page 2: 4061 Session 12 (2/22). Today Files and Directories

Today

• Files and Directories

Page 3: 4061 Session 12 (2/22). Today Files and Directories

Today’s Objectives• Describe the contents/function of:

– inode– directory file– symbolic link file

• Calculate the available storage of an inode, given storage parameters

• Trace how an operating system locates the data for a file, given a path name

• Describe the difference between soft and hard links

• Become familiar with some c functions for managing files

Page 4: 4061 Session 12 (2/22). Today Files and Directories

Admin

• Homework Due Tomorrow

• Quizzes back Monday

Page 5: 4061 Session 12 (2/22). Today Files and Directories

Disk Organization

• Disk organized into partitions– In Windows, think of this as the c:, d: drives– In UNIX, less obvious, but still present

• Each partition can have its own file system– Many different file systems exist: Windows

uses NTFS, Linux often uses ext3

• (In UNIX) each file system can be mounted by another file system

Page 6: 4061 Session 12 (2/22). Today Files and Directories

File System Organization

Page 7: 4061 Session 12 (2/22). Today Files and Directories

What Are Inodes?

• Data for a particular file on a hard disk are scattered– Where data goes depends on OS and use of

the system

• We use inodes to give us a logical picture of the file– a sequence of bytes with a beginning and an

end

Page 8: 4061 Session 12 (2/22). Today Files and Directories

More about Inodes

• stat() looks at the inode for information

• inodes are looked up in a filesystem by number– Table of inodes– / is usually inode 2 (see “stat /”)

Page 9: 4061 Session 12 (2/22). Today Files and Directories
Page 10: 4061 Session 12 (2/22). Today Files and Directories

Exercise

• Robbins pg. 159: 5.11

• Information about inode:– 128 bytes, status takes 68 bytes– block size 8 kilobytes– pointers 4 bytes

• How big of a file can we access with direct pointers?

• With a single/double/triple indirect pointer?

Page 11: 4061 Session 12 (2/22). Today Files and Directories

Inodes

• Trade-offs: direct vs. indirect pointers

• Strengths of inodes?

• Weaknesses of inodes?

Page 12: 4061 Session 12 (2/22). Today Files and Directories

Directories

• Yep, an inode

• But the data is structured

Page 13: 4061 Session 12 (2/22). Today Files and Directories

Directory Example

Page 14: 4061 Session 12 (2/22). Today Files and Directories

Hard Links

• A hard link occurs when two directories refer to the same inode

Page 15: 4061 Session 12 (2/22). Today Files and Directories

Symbolic (Soft) Links

• A file whose data blocks contain a path name

Page 16: 4061 Session 12 (2/22). Today Files and Directories

Creating Links in Unix

• ln [OPTION]... TARGET [LINK_NAME]

• -s, --symbolic– make symbolic links instead of hard links