Author
nash
View
21
Download
0
Embed Size (px)
DESCRIPTION
11. Heä thoáng file (file system). Giao dieän heä thoáng file Caùc yeâu caàu cuûa ngöôøi duøng File Thö muïc File system mounting Chia seû & baûo veä. Caùc yeâu caàu cuûa ngöôøi duøng. Persistence Speed Size Sharing/protection Ease of use. - PowerPoint PPT Presentation
11. He thong file (file system)Giao dien he thong fileCac yeu cau cua ngi dungFileTh mucFile system mountingChia se & bao ve
Cac yeu cau cua ngi dungPersistenceSpeedSize Sharing/protectionEase of use
S ho tr t phan cng va he ieu hanhPhan cng Persistence: cac thiet b lu tr ben vng (non-volatile memory)Speed: cung cap kha nang truy xuat ngau nhien, nang cao toc o a (5400 7200 10K 15K rpm)Size: dung lng ln, 20M 700M 40G 200G 1T byteHe ieu hanhPersistence: lu tr d tha, back-up phuc vu cho recoveryV du: RAID (Redundant Array of Independent Disks)Ease of use: Gan ten cho mot chuoi cac khoi d lieu fileHo tr quan ly cac file th mucUser khong can quan tam en cac chi tiet hardware (giao tiep vi disk controller theo IDE, SCSI,).Sharing/Protection: cho phep thiet lap cac quyen truy cap file/th muc
nh ngha fileFile la mot chuoi cac d lieu c at ten, cac tac vu co the thc thi len mot file laReadWrite
Cac loai file Cac loai fileregular fileASCIIbinarydirectoryspecial files (trong UNIX): character special file, block special file,
Cac kieu file Cach phan biet kieu fileextensionmagic number
Cac kieu file thong dung
nh dang file (1)ng dung co the lu va dien dch d lieu trong file theo nh dang riengMS WordPDFELF
nh dang file (2)V du trong UNIX
Cau truc fileCau truc file: mo hnh file e ngi dung lap trnhKhong co cau truc: mot chuoi byte (Unix, DOS, Windows), Hnh aCau truc recordFixed length, Hnh bVariable length: ho tr tm nhanh chong mot record vi key cho trc (IBM mainframe), Hnh c
Cac cach truy cap fileDung cac tac vu thong thng tren file,truy cap tuan t (sequential access) truy xuat d lieu theo th t, tng byte hoac recordtruy cap bat ky (random access)truy xuat d lieu, byte hoac record, tai v tr bat ky truy cap dung khoatruy xuat mot record da vao key cua no
Memory-mapped fileGia s co cac system call map va umapGoi map e chieu file vao khong gian a ch ao cua qua trnhDung cac tac vu truy xuat bo nh e truy xuat fileGoi umap khi xong
Cac thuoc tnh cua file
Cac tac vu tren file CreateTao mot file miWrite Thc hien tac vu ghi d lieu vao file tai v tr con tro ghi ReadThc hien tac vu oc d lieu t file tai v tr con tro ocRepositionThiet lap con tro oc/ghi en v tr do qua trnh ch nhDeleteXoa fileTruncate Gi lai tat ca cac thuoc tnh cua file, ngoai tr kch thc file c thiet lap ve 0OpenQua trnh phai m file trc khi s dungCloseQua trnh phai ong file sau khi s dung
Th mucTh muc (directory, folder) la mot tien ch cua he ieu hanh e ngi dung to chc cac file cua mnhNgi dung co the xac nh file thuoc ve hay nam trong mot directory; cach noi khac, directory cha file
Cac tac vu tren th mucV du t UNIXCreateTao mot directory miDeleteXoa mot directory trongOpendirQua trnh phai m directory trc khi oc noClosedirQua trnh phai ong directory sau khi oc noReaddiroc entry ti cua directoryLinkUnlink
Cac loai cau truc cua th muc
Single-level directoryMulti-level directoryTree-structured directoryAcyclic-graph directoryGeneral graph directory
Cac loai cau truc cua th muc (1)Single-level directoryCh co mot directory cho moi file trong he thong (CDC 6600, IBM MVS, PalmOS)
Cac loai cau truc cua th muc (2)Cai tien cau truc single-level directoryMot so muc tieu Thuan tien cho user khi at ten file, cac user khac nhau co the at ten file trung nhauFile co the co nhieu hn mot tenHo tr phan nhom (grouping): to chc cac files cung ac iem vao chung mot nhom (v du nhom file ma nguon ngon ng C, nhom file Word,)
Cac loai cau truc cua th muc (3)Neu directory, ngoai file ra, con co the cha directory khac
Two-level directory
Cac loai cau truc cua th muc (4)Tree-structured directoryMot cay th muc trong UNIX
Cac loai cau truc cua th muc (5)Acyclic-graph directory
Cac loai cau truc cua th muc (6)General-graph directoryVan e: cycle co the xuat hien dung giai thuat kiem tra chu trnh moi khi tao file?
ng danDung ng dan (path name) en mot file e ac ta v tr cua file trong cay hay rng directoryV duUNIX, LINUX/usr/ast/mailboxDOS, Windows\usr\ast\mailboxng dan tuyet oiTh muc hien thi (current directory, working directory)ng dan tng oi
File system mounting (1)Phai gan (mount) file system e co the truy xuat file cua no
Th muc e gan vao o mot file system c goi la mount point
e thc hien lenh gan# mount /device/thedisk /mountpointhe ieu hanh phai thc thi cac bcOS kiem tra xem file system co hp le hay khongGan file system vao v tr mountpoint
Neu mount point co cha file?Cac file cha trong th muc mount point se b che cho en khi unmount file system.
File system mounting (2)file system trong partition /dev/hda3Cac file b che khi file system trong partition /dev/hda3 c mount vi lenh mount /dev/hda3 /usersmount point
File system mounting (3)Sau khi mount, co the truy cap cac file trong partition /dev/hda3
Chia se file Nhu cau chia se file trong he thong multi-user Viec chia se phai thc hien di c che bao ve, kiem soat nghiem ngat He thong n: hard link va soft link, thiet lap quyen han chia se,Tren he thong mang, file co the c chia se qua mang may tnhTruy cap file bang FTPNetwork File System (NFS) la phng phap chia se file rat pho bien dung c che RPC (mo hnh client-server)File system t xa phai c gan (mount) trc khi s dung. V du: mount ditlab.hcmut.edu.vn:/oscourse /home/mydir
Khi file system a c mount, moi truy xuat en file hay th muc tren o nh bnh thng, user khong phan biet la local hay remote.
Hard link va soft linkTrong UNIXHard link:ln /dict/count /spell/countSoft link:ln -s /spell/words/list /dict/all
V du mount remote file system /homepapermydir/oscourseIOVMIOVM/home/mydir/VM/oscourse/VMditlab.hcmut.edu.vnLocal ClientRemote Server
Bao ve (protection)He ieu hanh phai ho tr chu nhan cua file kha nang kiem soat qua trnh truy cap fileCac tac vu co the thc hien tren file?Nhng ai c quyen thc hien thao tac tren file?Cac quyen truy xuat fileReadWriteExecuteAppendDeleteCach tiep can thong thng Moi file co mot Access-control list (ACL), gom cac cap Windows NT/2K/XP, Linuxuser co the la mot nhom
Access Control ListOwner cua processB: RFile F1:- Moi qua trnh cua user A co quyen oc/ghi- Moi qua trnh cua user B co quyen oc
Cac Access Control BitCac che o truy cap: read, write, executeBa nhom user: owner, group, other (public)User name va user identifier (user ID)Group name va group identifier (group ID)V du trong UNIX: moi nhom user co 1 field, moi field co 3 bit Field:read | write | executeTr: 0/1 0/1 0/1
r w xowner access71 1 1 group access61 1 0public access10 0 1