Handout 18

Unix File Systems*


Preliminaries

File Attributes

 -rw-r--r--+ 1 pheattch other 72 Feb 3 14:38 x.c
 00000000011111111112222222222333333333344444444445 
 12345678901234567890123456789012345678901234567890

Position 1 - can represent:

d the entry is a directory;
l the entry is a symbolic link - a file that contains the path information needed to access a file. Note that there is nothing to guarantee that this information is valid.
b the entry is a block special file - a file that is accessed a set number of bytes ( block ) at a time. The video screen on you pc is usually accessed as a block special file device.
c the entry is a character special file - a file that is to accessed one character at a time. The keyboard of your terminal would be accessed as a character file.
p the entry is a fifo (or "named pipe") special file;
- the entry is an ordinary file;
| the entry is a FIFO - when connecting the output of a command to the input of another, the system may need to buffer the data.


Position 2-10 - Interpreted as three sets of three bits each. The first set refers to the owner's permissions; the next to permissions of others in the user-group of the file; and the last to all others.

Position 11 - The plus sign indicates that there is an ACL (access control list, see below) associated with the file.

Position 13 - indicates the number of links to the file. Is incremented by the ln command as well as if it is a directory. (the original file is considered a link)

Position 15-22 - File owner.

Position 24-28 - File group.

Position 30-31 - File contains 72 bytes.

Position 33-43 - The last time that file's contents were modified owner.

Position 45-47 - File name.

linking

Hard links


Symbolic links (also called soft links or symlinks):

    1. With a symbolic link, there really are two different files. One file contains the actual data; the other file just contains the name of the first file and serves as a "pointer."
    2. The system knows that whenever it opens a link, it should read the contents of the link, and then access the file that really holds the data you want.
    3. Symbolic links are infinitely more flexible than hard links.

They can cross filesystems, or even computer systems (if you are using NFS or RFS).

You can make a symbolic link to a directory.

A symbolic link has its own inode and takes a small amount of disk space to store.

What are Access Control Lists?

Unix allows you to grant or deny access to users by putting users on a directory's access control list. Every directory has its own ACL that defines who can access the directory and its files. Groups are lists of users; some groups are created by the system, but users can also create their own groups.

If we issue the command:

setfacl -s user:bozo:rw-,user::rwx,group::---,mask:rw-,other:--- x.c

setfacl modifies the Access Control List (ACL) for a file or files. The -s option will set the ACL to the entries specified on the command line. The command above:


Unix Filesystem Overview

The structure of a simple Unix file system can generally be seperated into four parts, the boot block, the super block, the inode list and the data blocks.

The boot block is located at the beginning of the file system and can be accessed with the minimal code incorporated in the computer's rom bios. The boot block of the bootable partition contains the code needed to further initialize the operating system.

The super block describes the state of a file system - how large it is, how many files in can store, What parts of the storage area are already in use and what parts are available, etc.

The inode list (table) is a list of inodes that are used to track and maintain information about each file created on the filesystem. All access to a file is based on the data in the inode list. The inode list is found immediately after the super block, and the first usable inode is reserved for accessing the root directory of the filesystem.

The data blocks are where the data of a file is stored. These blocks follow the inode table and occupy most of the storage device's space.

SuperBlock

The super block contains the following information

Inodes

The inode list is a static list. Once the filesystem is created, the size of the list cannot change. The initial size of the inode list is determined by the Administrator and the size of the storage device.

An inode for a file contains the following information.

NFS

The Network File System (NFS) is a protocol suite that allows the file system to logically include directories and files in a file system while they physically reside on disks attached to remote hosts. The NFS is implemented using a set of remote procedure calls that transparently request and receive files across the network.

Disk space commands

df reports the free disk space or inodes on file systems, e.g. to report the disk space.
du reports the number of disk blocks used by directory or file.

Where Stuff Is

The actual locations and names of certain system configuration files will differ under different implementations of Unix. Here are
some examples:

/dev - Where special I/O files are kept
/bin - Executable system utilities, like sh, cp, rm
/etc - System configuration files and databases
/lib - Operating system and programming libraries
/tmp - System scratch files (all users can write here)
/lost+found - Where the file system checker puts detached files
/usr/bin - Additional user commands
/usr/include - Standard system header files
/usr/lib - More programming and system call libraries
/usr/local - Typically a place where local utilities go
/usr/man - The manual pages are kept here

Some Special Files

/dev/null - the bit bucket

/dev/pts/number - telnet session file identifier


* figure from here