{"id":2033,"date":"2010-11-23T16:18:12","date_gmt":"2010-11-23T08:18:12","guid":{"rendered":"http:\/\/edsionte.com\/techblog\/?p=2033"},"modified":"2010-11-29T11:06:42","modified_gmt":"2010-11-29T03:06:42","slug":"%e4%b8%8e%e6%96%87%e4%bb%b6%e7%b3%bb%e7%bb%9f%e7%9b%b8%e5%85%b3%e7%9a%84%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84","status":"publish","type":"post","link":"http:\/\/edsionte.com\/techblog\/archives\/2033","title":{"rendered":"VFS\u4e2d\u7684\u5176\u4ed6\u6570\u636e\u7ed3\u6784"},"content":{"rendered":"<p><strong><em><span style=\"color: #ff0000;\">Last Update:2010\/11\/27<\/span><\/em><\/strong><\/p>\n<p><strong><em>\u672c\u6587\u6d89\u53caVFS\u4e2d\u6570\u636e\u7ed3\u6784\u6709\uff1astruct file_system_type;struct vfsmount;struct fs_struct;struct files_struct;struct nameidata;struct qstr;<\/em><\/strong><\/p>\n<h4><strong>\u4e0e\u6587\u4ef6\u7cfb\u7edf\u76f8\u5173\u7684\u6570\u636e\u7ed3\u6784<\/strong><\/h4>\n<p>V<span style=\"font-size: 13.3333px;\">FS\u4e2d\u4f7f\u7528file_system_type\u7ed3\u6784\u6765\u63cf\u8ff0\u4e00\u4e2a\u5177\u4f53\u7684\u6587\u4ef6\u7cfb\u7edf\u7c7b\u578b\u3002\u4e5f\u5c31\u662f\u8bf4\uff0cLinux\u652f\u6301\u7684\u6240\u6709\u6587\u4ef6\u7cfb\u7edf\u7c7b\u578b\u90fd\u5206\u522b\u552f\u4e00\u7684\u5bf9\u5e94\u4e00\u4e2afile_system_type\u7ed3\u6784\u3002\u5982\u679c\u67d0\u4e2a\u5177\u4f53\u6587\u4ef6\u7c7b\u578b\u7684\u6587\u4ef6\u7cfb\u7edf\u88ab\u5b89\u88c5\u5230\u4e86\u7cfb\u7edf\u4e2d\uff0c\u90a3\u4e48\u7cfb\u7edf\u5c31\u4f1a\u521b\u5efa\u4e00\u4e2avfsmount\u7ed3\u6784\u3002\u8fd9\u4e2a\u7ed3\u6784\u7528\u6765\u63cf\u8ff0\u4e00\u79cd\u6587\u4ef6\u7cfb\u7edf\u7c7b\u578b\u7684\u4e00\u4e2a\u5b89\u88c5\u5b9e\u4f8b\u3002<\/span><\/p>\n<p><strong>struct file_system_type<\/strong><\/p>\n<p><strong><\/strong>\u8be5\u7ed3\u6784\u4f4d\u4e8eyoursource\/include\/linux\/fs.h\u4e2d\uff0c\u4e0b\u9762\u5bf9\u8be5\u7ed3\u6784\u4e2d\u90e8\u5206\u5b57\u6bb5\u8fdb\u884c\u8bf4\u660e\uff1a<\/p>\n<pre class=\"brush:c\">1736struct file_system_type {\r\n1737        const char *name;\r\n1738        int fs_flags;\r\n1739        int (*get_sb) (struct file_system_type *, int,\r\n1740                       const char *, void *, struct vfsmount *);\r\n1741        void (*kill_sb) (struct super_block *);\r\n1742        struct module *owner;\r\n1743        struct file_system_type * next;\r\n1744        struct list_head fs_supers;\r\n1745\r\n1746        struct lock_class_key s_lock_key;\r\n1747        struct lock_class_key s_umount_key;\r\n1748        struct lock_class_key s_vfs_rename_key;\r\n1749\r\n1750        struct lock_class_key i_lock_key;\r\n1751        struct lock_class_key i_mutex_key;\r\n1752        struct lock_class_key i_mutex_dir_key;\r\n1753        struct lock_class_key i_alloc_sem_key;\r\n1754};<\/pre>\n<p><strong>name<\/strong>\uff1a\u6587\u4ef6\u7cfb\u7edf\u7684\u540d\u5b57\uff0c\u4e0d\u80fd\u4e3a\u7a7a\uff1b<br \/>\n<strong> get_sb<\/strong>\uff1a\u5728\u5b89\u88c5\u6587\u4ef6\u7cfb\u7edf\u65f6\uff0c\u8c03\u7528\u6b64\u6307\u9488\u6240\u6307\u51fd\u6570\u4ee5\u5728\u78c1\u76d8\u4e2d\u83b7\u53d6\u8d85\u7ea7\u5757\uff1b<br \/>\n<strong> kill_sb<\/strong>\uff1a\u5378\u8f7d\u6587\u4ef6\u6587\u4ef6\u7cfb\u7edf\u65f6\u5019\uff0c\u8c03\u7528\u6b64\u6307\u9488\u6240\u6307\u51fd\u6570\u4ee5\u8fdb\u884c\u4e00\u4e9b\u6e05\u7406\u5de5\u4f5c\uff1b<br \/>\n<strong> owner<\/strong>\uff1a\u5982\u679c\u4e00\u4e2a\u6587\u4ef6\u7cfb\u7edf\u4ee5\u6a21\u5757\u7684\u5f62\u5f0f\u52a0\u8f7d\u5230\u5185\u6838\uff0c\u5219\u8be5\u5b57\u6bb5\u7528\u6765\u8bf4\u660e\u54ea\u4e2a\u6a21\u5757\u62e5\u6709\u8fd9\u4e2a\u7ed3\u6784\u3002\u4e00\u822c\u4e3aTHIS_MODULE\uff1b<br \/>\n<strong> next<\/strong>\uff1a\u6240\u6709\u7684\u6587\u4ef6\u7cfb\u7edf\u7c7b\u578b\u7ed3\u6784\u5f62\u6210\u4e00\u4e2a\u94fe\u8868\uff0c\u8be5\u94fe\u8868\u7684\u5934\u6307\u9488\u4e3a\u5168\u5c40\u53d8\u91cffile_systems\uff08struct file_system_type *file_systems\uff09\u3002\u8fd9\u4e2a\u5b57\u6bb5\u6307\u5411\u94fe\u8868\u4e2d\u4e0b\u4e00\u4e2a\u6587\u4ef6\u7cfb\u7edf\u7c7b\u578b\u7ed3\u6784\uff1b<br \/>\n<strong> fs_supers<\/strong>\uff1a\u540c\u4e00\u4e2a\u6587\u4ef6\u7cfb\u7edf\u7c7b\u578b\u4e0b\u7684\u6240\u6709\u8d85\u7ea7\u5757\u5f62\u6210\u4e00\u4e2a\u53cc\u8054\u8868\uff0c\u8fd9\u4e2a\u5b57\u6bb5\u662f\u8fd9\u4e2a\u53cc\u8054\u8868\u7684\u5934\u7ed3\u70b9\u3002\u8d85\u7ea7\u5757\u4e4b\u95f4\u901a\u8fc7s_instances\u5b57\u6bb5\u76f8\u4e92\u94fe\u63a5\uff1b<\/p>\n<p><strong>struct vfsmount<\/strong><\/p>\n<p><strong><\/strong>\u5728\u89e3\u91ca\u8fd9\u4e2a\u7ed3\u6784\u7684\u76f8\u5173\u5b57\u6bb5\u4e4b\u524d\uff0c\u6211\u4eec\u5f88\u6709\u5fc5\u8981\u4e86\u89e3\u4e00\u4e9b\u6982\u5ff5\u3002\u5f53\u6211\u4eec\u5b89\u88c5linux\u65f6\uff0c\u786c\u76d8\u4e0a\u5df2\u7ecf\u6709\u4e86\u4e00\u4e2a\u5206\u533a\u5b89\u88c5\u4e86ext3\uff08\u6216ext4\uff09\u6587\u4ef6\u7cfb\u7edf\uff0c\u8fd9\u4e2a\u6587\u4ef6\u7cfb\u7edf\u88ab\u79f0\u4e4b\u4e3a\u6839\u6587\u4ef6\u7cfb\u7edf\u3002\u7cfb\u7edf\u5b89\u88c5\u5b8c\u6bd5\u540e\uff0c\u5982\u679c\u8981\u7ee7\u7eed\u5b89\u88c5\u5176\u4ed6\u6587\u4ef6\u7cfb\u7edf\uff0c\u5c31\u9700\u8981\u6302\u8f7d\uff08mount\uff09\u3002\u5177\u4f53\u7684\uff0c\u5c06\u8981\u5b89\u88c5\u7684\u6587\u4ef6\u7cfb\u7edf\u7684\u6839\u76ee\u5f55\u6302\u8f7d\u5230\u6839\u6587\u4ef6\u7cfb\u7edf\u7684\u67d0\u4e2a\u5b50\u76ee\u5f55\u4e0a\u3002\u8fd9\u6837\uff0c\u65b0\u5b89\u88c5\u7684\u6587\u4ef6\u7cfb\u7edf\u7684\u6839\u76ee\u5f55\u5c31\u662f\u7236\u6587\u4ef6\u7cfb\u7edf\u4e0b\u7684\u67d0\u4e2a\u5b50\u76ee\u5f55\uff0c\u6211\u4eec\u5c06\u8fd9\u4e2a\u5b50\u76ee\u5f55\u79f0\u4e3a\u5b89\u88c5\u70b9\uff08mount point\uff09\u3002<\/p>\n<h4><span style=\"font-weight: normal; font-size: 13.3333px;\">\u8be5\u7ed3\u6784\u5b58\u50a8\u5728yoursource\/include\/linux\/mount.h\u4e2d\uff0c\u4e0b\u9762\u5bf9\u8be5\u7ed3\u6784\u7684\u90e8\u5206\u5b57\u6bb5\u8fdb\u884c\u8bf4\u660e\uff1a<\/span><\/h4>\n<pre class=\"brush:c\">  49struct vfsmount {\r\n  50        struct list_head mnt_hash;\r\n  51        struct vfsmount *mnt_parent;    \/* fs we are mounted on *\/\r\n  52        struct dentry *mnt_mountpoint;  \/* dentry of mountpoint *\/\r\n  53        struct dentry *mnt_root;        \/* root of the mounted tree *\/\r\n  54        struct super_block *mnt_sb;     \/* pointer to superblock *\/\r\n  55        struct list_head mnt_mounts;    \/* list of children, anchored here *\/\r\n  56        struct list_head mnt_child;     \/* and going through their mnt_child *\/\r\n  57        int mnt_flags;\r\n  63        const char *mnt_devname;        \/* Name of device e.g. \/dev\/dsk\/hda1 *\/\r\n  64        struct list_head mnt_list;\r\n\u2026\u2026 \u2026\u2026\r\n  71        int mnt_id;                     \/* mount identifier *\/\r\n  72        int mnt_group_id;               \/* peer group identifier *\/\r\n  78        atomic_t mnt_count;\r\n  79        int mnt_expiry_mark;            \/* true if marked for expiry *\/\r\n  80        int mnt_pinned;\r\n  81        int mnt_ghosts;\r\n\u2026\u2026 \u2026\u2026\r\n  87};<\/pre>\n<p><strong>mnt_hash<\/strong>\uff1a\u5185\u6838\u901a\u8fc7\u54c8\u5e0c\u8868\u5bf9vfsmount\u8fdb\u884c\u7ba1\u7406\uff0c\u5f53\u524dvfsmount\u7ed3\u6784\u901a\u8fc7\u8be5\u5b57\u6bb5\u94fe\u5165\u76f8\u5e94\u54c8\u5e0c\u503c\u5bf9\u5e94\u7684\u94fe\u8868\u5f53\u4e2d\uff1b<br \/>\n<strong> mnt_parent<\/strong>\uff1a\u6307\u5411\u7236\u6587\u4ef6\u7cfb\u7edf\u5bf9\u5e94\u7684vfsmount\u7ed3\u6784\uff1b<br \/>\n<strong><span style=\"color: #ff0000;\"> mnt_mountpoint<\/span><\/strong><span style=\"color: #ff0000;\">\uff1a\u6307\u5411\u8be5\u6587\u4ef6\u7cfb\u7edf\u5b89\u88c5\u70b9\u5bf9\u5e94\u7684dentry\uff1b<br \/>\n<strong> mnt_root<\/strong>\uff1a\u8be5\u6587\u4ef6\u7cfb\u7edf\u5bf9\u5e94\u7684\u8bbe\u5907\u6839\u76ee\u5f55\u7684dentry\uff1b\uff08\u4e24\u8005\u662f\u5426\u6307\u5411\u540c\u4e00\u4e2adentry\uff1fmnt_root\u662f\u6307\u5411\u8be5\u6587\u4ef6\u7cfb\u7edf\u8bbe\u5907\u6839\u76ee\u5f55\u7684dentry\uff0c\u5177\u4f53\u8fd9\u4e2adentry\u662f\u4ec0\u4e48\uff1f\uff09<\/span><br \/>\n<strong> mnt_sb<\/strong>\uff1a\u6307\u5411\u8be5\u6587\u4ef6\u7cfb\u7edf\u5bf9\u5e94\u7684\u8d85\u7ea7\u5757\uff1b<br \/>\n<strong> mnt_child<\/strong>\uff1a\u540c\u4e00\u4e2a\u7236\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u6240\u6709\u5b50\u6587\u4ef6\u7cfb\u7edf\u901a\u8fc7\u8be5\u5b57\u6bb5\u94fe\u63a5\u6210\u53cc\u8054\u8868\uff1b<br \/>\n<strong> mnt_mounts<\/strong>\uff1a\u8be5\u5b57\u6bb5\u662f\u4e0a\u8ff0\u5b50\u6587\u4ef6\u7cfb\u7edf\u5f62\u6210\u7684\u94fe\u8868\u7684\u5934\u7ed3\u70b9\uff1b<br \/>\n<strong> mnt_list<\/strong>\uff1a\u6240\u6709\u5df2\u5b89\u88c5\u7684\u6587\u4ef6\u7cfb\u7edf\u7684vfsmount\u7ed3\u6784\u901a\u8fc7\u8be5\u5b57\u6bb5\u94fe\u63a5\u5728\u4e00\u8d77\uff1b<\/p>\n<h4><strong>\u4e0e\u8def\u5f84\u67e5\u627e\u6709\u5173\u7684\u8f85\u52a9\u7ed3\u6784<\/strong><\/h4>\n<p>\u6211\u4eec\u5728\u4f7f\u7528open\u7cfb\u7edf\u8c03\u7528\u65f6\uff0c\u7ed9\u8be5\u51fd\u6570\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570\u4f20\u9012\u7684\u662f\u6587\u4ef6\u8def\u5f84\u540d\u3002open\u51fd\u6570\u5bf9\u6587\u4ef6\u7684\u64cd\u4f5c\u6700\u7ec8\u4f1a\u8f6c\u5316\u4e3a\u5bf9\u8be5\u6587\u4ef6inode\u7684\u64cd\u4f5c\u3002VFS\u4e3a\u4e86\u8bc6\u522b\u76ee\u6807\u6587\u4ef6\uff0c\u4f1a\u6cbf\u7740\u8def\u5f84\u9010\u5c42\u67e5\u627e\u3002\u56e0\u6b64\uff0cVFS\u4e2d\u5f15\u5165\u4e86nameidata\u7ed3\u6784\u3002nameidata\u7ed3\u6784\u7528\u4e8e\u5728\u8def\u5f84\u67e5\u627e\u8fc7\u7a0b\u4e2d\u8bb0\u5f55\u4e2d\u95f4\u4fe1\u606f\u548c\u67e5\u627e\u7ed3\u679c\u3002\u8be5\u7ed3\u6784\u4f53\u5b9a\u4e49\u5728yoursource\/include\/linux\/namei.h\u4e2d\u3002<\/p>\n<pre class=\"brush:c\">  18struct nameidata {\r\n  19        struct path     path;\r\n  20        struct qstr     last;\r\n  21        struct path     root;\r\n  22        unsigned int    flags;\r\n  23        int             last_type;\r\n  24        unsigned        depth;\r\n  25        char *saved_names[MAX_NESTED_LINKS + 1];\r\n  26\r\n  27        \/* Intent data *\/\r\n  28        union {\r\n  29                struct open_intent open;\r\n  30        } intent;\r\n  31};<\/pre>\n<pre class=\"brush:c\">33struct qstr {\r\n34        unsigned int hash;\r\n35        unsigned int len;\r\n36        const unsigned char *name;\r\n37};<\/pre>\n<h4>\u4e0e\u8fdb\u7a0b\u6709\u5173\u7684\u6570\u636e\u7ed3\u6784<\/h4>\n<p><strong>struct fs_struct<\/strong><\/p>\n<p><strong><\/strong>\u6bcf\u4e2a\u8fdb\u7a0b\u90fd\u6709\u81ea\u5df1\u7684\u6839\u76ee\u5f55\u548c\u5f53\u524d\u7684\u5de5\u4f5c\u76ee\u5f55\uff0c\u5185\u6838\u4f7f\u7528struct fs_struct\u6765\u8bb0\u5f55\u8fd9\u4e9b\u4fe1\u606f\uff0c\u8fdb\u7a0b\u63cf\u8ff0\u7b26\u4e2d\u7684fs\u5b57\u6bb5\u4fbf\u662f\u6307\u5411\u8be5\u8fdb\u7a0b\u7684fs_struct\u7ed3\u6784\u3002\u8be5\u7ed3\u6784\u5b9a\u4e49\u4e8eyoursource\/include\/linux\/fs_struct.h\u7ed3\u6784\u4e2d\u3002<\/p>\n<pre class=\"brush:c\">   6struct fs_struct {\r\n   7        int users;\r\n   8        spinlock_t lock;\r\n   9        int umask;\r\n  10        int in_exec;\r\n  11        struct path root, pwd;\r\n  12};<\/pre>\n<p><strong>users<\/strong>\uff1a\u7528\u6237\u6570\u91cf\uff1b<br \/>\n<strong> lock<\/strong>\uff1a\u4fdd\u62a4\u8be5\u7ed3\u6784\u7684\u81ea\u65cb\u9501\uff1b<br \/>\n<strong> umask<\/strong>\uff1a\u6253\u5f00\u6587\u4ef6\u65f6\u8bbe\u7f6e\u7684\u6587\u4ef6\u8bbf\u95ee\u6743\u9650\uff1b<br \/>\n<strong> paroot<\/strong>\uff1a\u8fdb\u7a0b\u7684\u6839\u76ee\u5f55\uff1b<br \/>\n<strong> pwd<\/strong>\uff1a\u8fdb\u7a0b\u7684\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff1b<\/p>\n<p><strong>struct files_struct<\/strong><\/p>\n<p><strong><\/strong>\u4e00\u4e2a\u8fdb\u7a0b\u53ef\u80fd\u6253\u5f00\u591a\u4e2a\u6587\u4ef6\u3002\u6240\u6709\u88ab\u67d0\u4e2a\u8fdb\u7a0b\u5df2\u6253\u5f00\u7684\u6587\u4ef6\u4f7f\u7528struct files_struct\u6765\u8bb0\u5f55\u3002\u8fdb\u7a0b\u63cf\u8ff0\u7b26\u7684files\u5b57\u6bb5\u4fbf\u6307\u5411\u8be5\u8fdb\u7a0b\u7684files_struct\u7ed3\u6784\u3002\u8be5\u7ed3\u6784\u5b9a\u4e49\u4e8eyoursource\/include\/linux\/fdtable.h\u4e2d\u3002<\/p>\n<pre class=\"brush:c\">  44struct files_struct {\r\n  48        atomic_t count;\r\n  49        struct fdtable *fdt;\r\n  50        struct fdtable fdtab;\r\n  54        spinlock_t file_lock ____cacheline_aligned_in_smp;\r\n  55        int next_fd;\r\n  56        struct embedded_fd_set close_on_exec_init;\r\n  57        struct embedded_fd_set open_fds_init;\r\n  58        struct file * fd_array[NR_OPEN_DEFAULT];\r\n  59};<\/pre>\n<p><strong>count<\/strong>\uff1a\u5f15\u7528\u8ba1\u6570\uff1b<br \/>\n<strong> fdtab<\/strong>\uff1a\u5185\u6838\u4e13\u95e8\u4f7f\u7528fdtable\u7ed3\u6784\uff08\u8be5\u7ed3\u6784\u4e5f\u79f0\u4e3a\u6587\u4ef6\u63cf\u8ff0\u7b26\u8868\uff09\u6765\u63cf\u8ff0\u6587\u4ef6\u63cf\u8ff0\u7b26\u3002\u8be5\u5b57\u6bb5\u4e3a\u521d\u59cb\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u8868\uff1b<br \/>\n<strong> fdt<\/strong>\uff1a\u6307\u5411fdtab\u63cf\u8ff0\u7b26\u8868\uff1b<br \/>\n<strong> next_fd<\/strong>\uff1a\u6700\u8fd1\u5173\u95ed\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u4e2d\u6570\u503c\u6700\u5c0f\u7684\u4e0b\u4e00\u4e2a\u53ef\u7528\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\uff1b<br \/>\n<strong> close_on_exec_init<\/strong>\uff1a\u6267\u884cexec()\u65f6\u9700\u8981\u5173\u95ed\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\uff1b<br \/>\n<strong> open_fds_init<\/strong>\uff1a\u5f53\u524d\u5df2\u7ecf\u6253\u5f00\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\uff1b<br \/>\n<strong> fd_array[NR_OPEN_DEFAULT]<\/strong>\uff1a\u6587\u4ef6\u5bf9\u8c61\u7684\u521d\u59cb\u5316\u6570\u7ec4\uff1b<\/p>\n<p>\u6211\u4eec\u90fd\u77e5\u9053open\u51fd\u6570\u6b63\u786e\u6267\u884c\u540e\u4f1a\u8fd4\u56de\u4e00\u4e2a\u6574\u5f62\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\uff0c\u5176\u5b9e\u8fd9\u4e2a\u6574\u6570\u4fbf\u662ffd_arrary\u6570\u7ec4\u7684\u4e0b\u6807\u3002\u6211\u4eec\u6240\u8bf4\u7684\u6807\u51c6\u8f93\u5165\u6587\u4ef6\u3001\u6807\u51c6\u8f93\u51fa\u6587\u4ef6\u548c\u6807\u51c6\u9519\u8bef\u6587\u4ef6\u5206\u522b\u662f\u8fd9\u4e2a\u6570\u7ec4\u76840\u30011\u548c2\u53f7\u5143\u7d20\u3002<\/p>\n<p>\u901a\u5e38\u5728x86\u4f53\u7cfb\u67b6\u6784\u4e2dNR_OPEN_DEFAULT\u7684\u5927\u5c0f\u4e3a32\uff0c\u96be\u9053\u4e00\u4e2a\u8fdb\u7a0b\u6700\u591a\u53ea\u53ef\u4ee5\u6253\u5f0032\u4e2a\u6587\u4ef6\u5417\uff1f\u5f53\u7136\u4e0d\u662f\uff0c\u6211\u4eec\u5728\u4e0a\u8ff0\u7684\u5b57\u6bb5\u63cf\u8ff0\u4e2d\uff0c\u5bf9fdtab\u548cfd_array\u90fd\u7528\u201c\u521d\u59cb\u5316\u201d\u6765\u4fee\u9970\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5f53\u4e00\u4e2a\u8fdb\u7a0b\u6253\u5f00\u7684\u6587\u4ef6\u6570\u76ee\u8d85\u8fc732\u7684\u65f6\u5019\uff0c\u5185\u6838\u5c31\u5206\u914d\u4e00\u4e2a\u66f4\u5927\u7684\u6587\u4ef6\u5bf9\u8c61\u6307\u9488\u6570\u7ec4\uff08fd_array\u4e2d\u7684\u6587\u4ef6\u5bf9\u8c61\u6307\u9488\u4e5f\u4f1a\u88ab\u201c\u590d\u5236\u201d\u65b0\u7684\u6570\u7ec4\u4e2d\uff09\uff0c\u4ee5\u4fbf\u53ef\u4ee5\u5b58\u653e\u66f4\u591a\u6253\u5f00\u6587\u4ef6\u6240\u5bf9\u5e94\u7684file\u7ed3\u6784\u4f53\u7684\u6307\u9488\u3002<\/p>\n<p>\u4e0a\u8ff0\u5b57\u6bb5\u5df2\u7ecf\u8bf4\u8fc7\uff0c\u5185\u6838\u901a\u8fc7\u4e13\u95e8\u7684struct fdtable\u6765\u63cf\u8ff0\u6587\u4ef6\u63cf\u8ff0\u7b26\u8868\u3002\u8be5\u7ed3\u6784\u5b9a\u4e49\u5728yoursource\/include\/linux\/file.h\u4e2d\u3002<\/p>\n<pre class=\"brush:c\">  32struct fdtable {\r\n  33        unsigned int max_fds;\r\n  34        struct file ** fd;      \/* current fd array *\/\r\n  35        fd_set *close_on_exec;\r\n  36        fd_set *open_fds;\r\n  37        struct rcu_head rcu;\r\n  38        struct fdtable *next;\r\n  39};<\/pre>\n<p><strong>max_fds<\/strong>\uff1a\u5f53\u524d\u6587\u4ef6\u5bf9\u8c61\u6570\u7ec4\u4e2d\u5143\u7d20\u7684\u4e2a\u6570\uff1b<br \/>\n<strong>fd<\/strong>\uff1a\u6307\u5411\u5f53\u524d\u6587\u4ef6\u5bf9\u8c61\u6570\u7ec4\uff0c\u521d\u59cb\u6307\u5411fd_arrary\uff1b<br \/>\n<strong>close_on_exec<\/strong>\uff1a\u6267\u884cexec\u65f6\u8981\u5173\u95ed\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\uff0c\u521d\u59cb\u6307\u5411close_on_exec_init\uff1b<br \/>\n<strong>open_fds<\/strong>\uff1a\u5f53\u524d\u5df2\u7ecf\u6253\u5f00\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\uff0c\u521d\u59cb\u6307\u5411open_fds_init\uff1b<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last Update:2010\/11\/27 \u672c\u6587\u6d89\u53caVFS\u4e2d\u6570\u636e\u7ed3\u6784\u6709\uff1astruct file_system [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[110],"tags":[174,176],"class_list":["post-2033","post","type-post","status-publish","format-standard","hentry","category-linux","tag-vfs","tag-176"],"views":9239,"_links":{"self":[{"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/posts\/2033","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/comments?post=2033"}],"version-history":[{"count":0,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/posts\/2033\/revisions"}],"wp:attachment":[{"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/media?parent=2033"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/categories?post=2033"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/tags?post=2033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}