Presentation is loading. Please wait.

Presentation is loading. Please wait.

Hard Disk Drives and UNIX File System EEN 322 Systems Programming November 18th, 2014.

Similar presentations


Presentation on theme: "Hard Disk Drives and UNIX File System EEN 322 Systems Programming November 18th, 2014."— Presentation transcript:

1 Hard Disk Drives and UNIX File System EEN 322 Systems Programming November 18th, 2014

2 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

3 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)

4 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

5 Structure of HDD T I/O = T seek + T rotation + T transfer

6 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

7 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

8 File Types 1.Regular file 2.Directory file 3.Symbolic link 4.Character file 5.Block file 6.Named pipe or FIFO 7.Socket

9 Disk Organization 1./etc/fstab and /etc/mtab 2.mount -t iso9660 -o ro /dev/cdrom /mnt

10 Disk Drive and UFS Illustration

11 UNIX inode 1.struct describe a file 2.flags 3.generation numbers 4.inode definition in sys/ufs/ufs/dinod.h

12 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

13 Link After unlink /dirA/name1

14 Symbolic Link 1.File contain the name of another file/directory 2.Created by: $ln -s /dirA/name1 /dirB/name2

15 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

16 setuid(), seteuid(), setreuid() 1.int setuid(uid_t uid); 2.int seteuid(uid_t uid); 3.int setreuid(uid_t ruid, uid_t euid);

17 Setuid Programs 1.passwd, su, chsh 2.setuid bit for a program file. #ls -l /usr/bin/passwd -r-sr-xr-x 2 rootwheel 6444 Nov 17 2014 /usr/bin/passwd 3.How passwd use seteuid to access the password file /etc/pwd.db?

18 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?

19 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$


Download ppt "Hard Disk Drives and UNIX File System EEN 322 Systems Programming November 18th, 2014."

Similar presentations


Ads by Google