Filesystems “如何存储”;“扩展属性”;在ext4 inode块中,我们有inode extra size“;我“额外的”;

Filesystems “如何存储”;“扩展属性”;在ext4 inode块中,我们有inode extra size“;我“额外的”;,filesystems,inode,ext4,Filesystems,Inode,Ext4,依照 考虑到我使用的inode size=256字节,我发现这可以用来存储扩展属性。几个问题: 我如何知道我的FS索引节点大小是256字节还是128字节 如何设置小的扩展属性( 我如何知道我的FS索引节点大小是256字节还是128字节 如何设置小的扩展属性 Ext3/4支持可配置的inode大小(从-I选项mkfs.ext{3,4}cmd参数),但默认inode大小为128字节。Ext4将默认为256字节。这需要容纳一些额外字段(如纳秒时间戳或inode版本控制),并且inode的剩余空间将用于

依照

考虑到我使用的inode size=256字节,我发现这可以用来存储扩展属性。几个问题:

  • 我如何知道我的FS索引节点大小是256字节还是128字节
  • 如何设置小的扩展属性( 我如何知道我的FS索引节点大小是256字节还是128字节

    如何设置小的扩展属性

    Ext3/4支持可配置的inode大小(从-I选项mkfs.ext{3,4}cmd参数),但默认inode大小为128字节。Ext4将默认为256字节。这需要容纳一些额外字段(如纳秒时间戳或inode版本控制),并且inode的剩余空间将用于存储足够小的扩展属性,以适应该空间。此外,您可能希望查看fs/ext4/file.c:struct inode_operations{.setattr、.getattr}实现的函数

    FileSystem/C lib对此有何调用

    请参阅API以设置扩展属性。使用命令
    attr、lsattr、chattr
    测试集合文件上的扩展属性。您可能还需要

    在128字节的inode之后映射额外字节的内存结构是什么,我想在这里存储我的小扩展属性

    提及

    "


    lsattr
    chattr
    操作
    无符号int i_标志;
    struc inode字段,因此与
    xattr
    关系不大。请参阅和
    /usr/include/linux/fs.h
    struct ext4_inode {
      .....
      __le16  i_extra_isize;
      .....
    }
    
    $ sudo tune2fs -l /dev/sda2  | egrep -i 'inode size'
    Inode size:               256
    
    * 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.