Documentation\filesystems\Sysfs-tagging

来源:互联网 发布:知乎 墨子号 编辑:程序博客网 时间:2024/06/07 09:07

Chinese translated version of Documentation\filesystems\Sysfs-tagging

If you have any comment or update to the content, please contact the
original document maintainer directly.  However, if you have a problem
communicating in English you can also ask the Chinese maintainer for
help.  Contact the Chinese maintainer if this translation is outdated
or if there is a problem with the translation.

Chinese maintainer: 赵晶  anana53@qq.com
---------------------------------------------------------------------
Documentation\filesystems\Sysfs-tagging 的中文翻译

如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
译存在问题,请联系中文版维护者。

中文版维护者: 赵晶  anana53@qq.com
中文版翻译者: 赵晶  anana53@qq.com
中文版校译者: 赵晶  anana53@qq.com

以下为正文
---------------------------------------------------------------------
Sysfs tagging
-------------

(Taken almost verbatim from Eric Biederman's netns tagging patch
commit msg)

The problem.  Network devices show up in sysfs and with the network
namespace active multiple devices with the same name can show up in
the same directory, ouch!

sysfs标记
-------------

(几乎一字不差从Eric Biederman's的netns标记的补丁
中提交的大量储存器组中提取)

这个问题,在sysfs中出现的网络设备与网络上
具有相同名称并活跃在多台设备上的命名空间将显示在
同一目录中,哎哟!

To avoid that problem and allow existing applications in network
namespaces to see the same interface that is currently presented in
sysfs, sysfs now has tagging directory support.

By using the network namespace pointers as tags to separate out the
the sysfs directory entries we ensure that we don't have conflicts
in the directories and applications only see a limited set of
the network devices.

为了避免这种问题,并允许现有的应用程序在网络
命名空间中看到当前显示在sysfs中相同的接口,
现在sysfs中有标记目录来支持。

通过使用网络命名空间指针作为标签,以分离出
sysfs目录条目,我们确保我们没有冲突
目录并且应用程序只能看到有限的一组
网络设备。

Each sysfs directory entry may be tagged with zero or one
namespaces.  A sysfs_dirent is augmented with a void *s_ns.  If a
directory entry is tagged, then sysfs_dirent->s_flags will have a
flag between KOBJ_NS_TYPE_NONE and KOBJ_NS_TYPES, and s_ns will
point to the namespace to which it belongs.

Each sysfs superblock's sysfs_super_info contains an array void
*ns[KOBJ_NS_TYPES].  When a task in a tagging namespace
kobj_nstype first mounts sysfs, a new superblock is created.  It
will be differentiated from other sysfs mounts by having its
s_fs_info->ns[kobj_nstype] set to the new namespace.  Note that
through bind mounting and mounts propagation, a task can easily view
the contents of other namespaces' sysfs mounts.  Therefore, when a
namespace exits, it will call kobj_ns_exit() to invalidate any
sysfs_dirent->s_ns pointers pointing to it.

每个的sysfs目录条目可能被标记0或1个
命名空间。 sysfs_dirent将被一个空的 *s_ns指针增加。如果
目录条目已经被标记,那么sysfs_dirent -> s_flags将有一个
标记在KOBJ_NS_TYPE_NONE和KOBJ_NS_TYPES之间, 并且s_ns
将指向它所属的命名空间。

每个sysfs中超级块的sysfs_super_info包含一个空数组
*NS [ KOBJ_NS_TYPES ] 。当一个在标记命名空间
kobj_nstype中的任务第一次加载sysfs 时,一个新的块将被创建。它
将有其区别于其他的sysfs加载,他们加载通过将
s_fs_info NS [ kobj_nstype ]设置为新的命名空间。需要注意的是
通过绑定加载和加载传播,一个任务可以轻松地查看
其他命名空间的sysfs加载的内容。因此,当一个
命名空间退出,它将调用kobj_ns_exit( )函数去让任何指向
sysfs_dirent > s_ns的指针无效。

Users of this interface:
- define a type in the kobj_ns_type enumeration.
- call kobj_ns_type_register() with its kobj_ns_type_operations which has
  - current_ns() which returns current's namespace
  - netlink_ns() which returns a socket's namespace
  - initial_ns() which returns the initial namesapce
- call kobj_ns_exit() when an individual tag is no longer valid

此接口的用户:
- 定义一个类型在kobj_ns_type枚举中。
- 调用 kobj_ns_type_register ( )函数与它的kobj_ns_type_operations,其中有
   - current_ns ()返回当前的命名空间
   - netlink_ns ()返回套接字的命名空间
   - initial_ns返回初始的命名空间
- 调用kobj_ns_exit ( )函数,当一个单独的标记不再有效

原创粉丝点击