COMP 3000 Operating Systems
File Systems and Storage Management (part 2)
Lianying Zhao
What is Stored in an inode?
• inodes are data structures, so they are real, even for special files
• They take space
• They are in the file system storage (although there’s an in-memory copy)
COMP 3000 (Winter 2021) 2
The stat Command
• Display detailed information about files/directories • More than ls does
• Mainly corresponding to the inode
• System calls stat(), fstat, lstat()
• How do you find out if a file/directory exists?
COMP 3000 (Winter 2021) 3
Directory entry (dentry)
• Represents a directory entry (not necessarily a directory) • System calls – getdents(), not read()
• Library calls – readdir()
• A file is mapped to its inode by its parent directory • The root (/) directory’s inode number is always 2 **
COMP 3000 (Winter 2021) 4
Hard Link and Symbolic Links
• Symbolic link
• Only linking to the target file name (more accurately: pathname) • What if the target file is deleted?
• Hard link
• Linking to the inode number
• Everything identical, except difference names • Not to a directory (why?)
• Link count
• Comparing with MS Windows again… • Shortcuts
• Reparse points
. and ..
File operations?
COMP 3000 (Winter 2021)
5
Copy/move/remove
• Copy creates a new inode
• For move, it depends
• Across different file systems, new inodes are created
• Within the same file system, just relinked to the new pathname
• Remove
• Decreases link count, if greater than 1, and removes that directory entry • Removes the inode as well if link count = 1
COMP 3000 (Winter 2021) 20
COMP 3000 Operating Systems
Misc.
COMP 3000 (Winter 2021) 7
Getting Familiar with gdb
• No exam questions directly testing your knowledge about gdb • But you may heavily rely on it to find out / verify things
• Single-stepping
• Peeking into variables/memory • Attach to an existing process
COMP 3000 (Winter 2021) 8
Address Space Layout Randomization (ASLR)
• A concept advanced from later security topics
• Memory corruption vulnerabilities?
• Now the process address space has been contained*
• What can an adversary do without direct manipulation? • Return Oriented Programming (ROP)
• Jump Oriented Programming (JOP)
• Or simply buffer overflow
• All require predictable memory layout
• The idea is to apply a randomly generated offset to the bases of critical
segments, e.g., heap, stack, and loaded libraries.
COMP 3000 (Winter 2021) 9