File System, Part 1: Introduction - tcloaa/SystemProgramming GitHub Wiki
<<<<<<< HEAD
Design a file system! What are your design goals?
The design of a file system is difficult problem because there many high-level design goals that we'd like to satisfy. An incomplete list of ideal goals include:
- Reliable and robust (even with hardware failures or incomplete writes due to power loss)
- Access (security) controls
- Accounting and quotas
- Indexing and search
- Versioning and backup capabilities
- Encryption
- Automatic compression
- High performance (e.g. Caching in-memory)
- Efficient use of storage de-duplication
Not all filesystems natively support all of these goals. For example, many filesystems do not automatically compress rarely-used files
60fd05ee2b76e648bf06d0d191cc885e8bd2cb43
.
, ..
, and ...
?
What are cd .
留在本目录
cd ..
去到parent directory
cd ...
无效!
What are absolute and relative paths?
Absolute paths are paths that start from the root node
of your directory tree.
- start with
/
/Users/[yourname]/Desktop/cs241
Relative paths are paths that start from your current position
in the tree.
- If currenly you are in your home directory ("~" for short), then
Desktop/cs241
would be a relative path
a/b/../c/./
?
WTF is Remember that ..
means 'parent folder' and that .
means 'current folder'.
Example: a/b/../c/./
- Step 1:
cd a
(in a) - Step 2:
cd b
(in a/b) - Step 3:
cd ..
(back toa
, because..
represents 'parent folder') - Step 4:
cd c
(ina/c
) - Step 5:
cd .
(ina/c
, because.
represents 'current folder')
Thus, this path can be simplified to a/c
.
Why make disk blocks the same size as memory pages?
To support virtual memory, so we can page stuff in and out of memory.
What are the traditional permissions: user – group – other permissions for a file?
Some common file permissions include:
- 755:
rwx r-x r-x
user: rwx
, group: r-x
, others: r-x
User can read, write and execute. Group and others can only read and execute.
- 644:
rw- r-- r--
user: rw-
, group: r--
, others: r--
User can read and write. Group and others can only read.
What are the the 3 permission bits for a regular file for each role?
- Read R (largest bit)
- Write W (second bit)
- Execute X (smallest bit)
For each of user/group/world, it owns 3 bits.
What do "644" "755" mean?
These are examples of permissions in octal format (base 8). Each octal digit corresponds to a different role (user, group, world).
We can read permissions in octal format as follows:
- 644
- user permissions: 6 = 110 = Read && Write = R/W
- group permissions: R = 100
- world permissions: R = 100
- 755
- user: R/W/X
- group: R/X
- world: R/X
What is an inode? Which of the above items is stored in the inode?
From Wikipedia:
In a Unix-style file system, an index node, informally referred to as an inode, is a data structure used to represent a filesystem object, which can be one of various things including a file or a directory. Each inode stores the attributes and disk block location(s) of the filesystem object's data. Filesystem object attributes may include manipulation metadata (e.g. change, access, modify time), as well as owner and permission data (e.g. group-id, user-id, permissions).
How does inode store the file contents?
Image source: http://en.wikipedia.org/wiki/Ext2
"All problems in computer science can be solved by another level of indirection." - David Wheeler
How many pointers can you store in each indirection table?
As a worked example, suppose we divide the disk into 4KB blocks and we want to address up to 2^32 blocks.
The maximum disk size is 4KB *2^32 = 16TB (remember 2^10 = 1024)
A disk block can store 4KB / 4B (each pointer needs to be 32 bits) = 1024 pointers. Each pointer refers to a 4KB disk block - so you can refer up to 1024*4KB = 4MB of data
For the same disk configuration, a double indirect block stores 1024 pointers to 1024 indirection tables. Thus a double-indirect block can refer up to 1024 * 4MB = 4GB of data.
Similarly, a triple indirect block can refer up to 4TB of data.