linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs: add the FIGETFROZEN ioctl call
@ 2016-04-14  7:57 Florian Margaine
  2016-04-14  8:10 ` Florian Margaine
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Florian Margaine @ 2016-04-14  7:57 UTC (permalink / raw)
  To: Alexander Viro, Jeff Layton, J. Bruce Fields, linux-fsdevel,
	linux-kernel

This lets userland get the filesystem freezing status, aka whether the
filesystem is frozen or not. This is so that an application can know if
it should freeze the filesystem or if it isn't necessary when taking a
snapshot.
---
 fs/compat_ioctl.c       |  1 +
 fs/ioctl.c              | 13 +++++++++++++
 include/uapi/linux/fs.h |  1 +
 3 files changed, 15 insertions(+)

diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index bd01b92..d2173ab 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -918,6 +918,7 @@ COMPATIBLE_IOCTL(FIGETBSZ)
 COMPATIBLE_IOCTL(FIFREEZE)
 COMPATIBLE_IOCTL(FITHAW)
 COMPATIBLE_IOCTL(FITRIM)
+COMPATIBLE_IOCTL(FIGETFROZEN)
 COMPATIBLE_IOCTL(KDGETKEYCODE)
 COMPATIBLE_IOCTL(KDSETKEYCODE)
 COMPATIBLE_IOCTL(KDGKBTYPE)
diff --git a/fs/ioctl.c b/fs/ioctl.c
index 116a333..249ed20 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -568,6 +568,16 @@ static int ioctl_fsthaw(struct file *filp)
  return thaw_super(sb);
 }

+static int ioctl_fsgetfrozen(struct file *filp)
+{
+ struct super_block *sb = file_inode(filp)->i_sb;
+
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
+
+ return sb->s_writers.frozen;
+}
+
 static long ioctl_file_dedupe_range(struct file *file, void __user *arg)
 {
  struct file_dedupe_range __user *argp = arg;
@@ -652,6 +662,9 @@ int do_vfs_ioctl(struct file *filp, unsigned int
fd, unsigned int cmd,
  error = ioctl_fsthaw(filp);
  break;

+ case FIGETFROZEN:
+ return put_user(ioctl_fsgetfrozen(filp), argp);
+
  case FS_IOC_FIEMAP:
  return ioctl_fiemap(filp, arg);

diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index 149bec8..d48f19c 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -230,6 +230,7 @@ struct fsxattr {
 #define FIFREEZE _IOWR('X', 119, int) /* Freeze */
 #define FITHAW _IOWR('X', 120, int) /* Thaw */
 #define FITRIM _IOWR('X', 121, struct fstrim_range) /* Trim */
+#define FIGETFROZEN _IOWR('X', 122, int) /* Frozen status */
 #define FICLONE _IOW(0x94, 9, int)
 #define FICLONERANGE _IOW(0x94, 13, struct file_clone_range)
 #define FIDEDUPERANGE _IOWR(0x94, 54, struct file_dedupe_range)
-- 
2.8.0

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-04-22 23:14 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-14  7:57 [PATCH] fs: add the FIGETFROZEN ioctl call Florian Margaine
2016-04-14  8:10 ` Florian Margaine
2016-04-15  0:50 ` Mateusz Guzik
2016-04-15  2:17 ` Dave Chinner
2016-04-16 12:18   ` Florian Margaine
2016-04-17 15:05     ` Jan Kara
2016-04-18 15:20   ` Eric Sandeen
2016-04-18 17:20     ` Florian Margaine
2016-04-18 17:47       ` Eric Sandeen
2016-04-18 23:06     ` Dave Chinner
2016-04-22 21:53       ` Florian Margaine
2016-04-22 23:14         ` Dave Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).