根据
struct ext4_inode {
.....
__le16 i_extra_isize;
.....
}
我看到这可用于存储扩展属性,因为我使用的是inode size = 256字节。几个问题:
答案 0 :(得分:1)
我如何知道我的FS inode大小是256还是128字节?
$ sudo tune2fs -l /dev/sda2 | egrep -i 'inode size'
Inode size: 256
如何设置小扩展属性
Ext3 / 4支持可配置的inode大小(来自-I选项mkfs.ext {3,4} cmd参数),但默认的inode大小为128个字节。 Ext4默认为256个字节。这需要适应一些额外的字段(如纳秒时间戳或inode版本控制),并且inode的剩余空间将用于存储足够小以适合该空间的扩展属性。您还可以查看fs / ext4 / file.c实现的函数:struct inode_operations {.setattr,.getattr}。
Fileystem / C lib调用了什么?
请参阅API setxattr(), lsetxattr(), fsetxattr()
以设置扩展属性编程。使用命令attr, lsattr, chattr
测试设置文件的扩展属性。您也可以look into
是什么内存结构用于在128个字节的inode之后映射额外的字节,这是我想要存储我的小扩展属性的地方。
"
* Extended attributes are stored directly in inodes (on file systems with
18 * inodes bigger than 128 bytes) and on additional disk blocks. The i_file_acl
19 * field contains the block number if an inode uses an additional block. All
20 * attributes must fit in the inode and one additional block. Blocks that
21 * contain the identical set of attributes may be shared among several inodes.
22 * Identical blocks are detected by keeping a cache of blocks that have
23 * recently been accessed.
24 *
25 * The attributes in inodes and on blocks have a different header; the entries
26 * are stored in the same format:
27 *
28 * +------------------+
29 * | header |
30 * | entry 1 | |
31 * | entry 2 | | growing downwards
32 * | entry 3 | v
33 * | four null bytes |
34 * | . . . |
35 * | value 1 | ^
36 * | value 3 | | growing upwards
37 * | value 2 | |
38 * +------------------+
39 *
40 * The header is followed by multiple entry descriptors. In disk blocks, the
41 * entry descriptors are kept sorted. In inodes, they are unsorted. The
42 * attribute values are aligned to the end of the block in no specific order.
"