Hệ thống file file system HH Giao đieãn heã thodang file — Các yêu cầu của người dùng — File — Thư mục — File system mounting — Chia sé & bao vệ... Cac cach truy cap file UW Dugng ca
Trang 111 Hệ thống file (file system)
HH Giao đieãn heã thodang file
— Các yêu cầu của người dùng
— File
— Thư mục
— File system mounting
— Chia sé & bao vệ
Trang 2Các yêu cầu của người dùng
Trang 3Sự hỗ trợ từ phần cứng và hệ điều hành
UW Phaan cứng
— Persistence: cac thiết bị lưu trữ bền vững (non-volatile memory)
— Speed: cung cấp khả năng truy xuất ngẫu nhiên, nâng cao tốc độ đĩa
(5400 —› 7200 —› 10K —› 15K rpm)
— Size: dung lượng lớn, 20M —› 700M —› 40G — 200G — TT byte
UW Hed nieau hagnh
— Persistence: luu tru du thua, back-up phuc vu cho recovery
= Vi du: RAID (Redundant Array of Independent Disks)
— Ease of use:
“" Gán tên cho một chuỗi các khối dữ liệu — file
" Hỗ trợ quản lý các file —› thư mục
" LJser khơng cần quan tâm đến các chỉ tiết hardware (giao tiếp với
disk controller theo IDE, SCSIl )
— Sharing/Protection: cho phép thiết lập các quyền truy cập file/thư mục
Trang 7
Các kiểu file thông dụng
doc formats library lib, a, so, dll libraries of routines for
programmers print or view ps, pdf, jpg ASCII or binary file in a
format for printing or viewing
archive arc, Zip, tar related files grouped into
one file, sometimes com-
pressed, for archiving
or storage multimedia mpeg, mov, rm, | binary file containing mp3, avi audio or A/V information
Trang 8Định dạng file (1)
1 Ơng dụng có thệ lưu vag diedn déch déé liedu trong
file theo nonh daing rieang
Trang 9Định dạng file (2)
Executable file Archive
Khoa Coane Noheg Thodne Tin — Nati Hoic Batch Khoa TP
Trang 10Cấu trúc file
- Không có cấu trúc: một chuỗi byte (Unix, DOS, Windows), Hình a
Ant Fox Pig
Cat || Cow |} Dog Goat |} Lion |} Owl Pony |} Rat ||Worm
Hen |} Ibis || Lamb
Trang 11Cac cach truy cap file
UW Dugng cauc tauc vul thoang thdédeng trean file,
— truy cap fuan tu (sequential access)
" truy xuất dữ liệu theo thứ tự, tung byte hoac record
— truy cập bat ky (random access)
" truy xuất dữ liệu, byte hoặc record, tại vị trí bất kỳ
— truy cập dùng khóa
" †rUy Xuất một record dựa vào key của nó
U Memory-mapped file
— Gia su c6 cac system call map va umap
— Gọi map để “chiếu” file vào không gian dia chi ảo của quá trình
— Dùng các tác vụ truy xuất bộ nhớ để truy xuất file
— Gọi umap khi xong
Trang 12
Các thuộc tính của file
Protection Who can access the file and in what way Password Password needed to access the file
Creator ID of the person who created the file
Read-only flag O for read/write; 1 for read only Hidden flag O for normal; 1 for do not display in listings System flag O for normal files; 1 for system file
Archive flag O for has been backed up; 1 for needs to be backed up
Lock flags O for unlocked; nonzero for locked Record length Number of bytes in a record
Key position Offset of the key within each record Key length Number of bytes in the key field
Trang 14Thư mục
UW Tho muic (directory, folder) lag modt tiedn ich cuta hed fieau hagnh fiea ngddgi dugng toa chduc các file cuta minh
— Ngudi ding co thé xac dinh file thudc vé hay nam trong mot directory;
cách nĩi khác, directory chứa file
Trang 16
Cac loai cau trúc của thư mục
— Single-level directory
— Multi-level directory
— Tree-structured directory
— Acyclic-graph directory
— General graph directory
Trang 17Các loại cấu trúc của thư mục (1)
Trang 18Các loại cấu trúc của thư mục (2)
Caöô1 tiean caau truuc single-level directory
— Thuận tiện cho user khi đặt tên file, các user khác nhau có thể đặt tên
file trùng nhau
— File có thể có nhiều hơn một tên
— Hỗ trợ phân nhóm (grouping): tổ chức các files cùng đặc điểm vào
chung một nhóm (ví dụ nhóm file mã nguồn ngôn ngữ C, nhóm file Word )
Trang 19
Các loại cấu trúc của thư mục (3)
Trang 20Các loại cấu trúc của thư mục (4)
Trang 21Các loại cấu trúc của thư mục (5)
Trang 22Các loại cấu trúc của thư mục (6)
UW General-graph directory
— Vấn đề: cycle có thể xuất hiện
—> dùng giải thuật kiểm tra chu trình mỗi khi tạo file?
root | avi tc jim
text | mail | count| book book | mail |unhex| hyp
avi | count unhex| hex
Trang 23
— UNIX, LINUX /usr/ast/mailbox
— DOS, Windows \usr\ast\mailbox
Đường dẫn tuyệt đối
Tho muic hiễän thời (current directory, working
Trang 24File system mounting (1)
L] Phaơ1 gắn (mount) file system đệ có thệ truy xuất
file cuta nou
Tho muic hea gắn vago fiou modt file system fAddédic gori
lag mount point
Đệ thực hiện lệnh gắn
hed fAieau hagnh phati thdic thi cauc bdduc
— OS kiém tra xem file system cĩ hợp lệ hay khơng
- Gắn file system vào vị trí mountboint
Nếu mount point cou chdua file?
— Cac file chWa trong thu muc mount point sé bi che cho dén khi unmount file system
Trang 25
File system mounting (2)
Trang 26File system mounting (3)
Users
jane
prog
Sau khi mount, có thể truy cập các file trong partition /dev/hda3
Trang 27Chia sẻ file
UW Nhu caau chia set file trong hed thoang multi-user
UW Viedc chia set phati thdic hiedn dddui cé chea batio
ved, kieam soaut nghieam ngaét
UW Hed thoáng ndn: hard link vag soft link, thieat ladp gquyean hain chia seÔ,
H1 Trea4n hed thodng maing, file cou thea fAddic chia set qua maing mauy tinh
— Truy cap file bang FTP
— Network File System (NFS) la phucng phap chia sẻ file rất phổ biến
dung co ché RPC (m6 hinh client-server)
" File system từ xa phải được gắn (mount) trước khi sử dụng Ví dụ:
mount ditlab.hcmut.edu.vn:/oscourse /home/mydir
" Khi file system đã được mount, mọi truy xuất đến file hay thư mục trên đó như bình thường, user không phân biệt là local hay remote
Trang 28
Hard link va soft link
root | dict | spell
OQ Hard link: In /dict/fcount /spell/count
O Soft link: 1n -s /spell/words/list /dict/all
Trang 29Vi du mount remote file system
Trang 30Bảo vệ (protection)
UW Hed Aieau hành phaơ1 hỗ trơi chuơ nhân cuơa file
khaơ năng kiệm soát quáị trình truy cập file
— Các tác vụ cĩ thể thực hiện trên file?
— Những ai được quyền thực hiện thao tác trên file?
UW Cauch tieap cadn thông thường
— Mỗi file cĩ một Access-control Iist (ACL), gồm các cặp <user, rights>
Trang 31Access Control List
- Mọi quá trình của user A có quyền đọc/ghi
- Mọi quá trình của user B có quyền đọc
Trang 32
Cac Access Control Bit
UW Cauc chea fiod truy cadp: read, write, execute
UW Ba nhoum user: owner, group, other (public)
— User name va user identifier (user ID)
— Group name va group identifier (group ID)
UO Vi dui trong UNIX: modi nhoum user cou 1 field, modi field cou 3 bit
— Field: read | write | execute
TW x
Group access 6 => 1 1 0Ö public access 1 => 0 0 1