{"id":70892,"date":"2026-02-02T18:24:57","date_gmt":"2026-02-02T10:24:57","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/70892.html"},"modified":"2026-02-02T18:24:57","modified_gmt":"2026-02-02T10:24:57","slug":"%e6%b7%b1%e5%85%a5%e6%8f%ad%e7%a7%98-linux-%e8%99%9a%e6%8b%9f%e6%96%87%e4%bb%b6%e7%b3%bb%e7%bb%9f-vfs-%ef%bc%88%e4%b8%8b%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/70892.html","title":{"rendered":"\u6df1\u5165\u63ed\u79d8 Linux \u865a\u62df\u6587\u4ef6\u7cfb\u7edf VFS \uff08\u4e0b\uff09"},"content":{"rendered":"<h2>1. \u524d\u8a00<\/h2>\n<p>\u4e0a\u4e00\u7bc7\u6587\u7ae0\u6211\u4eec\u9010\u4e2a\u5b66\u4e60\u4e86 VFS \u7684\u56db\u5927\u6838\u5fc3\u5bf9\u8c61&#xff0c;\u90a3\u4e48\u672c\u7bc7\u6587\u7ae0\u6211\u4eec\u5c06\u66f4\u52a0\u6df1\u5165\u5185\u6838&#xff0c;\u6df1\u5ea6\u62c6\u89e3\u8fd9\u4e9b\u5bf9\u8c61\u662f\u5982\u4f55\u901a\u8fc7\u8def\u5f84\u67e5\u627e\u3001\u63a5\u53e3\u591a\u6001\u6765\u534f\u4f5c\u5b8c\u6210\u4e00\u6b21\u771f\u5b9e\u7684\u6587\u4ef6\u64cd\u4f5c\u7684\u3002<\/p>\n<p>\u6211\u4eec\u8bdd\u4e0d\u591a\u8bf4&#xff0c;\u76f4\u63a5\u8fdb\u5165\u6b63\u9898\u3002<\/p>\n<h2>2. \u8def\u5f84\u67e5\u627e<\/h2>\n<p>\u6211\u4eec\u5728\u5199\u4ee3\u7801\u65f6&#xff0c;\u901a\u5e38\u50cf\u4e0b\u9762\u8fd9\u6837\u6253\u5f00\u4e00\u4e2a\u6587\u4ef6&#xff1a;<\/p>\n<p><span class=\"token keyword\">int<\/span> fd <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">open<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\/home\/user\/a.txt&#034;<\/span><span class=\"token punctuation\">,<\/span> O_RDONLY<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd9\u91cc\u4f7f\u7528\u7684\u8def\u5f84\u662f\u7edd\u5bf9\u8def\u5f84&#xff0c;\u4e5f\u53ef\u4ee5\u4f7f\u7528\u76f8\u5bf9\u8def\u5f84\u3002<\/p>\n<p>\u5bf9\u4e8e\u7528\u6237\u7a0b\u5e8f\u6765\u8bf4&#xff0c;\u6211\u4eec\u53ea\u662f\u63d0\u4f9b\u4e86\u4e00\u4e2a\u51b7\u51b0\u51b0\u7684\u5b57\u7b26\u4e32\u8def\u5f84&#xff0c;\u4f46\u662f\u5bf9\u4e8e\u5185\u6838\u6765\u8bf4&#xff0c;\u5b83\u53ea\u8ba4\u8bc6 Inode\u3002<\/p>\n<p>\u90a3\u4e48&#xff0c;\u5185\u6838\u7a76\u7adf\u662f\u5982\u4f55\u628a\u8fd9\u4e2a\u5b57\u7b26\u4e32 \/home\/user\/a.txt&#xff0c;\u4e00\u6b65\u6b65\u8f6c\u6362\u6210\u5185\u5b58\u4e2d\u5177\u4f53\u7684 struct inode \u7684&#xff1f;\u5176\u5b9e\u8fd9\u4e2a\u8fc7\u7a0b\u5728 Linux \u5185\u6838\u4e2d\u88ab\u79f0\u4e3a Path Walking&#xff08;\u8def\u5f84\u67e5\u627e&#xff09;\u3002<\/p>\n<p>\u5177\u6709\u4e00\u5b9a\u7f16\u7a0b\u601d\u7ef4\u7684\u4eba\u53ef\u80fd\u5728\u9605\u8bfb\u5185\u6838\u6e90\u7801\u4e4b\u524d\u5c31\u5df2\u7ecf\u6709\u601d\u8def\u4e86&#xff1a;\u53ea\u9700\u8981\u628a\u5b57\u7b26\u4e32\u6309 \/ \u5207\u5206&#xff0c;\u4e00\u7ea7\u4e00\u7ea7\u627e\u4e0d\u5c31\u884c\u4e86\u3002<\/p>\n<p>\u8fd9\u4e2a\u601d\u8def\u5176\u5b9e\u5f88\u7b80\u5355&#xff0c;\u903b\u8f91\u4e0a\u4e5f\u786e\u5b9e\u662f\u8fd9\u6837\u7684\u3002\u4f46\u5728\u5de5\u7a0b\u5b9e\u73b0\u4e0a&#xff0c;\u4e3a\u4e86\u4fdd\u8bc1\u6781\u81f4\u7684\u6027\u80fd\u548c\u529f\u80fd\u7684\u7075\u6d3b\u6027&#xff0c;\u5c31\u4e0d\u80fd\u6bcf\u5207\u5206\u4e00\u7ea7\u76ee\u5f55\u5c31\u53bb\u8bfb\u4e00\u6b21\u78c1\u76d8&#xff0c;\u8fd8\u8981\u505a\u597d\u5bf9\u6302\u8f7d\u70b9\u7684\u5904\u7406&#xff0c;\u56e0\u6b64 Linux \u5728\u8fd9\u91cc\u8bbe\u8ba1\u4e86\u6781\u5176\u7cbe\u5999\u7684\u673a\u5236\u3002<\/p>\n<h3>2.1 \u76ee\u5f55\u9879\u7f13\u5b58 Dcache<\/h3>\n<p>\u5982\u679c\u771f\u7684\u50cf\u6700\u539f\u59cb\u7684\u903b\u8f91\u90a3\u6837&#xff0c;\u6bcf\u67e5\u627e\u4e00\u7ea7\u76ee\u5f55&#xff0c;\u90fd\u8981\u53bb\u8bfb\u4e00\u6b21\u7269\u7406\u78c1\u76d8&#xff0c;\u90a3\u4e48 Linux \u7684 I\/O \u6027\u80fd\u5c06\u6162\u5f97\u4ee4\u4eba\u5d29\u6e83\u3002<\/p>\n<p>\u6211\u4eec\u6309\u7167\u8fd9\u4e2a\u539f\u59cb\u903b\u8f91\u611f\u53d7\u4e00\u4e0b&#xff0c;\u67e5\u627e \/usr\/bin\/vim \u8fd9\u4e2a\u8def\u5f84&#xff1a;<\/p>\n<li>\u8bfb\u53d6\u6839\u76ee\u5f55 \/ \u7684 Inode&#xff0c;\u8fd9\u662f\u78c1\u76d8 IO\u3002\u7136\u540e\u89e3\u6790\u6570\u636e\u5757&#xff0c;\u518d\u627e\u5230 usr \u7684\u4f4d\u7f6e\u3002<\/li>\n<li>\u8bfb\u53d6 usr \u7684 Inode&#xff0c;\u8fd9\u662f\u78c1\u76d8 IO\u3002\u7136\u540e\u89e3\u6790\u6570\u636e\u5757&#xff0c;\u627e\u5230 bin \u7684\u4f4d\u7f6e\u3002<\/li>\n<li>\u8bfb\u53d6 bin \u7684 Inode&#xff0c;\u8fd9\u662f\u78c1\u76d8 IO\u3002\u89e3\u6790\u6570\u636e\u5757&#xff0c;\u6700\u540e\u627e\u5230 vim \u7684\u4f4d\u7f6e\u3002<\/li>\n<p>\u6bcf\u4e00\u6b21\u78c1\u76d8 IO \u90fd\u662f\u6beb\u79d2\u7ea7\u7684\u5f00\u9500&#xff0c;\u4e3a\u4e86\u907f\u514d\u8fd9\u79cd\u8017\u65f6\u7684\u64cd\u4f5c&#xff0c;VFS \u5f15\u5165\u4e86 Dcache (Dentry Cache)\u3002<\/p>\n<p>\u8fd8\u8bb0\u5f97\u6211\u4eec\u4e0a\u7bc7\u6587\u7ae0\u8bb2\u7684struct dentry\u5417&#xff1f;\u5b83\u4e0d\u4ec5\u4ec5\u4ee3\u8868\u8def\u5f84&#xff0c;\u5728\u5185\u5b58\u4e2d\u5b83\u8fd8\u662f\u4e00\u4e2a\u54c8\u5e0c\u8868\u8282\u70b9\u3002<\/p>\n<p>\u5f53\u5185\u6838\u5f00\u59cb\u89e3\u6790\u8def\u5f84\u65f6&#xff0c;\u5b83\u7684\u7b2c\u4e00\u53cd\u5e94\u7edd\u4e0d\u662f\u8bfb\u78c1\u76d8&#xff0c;\u800c\u662f\u67e5\u5185\u5b58&#xff1a;\u770b\u770b Dcache \u91cc\u6709\u6ca1\u6709\u7f13\u5b58\u8fc7 usr \u8fd9\u4e2a\u76ee\u5f55\u9879&#xff1f;<\/p>\n<p>\u5982\u679c Cache Hit&#xff08;\u7f13\u5b58\u547d\u4e2d&#xff09;&#xff1a;\u76f4\u63a5\u62ff\u5230 dentry&#xff0c;\u4e0d\u9700\u8981\u8bfb\u76d8&#xff0c;\u7eb3\u79d2\u7ea7\u5b8c\u6210\u3002<\/p>\n<p>\u5982\u679c Cache Miss&#xff08;\u7f13\u5b58\u672a\u547d\u4e2d&#xff09;&#xff1a;\u5c31\u8c03\u7528\u5177\u4f53\u6587\u4ef6\u7cfb\u7edf\u7684 lookup \u63a5\u53e3&#xff0c;\u53bb\u78c1\u76d8\u8bfb\u53d6\u5143\u6570\u636e&#xff0c;\u6784\u5efa\u4e00\u4e2a\u65b0\u7684 dentry \u653e\u5165\u7f13\u5b58&#xff0c;\u4ee5\u4fbf\u4e0b\u6b21\u9ad8\u6548\u67e5\u627e\u3002<\/p>\n<p>\u8fd9\u91cc\u8bb2\u4e00\u4e2a\u51b7\u77e5\u8bc6&#xff1a;Linux \u7cfb\u7edf\u4e2d 90% \u4ee5\u4e0a\u7684\u7a7a\u95f2\u5185\u5b58\u5f80\u5f80\u90fd\u88ab Page Cache \u548c Dcache \u5360\u636e\u3002\u5f53\u4f60\u53d1\u73b0\u7cfb\u7edf\u5185\u5b58\u5360\u7528\u5f88\u9ad8\u4f46\u8fd0\u884c\u6d41\u7545\u65f6&#xff0c;\u901a\u5e38\u5c31\u662f\u5b83\u4eec\u5728\u66ff\u4f60\u52a0\u901f\u3002<\/p>\n<h3>2.2 \u8def\u5f84\u89e3\u6790\u7684\u8be6\u7ec6\u6d41\u7a0b<\/h3>\n<p>\u8ba9\u6211\u4eec\u6a21\u62df\u4e00\u4e0b\u5185\u6838\u89e3\u6790 \/home\/user\/a.txt \u7684\u5168\u8fc7\u7a0b\u3002\u867d\u7136\u5185\u6838\u6e90\u7801\u4e2d\u8d1f\u8d23\u6b64\u5de5\u4f5c\u7684 filename_lookup \u51fd\u6570\u975e\u5e38\u590d\u6742&#xff0c;\u4f46\u903b\u8f91\u4e0a\u6211\u4eec\u5206\u6790\u4e2a\u5927\u6982\u8fd8\u662f\u6ca1\u6709\u4ec0\u4e48\u96be\u5ea6\u7684\u3002<\/p>\n<li>\n<p>\u786e\u5b9a\u8d77\u70b9<\/p>\n<p>\u5185\u6838\u9996\u5148\u8981\u5224\u65ad\u4ece\u7528\u6237\u5c42\u63a5\u6536\u5230\u7684\u5b57\u7b26\u4e32\u8def\u5f84\u5230\u5e95\u662f\u7edd\u5bf9\u8def\u5f84\u8fd8\u662f\u76f8\u5bf9\u8def\u5f84\u3002\u8fd9\u5c31\u662f\u524d\u9762\u63d0\u5230\u7684open\u4e2d\u4e0d\u8bba\u586b\u7edd\u5bf9\u8def\u5f84\u8fd8\u662f\u76f8\u5bf9\u8def\u5f84\u90fd\u53ef\u4ee5&#xff0c;\u5185\u6838\u4e2d\u5df2\u7ecf\u628a\u5224\u65ad\u7684\u903b\u8f91\u5199\u597d\u4e86\u3002<\/p>\n<p>\u5982\u679c\u5b57\u7b26\u4e32\u4ee5\/\u5f00\u5934&#xff0c;\u90a3\u5c31\u8bf4\u660e\u662f\u7edd\u5bf9\u8def\u5f84&#xff0c;\u4ece current-&gt;fs-&gt;root\u5f00\u59cb\u8d70\u3002<\/p>\n<p>\u5982\u679c\u5b57\u7b26\u4e32\u4e0d\u4ee5 \/ \u5f00\u5934&#xff0c;\u90a3\u5c31\u8bf4\u660e\u662f\u76f8\u5bf9\u8def\u5f84&#xff0c;\u4ececurrent-&gt;fs-&gt;pwd\u5f00\u59cb\u8d70\u3002<\/p>\n<p>\u672c\u4f8b\u4e2d&#xff0c;\u6211\u4eec\u662f\u7edd\u5bf9\u8def\u5f84&#xff0c;\u4ece\u6839\u76ee\u5f55 \/ \u51fa\u53d1\u3002<br \/>\n\u8fd9\u91cc\u8865\u5145\u4e00\u70b9&#xff1a;\u53ef\u80fd\u6709\u4e0d\u5c11\u4eba\u77e5\u9053current-&gt;fs-&gt;root\u5927\u81f4\u662f\u4ec0\u4e48\u610f\u601d&#xff0c;\u4f46\u7591\u60d1\u5b83\u5230\u5e95\u662f\u4e2a\u4ec0\u4e48&#xff0c;\u8fd9\u90e8\u5206\u5185\u5bb9\u5c06\u4f1a\u653e\u5728\u672c\u7ae0\u5c0f\u7ed3\u4e2d\u4e3a\u5927\u5bb6\u89e3\u91ca\u3002<\/p>\n<\/li>\n<li>\n<p>\u9010\u7ea7\u89e3\u6790\u8def\u5f84<br \/>\n\u5185\u6838\u4f1a\u5c06\u8def\u5f84\u5b57\u7b26\u4e32\u62c6\u89e3\u4e3a\u4e09\u4e2a\u5206\u91cf&#xff0c;\u5373 home\u3001user\u3001a.txt&#xff0c;\u7136\u540e\u5f00\u59cb\u4e00\u4e2a\u5faa\u73af\u3002<\/p>\n<p>\u7b2c\u4e00\u6b65&#xff1a;\u62ff\u6839\u76ee\u5f55\u7684 dentry \u548c\u5b57\u7b26\u4e32 &#034;home&#034; \u8ba1\u7b97\u54c8\u5e0c\u503c&#xff0c;\u5728 Dcache \u4e2d\u67e5\u627e\u3002\u5982\u679c\u6ca1\u627e\u5230&#xff0c;\u5c31\u8ba9 EXT4 \u53bb\u78c1\u76d8\u628a home \u76ee\u5f55\u8bfb\u51fa\u6765&#xff0c;\u751f\u6210\u4e00\u4e2a dentry \u653e\u5728\u5185\u5b58\u91cc\u3002\u6b64\u5916\u8fd8\u4f1a\u68c0\u67e5\u8be5\u8fdb\u7a0b\u6709\u6ca1\u6709\u6743\u9650\u8bbf\u95eehome\u76ee\u5f55\u3002<br \/>\n\u7b2c\u4e8c\u6b65&#xff1a;\u62ff\u7740\u521a\u624d\u627e\u5230\u7684 home \u7684 dentry&#xff0c;\u5728\u4e0b\u9762\u67e5\u627e &#034;user&#034;&#xff0c;\u67e5\u627e\u6b65\u9aa4\u4e0e\u7b2c\u4e00\u6b65\u76f8\u540c\u3002<br \/>\n\u7b2c\u4e09\u6b65&#xff1a;\u540c\u7406&#xff0c;\u53ef\u4ee5\u67e5\u627e\u5230&#034;a.txt&#034;\u3002\u6700\u7ec8\u627e\u5230\u4e86\u76ee\u6807\u6587\u4ef6\u7684 dentry \u548c\u5bf9\u5e94\u7684 inode\u3002<\/p>\n<\/li>\n<li>\n<p>\u7a7f\u8d8a\u6302\u8f7d\u70b9<\/p>\n<p>\u8fd9\u53ef\u4ee5\u8bf4\u662f\u8def\u5f84\u67e5\u627e\u4e2d\u6700\u8ba9\u4eba\u6478\u4e0d\u7740\u5934\u8111\u7684\u5730\u65b9\u3002<br \/>\n\u5047\u8bbe\u4f60\u7684\u7cfb\u7edf\u91cc\u6302\u8f7d\u4e86\u4e00\u4e2a U \u76d8&#xff0c;\u6302\u8f7d\u70b9\u662f \/mnt\/usb\u3002\u5f53\u4f60\u8bbf\u95ee\u8def\u5f84 \/mnt\/usb\/photo.jpg \u65f6&#xff0c;\u5185\u6838\u5728\u89e3\u6790\u5230 usb \u8fd9\u4e00\u5c42\u65f6&#xff0c;\u4f1a\u53d1\u73b0usb \u8fd9\u4e2a\u76ee\u5f55\u9879\u88ab\u6253\u4e0a\u4e86\u4e00\u4e2a\u7279\u6b8a\u7684\u6807\u8bb0\u2014\u2014DCACHE_MOUNTED\u3002<br \/>\n\u8fd9\u65f6 VFS \u4f1a\u610f\u8bc6\u5230&#xff1a;\u8fd9\u91cc\u867d\u7136\u53eb usb&#xff0c;\u4ee5\u53ca\u867d\u7136\u662f\u4ece \/mnt \u8d70\u8fc7\u6765\u7684&#xff0c;\u4f46\u5b83\u5df2\u7ecf\u4e0d\u662f\u539f\u6765\u7684\u90a3\u4e2a\u76ee\u5f55\u4e86&#xff0c;\u5b83\u662f\u53e6\u4e00\u4e2a\u6587\u4ef6\u7cfb\u7edf\u7684\u5165\u53e3\u3002<\/p>\n<p>\u6b64\u65f6&#xff0c;\u5185\u6838\u4f1a\u6839\u636e\u6302\u8f7d\u8bb0\u5f55&#xff0c;\u81ea\u52a8\u8df3\u8f6c\u5230\u5bf9\u5e94\u6587\u4ef6\u7cfb\u7edf\u7684\u6839\u76ee\u5f55 Dentry \u4e0a\u3002<\/p>\n<\/li>\n<p>\u8fd9\u4e9b\u64cd\u4f5c\u5bf9\u7528\u6237\u662f\u5b8c\u5168\u900f\u660e\u7684&#xff0c;\u7528\u6237\u6839\u672c\u611f\u89c9\u4e0d\u5230\u81ea\u5df1\u5df2\u7ecf\u8de8\u8d8a\u4e86\u6587\u4ef6\u7cfb\u7edf\u7684\u8fb9\u754c&#xff0c;\u4ece\u4e00\u4e2a\u6587\u4ef6\u7cfb\u7edf\u7684\u5730\u76d8\u8df3\u5230\u4e86\u53e6\u4e00\u4e2a\u6587\u4ef6\u7cfb\u7edf\u7684\u5730\u76d8\u3002\u8fd9\u5c31\u662f VFS \u5c4f\u853d\u5e95\u5c42\u5dee\u5f02\u7684\u6838\u5fc3\u624b\u6bb5\u4e4b\u4e00\u3002<\/p>\n<h3>2.3 \u8def\u5f84\u67e5\u627e\u8fdb\u5165\u5c3e\u58f0<\/h3>\n<p>\u622a\u81f3\u73b0\u5728&#xff0c;VFS \u7ec8\u4e8e\u627e\u5230\u4e86 a.txt \u5bf9\u5e94\u7684 struct inode\u3002<\/p>\n<p>\u4f46 open() \u7cfb\u7edf\u8c03\u7528\u8fd4\u56de\u7ed9\u7528\u6237\u7684&#xff0c;\u5374\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6574\u6570 fd\u3002\u867d\u7136\u5927\u5bb6\u90fd\u77e5\u9053\u8fd9\u5c31\u662f\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff0c;\u4f46\u6211\u8fd8\u662f\u60f3\u8bb2\u4e00\u4e0b\u5b83\u5230\u5e95\u662f\u600e\u4e48\u6765\u7684&#xff1f;<\/p>\n<p>\u5185\u6838\u5728\u521b\u5efa File \u5bf9\u8c61\u65f6&#xff0c;\u4f1a\u5206\u914d\u4e00\u4e2a\u5168\u65b0\u7684 struct file&#xff0c;\u5c06 f_path.dentry \u6307\u5411\u521a\u624d\u627e\u5230\u7684 dentry&#xff0c;\u5c06 f_path.mnt \u6307\u5411\u5bf9\u5e94\u7684\u6302\u8f7d\u70b9&#xff0c;\u518d\u521d\u59cb\u5316 f_pos \u4e3a 0\u3002<\/p>\n<p>\u7136\u540e\u5728\u5f53\u524d\u8fdb\u7a0b\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u8868fd_array\u4e2d&#xff0c;\u627e\u4e00\u4e2a\u6700\u5c0f\u7684\u7a7a\u95f2\u4e0b\u6807&#xff0c;\u4f5c\u4e3a\u6587\u4ef6\u63cf\u8ff0\u7b26fd\u3002<\/p>\n<p>\u63a5\u7740\u5efa\u7acb\u6587\u4ef6\u63cf\u8ff0\u7b26\u8868\u4e2d\u76f8\u5e94\u4f4d\u7f6e\u4e0estruct file\u6307\u9488\u7684\u5173\u7cfb&#xff1a;<\/p>\n<p>fd_array[fd] &#061; \u8fd9\u4e2a\u65b0\u7684 struct file \u6307\u9488<\/p>\n<p>\u6700\u540e\u5c06fd\u8fd4\u56de\u7ed9\u7528\u6237\u3002<\/p>\n<p>\u6b63\u56e0\u4e3a open \u505a\u4e86\u7e41\u91cd\u7684\u8def\u5f84\u67e5\u627e\u5de5\u4f5c&#xff0c;\u5e76\u5efa\u7acb\u597d\u4e86 fd \u5230 struct file \u7684\u6620\u5c04&#xff0c;\u6240\u4ee5\u540e\u7eed\u7684 read \u64cd\u4f5c\u624d\u80fd\u6781\u5176\u9ad8\u6548\u3002\u5185\u6838\u76f4\u63a5\u901a\u8fc7 fd \u5c31\u80fd\u62ff\u5230 file \u548c inode&#xff0c;\u518d\u4e5f\u4e0d\u7528\u53bb\u89e3\u6790\u90a3\u957f\u957f\u7684\u5b57\u7b26\u4e32\u8def\u5f84\u4e86\u3002<\/p>\n<h3>2.4 \u5c0f\u7ed3<\/h3>\n<p>\u4e0b\u9762\u6211\u4eec\u6765\u8bb2\u4e00\u4e0bcurrent-&gt;fs-&gt;root\u5230\u5e95\u5728\u5e72\u4ec0\u4e48\u3002<\/p>\n<p>current\u662f\u5185\u6838\u4e2d\u6700\u91cd\u8981\u7684\u5b8f\u4e4b\u4e00&#xff0c;\u5b83\u59cb\u7ec8\u6307\u5411\u5f53\u524d\u6b63\u5728 CPU \u4e0a\u8fd0\u884c\u7684\u90a3\u4e2a\u8fdb\u7a0b\u7684\u8fdb\u7a0b\u63a7\u5236\u5757&#xff08;struct task_struct&#xff09;\u3002<\/p>\n<p>fs\u662fstruct task_struct\u4e2d\u7684\u4e00\u4e2a\u6210\u5458struct fs_struct&#xff0c;\u4e13\u95e8\u7528\u6765\u5b58\u50a8\u8be5\u8fdb\u7a0b\u4e0e\u6587\u4ef6\u7cfb\u7edf\u76f8\u5173\u7684\u4e0a\u4e0b\u6587\u4fe1\u606f\u3002\u5b83\u8bb0\u5f55\u4e86\u6839\u76ee\u5f55\u5728\u54ea\u3001\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u5728\u54ea\u3002<\/p>\n<p>root\u6307\u5411\u4e86\u8be5\u8fdb\u7a0b\u8ba4\u4e3a\u7684\u6839\u76ee\u5f55\u7684dentry\u3002<\/p>\n<p>pwd\u6307\u5411\u4e86\u8be5\u8fdb\u7a0b\u8ba4\u4e3a\u7684\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u7684dentry\u3002<\/p>\n<p>\u6839\u76ee\u5f55\u4f5c\u4e3a\u4e00\u4e2a\u6240\u6709\u8fdb\u7a0b\u90fd\u53ef\u80fd\u8bbf\u95ee\u7684\u76ee\u5f55&#xff0c;\u4e3a\u4ec0\u4e48\u8981\u653e\u5728\u8fdb\u7a0b\u91cc\u9762&#xff0c;\u800c\u4e0d\u662f\u4f5c\u4e3a\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\u5462&#xff1f;<\/p>\n<p>\u5b9e\u9645\u4e0a&#xff0c;\u901a\u5e38\u60c5\u51b5\u4e0b\u6240\u6709\u8fdb\u7a0b\u7684 root \u90fd\u6307\u5411\u771f\u6b63\u7684\u7cfb\u7edf\u6839\u76ee\u5f55 \/\u3002\u4f46\u662f&#xff0c;Linux \u5141\u8bb8\u6211\u4eec\u4fee\u6539\u8fd9\u4e2a\u6307\u5411&#xff0c;\u8fd9\u5c31\u662f chroot \u547d\u4ee4 \u4ee5\u53ca\u73b0\u4ee3 \u5bb9\u5668\u6280\u672f&#xff08;Docker&#xff09; \u7684\u6838\u5fc3\u539f\u7406\u3002<\/p>\n<li>\u5bf9\u4e8e\u5bbf\u4e3b\u673a\u8fdb\u7a0b&#xff1a;current-&gt;fs-&gt;root \u6307\u5411\u771f\u6b63\u7684\u78c1\u76d8\u6839\u76ee\u5f55 \/\u3002<\/li>\n<li>\u5bf9\u4e8e Docker \u5bb9\u5668\u5185\u7684\u8fdb\u7a0b&#xff1a;\u5185\u6838\u628a\u5b83\u7684 current-&gt;fs-&gt;root \u4fee\u6539\u6307\u5411\u4e86\u5bbf\u4e3b\u673a\u4e0a\u7684\u67d0\u4e2a\u5b50\u76ee\u5f55&#xff0c;\u4f5c\u4e3a Docker \u5185\u8fdb\u7a0b\u7684\u6839\u76ee\u5f55\u3002<\/li>\n<p>\u7ed3\u679c\u5f53\u5bb9\u5668\u5185\u7684\u8fdb\u7a0b\u53bb\u8bbf\u95ee \/etc\/passwd \u65f6&#xff0c;\u5185\u6838\u4ece\u5b83\u7684 fs-&gt;root \u5f00\u59cb\u627e&#xff0c;\u5b9e\u9645\u4e0a\u627e\u5230\u7684\u662f\u5bbf\u4e3b\u673a\u90a3\u4e2a\u5b50\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u3002\u5bb9\u5668\u8fdb\u7a0b\u5c31\u50cf\u88ab\u5173\u5728\u4e86\u4e00\u4e2a\u5c0f\u9ed1\u5c4b\u91cc&#xff0c;\u5b83\u4ee5\u4e3a\u81ea\u5df1\u770b\u5230\u4e86\u5168\u4e16\u754c&#xff08;\u6839\u76ee\u5f55&#xff09;&#xff0c;\u5176\u5b9e\u5b83\u770b\u5230\u7684\u53ea\u662f\u5bbf\u4e3b\u673a\u7684\u4e00\u4e2a\u89d2\u843d&#xff0c;\u4e5f\u5c31\u662f\u6211\u4eec\u60f3\u8ba9\u5b83\u770b\u5230\u7684\u4e1c\u897f\u3002<\/p>\n<h2>3. \u63a5\u53e3\u4e0e\u591a\u6001<\/h2>\n<p>VFS \u4f5c\u4e3a\u4e00\u4e2a\u62bd\u8c61\u5c42&#xff0c;\u5b83\u81ea\u5df1\u662f\u4e0d\u5b58\u50a8\u6570\u636e\u7684\u3002\u5b83\u4e0d\u77e5\u9053\u6570\u636e\u662f\u5728\u78c1\u76d8\u7684\u7b2c\u51e0\u4e2a\u6247\u533a&#xff0c;\u4e5f\u4e0d\u77e5\u9053\u7f51\u5361\u6536\u5230\u4e86\u4ec0\u4e48\u5305\u3002\u771f\u6b63\u5e72\u6d3b\u7684&#xff0c;\u662f\u5e95\u5c42\u7684 EXT4&#xff0c;FAT32 \u6216\u8005 TCP\/IP \u534f\u8bae\u6808\u3002<\/p>\n<p>\u800c VFS \u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\u8981\u505a\u7684\u5c31\u53ea\u6709\u6807\u51c6\u5316\u63a5\u53e3\u3002<\/p>\n<p>\u7528\u9762\u5411\u5bf9\u8c61\u7684\u8bed\u8a00\u6765\u8bf4&#xff0c;\u8fd9\u53eb\u505a\u591a\u6001\u3002\u4f46 C \u8bed\u8a00\u6ca1\u6709 interface \u5173\u952e\u5b57&#xff0c;Linux \u5185\u6838\u7684\u5927\u4f6c\u4eec\u5c31\u7528\u51fd\u6570\u6307\u9488\u624b\u6413\u4e86\u4e00\u5957\u591a\u6001\u673a\u5236\u3002<\/p>\n<h3>3.1 \u4e09\u4e2a\u64cd\u4f5c\u96c6<\/h3>\n<p>\u8fd9\u4e09\u4e2a\u64cd\u4f5c\u96c6\u7ed3\u6784\u4f53\u7684\u5185\u5bb9\u90fd\u662f\u6bd4\u8f83\u591a\u7684&#xff0c;\u6211\u5c31\u4e0d\u653e\u6e90\u7801\u4e86&#xff0c;\u4e0b\u6587\u4e2d\u53ea\u4ecb\u7ecd\u5173\u952e\u6210\u5458&#xff0c;\u60f3\u770b\u5b8c\u6574\u5185\u6838\u6e90\u7801\u53ef\u4ee5\u53bb\u6e90\u7801\u76ee\u5f55\/include\/linux\/fs.h\u4e2d\u627e&#xff0c;\u4e09\u4e2a\u7ed3\u6784\u4f53\u8fde\u7740\u5b9a\u4e49\u7684&#xff0c;\u5f88\u597d\u627e\u3002<\/p>\n<h4>3.1.1 \u6587\u4ef6\u5185\u5bb9\u64cd\u4f5c<\/h4>\n<p>\u6587\u4ef6\u5185\u5bb9\u64cd\u4f5cstruct file_operations&#xff1a;\u8fd9\u662f\u5e73\u65f6\u5199\u5e94\u7528\u7a0b\u5e8f\u65f6\u6700\u5e38\u7528\u7684\u63a5\u53e3&#xff0c;\u5b83\u5b9a\u4e49\u4e86\u5bf9\u6253\u5f00\u7684\u6587\u4ef6\u5185\u5bb9\u53ef\u4ee5\u505a\u54ea\u4e9b\u64cd\u4f5c\u3002<\/p>\n<p>\u8be5\u7ed3\u6784\u4f53\u7684\u6838\u5fc3\u6210\u5458\u5305\u62ec&#xff1a;read\u8bfb\u6587\u4ef6\u5185\u5bb9&#xff0c;write\u5199\u6587\u4ef6\u5185\u5bb9&#xff0c;mmap\u5185\u5b58\u6620\u5c04&#xff0c;open\u6253\u5f00&#xff0c;release\u5173\u95ed\u3002<\/p>\n<p>\u4e0b\u9762\u5177\u4f53\u63cf\u8ff0\u4e00\u4e0b&#xff1a;<\/p>\n<p>\u5982\u679c\u6211\u4eec\u8981\u8bfb\u7684\u662f EXT4 \u6587\u4ef6&#xff0c;\u5c31\u5c06read\u5bf9\u5e94\u7684\u51fd\u6570\u6307\u9488\u521d\u59cb\u5316\u4e3a ext4_file_read_iter&#xff0c;\u800cext4_file_read_iter\u7684\u5b9e\u73b0\u5e76\u4e0d\u5c5e\u4e8e VFS \u7684\u7ba1\u7406\u8303\u7574&#xff0c;\u5b83\u662f EXT4 \u6587\u4ef6\u7cfb\u7edf\u5e95\u5c42\u9700\u8981\u5b8c\u6210\u7684\u3002<\/p>\n<p>\u5982\u679c\u662f Socket \u5957\u63a5\u5b57&#xff0c;\u51fd\u6570\u6307\u9488\u5c31\u521d\u59cb\u5316\u4e3a sock_read_iter\u3002<\/p>\n<p>\u8fd9\u5c31\u662f\u5c06\u64cd\u4f5c\u4e0e\u76f8\u5e94\u51fd\u6570\u5bf9\u5e94\u8d77\u6765\u7684\u65b9\u6cd5\u3002<\/p>\n<h4>3.1.2 \u5143\u6570\u636e\u64cd\u4f5c<\/h4>\n<p>struct inode_operations\u8fd9\u7ec4\u63a5\u53e3\u5173\u6ce8\u7684\u662f\u6587\u4ef6\u672c\u8eab\u6216\u8005\u8bf4\u662f\u76ee\u5f55\u9879\u7684\u64cd\u4f5c&#xff0c;\u800c\u4e0d\u662f\u6587\u4ef6\u91cc\u9762\u7684\u5185\u5bb9\u3002<\/p>\n<p>\u6838\u5fc3\u6210\u5458\u6709&#xff1a;create\u521b\u5efa\u65b0\u6587\u4ef6&#xff0c;mkdir\u521b\u5efa\u76ee\u5f55&#xff0c;lookup\u5728\u76ee\u5f55\u4e2d\u67e5\u627e\u6587\u4ef6&#xff0c;setattr\u4fee\u6539\u6743\u9650\u548c\u65f6\u95f4\u6233\u3002<\/p>\n<p>\u8fd9\u91cc **file_op \u548c inode_op **\u4e00\u5b9a\u8981\u533a\u5206\u5f00&#xff0c;\u6709\u4e9b\u64cd\u4f5c\u662f\u4e0d\u9700\u8981\u6253\u5f00\u6587\u4ef6\u5c31\u53ef\u4ee5\u6267\u884c\u7684\u3002\u6bd4\u5982 mkdir&#xff0c;\u4f60\u4e0d\u9700\u8981\u6253\u5f00\u4e00\u4e2a\u76ee\u5f55\u5c31\u80fd\u521b\u5efa\u5b83\u3002\u6bd4\u5982 rm (\u8c03\u7528 unlink)&#xff0c;\u4f60\u5220\u9664\u6587\u4ef6\u65f6\u4e5f\u4e0d\u9700\u8981\u5148 open \u5b83\u3002\u8fd9\u4e9b\u64cd\u4f5c\u9488\u5bf9\u7684\u662f Inode&#xff08;\u6587\u4ef6\u5b9e\u4f53&#xff09;\u800c\u975e File&#xff08;\u53e5\u67c4&#xff09;\u3002<\/p>\n<h4>3.1.3 \u6587\u4ef6\u7cfb\u7edf\u6574\u4f53\u64cd\u4f5c<\/h4>\n<p>struct super_operations\u7ba1\u7406\u7684\u662f\u6574\u4e2a\u6587\u4ef6\u7cfb\u7edf\u7684\u751f\u547d\u5468\u671f\u3002<\/p>\n<p>\u6838\u5fc3\u6210\u5458&#xff1a;<\/p>\n<li>alloc_inode: \u4e3a\u8fd9\u4e2a\u6587\u4ef6\u7cfb\u7edf\u5206\u914d\u4e00\u4e2a inode\u3002<\/li>\n<li>write_inode: \u628a\u5185\u5b58\u91cc\u7684 inode \u5237\u56de\u78c1\u76d8\u3002<\/li>\n<li>sync_fs: \u628a\u6240\u6709\u810f\u6570\u636e\u5237\u76d8\u3002<\/li>\n<h3>3.2 \u5177\u4f53\u573a\u666f\u6f14\u793a<\/h3>\n<p>\u4e0b\u9762\u8ba9\u6211\u4eec\u770b\u770b\u5f53\u7528\u6237\u6267\u884c read \u65f6&#xff0c;\u5185\u6838\u91cc\u53d1\u751f\u4e86\u4ec0\u4e48&#xff1f;<\/p>\n<p>\u5728 VFS \u5c42&#xff08;\u6e90\u7801\u76ee\u5f55fs\/read_write.c&#xff09;&#xff0c;\u4ee3\u7801\u903b\u8f91\u975e\u5e38\u7b80\u6d01&#xff0c;\u5982\u4e0b&#xff1a;<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202102453-69807b75287bc.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u6838\u5fc3\u903b\u8f91\u6211\u4eec\u4ece\u7b2c 493 \u884c\u5f00\u59cb\u770b&#xff0c;VFS \u5c42\u76f4\u63a5\u8c03\u7528\u51fd\u6570\u6307\u9488&#xff0c;\u6839\u672c\u4e0d\u5173\u5fc3\u5b83\u662f EXT4 \u6587\u4ef6\u7cfb\u7edf\u8fd8\u662f FAT32 \u6587\u4ef6\u7cfb\u7edf\u3002\u4e3a\u4ec0\u4e48\u53ef\u4ee5\u8fd9\u6837\u505a\u5462&#xff1f;<\/p>\n<p>\u5b9e\u9645\u4e0a&#xff0c;\u5f53 EXT4 \u6587\u4ef6\u521b\u5efa\u65f6&#xff0c;\u5185\u6838\u628a inode-&gt;i_fop \u6307\u5411\u4e86\u5168\u5c40\u53d8\u91cf ext4_file_operations&#xff0c;\u4e00\u4e2a\u5177\u4f53\u6587\u4ef6\u6253\u5f00\u65f6&#xff0c;struct file\u51fa\u73b0\u4e86&#xff0c;file-&gt;f_op\u4f1a\u7ee7\u627f inode-&gt;i_fop&#xff0c;\u7136\u540evfs_read \u8c03\u7528 file-&gt;f_op-&gt;read&#xff0c;\u5b9e\u9645\u4e0a\u6267\u884c\u7684\u662f ext4_file_read_iter\u3002\u8fd9\u5c31\u662f VFS \u5c42\u8c03\u7528\u518d\u901a\u5411\u67d0\u4e2a\u6587\u4ef6\u7cfb\u7edf\u5177\u4f53\u8c03\u7528\u7684\u8fc7\u7a0b\u3002\u4e0b\u9762\u6211\u4eec\u6765\u770b\u770b\u8fd9\u4e2a\u8fc7\u7a0b\u5728\u5185\u6838\u6e90\u7801\u4e2d\u7684\u4f53\u73b0\u3002<\/p>\n<p>\u5f53 EXT4 \u4ece\u78c1\u76d8\u8bfb\u51fa\u4e00\u4e2a Inode \u65f6\u3002\u5982\u679c\u53d1\u73b0\u8fd9\u4e2a Inode \u662f\u4e2a\u666e\u901a\u6587\u4ef6S_ISREG&#xff0c;\u5c31\u628a ext4_file_operations \u6302\u4e0a\u53bb&#xff0c;\u8fd9\u6837\u4ee5\u540e\u5bf9\u5b83\u7684 read \u5c31\u4f1a\u8c03\u7528 EXT4 \u7684\u8bfb\u51fd\u6570\u3002\u5982\u679c\u53d1\u73b0\u5b83\u662f\u4e2a\u76ee\u5f55S_ISDIR&#xff0c;\u5c31\u628a ext4_dir_operations \u6302\u4e0a\u53bb&#xff0c;\u8fd9\u6837\u5bf9\u5b83\u7684 read\u5c31\u4f1a\u53bb\u8bfb\u53d6\u76ee\u5f55\u9879\u5217\u8868\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u5728\u51fd\u6570__ext4_iget\u4e2d\u5b9e\u73b0&#xff0c;\u8be5\u51fd\u6570\u4f4d\u4e8e\u5185\u6838\u6e90\u7801\/fs\/ext4\/inode.c\u4e2d&#xff0c;\u8fd9\u4e2a\u51fd\u6570\u6709\u597d\u51e0\u767e\u884c&#xff0c;\u6211\u53ea\u622a\u53d6\u4e86\u91cd\u8981\u7684\u51e0\u884c&#xff0c;\u5982\u4e0b&#xff1a;<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202102453-69807b75946a9.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u4e24\u4e2a\u64cd\u4f5c\u96c6\u7684\u5b9e\u73b0\u5728\/fs\/ext4\/file.c\u4e2d&#xff0c;\u5982\u4e0b\u56fe&#xff1a;<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202102453-69807b75b8c65.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u5c31\u662f\u5728\u8fd9\u91cc\u5b8c\u6210 VFS \u5c42\u7684\u8bfb\u64cd\u4f5c\u5230EXT4\u6587\u4ef6\u7cfb\u7edf\u8bfb\u51fd\u6570\u7684\u6620\u5c04\u7684\u3002<\/p>\n<p>\u5230\u6b64&#xff0c;\u6211\u4eec\u5df2\u7ecf\u628a\u7528\u6237\u5c42\u8c03\u7528read\u5230\u5177\u4f53\u7684\u6587\u4ef6\u7cfb\u7edf\u6267\u884c\u76f8\u5173\u8bfb\u51fd\u6570\u8fd9\u6761\u7ebf\u634b\u6e05\u4e86\u3002<\/p>\n<h2>4. \u5168\u94fe\u8def\u8ffd\u8e2a\u4e00\u4e2aread\u8bf7\u6c42<\/h2>\n<p>\u5047\u8bbe\u5e94\u7528\u7a0b\u5e8f\u6267\u884c\u4e86\u8fd9\u6837\u4e00\u884c\u7b80\u5355\u7684\u4ee3\u7801&#xff1a;<\/p>\n<p><span class=\"token class-name\">ssize_t<\/span> n <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">read<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">,<\/span> buf<span class=\"token punctuation\">,<\/span> <span class=\"token number\">4096<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd9\u662f\u4e00\u4e2a\u6781\u5176\u666e\u901a\u7684\u8c03\u7528&#xff0c;\u4f46\u5728 Linux \u5185\u6838\u7684\u5fae\u89c2\u4e16\u754c\u91cc&#xff0c;\u5374\u76f8\u5f53\u590d\u6742\u3002<\/p>\n<p>\u8ba9\u6211\u4eec\u7ed3\u5408\u5185\u6838\u6e90\u7801&#xff0c;\u4e00\u884c\u884c\u8ffd\u8e2a\u6570\u636e\u7684\u6d41\u5411\u3002<\/p>\n<h3>4.1 \u7cfb\u7edf\u8c03\u7528\u5165\u53e3<\/h3>\n<p>\u5f53\u7528\u6237\u7a0b\u5e8f\u6267\u884c read \u65f6&#xff0c;CPU \u53d1\u751f\u6a21\u5f0f\u5207\u6362&#xff0c;\u901a\u8fc7\u7cfb\u7edf\u8c03\u7528\u8868\u8df3\u8f6c\u5230\u5185\u6838\u5165\u53e3\u3002\u5728 Linux \u6e90\u7801\u4e2d&#xff0c;\u7cfb\u7edf\u8c03\u7528\u7684\u5b9a\u4e49\u901a\u5e38\u4f7f\u7528 SYSCALL_DEFINE \u5b8f\u3002<\/p>\n<p>\u6e90\u7801\u4f4d\u4e8efs\/read_write.c\u4e2d&#xff0c;\u5982\u4e0b&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202102454-69807b760ce8c.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u5b8f\u5c55\u5f00\u540e\u5c31\u662f sys_read \u51fd\u6570&#xff0c;\u8c03\u7528 ksys_read&#xff0c;\u8fd9\u662f\u5185\u6838\u5185\u90e8\u7684\u901a\u7528\u5165\u53e3\u3002<\/p>\n<p>\u5728ksys_read\u5185\u90e8&#xff0c;\u6839\u636e\u7528\u6237\u4f20\u5165\u7684 fd \u83b7\u53d6 struct file \u6307\u9488&#xff0c;\u5176\u5b9efdget_pos \u5c31\u662f\u53bb\u5f53\u524d\u8fdb\u7a0b\u7684 files_struct\u6587\u4ef6\u63cf\u8ff0\u7b26\u8868\u91cc\u67e5&#xff0c;\u628a\u6574\u6570 fd\u53d8\u6210\u4e86 struct file * \u6307\u9488\u3002\u7b2c 629 \u884c\u83b7\u53d6\u5f53\u524d\u6587\u4ef6\u7684\u8bfb\u53d6\u4f4d\u7f6e\u3002\u7b2c 634 \u884c\u8fdb\u5165 VFS \u7684\u901a\u7528\u8bfb\u53d6\u903b\u8f91\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202102454-69807b7621bb4.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u5230\u6b64&#xff0c;\u6211\u4eec\u5df2\u7ecf\u8e0f\u5165 VFS \u7684\u5927\u95e8\u4e86\u3002<\/p>\n<h3>4.2 VFS \u5206\u53d1<\/h3>\n<p>vfs_read \u53ef\u4ee5\u7406\u89e3\u4e3a\u4e00\u4e2a\u5177\u6709\u5206\u53d1\u529f\u80fd\u7684\u51fd\u6570&#xff0c;\u5b83\u4e0d\u8d1f\u8d23\u5177\u4f53\u7684\u8bfb\u5199&#xff0c;\u53ea\u8d1f\u8d23\u8def\u7531\u5206\u53d1\u3002\u5b83\u8981\u6839\u636e\u6587\u4ef6\u7cfb\u7edf\u7684\u5b9e\u73b0\u60c5\u51b5&#xff0c;\u51b3\u5b9a\u8c03\u7528\u54ea\u4e2a\u51fd\u6570\u3002\u6e90\u7801\u4f4d\u7f6e&#xff1a;fs\/read_write.c\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202102454-69807b764bd7f.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u524d\u9762\u90fd\u662f\u4e00\u4e9b\u6743\u9650\u68c0\u67e5\u4e4b\u7c7b\u7684\u64cd\u4f5c&#xff0c;\u6838\u5fc3\u903b\u8f91\u4ece 493 \u884c\u5f00\u59cb\u3002<\/p>\n<p>\u7b2c 493 \u884c\u53ef\u4ee5\u770b\u5230&#xff0c;VFS \u4f1a\u4f18\u5148\u8c03\u7528 read&#xff0c;\u6ca1\u6709read\u5219\u8c03\u7528 read_iter&#xff0c;\u533a\u522b\u5728\u4e8eread_iter\u6bd4\u8f83\u73b0\u4ee3&#xff0c;EXT4&#xff0c;XFS \u7b49\u73b0\u4ee3\u6587\u4ef6\u7cfb\u7edf\u90fd\u5728\u8fd9\u91cc\u3002<\/p>\n<p>\u8fd9\u91cc\u4f53\u73b0\u4e86 C \u8bed\u8a00\u7684\u591a\u6001\u3002EXT4 \u6ca1\u6709\u5b9e\u73b0 .read&#xff0c;\u800c\u662f\u5b9e\u73b0\u4e86 .read_iter&#xff0c;\u6240\u4ee5\u903b\u8f91\u4f1a\u8d70\u5230 new_sync_read\u3002<\/p>\n<p>\u8be5\u51fd\u6570\u5b9e\u73b0\u5982\u4e0b&#xff1a;<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202102454-69807b76cd9d8.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u53ef\u4ee5\u770b\u5230\u5b83\u6700\u7ec8\u8c03\u7528\u4e86call_read_iter&#xff0c;\u5b83\u4f4d\u4e8einclude\/linux\/fs.h&#xff0c;\u6211\u4eec\u7ee7\u7eed\u8df3\u8f6c&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202102455-69807b7724661.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u5230\u8fd9\u91cc\u662f\u4e0d\u662f\u6709\u70b9\u719f\u6089\u7684\u611f\u89c9\u3002\u7ee7\u7eed&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202102455-69807b7742381.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u4e0d\u7ba1\u662fread\u8fd8\u662fread_iter&#xff0c;\u515c\u515c\u8f6c\u8f6c\u90fd\u662f\u6765\u5230\u4e86\u8fd9\u91cc\u3002<\/p>\n<p>\u4e0b\u4e00\u6b65\u6211\u4eec\u5c06\u4f1a\u79bb\u5f00 VFS&#xff0c;\u8fdb\u5165 EXT4 \u7684\u9886\u5730\u3002<\/p>\n<h3>4.3 \u8fdb\u5165EXT4<\/h3>\n<p>\u7ecf\u8fc7 VFS \u7684\u5206\u53d1&#xff0c;\u63a7\u5236\u6743\u7ec8\u4e8e\u6765\u5230\u4e86\u5177\u4f53\u7684\u6587\u4ef6\u7cfb\u7edf\u624b\u4e2d\u3002\u6e90\u7801\u4f4d\u7f6efs\/ext4\/file.c\u3002<\/p>\n<p>\u6211\u4eec\u6765\u770b\u770b\u8fd9\u4e2a\u51fd\u6570\u7684\u5177\u4f53\u5b9e\u73b0&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202102455-69807b779415c.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u8fd9\u4e2a\u51fd\u6570\u6700\u540e\u53c8\u8c03\u7528\u4e86generic_file_read_iter\u51fd\u6570&#xff0c;EXT4 \u6700\u7ec8\u53c8\u628a\u810f\u6d3b\u7d2f\u6d3b\u90fd\u5916\u5305\u7ed9\u4e86 Linux \u7684\u5185\u5b58\u7ba1\u7406\u5b50\u7cfb\u7edf\u3002<\/p>\n<p>\u8fd9\u5176\u5b9e\u6b63\u662f Linux \u8bbe\u8ba1\u7cbe\u5999\u4e4b\u5904&#xff0c;\u5bf9\u4e8e\u57fa\u4e8e\u78c1\u76d8\u7684\u6587\u4ef6\u7cfb\u7edf&#xff0c;\u8bfb\u53d6\u903b\u8f91\u9ad8\u5ea6\u76f8\u4f3c&#xff0c;\u90fd\u662f\u67e5 Page Cache&#xff0c;\u6ca1\u6709\u5c31\u8bfb\u76d8&#xff0c;\u6240\u4ee5\u5185\u6838\u5728 mm\u5185\u5b58\u7ba1\u7406\u5b50\u7cfb\u7edf\u91cc\u63d0\u4f9b\u4e86\u4e00\u5957\u901a\u7528\u7684\u6807\u51c6\u5b9e\u73b0\u3002<\/p>\n<h3>4.4 \u9875\u7f13\u5b58 Page Cache<\/h3>\n<p>\u8fd9\u662f IO \u6027\u80fd\u7684\u5173\u952e\u70b9&#xff0c;generic_file_read_iter \u4f1a\u53bb\u67e5\u8be2\u9875\u7f13\u5b58&#xff0c;\u8be5\u51fd\u6570\u7684\u5b9e\u73b0\u4f4d\u4e8emm\/filemap.c\u3002\u8be5\u51fd\u6570\u4f9d\u7136\u53ea\u8d34\u51fa\u5173\u952e\u90e8\u5206\u7684\u622a\u56fe&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202102455-69807b77d2b09.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u7b2c 2525 \u884c\u5230\u7b2c 2535 \u884c\u662f Direct I\/O \u7684\u6267\u884c\u903b\u8f91&#xff0c;\u5982\u679c\u7528\u6237\u5728 open \u65f6\u52a0\u4e86 O_DIRECT \u6807\u5fd7&#xff0c;iocb-&gt;ki_flags \u5c31\u4f1a\u6709 IOCB_DIRECT&#xff0c;\u8fd9\u6837\u4f1a\u7ed5\u8fc7 Page Cache&#xff0c;\u76f4\u63a5\u8c03\u7528\u6587\u4ef6\u7cfb\u7edf\u7684 direct_IO \u63a5\u53e3\u3002\u5982\u679c\u5728\u8fd9\u91cc\u8bfb\u53d6\u6210\u529f&#xff0c;\u6216\u8005\u8bfb\u5b8c\u4e86&#xff0c;\u5c31\u76f4\u63a5\u5728goto out&#xff0c;\u4e0d\u8d70\u4e0b\u9762\u7684\u7f13\u5b58\u903b\u8f91\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202102456-69807b7828535.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u5176\u5b9e\u7edd\u5927\u591a\u6570\u90fd\u662f\u8d70\u67e5\u7f13\u5b58\u903b\u8f91\u7684&#xff0c;\u4ee3\u7801\u4f1a\u6267\u884c 2560 \u884c\u7684generic_file_buffered_read\u3002<\/p>\n<p>\u8fd9\u4e2a\u51fd\u6570\u6781\u957f&#xff0c;\u597d\u51e0\u767e\u884c&#xff0c;\u8fd9\u91cc\u5c31\u4e0d\u8d34\u4ee3\u7801\u4e86&#xff0c;\u8fd9\u4e48\u591a\u4ee3\u7801\u4e3b\u8981\u505a\u4e86\u4e24\u4ef6\u4e8b\u3002\u7b2c\u4e00\u4ef6\u662f\u67e5\u7f13\u5b58&#xff0c;\u53bb\u627e\u6709\u6ca1\u6709\u73b0\u6210\u7684\u9875\u3002\u7b2c\u4e8c\u4ef6\u4e8b\u662f\u9884\u8bfb&#xff0c;\u5982\u679c\u6ca1\u6709\u73b0\u6210\u7684\u9875&#xff0c;\u5b83\u4e0d\u4ec5\u4f1a\u628a\u5f53\u524d\u9700\u8981\u7684\u9875\u8bfb\u8fdb\u6765&#xff0c;\u8fd8\u4f1a\u628a\u540e\u9762\u51e0\u9875\u4e5f\u987a\u4fbf\u8bfb\u8fdb\u6765&#xff0c;\u4ee5\u63d0\u9ad8\u6027\u80fd\u3002<\/p>\n<h3>4.5 \u67e5\u627e\u7269\u7406\u5757<\/h3>\n<p>\u5f53\u5185\u5b58\u5b50\u7cfb\u7edf\u51b3\u5b9a\u8981\u4ece\u78c1\u76d8\u8bfb\u6570\u636e\u65f6&#xff0c;\u5b83\u4f1a\u95ee EXT4 \u6587\u4ef6\u7684\u7b2c 0 \u9875\u5bf9\u5e94\u78c1\u76d8\u7684\u54ea\u4e2a\u5757\u3002<\/p>\n<p>\u8be5\u90e8\u5206\u6e90\u7801\u4f4d\u7f6efs\/ext4\/inode.c\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202102456-69807b7880620.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u5c06\u903b\u8f91\u504f\u79fb\u91cf\u8f6c\u6362\u4e3a\u7269\u7406\u6247\u533a\u53f7&#xff0c;\u6700\u7ec8map-&gt;m_pblk \u5b58\u50a8\u4e86\u7269\u7406\u78c1\u76d8\u5757\u53f7\u3002<\/p>\n<p>\u62ff\u5230\u4e86\u7269\u7406\u5757\u53f7&#xff0c;\u5185\u6838\u5c06\u5176\u5c01\u88c5\u6210\u4e00\u4e2a struct bio (Block IO) \u8bf7\u6c42&#xff0c;\u63d0\u4ea4\u7ed9\u901a\u7528\u5757\u5c42\u3002<\/p>\n<p>submit_bio \u4f1a\u5c06\u8bf7\u6c42\u653e\u5165\u7535\u68af\u8c03\u5ea6\u961f\u5217&#xff0c;\u6700\u7ec8\u7531 NVMe \u6216 SATA \u9a71\u52a8\u901a\u8fc7 DMA \u5c06\u6570\u636e\u642c\u8fd0\u5230\u5185\u5b58\u3002<\/p>\n<h3>4.6 \u5c0f\u7ed3<\/h3>\n<p>\u770b\u5230\u8fd9\u91cc&#xff0c;\u4f60\u5e94\u8be5\u660e\u767d\u4e86&#xff0c;Linux \u7684 VFS \u4e0d\u4ec5\u4ec5\u662f\u4e00\u5c42\u63a5\u53e3&#xff0c;\u5b83\u66f4\u50cf\u662f\u4e00\u5957\u7cbe\u5bc6\u7684\u6d41\u6c34\u7ebf\u3002 \u4e0a\u5c42\u7684 read_write.c \u8d1f\u8d23\u63a5\u5f85&#xff0c;\u4e2d\u5c42\u7684 filemap.c \u8d1f\u8d23\u7f13\u5b58\u52a0\u901f&#xff0c;\u5e95\u5c42\u7684 ext4 \u8d1f\u8d23\u7269\u7406\u5bfb\u5740&#xff0c;\u5206\u5de5\u5f88\u660e\u786e\u3002<\/p>\n<h2>5. \u603b\u7ed3<\/h2>\n<p>\u81f3\u6b64&#xff0c;\u6211\u4eec\u5b8c\u6210\u4e86\u5bf9 Linux VFS \u7684\u62c6\u89e3\u3002<\/p>\n<p>\u65e0\u8bba\u5e95\u5c42\u662f EXT4\u3001FAT32 \u8fd8\u662f\u7f51\u7edc NFS&#xff0c;VFS \u90fd\u628a\u5b83\u4eec\u4f2a\u88c5\u6210\u7edf\u4e00\u7684 struct file \u548c struct inode\u3002\u4f7f\u5f97\u5e94\u7528\u5f00\u53d1\u53d8\u7684\u5982\u6b64\u7b80\u5355\u3002<\/p>\n<p>Linux \u5185\u6838\u7528\u6700\u53e4\u8001\u7684 C \u8bed\u8a00&#xff0c;\u901a\u8fc7\u7ed3\u6784\u4f53\u548c\u51fd\u6570\u6307\u9488&#xff0c;\u5b9e\u73b0\u4e86\u6700\u6781\u81f4\u7684\u591a\u6001\u4e0e\u62bd\u8c61&#xff0c;Linux \u5185\u6838\u672c\u8eab\u5c31\u662f\u4e00\u672c\u6559\u79d1\u4e66\u3002<\/p>\n<p>\u5e0c\u671b\u901a\u8fc7\u8fd9\u4e2a\u7cfb\u5217\u6587\u7ae0&#xff0c;\u5f53\u4f60\u4e0b\u6b21\u6572\u4e0b open() \u6216 read() \u65f6&#xff0c;\u8111\u6d77\u4e2d\u4e0d\u518d\u53ea\u662f\u67af\u71e5\u7684 API \u548c\u8bb0\u4e0d\u5b8c\u7684\u53c2\u6570&#xff0c;\u800c\u662f\u80fd\u6d6e\u73b0\u51fa\u90a3\u5f20\u5de8\u5927\u7684\u5173\u7cfb\u56fe&#xff1a;\u4ece fd \u5230 dentry&#xff0c;\u4ece inode \u5230\u9a71\u52a8&#xff0c;\u771f\u771f\u5207\u5207\u5730\u611f\u53d7\u5185\u6838\u4e2d\u7684\u6570\u636e\u6f02\u6d41\u3002<\/p>\n<p>\u672c\u6587\u5b8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u524d\u8a00<br \/>\n\u4e0a\u4e00\u7bc7\u6587\u7ae0\u6211\u4eec\u9010\u4e2a\u5b66\u4e60\u4e86 VFS \u7684\u56db\u5927\u6838\u5fc3\u5bf9\u8c61&#xff0c;\u90a3\u4e48\u672c\u7bc7\u6587\u7ae0\u6211\u4eec\u5c06\u66f4\u52a0\u6df1\u5165\u5185\u6838&#xff0c;\u6df1\u5ea6\u62c6\u89e3\u8fd9\u4e9b\u5bf9\u8c61\u662f\u5982\u4f55\u901a\u8fc7\u8def\u5f84\u67e5\u627e\u3001\u63a5\u53e3\u591a\u6001\u6765\u534f\u4f5c\u5b8c\u6210\u4e00\u6b21\u771f\u5b9e\u7684\u6587\u4ef6\u64cd\u4f5c\u7684\u3002<br \/>\n\u6211\u4eec\u8bdd\u4e0d\u591a\u8bf4&#xff0c;\u76f4\u63a5\u8fdb\u5165\u6b63\u9898\u3002<br \/>\n2. \u8def\u5f84\u67e5\u627e<br \/>\n\u6211\u4eec\u5728\u5199\u4ee3\u7801\u65f6&#xff0c;\u901a\u5e38\u50cf\u4e0b\u9762\u8fd9\u6837\u6253\u5f00\u4e00\u4e2a\u6587\u4ef6&#xff1a;<br \/>\nint fd  open(\\&#8221;\/home\/user\/a.txt\\&#8221;, O_RDONLY);\u8fd9\u91cc\u4f7f\u7528\u7684\u8def\u5f84\u662f\u7edd\u5bf9\u8def\u5f84&#xff0c;\u4e5f\u53ef\u4ee5\u4f7f\u7528\u76f8\u5bf9\u8def\u5f84\u3002<\/p>\n","protected":false},"author":2,"featured_media":70879,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[58,269,2787,383],"topic":[],"class_list":["post-70892","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-linux","tag-269","tag-2787","tag-383"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u6df1\u5165\u63ed\u79d8 Linux \u865a\u62df\u6587\u4ef6\u7cfb\u7edf VFS \uff08\u4e0b\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/70892.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u6df1\u5165\u63ed\u79d8 Linux \u865a\u62df\u6587\u4ef6\u7cfb\u7edf VFS \uff08\u4e0b\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"1. \u524d\u8a00 \u4e0a\u4e00\u7bc7\u6587\u7ae0\u6211\u4eec\u9010\u4e2a\u5b66\u4e60\u4e86 VFS \u7684\u56db\u5927\u6838\u5fc3\u5bf9\u8c61&#xff0c;\u90a3\u4e48\u672c\u7bc7\u6587\u7ae0\u6211\u4eec\u5c06\u66f4\u52a0\u6df1\u5165\u5185\u6838&#xff0c;\u6df1\u5ea6\u62c6\u89e3\u8fd9\u4e9b\u5bf9\u8c61\u662f\u5982\u4f55\u901a\u8fc7\u8def\u5f84\u67e5\u627e\u3001\u63a5\u53e3\u591a\u6001\u6765\u534f\u4f5c\u5b8c\u6210\u4e00\u6b21\u771f\u5b9e\u7684\u6587\u4ef6\u64cd\u4f5c\u7684\u3002 \u6211\u4eec\u8bdd\u4e0d\u591a\u8bf4&#xff0c;\u76f4\u63a5\u8fdb\u5165\u6b63\u9898\u3002 2. \u8def\u5f84\u67e5\u627e \u6211\u4eec\u5728\u5199\u4ee3\u7801\u65f6&#xff0c;\u901a\u5e38\u50cf\u4e0b\u9762\u8fd9\u6837\u6253\u5f00\u4e00\u4e2a\u6587\u4ef6&#xff1a; int fd open(&quot;\/home\/user\/a.txt&quot;, O_RDONLY);\u8fd9\u91cc\u4f7f\u7528\u7684\u8def\u5f84\u662f\u7edd\u5bf9\u8def\u5f84&#xff0c;\u4e5f\u53ef\u4ee5\u4f7f\u7528\u76f8\u5bf9\u8def\u5f84\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/70892.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-02T10:24:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202102453-69807b75287bc.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/70892.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/70892.html\",\"name\":\"\u6df1\u5165\u63ed\u79d8 Linux \u865a\u62df\u6587\u4ef6\u7cfb\u7edf VFS \uff08\u4e0b\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-02T10:24:57+00:00\",\"dateModified\":\"2026-02-02T10:24:57+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/70892.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/70892.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/70892.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u6df1\u5165\u63ed\u79d8 Linux \u865a\u62df\u6587\u4ef6\u7cfb\u7edf VFS \uff08\u4e0b\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u6df1\u5165\u63ed\u79d8 Linux \u865a\u62df\u6587\u4ef6\u7cfb\u7edf VFS \uff08\u4e0b\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/70892.html","og_locale":"zh_CN","og_type":"article","og_title":"\u6df1\u5165\u63ed\u79d8 Linux \u865a\u62df\u6587\u4ef6\u7cfb\u7edf VFS \uff08\u4e0b\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"1. \u524d\u8a00 \u4e0a\u4e00\u7bc7\u6587\u7ae0\u6211\u4eec\u9010\u4e2a\u5b66\u4e60\u4e86 VFS \u7684\u56db\u5927\u6838\u5fc3\u5bf9\u8c61&#xff0c;\u90a3\u4e48\u672c\u7bc7\u6587\u7ae0\u6211\u4eec\u5c06\u66f4\u52a0\u6df1\u5165\u5185\u6838&#xff0c;\u6df1\u5ea6\u62c6\u89e3\u8fd9\u4e9b\u5bf9\u8c61\u662f\u5982\u4f55\u901a\u8fc7\u8def\u5f84\u67e5\u627e\u3001\u63a5\u53e3\u591a\u6001\u6765\u534f\u4f5c\u5b8c\u6210\u4e00\u6b21\u771f\u5b9e\u7684\u6587\u4ef6\u64cd\u4f5c\u7684\u3002 \u6211\u4eec\u8bdd\u4e0d\u591a\u8bf4&#xff0c;\u76f4\u63a5\u8fdb\u5165\u6b63\u9898\u3002 2. \u8def\u5f84\u67e5\u627e \u6211\u4eec\u5728\u5199\u4ee3\u7801\u65f6&#xff0c;\u901a\u5e38\u50cf\u4e0b\u9762\u8fd9\u6837\u6253\u5f00\u4e00\u4e2a\u6587\u4ef6&#xff1a; int fd open(\"\/home\/user\/a.txt\", O_RDONLY);\u8fd9\u91cc\u4f7f\u7528\u7684\u8def\u5f84\u662f\u7edd\u5bf9\u8def\u5f84&#xff0c;\u4e5f\u53ef\u4ee5\u4f7f\u7528\u76f8\u5bf9\u8def\u5f84\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/70892.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-02T10:24:57+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260202102453-69807b75287bc.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/70892.html","url":"https:\/\/www.wsisp.com\/helps\/70892.html","name":"\u6df1\u5165\u63ed\u79d8 Linux \u865a\u62df\u6587\u4ef6\u7cfb\u7edf VFS \uff08\u4e0b\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-02T10:24:57+00:00","dateModified":"2026-02-02T10:24:57+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/70892.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/70892.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/70892.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u6df1\u5165\u63ed\u79d8 Linux \u865a\u62df\u6587\u4ef6\u7cfb\u7edf VFS \uff08\u4e0b\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/70892","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=70892"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/70892\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/70879"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=70892"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=70892"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=70892"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=70892"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}