Skip to content

Commit 93bc420

Browse files
yangerkunjankara
authored andcommitted
ext2: support statx syscall
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. Reviewed-by: zhangyi (F) <yi.zhang@huawei.com> Signed-off-by: yangerkun <yangerkun@huawei.com> Signed-off-by: Jan Kara <jack@suse.cz>
1 parent 4f5edd8 commit 93bc420

5 files changed

Lines changed: 32 additions & 0 deletions

File tree

‎fs/ext2/ext2.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,7 @@ extern int ext2_write_inode (struct inode *, struct writeback_control *);
774774
extern void ext2_evict_inode(struct inode *);
775775
extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int);
776776
extern int ext2_setattr (struct dentry *, struct iattr *);
777+
extern int ext2_getattr (const struct path *, struct kstat *, u32, unsigned int);
777778
extern void ext2_set_inode_flags(struct inode *inode);
778779
extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
779780
u64 start, u64 len);

‎fs/ext2/file.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ const struct inode_operations ext2_file_inode_operations = {
199199
#ifdef CONFIG_EXT2_FS_XATTR
200200
.listxattr = ext2_listxattr,
201201
#endif
202+
.getattr = ext2_getattr,
202203
.setattr = ext2_setattr,
203204
.get_acl = ext2_get_acl,
204205
.set_acl = ext2_set_acl,

‎fs/ext2/inode.c‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,6 +1637,32 @@ int ext2_write_inode(struct inode *inode, struct writeback_control *wbc)
16371637
return __ext2_write_inode(inode, wbc->sync_mode == WB_SYNC_ALL);
16381638
}
16391639

1640+
int ext2_getattr(const struct path *path, struct kstat *stat,
1641+
u32 request_mask, unsigned int query_falgs)
1642+
{
1643+
struct inode *inode = d_inode(path->dentry);
1644+
struct ext2_inode_info *ei = EXT2_I(inode);
1645+
unsigned int flags;
1646+
1647+
flags = ei->i_flags & EXT2_FL_USER_VISIBLE;
1648+
if (flags & EXT2_APPEND_FL)
1649+
stat->attributes |= STATX_ATTR_APPEND;
1650+
if (flags & EXT2_COMPR_FL)
1651+
stat->attributes |= STATX_ATTR_COMPRESSED;
1652+
if (flags & EXT2_IMMUTABLE_FL)
1653+
stat->attributes |= STATX_ATTR_IMMUTABLE;
1654+
if (flags & EXT2_NODUMP_FL)
1655+
stat->attributes |= STATX_ATTR_NODUMP;
1656+
stat->attributes_mask |= (STATX_ATTR_APPEND |
1657+
STATX_ATTR_COMPRESSED |
1658+
STATX_ATTR_ENCRYPTED |
1659+
STATX_ATTR_IMMUTABLE |
1660+
STATX_ATTR_NODUMP);
1661+
1662+
generic_fillattr(inode, stat);
1663+
return 0;
1664+
}
1665+
16401666
int ext2_setattr(struct dentry *dentry, struct iattr *iattr)
16411667
{
16421668
struct inode *inode = d_inode(dentry);

‎fs/ext2/namei.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ const struct inode_operations ext2_dir_inode_operations = {
416416
#ifdef CONFIG_EXT2_FS_XATTR
417417
.listxattr = ext2_listxattr,
418418
#endif
419+
.getattr = ext2_getattr,
419420
.setattr = ext2_setattr,
420421
.get_acl = ext2_get_acl,
421422
.set_acl = ext2_set_acl,
@@ -426,6 +427,7 @@ const struct inode_operations ext2_special_inode_operations = {
426427
#ifdef CONFIG_EXT2_FS_XATTR
427428
.listxattr = ext2_listxattr,
428429
#endif
430+
.getattr = ext2_getattr,
429431
.setattr = ext2_setattr,
430432
.get_acl = ext2_get_acl,
431433
.set_acl = ext2_set_acl,

‎fs/ext2/symlink.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
const struct inode_operations ext2_symlink_inode_operations = {
2525
.get_link = page_get_link,
26+
.getattr = ext2_getattr,
2627
.setattr = ext2_setattr,
2728
#ifdef CONFIG_EXT2_FS_XATTR
2829
.listxattr = ext2_listxattr,
@@ -31,6 +32,7 @@ const struct inode_operations ext2_symlink_inode_operations = {
3132

3233
const struct inode_operations ext2_fast_symlink_inode_operations = {
3334
.get_link = simple_get_link,
35+
.getattr = ext2_getattr,
3436
.setattr = ext2_setattr,
3537
#ifdef CONFIG_EXT2_FS_XATTR
3638
.listxattr = ext2_listxattr,

0 commit comments

Comments
 (0)