Operating Systems 2018F Lecture 6

From Soma-notes
Jump to navigation Jump to search

Video

Video from the lecture given on September 21, 2018 is now available.

Code

Code and files from the lecture (captured as they were at the end) are available here.

Notes

Terminal Notes:

  • ls -la →
1st column:   read/write permissions. (r: read, w: write, x: execute)
2nd column:   # of pointers to a file/directory.
3rd column:   user (owner)
4th column:   group 
5th column:   size of file/directory
6th column:   date last modified
Last column:  file/directory name
  • ls -lai →
list the inodes as well (shows in first column)


  • ln -s f1 f2 →
Create symbolic link. f2 becomes a reference to f1. 

Note: f2 is refering to f1's name. NOT its inode. (f1 and f2 are the file/directory names)

If you remove f1 after creating the above link, it will break the link.


  • ln f1 f3 →
Create hard link. f3 becomes a reference to f1.

Note: The absence of the '-s' in the ln command causes the link to be to f1's inode. If you remove f1 after creating the above link, it will NOT break the link.


  • More Information on Symbolic Links and Inode's:
    • A symbolic link that refers to a file that doesn't exist is broken. You have to recreate the target to fix it.
    • Symbolic link can link to a file OR a directory.
    • They can also point to filesystems.
    • Inode #s are only unique to the specific filesystem they belong to.
Example: For a given file in your user directory... a file with an identical inode can exist in the virtual filesystem (/proc).
  • Information on removing files:
    • rm in Unix does not necessarily remove the file. It only removes the name and space.
    • The inode is only reclaimed when there are no references remaining for the file.
  • Information on finding inodes:
    • Only the kernel can give us information about a file name's associated inode. Therefore, we must make a system call. (i.e. lstat, fstat, etc..)
    • ls -l → the '-l' option does a 'stat' system call on the directory to also provide file info such as name, size, etc..
Note: lsat will return information about a link if a symbolic link exists, rather than the file that is being linked to. Fsat will not do this. Fsat will give information about the linked file.
  • Information on Filesystems:
    • Linux supports many filesystems, whereas windows does not.
    • df . → tells you the location of the filesystem of the current directory you are in.

Lecture Notes

  • inode
    • key data structure in UNIX-like filesystems
  • Files have two parts
    • file inode (metadata)
    • file data
  • Directories associate file names with inodes (specifically, inode numbers)
  • file metadata in an inode
    • owner
    • group
    • size
    • permissions
    • pointers to data blocks (in some format)
  • Where are filesystems stored?
    • persistent arrays
    • array entries are "blocks"
    • 4K traditionally, but can be bigger or smaller
  • To access, kernel gives device a block number, gets back block contents.