From patchwork Thu Apr 14 07:57:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Margaine X-Patchwork-Id: 8832301 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B16A59F3D1 for ; Thu, 14 Apr 2016 07:57:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AD239201F5 for ; Thu, 14 Apr 2016 07:57:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ACD9C200E7 for ; Thu, 14 Apr 2016 07:57:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753142AbcDNH53 (ORCPT ); Thu, 14 Apr 2016 03:57:29 -0400 Received: from mail-vk0-f49.google.com ([209.85.213.49]:33188 "EHLO mail-vk0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752364AbcDNH52 (ORCPT ); Thu, 14 Apr 2016 03:57:28 -0400 Received: by mail-vk0-f49.google.com with SMTP id k1so100480035vkb.0 for ; Thu, 14 Apr 2016 00:57:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=margaine-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=+Y7fcmdI1Pt4qdOqkRgWTbj4quX8YkKFeUrnqpOYIUI=; b=OPfqg1sh6jG1wAjFrjNHwA7Jn1zLTXkbsxO7aNitMJcrXLT5Qftqy+5nNnXQEkA7LB m3+qp0HzDBraeEFCXh5UV8BTKtuTaE9wnAM5gWdOYR3qrZXQPbnYwysgmbrG2QK//XAN jOippYXGV0SXRiEbjrO8rWffnGPtT3T2AUao56gj3gOimqGDKi8l0Mgd+uLuPhObMNdz tZYJlH4sYMcisXpBIOQ0Bf5/2Z6nR6yAqa5YHVbpQIvxgIYimntcbksxJP052VU1Nedx lcN6/IYnVRwX/3bZzFSGrI8D8GdPeajkdv/RBwkFxuOIOQ/tGUbuhM/ily3mLAPPGzWQ zu2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=+Y7fcmdI1Pt4qdOqkRgWTbj4quX8YkKFeUrnqpOYIUI=; b=TX3NrrEHXpH4gm6kh93VrPkC73Yppw+RMjOr01DDGFfTIiYKSINLuKMqDAqJ/KxWjy 2AIoYaMCa2Ae3GrW81l1ok6+QRvlZGkDPdSzfIjOu2ATyBTa9C8RNHNnqxJHjUReP4k+ K8EtowWRT18AskvGkGYY7oHqcmBVkPalQ05WweuDQ8mKHcCPN8CnbkC3OBvmhGJZMvGJ w3C1Dyh7p/dQvfMKZ7BdvTK+v1uHXkd5zv4KK2mW9kHZYJj8aIEga0rE2mCxEXaOQC1t zqxgS8NWd6IV6ZN3OQ7w3QP8OVk8A3F01TWrA32UWLzu6nnTXFFxuOed/sBfht4Zzqnu dSPQ== X-Gm-Message-State: AOPr4FVj7qTYIzj1DqijmAfkJGMkGikIg34zidTlavbUlEgvETiTc5e+p0CJMxR5RWtWUM3k888JsrWNpDXo6A== X-Received: by 10.31.52.73 with SMTP id b70mr5909062vka.16.1460620647063; Thu, 14 Apr 2016 00:57:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.159.37.202 with HTTP; Thu, 14 Apr 2016 00:57:07 -0700 (PDT) X-Originating-IP: [5.49.178.78] From: Florian Margaine Date: Thu, 14 Apr 2016 09:57:07 +0200 Message-ID: Subject: [PATCH] fs: add the FIGETFROZEN ioctl call To: Alexander Viro , Jeff Layton , "J. Bruce Fields" , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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)