
Hard Disk Drives and File Systems in UNIX
Explore the architecture of Hard Disk Drives (HDDs) and the functionalities of UNIX file systems. Learn about the components of HDDs, file system tasks, structure of HDDs, different file system types, disk organization, and more in this detailed guide. Discover the essential concepts behind data storage and management in UNIX environments.
Uploaded on | 0 Views
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Hard Disk Drives and UNIX File System EEN 322 Systems Programming November 18th, 2014
Hard Disk Drive (HDD) 1. Attached to a computer by I/O bus (SATA/SCSI) 2. Host controller 3. Disk controller 4. Memory-mapped I/O ports 5. Built-in cache on disk controller
Hard Disk Drive (HDD) 1. Attached to a computer by I/O bus (SATA/SCSI) 2. Host controller 3. Disk controller 4. Memory-mapped I/O ports 5. Built-in cache on disk controller IBM 305 RAMAC Disk System (1956- 1969)
Hard Disk Drive (HDD) 1. Attached to a computer by I/O bus (SATA/SCSI) 2. Host controller 3. Disk controller 4. Memory-mapped I/O ports 5. Built-in cache on disk controller
Structure of HDD TI/O= Tseek+ Trotation+ Ttransfer
File System 1. Tasks: a. Provide user interface b. Mapping between user interface and device 2. FAT32, NTFS, ext family (ext2, ext3, and ext4) 3. UFS 4. Format, Partition
Big Picture 1. Application programs: Client of file system 2. Logical file system: metadata information a. file system structure data except real data b. file control block (inode) 3. File organization module: logical/physical blocks a. logical block to physical block translation b. Free block management 4. Basic file system: command to device driver a. Block 88 -> (drive 1, cylinder 73, track 2, sector 10) a. Manage buffers and caches. 1. I/O control: device driver and interrupt handler a. Read block 88 -> Disk controller instruction 2. Devices: HDD, CD/DVD, SSD
File Types 1. Regular file 2. Directory file 3. Symbolic link 4. Character file 5. Block file 6. Named pipe or FIFO 7. Socket
Disk Organization 1. /etc/fstab and /etc/mtab 2. mount -t iso9660 -o ro /dev/cdrom /mnt
UNIX inode 1. struct describe a file 2. flags 3. generation numbers 4. inode definition in sys/ufs/ufs/dinod.h
Link 1. A directory entry point to the inode 2. Created by: $ln /dirA/name1 /dirB/name2 open("/dirA/name1"); read close modify memory image of the file unlink("/dirA/name1"); open("/dirA/name1"); write close
Link After unlink /dirA/name1
Symbolic Link 1. File contain the name of another file/directory 2. Created by: $ln -s /dirA/name1 /dirB/name2
Access Privilege 1. Least-privilege: given only those privileges that it needs in order to complete its task. 2. What about change your password? 3. UNIX process IDs 4. setuid(), seteuid(), setreuid() syscalls
setuid(), seteuid(), setreuid() 1. int setuid(uid_t uid); 2. int seteuid(uid_t uid); 3. int setreuid(uid_t ruid, uid_t euid);
Setuid Programs 1. passwd, su, chsh 2. setuid bit for a program file. #ls -l /usr/bin/passwd -r-sr-xr-x 2 root wheel 6444 Nov 17 2014 /usr/bin/passwd 3. How passwd use seteuid to access the password file /etc/pwd.db?
Exercise Your classmate allow you to use his/her account in a system you also has an account. How can you take over his/her account in 10 seconds?
Exercise Your classmate allow you to use his/her account in a system you also has an account. How can you take over his/her account in 10 seconds? victim$cp /bin/sh /tmp victim$chmod 4777 /tmp/sh attacker$cd /tmp attacker$./sh victim$