summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/fs-ioctl.c
diff options
context:
space:
mode:
authorHongbo Li <lihongbo22@huawei.com>2024-06-03 15:26:18 +0200
committerKent Overstreet <kent.overstreet@linux.dev>2024-07-15 01:00:14 +0200
commit8a4ef7e28abade861d894e25b167988c5b8977a7 (patch)
treefe47d3115494ad532787496973f5969924ff7775 /fs/bcachefs/fs-ioctl.c
parentbcachefs: Unlock trans when waiting for user input in fsck (diff)
downloadlinux-8a4ef7e28abade861d894e25b167988c5b8977a7.tar.xz
linux-8a4ef7e28abade861d894e25b167988c5b8977a7.zip
bcachefs: implement FS_IOC_GETVERSION to support lsattr
In this patch we add the FS_IOC_GETVERSION ioctl for getting i_generation from inode, after that, users can list file's generation number by using "lsattr". Signed-off-by: Hongbo Li <lihongbo22@huawei.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/fs-ioctl.c')
-rw-r--r--fs/bcachefs/fs-ioctl.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/bcachefs/fs-ioctl.c b/fs/bcachefs/fs-ioctl.c
index 79a0c8732bce..add90172b475 100644
--- a/fs/bcachefs/fs-ioctl.c
+++ b/fs/bcachefs/fs-ioctl.c
@@ -272,6 +272,11 @@ err1:
return ret;
}
+static int bch2_ioc_getversion(struct bch_inode_info *inode, u32 __user *arg)
+{
+ return put_user(inode->v.i_generation, arg);
+}
+
static int bch2_ioc_goingdown(struct bch_fs *c, u32 __user *arg)
{
u32 flags;
@@ -499,7 +504,7 @@ long bch2_fs_file_ioctl(struct file *file, unsigned cmd, unsigned long arg)
break;
case FS_IOC_GETVERSION:
- ret = -ENOTTY;
+ ret = bch2_ioc_getversion(inode, (u32 __user *) arg);
break;
case FS_IOC_SETVERSION:
@@ -547,6 +552,9 @@ long bch2_compat_fs_ioctl(struct file *file, unsigned cmd, unsigned long arg)
case FS_IOC32_SETFLAGS:
cmd = FS_IOC_SETFLAGS;
break;
+ case FS_IOC32_GETVERSION:
+ cmd = FS_IOC_GETVERSION;
+ break;
default:
return -ENOIOCTLCMD;
}