扩展属性attr

来源:互联网 发布:广州淘宝运营助理招聘 编辑:程序博客网 时间:2024/05/17 22:33

【原文地址】http://linux.about.com/library/cmd/blcmdl5_attr.htm

NAME

attr - Extended attributes

DESCRIPTION

Extended attributes are name:value pairs associated permanently with files and directories, similar to the environment strings associated with a process. An attribute may be defined or undefined. If it is defined, its value may be empty or non-empty.

扩展属性是与文件和目录相关的键值对,就像环境变量对进程一样。可以设定或者删除一个属性。如果设定了,它的值可以是空或者非空。

Extended attributes are extensions to the normal attributes which are associated with all inodes in the system (i.e. the stat(2) data). They are often used to provide additional functionality to a filesystem - for example, additional security features such as Access Control Lists (ACLs) may be implemented using extended attributes.

扩展属性是对普通属性的扩展。它们常被用于给文件系统提供额外的功能。例如,可以使用扩展属性实现诸如ACLs的安全特性。

Users with search access to a file or directory may retrieve a list of attribute names defined for that file or directory.

用户可以检索文件或者目录的属性名

Currently, support for extended attributes is implemented on Linux by the ext2, ext3 and XFS filesystem patches.

当前ext2,ext3和XFS文件系统已支持扩展属性。


EXTENDED ATTRIBUTE NAMESPACES

Attribute names are zero-terminated strings. The attribute name is always specified in the fully qualified namespace.attribute form, eg. user.mime_typetrusted.md5sum, orsystem.posix_acl_access
扩展属性名是以'\0'结尾的字符串。格式为namespace.attribute,例如user.mime_type, trusted.md5sum, orsystem.posix_acl_access

The namespace mechanism is used to define different classes of extended attributes. These different classes exist for several reasons, e.g. the permissions and capabilities required for manipulating extended attributes of one namespace may differ to another.

命名空间机制用来定义不同类的扩展属性。这些不同类的属性存在有各种理由,例如每个命名空间里操作扩展属性所需的权限和功能并不相同。

Currently the usertrusted, and system extended attribute classes are defined as described below. Additional classes may be added in the future. 

当前,user,trusted和system扩展属性定义如下。

Extended user attributes

Extended user attributes may be assigned to files and directories for storing arbitrary additional information such as the mime type, character set or encoding of a file. The access permissions for user attributes are defined by the file permission bits.

扩展用户属性可以赋给文件和目录用来存储任意的额外属性,例如mine类型、字符集或者文件编码。扩展用户属性的访问权限由文件权限位决定。

The file permission bits of regular files and directories are interpreted differently from the file permission bits of special files and symbolic links. For regular files and directories the file permission bits define access to the file's contents, while for special files they define access to the device described by the special file. The file permissions of symbolic links are not used in access checks. These differences would allow users to consume filesystem resources in a way not controllable by disk quotas for group or world writable special files and directories.

普通文件和目录的文件权限位意义与特殊文件和符号链接的不同。对普通文件和目录来说,文件权限位定义了对文件内容的访问权限。而对特殊文件来说是对设备的访问权限。而符号链接不使用文件权限来进行访问检查。( to be continued...)

For this reason, extended user attributes are disallowed for symbolic links and special files, and access to extended user attributes is restricted to the owner and to users with appropriate capabilities for directories with the sticky bit set (see the chmod(1) manual page for an explanation of Sticky Directories).

Trusted extended attributes

Trusted extended attributes are visible and accessible only to processes that have the CAP_SYS_ADMIN capability (the super user usually has this capability). Attributes in this class are used to implement mechanisms in user space (i.e., outside the kernel) which keep information in extended attributes to which ordinary processes should not have access.

Extended system attributes

Extended system attributes are used by the kernel to store system objects such as Access Control Lists and Capabilities. Read and write access permissions to system attributes depend on the policy implemented for each system attribute implemented in the kernel.
0 0
原创粉丝点击