[RAMEN9610-19641][COMMON] ext2: support statx syscall
authorhgchu <hg.chu@samsung.com>
Wed, 31 Jul 2019 05:01:06 +0000 (14:01 +0900)
committerCosmin Tanislav <demonsingur@gmail.com>
Mon, 22 Apr 2024 17:23:35 +0000 (20:23 +0300)
Since statx, every filesystem should fill the attributes/attributes_mask
in routine getattr. But the generic_fillattr has not fill that, so add
ext2_getattr to do this. This can fix generic/424 while testing ext2.

Change-Id: I08fa576ebf8191462290f81bdd5fb93d79018b57
Signed-off-by: hgchu <hg.chu@samsung.com>
Signed-off-by: Kim Gunho <gunho.kim@samsung.com>
fs/ext2/ext2.h
fs/ext2/file.c
fs/ext2/inode.c
fs/ext2/namei.c
fs/ext2/symlink.c

index 032295e1d3865383342f843b99b4c2c0e972078c..a6f8b5afeea16ca5c2d273cb8afdded26237b345 100644 (file)
@@ -780,6 +780,7 @@ extern int ext2_write_inode (struct inode *, struct writeback_control *);
 extern void ext2_evict_inode(struct inode *);
 extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int);
 extern int ext2_setattr (struct dentry *, struct iattr *);
+extern int ext2_getattr (const struct path *, struct kstat *, u32, unsigned int);
 extern void ext2_set_inode_flags(struct inode *inode);
 extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
                       u64 start, u64 len);
index c67b486488fd2a1113dc8a121ef2ac79d5247f45..c10c1250e31e90fe085b79df46f369ab434869b2 100644 (file)
@@ -200,6 +200,7 @@ const struct inode_operations ext2_file_inode_operations = {
 #ifdef CONFIG_EXT2_FS_XATTR
        .listxattr      = ext2_listxattr,
 #endif
+       .getattr        = ext2_getattr,
        .setattr        = ext2_setattr,
        .get_acl        = ext2_get_acl,
        .set_acl        = ext2_set_acl,
index 31c5a7b5f1f312da6edb49bf12372262b628c694..306fad917cf776790a8e065a3e8aba9e3c882109 100644 (file)
@@ -1630,6 +1630,33 @@ int ext2_write_inode(struct inode *inode, struct writeback_control *wbc)
        return __ext2_write_inode(inode, wbc->sync_mode == WB_SYNC_ALL);
 }
 
+int ext2_getattr(const struct path *path, struct kstat *stat,
+               u32 request_mask, unsigned int query_falgs)
+{
+       struct inode *inode = d_inode(path->dentry);
+       struct ext2_inode_info *ei = EXT2_I(inode);
+       unsigned int flags;
+
+       flags = ei->i_flags & EXT2_FL_USER_VISIBLE;
+       if (flags & EXT2_APPEND_FL)
+               stat->attributes |= STATX_ATTR_APPEND;
+       if (flags & EXT2_COMPR_FL)
+               stat->attributes |= STATX_ATTR_COMPRESSED;
+       if (flags & EXT2_IMMUTABLE_FL)
+               stat->attributes |= STATX_ATTR_IMMUTABLE;
+       if (flags & EXT2_NODUMP_FL)
+               stat->attributes |= STATX_ATTR_NODUMP;
+       stat->attributes_mask |= (STATX_ATTR_APPEND |
+                       STATX_ATTR_COMPRESSED |
+                       STATX_ATTR_ENCRYPTED |
+                       STATX_ATTR_IMMUTABLE |
+                       STATX_ATTR_NODUMP);
+
+       generic_fillattr(inode, stat);
+       return 0;
+}
+
+
 int ext2_setattr(struct dentry *dentry, struct iattr *iattr)
 {
        struct inode *inode = d_inode(dentry);
index aa6ec191cac08d42c8d83039800f19c46d0844d6..9d8a478017c099a804e1d46a627477079e1ff405 100644 (file)
@@ -433,6 +433,7 @@ const struct inode_operations ext2_dir_inode_operations = {
 #ifdef CONFIG_EXT2_FS_XATTR
        .listxattr      = ext2_listxattr,
 #endif
+       .getattr        = ext2_getattr,
        .setattr        = ext2_setattr,
        .get_acl        = ext2_get_acl,
        .set_acl        = ext2_set_acl,
@@ -443,6 +444,7 @@ const struct inode_operations ext2_special_inode_operations = {
 #ifdef CONFIG_EXT2_FS_XATTR
        .listxattr      = ext2_listxattr,
 #endif
+       .getattr        = ext2_getattr,
        .setattr        = ext2_setattr,
        .get_acl        = ext2_get_acl,
        .set_acl        = ext2_set_acl,
index d5589ddcc281fc8d872fae64a16c446da150d9c7..00cdb86794861d77b161f3297895c7cc11e0c7c0 100644 (file)
@@ -23,6 +23,7 @@
 
 const struct inode_operations ext2_symlink_inode_operations = {
        .get_link       = page_get_link,
+       .getattr        = ext2_getattr,
        .setattr        = ext2_setattr,
 #ifdef CONFIG_EXT2_FS_XATTR
        .listxattr      = ext2_listxattr,
@@ -31,6 +32,7 @@ const struct inode_operations ext2_symlink_inode_operations = {
  
 const struct inode_operations ext2_fast_symlink_inode_operations = {
        .get_link       = simple_get_link,
+       .getattr        = ext2_getattr,
        .setattr        = ext2_setattr,
 #ifdef CONFIG_EXT2_FS_XATTR
        .listxattr      = ext2_listxattr,