檔案系統–讀取/etc/passwd的順序

來源:互聯網
上載者:User

 /etc/passwd中的東東怎麼讀出來的呢?

首先我們列出各目錄的inode資訊:
root@ubuntu:/home/jack# ll -di / /etc /etc/passwd
     2 drwxr-xr-x  23 root root  4096 2013-05-26 10:05 //
655364 drwxr-xr-x 132 root root 12288 2013-05-26 10:06 /etc/
665904 -rw-r--r--   1 root root  2201 2013-05-25 21:32 /etc/passwd
/etc/passwd 有關的目錄與檔案資料如上所示,通常一個 filesystem 的最頂層 inode 號碼會由 2 號開始。
1)/ 的 inode:
透過掛載點的資訊找到 /dev/hdc2 的 inode 號碼為 2 的根目錄 inode,且 inode 規範的許可權讓我們可以讀取該 block 的內容(有 r 與 x) ;
2)/ 的 block:
經過上個步驟取得 block 的號碼,並找到該內容有 etc/ 目錄的 inode 號碼 (1912545); 
3)etc/ 的 inode:
讀取 1912545 號 inode 得知 vbird 具有 r 與 x 的許可權,因此可以讀取 etc/ 的 block 內容; 
4)etc/ 的 block:
經過上個步驟取得 block 號碼,並找到該內容有 passwd 檔案的 inode 號碼 (1914888); 
5)passwd 的 inode:
讀取 1914888 號 inode 得知 vbird 具有 r 的許可權,因此可以讀取 passwd 的 block 內容; 
6)passwd 的 block:
最後將該 block 內容的資料讀出來。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.