Ex1: inode inode structure: -- metadata: Size of a file Owner's user id Permission: File type: directory, regular file or soft link. Access permission: how different users can access it. Timestamps: Access time, modification time and change time. Link count: How many files are associated with this inode. -- Pointers: Direct Pointer 1 --> data block Direct Pointer 2 --> data block ... Direct Pointer 12 --> data block Single Indirect Pointer --> indirect block: Pointer --> data block Pointer --> data block ... Pointer --> data block Double Indirect Pointer --> indirect block: Indirect Pointer --> indirect block: Pointer --> data block Pointer --> data block ... Pointer --> data block ... Indirect Pointer --> ditto Triple Indirect Pointer --> ... Question: Which factors determine many pointers one indirect block can hold? Question: Given this structure, can we have file of any size? Question: Say we have 512-byte block, 4-byte pointer, 12 direct pointers, 1 single indirect pointer, 1 double, and 1 triple. How many regular files (no links) can we have? What is the maximum size of a file? Ex2: Directories In a terminal, we first type: $ cd / Note that / is a file. Say we have the file *content* to '/' as: [name, i-number] ... Briefly describe the actions when we type: $ ls bin Ex3: Problem for inodes and directories Consider a very simple file system for a tiny disk. Each sector on the disk holds 2 integers, and all data blocks, indirect blocks, and inodes are 1 disk sector in size (each contains 2 integers). All files stored on disk are interpreted as directories by the file system (there are no "data files"). The file system defines the layout for the following data types on disk: -- inode = 1 pointer to a data block + 1 pointer to indirect block -- indirect block = 2 pointers to data blocks -- directory = a regular file containing zero or more pairs of integers; the first integer of each pair is a file name and the second is the file's inumber The value "99" signifies a null pointer when referring to a disk block address or directory name. An empty directory has one disk block with the contents "99 99". The inumber for root directory is "/" is 0. The following data are stored on disk: inode array: +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |10 |11 |12 |13 |14 |15 | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ |10 | 7 | | 8 | | | 3 | | | | | | | | | | | 6 |99 | |99 | | |99 | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ disk blocks: +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |10 |11 |12 |13 |14 |15 | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | |32 | |96 | | | 1 |99 |99 | |57 | | | | | | | | 3 | | 1 | | |99 |99 |99 | | 6 | | | | | | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 1. How many entries can appear in a maximum-sized directory? (Each entry is a pair of integers) 2. List all directories stored on this disk (full path names) along with the names of the files stored in each directory. +----------+----------+-----------------+-------------+---------------+ | path | i-number | indirect blocks | data blocks | subdirs | +----------+----------+-----------------+-------------+---------------+ | / | | | | | +----------+----------+-----------------+-------------+---------------+ | | | | | | +----------+----------+-----------------+-------------+---------------+ | | | | | | +----------+----------+-----------------+-------------+---------------+ | | | | | | +----------+----------+-----------------+-------------+---------------+ | | | | | | +----------+----------+-----------------+-------------+---------------+ 3. Modify the above data structures to add an empty directory called "87" to directory "/" Ex4: Hard/soft links pwd data: /bin data +-----------+ +-----------+ | | | cp - 1001 | +-----------+ +-----------+ |... | |... | inode 1001: link count: 1 What will the above look like after we type? Any other changes else where? $ ln /bin/cp cc What will the above look like after we type? Any other changes else where? $ ln -s /bin/cp cc