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
Admin Homework Due Tomorrow Quizzes back Monday
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
File System Organization
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
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 /”)
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?
Inodes Trade-offs: direct vs. indirect pointers Strengths of inodes? Weaknesses of inodes?
Directories Yep, an inode But the data is structured
Directory Example
Hard Links A hard link occurs when two directories refer to the same inode
Symbolic (Soft) Links A file whose data blocks contain a path name
Creating Links in Unix ln [OPTION]... TARGET [LINK_NAME] -s, --symbolic –make symbolic links instead of hard links