OS-file system interface(用戶角度)

File-system Interface

File--nonvolatile 非易失性

A file is a logical storage unit.

A file is? a named collection of related information that is recorded on secondary storage.

contiguous logical address space

File Attribute--kept in the directory,also maintained on the secondary storage

????A file's attributes vary from one OS to another but typically consist of :

name,identifier,type,location,size,protection,time,data and user identification

????A directory entry only consists of the file's name and its unique identifier,the identifier in turn locates the other file attributes.

FIle is an abstract data type.

6 basic system calls:

create:allocate space and create a directory entry

wirte and read:pointer

reposition within file:seek

delete:release space and erase the directory entry

truncate:file len=0,release space,all other attributes remain unchanged

OPEN-->find entry FI-->move the content of entry to memory

CLOSE-->寫回屬性

Open file table:a small table containing information about all open files

? ? ? ? ? ? ? ? ? ? ? ? ? ? 記錄打開了哪些,讀到了哪里

2 level 訪問:

a per-process table(每個(gè)進(jìn)程都有一個(gè)open file table,記錄一些與進(jìn)程相關(guān)的信息):

*file pointer:讀到了哪些信息绊率,寫了哪些信息

*access control:訪問模式肠鲫,可讀可寫可執(zhí)行

a system-wide table( with process-independent information,記錄一些通用信息)

*file-open count:記錄被打開的次數(shù)?

*disk location of the file

File Structure

*none 無結(jié)構(gòu)的字節(jié)流曼追,sequence of words,bytes

*simple record structure

*complex structure



Internal file structure

how to locate an offset within a file?

Packing-pack a number of logical records (vary in length) into physical blocks (fixed size)

把字節(jié)流打包成塊,再映射

Internal fragmentation will occur.


Access Methods

Files store information.When it is used ,this information must be accessed and read into computer memory.

Sequential Access

the simplest access method.Information in the file is processed in order,one record after the other.

a most common access mode:editors,compilers

A tape model of file

Direct Access:

information in the file is processed in no particular order

File is made up of a number sequence of fixed-length logical records.

A disk model of file :allow random access,immediate access:databases ,airline-reservation system

can move quickly to any recored location by supplying a relative record number

Indexed Access

to improves seach time and reduce I/O

Make an index file for the file,which contains pointers to various records

search the index file first-->use the pointer to access the file directly -->find the desired record

with large files,the index file itself may become too large to be kept in memory --->multi-level index table


Directory Structure

partition=files+directories

directory:a collection of nodes containing information about all files

directory + files : all reside on disk

backups of these two structures are kept on tapes

Organize the directory (logically) to obtain :efficiency ,naming and grouping

Directory Structures:

1.Single-level directory

2.Two-level directory

3.Tree-structured directory

4.Acyclic-graoh directory

5.General-graph directory

Single-level directory:

esay but:

1.very low searching speed 2.name problem (small name space and name collison)

Two-level directory

Separate directory for each user

User File Directory(UFD) :for user

Master file directory(MFD): user name and a pointer to his UFD

same file name for different user is ok

efficient searching

easy management

no grouping capability

security and sharing

Tree-Structured Directory

root directory and directory and subdirectory

efficient searching

grouping capability

tree structure

prohibits the sharing of files and directories

用戶可以訪問到其他用戶的文件

Acyclic-Graph Directories(無環(huán)圖目錄)

*Have shared subdirectories and files,with no cycles(結(jié)構(gòu)無環(huán))

*The same file or directory may be in two different directories,having two different names(aliasing)

這里是共享文件,而不是文件復(fù)制叶堆!對于共享文件,任何改變都會為其他用戶所見?

Implementation

1.Symbolic links (另一文件或目錄的指針)

鏈接通過路徑定位文件來解析

A special new directory entry(link)

The content of? such file is the path name of the real file/directory

2.duplicates directory entries

hard to maintain consistency

Problem

1.Traverse Problem?

一個(gè)文件可以擁有多個(gè)絕對路徑名

多次重復(fù)遍歷共享目錄

2.delete problem

dangling pointer

preserve the file until all reference to it are deleted

solutions:

file-reference list

reference count

通過禁止對目錄的多重引用斥杜,維護(hù)無環(huán)圖結(jié)構(gòu)

General Graph Directory

traversing problem and deleting problem still exists,even more complicatedly

infinite loop

garbage and garbage collection

保證無環(huán)

allow only links to file not subdirectories

add new link,use a cycle detection algorithm to determine whether it's ok




Protection

reliability(可靠性):guarding against physical damage

protection(保護(hù)虱颗,安全性):guarding against improper access

Access control:

ID-dependent access:make access dependent on the ID of the user

implement:Access control list(ACL)

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市蔗喂,隨后出現(xiàn)的幾起案子忘渔,更是在濱河造成了極大的恐慌,老刑警劉巖缰儿,帶你破解...
    沈念sama閱讀 219,427評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件畦粮,死亡現(xiàn)場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)宣赔,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,551評論 3 395
  • 文/潘曉璐 我一進(jìn)店門预麸,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人儒将,你說我怎么就攤上這事吏祸。” “怎么了钩蚊?”我有些...
    開封第一講書人閱讀 165,747評論 0 356
  • 文/不壞的土叔 我叫張陵贡翘,是天一觀的道長。 經(jīng)常有香客問我砰逻,道長床估,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,939評論 1 295
  • 正文 為了忘掉前任诱渤,我火速辦了婚禮丐巫,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘勺美。我一直安慰自己递胧,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,955評論 6 392
  • 文/花漫 我一把揭開白布赡茸。 她就那樣靜靜地躺著缎脾,像睡著了一般。 火紅的嫁衣襯著肌膚如雪占卧。 梳的紋絲不亂的頭發(fā)上遗菠,一...
    開封第一講書人閱讀 51,737評論 1 305
  • 那天,我揣著相機(jī)與錄音华蜒,去河邊找鬼辙纬。 笑死,一個(gè)胖子當(dāng)著我的面吹牛叭喜,可吹牛的內(nèi)容都是我干的贺拣。 我是一名探鬼主播,決...
    沈念sama閱讀 40,448評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼捂蕴,長吁一口氣:“原來是場噩夢啊……” “哼譬涡!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起啥辨,我...
    開封第一講書人閱讀 39,352評論 0 276
  • 序言:老撾萬榮一對情侶失蹤涡匀,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后溉知,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體陨瘩,經(jīng)...
    沈念sama閱讀 45,834評論 1 317
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡腕够,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,992評論 3 338
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了拾酝。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片燕少。...
    茶點(diǎn)故事閱讀 40,133評論 1 351
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖蒿囤,靈堂內(nèi)的尸體忽然破棺而出客们,到底是詐尸還是另有隱情,我是刑警寧澤材诽,帶...
    沈念sama閱讀 35,815評論 5 346
  • 正文 年R本政府宣布底挫,位于F島的核電站,受9級特大地震影響脸侥,放射性物質(zhì)發(fā)生泄漏建邓。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,477評論 3 331
  • 文/蒙蒙 一睁枕、第九天 我趴在偏房一處隱蔽的房頂上張望官边。 院中可真熱鬧,春花似錦外遇、人聲如沸注簿。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,022評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽诡渴。三九已至,卻和暖如春菲语,著一層夾襖步出監(jiān)牢的瞬間妄辩,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,147評論 1 272
  • 我被黑心中介騙來泰國打工山上, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留眼耀,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,398評論 3 373
  • 正文 我出身青樓胶哲,卻偏偏與公主長得像畔塔,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個(gè)殘疾皇子鸯屿,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,077評論 2 355

推薦閱讀更多精彩內(nèi)容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,336評論 0 10
  • 本文轉(zhuǎn)載自何雷(微信號公眾號“不正確青年”)發(fā)布于「人人都是產(chǎn)品經(jīng)理」的文章寄摆,http://www.woshipm...
    使徒行者via閱讀 1,733評論 2 22
  • 人·生 首先 先要做好一個(gè)人 其次 學(xué)會好好生活 最簡單的 往往是難的 最便宜的 也往往是最貴的 吾日三省吾身 在...
    牛小屁DQ閱讀 258評論 0 0
  • 2018.5.2 第43天 讀一遍規(guī)畫已讀 每天一句愛的表達(dá):對彬彬說愛你,對幫助我的人說謝謝 每天一次自我確認(rèn):...
    雙小寶閱讀 107評論 0 0
  • 第一天 ①書名:《最好的告別》(關(guān)于衰老與死亡修赞,你必須知道的常識婶恼。共248頁桑阶,亞馬遜年度好書《紐約時(shí)報(bào)》暢銷書) ...
    舒曉漁閱讀 1,545評論 0 7