扩展属性存储在哪里? [英] where are extended attributes stored?

查看:150
本文介绍了扩展属性存储在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个简单的问题,但我已经做了一些研究,找不到任何答案...所以有人知道,当我们通过xattr定义扩展属性时,这些属性存储在 - 作为 - 的一部分file'c​​ontents(在biggining,到底?),或者如果inode有一个特殊的区域来存储这些?



顺便说一句,我读过在ext4中每个扩展属性被限制在一个文件系统块(例如4 KiB)。如果我想将7个扩展属性存储到文件系统中的每个文件,我不知道这是否足够。这是真的吗?



我最后的问题是,如果这些扩展属性是可移植的,如果文件移动到不同文件系统的其他机器,这个属性会发生什么?

解决方案

如果您查看inode规范,您会发现在结尾处有少量空间inode以适应扩展属性。如果你溢出那个区域,ext4允许你为另外的扩展属性分配另一个块(基本上就像资源分叉)。这个4KB限制是每个文件的每个属性,所以你可以确定每个文件存储7个扩展属性,除非这个属性是一个大于4KB的BLOB。但是,如果溢出inode结尾的空间,则会将块分配给元数据而不是数据,从而减少文件系统的可用大小。



来源: https://ext4.wiki.kernel.org/index.php/ Ext4_Disk_Layout#Extended_Attributes



为了回答您关于可移植性的问题,扩展属性在默认情况下不会被复制,即使在单个文件系统中也是如此,并且不能在文件之间移植系统。



请参阅: https://unix.stackexchange.com/questions/44253/how-to-clone-copy-all-file-directory-attributes-onto-different-file-directory 进一步的讨论。 Rysnc可以为复制扩展属性做很多事情,但是如果目标文件系统不支持xattrs,那就不好运气了。

This is a simple question but I've done some research and can't find any answers... So does anyone know if when we define extended attributes through xattr, those attributes are stored within - as a part of - the file'contents(in the biggining, in the end?), or if the inode has a special region to store these?

And by the way, i've read that in ext4 "each extended attribute is limited to a filesystem block (e.g. 4 KiB)". I can't tell if this is enough if I wanted to store 7 extended attributes to each file in the file system. Is this reallistic?

My last question is if those extended attributes are portable in the sense that if the files move to other machines with different file systems what happens to this attributes?

解决方案

If you look at the inode spec, you'll discover that there is a small amount of space at the end of the inode to accommodate extended attributes. If you overflow that area, ext4 allows to you allocate another block (basically like a resource fork) for additional extended attributes. That 4KB restriction is per attribute, per file, so you can certainly store 7 extended attributes per file, unless the attribute is a BLOB larger than 4KB. However, if you overrun the space at the end of the inode, you'll be allocating blocks to metadata instead of data, reducing the usable size of your file system.

Source: https://ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout#Extended_Attributes

To answer your question about portability, extended attributes are not copied by default, even within a single file system, and are not portable between file systems.

See: https://unix.stackexchange.com/questions/44253/how-to-clone-copy-all-file-directory-attributes-onto-different-file-directory for some further discussion on this. Rysnc can do a lot for copying extended attributes, but if the target file system doesn't support xattrs, you're out of luck.

这篇关于扩展属性存储在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆