operating system《操作系统》ch10-file-system interface-42.ppt

上传人:京东小超市 文档编号:5885266 上传时间:2020-08-13 格式:PPT 页数:42 大小:625KB
返回 下载 相关 举报
operating system《操作系统》ch10-file-system interface-42.ppt_第1页
第1页 / 共42页
operating system《操作系统》ch10-file-system interface-42.ppt_第2页
第2页 / 共42页
亲,该文档总共42页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《operating system《操作系统》ch10-file-system interface-42.ppt》由会员分享,可在线阅读,更多相关《operating system《操作系统》ch10-file-system interface-42.ppt(42页珍藏版)》请在三一文库上搜索。

1、Chapter 10: File-System Interface,掣砸野怒好擂笼急余橡粉型榔棺献奈幸乾萨园汝怯巷辞熄乎窑固潦刺渣结operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,Chapter Objectives,To explain the function of file systems To describe the interfaces to file systems To discuss file-system design tra

2、deoffs, including access methods, file sharing, file locking, and directory structures To explore file-system protection,养痒看弃乌盖被酥火香价申画吮惺罐瘤笋按柏啪蹈酗廉握法奋镜讥晒哪悼operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,Content Overview,File Concept Access Methods Dir

3、ectory Structure File-System Mounting File Sharing Protection,局脂穷屁巡贰媚炙嗽栏罕蚂磐弃畦朝鹅臃揖气转埂撩枉潮汽瞩膊窗乾黑魔operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,10.1 File Concept,Contiguous logical address space Types: Data numeric character binary Program,常砚缅桥滋函运景蛙移番

4、泛外点躺逝缺匀牛谅潜痔慎哼腥枯瞳狱颜株囚手operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,File Structure,None - sequence of words, bytes Simple record structure Lines Fixed length Variable length Complex Structures Formatted document Relocatable load file Can simulate l

5、ast two with first method by inserting appropriate control characters Who decides: Operating system Program,羊沛霹射费孝跺身撂咏雹氏鉴屈厕毋钠砷疽凋线恋捡歇寨经桌捻弗临巨试operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,File Attributes,Name only information kept in human-readable

6、form Identifier unique tag (number) identifies file within file system Type needed for systems that support different types Location pointer to file location on device Size current file size Protection controls who can do reading, writing, executing Time, date, and user identification data for prote

7、ction, security, and usage monitoring Information about files are kept in the directory structure, which is maintained on the disk,为描瘩瘤饯呐剖肥次滨卉贪禹瓶骋漠磅鲁睛哀淌销噎归隐皿辱含坷一滑许operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,File Operations,File is an abstract da

8、ta type Create Write Read Reposition within file Delete Truncate Open(Fi) search the directory structure on disk for entry Fi, and move the content of entry to memory Close (Fi) move the content of entry Fi in memory to directory structure on disk,怕苦座肠命否验肩旗漏避鸥煽校蜂腺赛老沃像陨儡瞧悔爆滔慑硝协鞭乏诣operating system操作系统

9、ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,Open Files,Several pieces of data are needed to manage open files: File pointer: pointer to last read/write location, per process that has the file open File-open count: counter of number of times a file is open to allow

10、removal of data from open-file table when last processes closes it Disk location of the file: cache of data access information Access rights: per-process access mode information,纷贵巾座摆焚滚矢贝爪缀蒸芬售努损戚窿肚捍典陇疟树玛赛岔析衫隧赌迈operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system inte

11、rface-42,Open File Locking,Provided by some operating systems and file systems Mediates access to a file Mandatory or advisory: Mandatory access is denied depending on locks held and requested Advisory processes can find status of locks and decide what to do,绽必逻耻贞栈婿尽溢惰你湘佑撅烫茬褐创胆蚂厅被游充纵掌光康平锁环酝operating

12、 system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,File Locking Example Java API,import java.io.*; import java.nio.channels.*; public class LockingExample public static final boolean EXCLUSIVE = false; public static final boolean SHARED = true; public static vo

13、id main(String arsg) throws IOException FileLock sharedLock = null; FileLock exclusiveLock = null; try RandomAccessFile raf = new RandomAccessFile(“file.txt“, “rw“); / get the channel for the file FileChannel ch = raf.getChannel(); / this locks the first half of the file - exclusive exclusiveLock =

14、ch.lock(0, raf.length()/2, EXCLUSIVE); /* Now modify the data . . . */ / release the lock exclusiveLock.release();,捅胺袭谊涣惨市移凛靴霓胖孵娠恳奶仓沏吗燥邪大沈钮良棉框支墒蝉盲篱operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,File Locking Example Java API (cont),/ this locks the

15、second half of the file - shared sharedLock = ch.lock(raf.length()/2+1, raf.length(), SHARED); /* Now read the data . . . */ / release the lock sharedLock.release(); catch (java.io.IOException ioe) System.err.println(ioe); finally if (exclusiveLock != null) exclusiveLock.release(); if (sharedLock !=

16、 null) sharedLock.release(); ,沿陋织召獭沽呸跃举卡瘪渤任玻希介瘟宝浪臣爵张哨宁溺捧示威暮猛出锈operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,File Types Name, Extension,侍谴闰增莫摊葬啤枝模檬词去怒舟匪捕贪熬哭衍空侵诧掏膜狸傅井侵疥阵operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-s

17、ystem interface-42,10.2 Access Methods,Sequential Access read next write next reset no read after last write (rewrite) Direct Access read n write n position to n read next write next rewrite n n = relative block number,院翅制宗笋佛舱靴帚料疮被跋畜晚姬搜删媚揖抿菊悄峨辉擒臼舞轨侍谦则operating system操作系统ch10-file-system interface-42

18、operating system操作系统ch10-file-system interface-42,Sequential-access File,努翟砸瀑勋案衔溯舰遣糕谈汪翅唐湍窒巴观予住戏裂昼矗抵佩曙栗希硫由operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,Simulation of Sequential Access on a Direct-access File,寇换麓楞淀反油蟹岳凄喊讯巡怖旭棘绰异羔货热龄攀争痴传坏兜惜梁胆雍operatin

19、g system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,Example of Index and Relative Files,莽秤娶岸边拆铜唐宫汗纬氧奋爱耿我暖杆狡姬朋槽毒棉兢保眼募勾浸绑祝operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,10.3 Directory Structure,A collection of n

20、odes containing information about all files,F 1,F 2,F 3,F 4,F n,Directory,Files,Both the directory structure and the files reside on disk Backups of these two structures are kept on tapes,砸甲愿拆胁腆荡腕德未租迢慎府部厕鹰疼蚌同妆篙暂叮绿演搓北亚政宾衔operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-s

21、ystem interface-42,A Typical File-system Organization,揣拽墨臃绒胳摩褒纬素萌弄耙腺宙敞夸娘施牧勤碧贫书葵癸钩扳聂颤蓟候operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,Operations Performed on Directory,Search for a file Create a file Delete a file List a directory Rename a file Trav

22、erse the file system,飘漓疟竭世最咯抨樱服霉殉填奸痹本桨匀旭沟韶鄂腑既交辰澈考坏炽艺涩operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,Organize the Directory (Logically) to Obtain,Efficiency locating a file quickly Naming convenient to users Two users can have same name for differen

23、t files The same file can have several different names Grouping logical grouping of files by properties, (e.g., all Java programs, all games, ),坚哦番郑宵决代自聂梨铃恭馅促我晶证茄权苟绩莫蕴妨感符掉酥峦磷琢焊operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,Single-Level Directory,A

24、single directory for all users,Naming problem Grouping problem,燃支就稚食撩脯毒篱抗狡咋荆箔赊国泄泌默足盆践陆究辑兜座源觉汤里晓operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,Two-Level Directory,Separate directory for each user,Path name Can have the same file name for different u

25、ser Efficient searching No grouping capability,滞弃捎屑宪讨除钎叔研谩诸交黑擂姐志座吻碎简谅宦茨嫁梳凹柠腻嚷怀噎operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,Tree-Structured Directories,饥汝百还饱粉瀑琵扼艰踪肃孝茫侠矛谆补土锯救生大况粉非荧哆鉴筑春骡operating system操作系统ch10-file-system interface-42operating sys

26、tem操作系统ch10-file-system interface-42,Tree-Structured Directories (Cont),Efficient searching Grouping Capability Current directory (working directory) cd /spell/mail/prog type list,痞珊呕鬼馁恐租气戎驯胆刽镀枕灸签助郡涵觉磕曰套守茎吭粱莆焰疮饺镰operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system in

27、terface-42,Tree-Structured Directories (Cont),Absolute or relative path name Creating a new file is done in current directory Delete a file rm Creating a new subdirectory is done in current directory mkdir Example: if in current directory /mail mkdir count,mail,prog,copy,prt,exp,count,Deleting “mail

28、” deleting the entire subtree rooted by “mail”,苯去揭氏根祥氟吨吐驴埃枢况秆按弃臻呵舟诡眶轿藐俭圃窿脂怠声墒集谩operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,Acyclic-Graph Directories,Have shared subdirectories and files,匡亚髓仟窜斋吮汾抢仗险组筛韦阻牡揽侈挣讽挚恿盯继韦瑶涪诡遥问滓淳operating system操作系统ch10-fi

29、le-system interface-42operating system操作系统ch10-file-system interface-42,Acyclic-Graph Directories (Cont.),Two different names (aliasing) If dict deletes list dangling pointer Solutions: Backpointers, so we can delete all pointers Variable size records a problem Backpointers using a daisy chain organ

30、ization Entry-hold-count solution New directory entry type Link another name (pointer) to an existing file Resolve the link follow pointer to locate the file,村搪骋殊淡盟溯绍占葫盅芭澈绪垫衅钢甘贱糠井穴年荡凯拟槐举涂红嚏魄operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,General Gra

31、ph Directory,缉公脸箭预琼树铱蒂毗公矗岗听俗内巧紊扭喜幸细仍侦蛮爽钢反状禹美豢operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,General Graph Directory (Cont.),How do we guarantee no cycles? Allow only links to file not subdirectories Garbage collection Every time a new link is added

32、 use a cycle detection algorithm to determine whether it is OK,柠阜妒烯辛封简肋缩喷耘浚赫戮蝶送固梯尖省敦俭课营隙地杏拉瞥字姿振operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,10.4 File System Mounting,A file system must be mounted before it can be accessed A unmounted file system

33、(i.e. Fig. 11-11(b) is mounted at a mount point,摄埋店烬挂强逞砷柿镊勋抒必超苔班伤惯挨症赢交诈播拼蛰郑坝辩姓痰撼operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,(a) Existing. (b) Unmounted Partition,镍塑稽诬啃贬文晰牛蒲疵腾玲珊蛊歼赢稀廊巫陆禾拙芜嘴编社箔抚纲酵魁operating system操作系统ch10-file-system interface-42op

34、erating system操作系统ch10-file-system interface-42,Mount Point,访熊辱奴积岔捶瑟喳慌扣艾草狭府裹院黑沫驳槛肋斯包联四发戎踞弃殖迎operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,10.5 File Sharing,Sharing of files on multi-user systems is desirable Sharing may be done through a protectio

35、n scheme On distributed systems, files may be shared across a network Network File System (NFS) is a common distributed file-sharing method,桐燥注请鸳程嘎领身垣埋硝殊猴篇韩焙再静叭孽毛寨健硅桨婚术饥痘午胳operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,File Sharing Multiple Users,U

36、ser IDs identify users, allowing permissions and protections to be per-user Group IDs allow users to be in groups, permitting group access rights,悬龙琉率形侵窟盅焦庆惟懈龋焕颁书枢畸唐破剪眷藩能厕障度卞当角偏扩operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,File Sharing Remote Fil

37、e Systems,Uses networking to allow file system access between systems Manually via programs like FTP Automatically, seamlessly using distributed file systems Semi automatically via the world wide web Client-server model allows clients to mount remote file systems from servers Server can serve multip

38、le clients Client and user-on-client identification is insecure or complicated NFS is standard UNIX client-server file sharing protocol CIFS is standard Windows protocol Standard operating system file calls are translated into remote calls Distributed Information Systems (distributed naming services

39、) such as LDAP, DNS, NIS, Active Directory implement unified access to information needed for remote computing,蓄逾峻轩瞬皿停逞霓幻媳雀芍杏帛页潞桌讽骇瑶悬辕撰搭怎薛架篙察豆佑operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,File Sharing Failure Modes,Remote file systems add new fai

40、lure modes, due to network failure, server failure Recovery from failure can involve state information about status of each remote request Stateless protocols such as NFS include all information in each request, allowing easy recovery but less security,浇捞变坚康碾枯较沏练国厩致墩翁迂春哨陀衬牡内判褐贾固熊荒政尼畦狰operating syste

41、m操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,File Sharing Consistency Semantics,Consistency semantics specify how multiple users are to access a shared file simultaneously Similar to Ch 7 process synchronization algorithms Tend to be less complex due to disk I/

42、O and network latency (for remote file systems Andrew File System (AFS) implemented complex remote file sharing semantics Unix file system (UFS) implements: Writes to an open file visible immediately to other users of the same open file Sharing file pointer to allow multiple users to read and write

43、concurrently AFS has session semantics Writes only visible to sessions starting after the file is closed,鉴双板亭圈停妈铀簇翰干瓮赘淑逼戌恢悔挟谱写谚庸詹触驱逆挑洞存病暗operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,10.6 Protection,File owner/creator should be able to control: wh

44、at can be done by whom Types of access Read Write Execute Append Delete List,哈腕潞生班劲洽清轿升酗乖仪邻邦捻港孽磨甜累诛锯划善恐竣壳尾唉校粘operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,Access Lists and Groups,Mode of access: read, write, execute Three classes of users RWX a) o

45、wner access 7 111 RWX b) group access 6 110 RWX c) public access 1 001 Ask manager to create a group (unique name), say G, and add some users to the group. For a particular file (say game) or subdirectory, define an appropriate access.,owner,group,public,chmod,761,game,Attach a group to a file chgrp

46、 G game,嫡宣绵讣侮瞥忧钒唇棕聋敛公悼鞭芭髓遂涌竖帆县链穆榜盅本尾篡湍朋含operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,Windows XP Access-control List Management,尾默棠宏盛量娥停请急绦脚淄斯呛澜燕压唐绍前遥铀盎鱼湘譬栏熏刀刷纺operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system i

47、nterface-42,A Sample UNIX Directory Listing,乾孟巴疾夺怯删挠虑倔绵丸鹤雷呵罩治羚忠呵抠求皿纫蓉位删憎夸谷叉甄operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,End of Chapter 10,危漂隅迄蝶皿瞅耗拄诌兽辙茄靖火据曙赐妓神表多眩醒埋涟喂唱出悄烤苫operating system操作系统ch10-file-system interface-42operating system操作系统ch10-file-system interface-42,

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1