Received: by 10.192.165.156 with SMTP id m28csp2087558imm; Thu, 12 Apr 2018 08:24:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx48B5KRSXNlcJD5XPFLAHLAi8O5Ox2tYfSVCZk9GiWSgn5A//es1ixqCBEp/ZpYk7z0XIggA X-Received: by 2002:a17:902:5416:: with SMTP id d22-v6mr1524015pli.111.1523546666769; Thu, 12 Apr 2018 08:24:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523546666; cv=none; d=google.com; s=arc-20160816; b=LswH5CoQnQyPD50QxoKiKGPD30Xc598TTX/jnVrJ08Cvx6NWkBexRL3MYbAiju08ke jAg2Y/WpS251aI1RSLV2SrhGodRT9p/TSumYD06NYSSUYODwwZAIcRoueO6cFU36W8de ge792uYVM5vn1ODRrVZrMnWnFnr1n0deWzErHcHZeUkMgw8+f/sKvHxf4ciJPzZfhOGW u/HEc7g89YKR8P+H6VtiZ4/YrJDYrIgViVyI3aqURhb5aj2fNVncD0TbYAyN74+SWX2K L9ivMCDjXSkNgyurxEKZ5dnc5ZJI8aIfSi5K8r2NDeJ5AoM3lwmnVpNYUqAO0Su6t7Gt /A/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=cNNbwPrs8zIpHIFlavlGhKOeq8gu/fOV4t69X49oivY=; b=fBFyGpIv9suxMKBU+ThmJKhgn+Fz5Fs+opQ4quf4g8J7E8uiA4bJX2xzknTsJvWFAi /q5W4K/2628KEHdAXKKJEhB4UpHEht1InBFHDvlxN35lgajSHBRlwEHwNDh5IXu0cU7s 2z0kFZ3Oy+0Z5xLn3Yb57mXNiYTeuVHVzgmLaYffYX9ERbruJWiPJUvFgjqb6UCLiT/y QUq43RV1sM/lMZ813FIDRS3odC91ulzeCDpcvqPqQMGATKp4Ka2h1KUuqucVFiUtV9ug Nj+PWp00aDXDAEYyCft+N9x3UvJkOLMTu4iMmyloUrKIgnekggvdJpy/GcC8jUYsLje2 TxWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t137si2361719pgb.288.2018.04.12.08.23.49; Thu, 12 Apr 2018 08:24:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753372AbeDLPIz (ORCPT + 99 others); Thu, 12 Apr 2018 11:08:55 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:53020 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753405AbeDLPIv (ORCPT ); Thu, 12 Apr 2018 11:08:51 -0400 Received: by mail-wm0-f66.google.com with SMTP id g8so12316728wmd.2 for ; Thu, 12 Apr 2018 08:08:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cNNbwPrs8zIpHIFlavlGhKOeq8gu/fOV4t69X49oivY=; b=JhAyT+HzpKX9Bjdm3YizjiEdhs2VVFbwQJ3Gqk3XUaaXwqEsJeGv1N0RYUFgylikgV XwCPP9To+dP3gNX8PIOhMWa7/twev88jMpEh1PhrfgcSSmJutdiHq7JHGozN3FNMVHN9 SKtSehYukRAUj06Z7rAzwunpcXrI+mEWYaEyIrplfy6uUiNxktzNnzKELskN1zfy+lpI tI6pOlg28oyMjCBgX5KjIyWkLQYTuedSqRPJYutxvuU7wX8vWMAEv1zDN4m8Sg97dRYk rc5LeELnl3S9MghBY1gQy50PbfSJI+33Dmje4ZE5KMGeYNJcHyHI5HqhQ6KXqeWWhI9V n4iQ== X-Gm-Message-State: ALQs6tBNSLXuLeA4s9jwNUnpwSYUt4EeDzHHGvydD4ACJOs82n7oOFfb RB/zPAHk3MVX2hN/zKHZgKLDmQ== X-Received: by 10.28.197.205 with SMTP id v196mr1087254wmf.39.1523545730277; Thu, 12 Apr 2018 08:08:50 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (catv-176-63-54-97.catv.broadband.hu. [176.63.54.97]) by smtp.gmail.com with ESMTPSA id p197sm2621783wme.43.2018.04.12.08.08.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Apr 2018 08:08:49 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 16/35] ovl: readd lsattr/chattr support Date: Thu, 12 Apr 2018 17:08:07 +0200 Message-Id: <20180412150826.20988-17-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180412150826.20988-1-mszeredi@redhat.com> References: <20180412150826.20988-1-mszeredi@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implement FS_IOC_GETFLAGS and FS_IOC_SETFLAGS. Needs vfs_ioctl() exported to modules. Signed-off-by: Miklos Szeredi --- fs/internal.h | 1 - fs/ioctl.c | 1 + fs/overlayfs/file.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/fs.h | 2 ++ 4 files changed, 62 insertions(+), 1 deletion(-) diff --git a/fs/internal.h b/fs/internal.h index 3319bf39e339..d5108d9c6a2f 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -176,7 +176,6 @@ extern const struct dentry_operations ns_dentry_operations; */ extern int do_vfs_ioctl(struct file *file, unsigned int fd, unsigned int cmd, unsigned long arg); -extern long vfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg); /* * iomap support: diff --git a/fs/ioctl.c b/fs/ioctl.c index 5ace7efb0d04..696f4c46a868 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -49,6 +49,7 @@ long vfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) out: return error; } +EXPORT_SYMBOL(vfs_ioctl); static int ioctl_fibmap(struct file *filp, int __user *p) { diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index 05e3e2f80b89..cc004ff1b05b 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include "overlayfs.h" @@ -291,6 +292,63 @@ long ovl_fallocate(struct file *file, int mode, loff_t offset, loff_t len) return ret; } +static long ovl_real_ioctl(struct file *file, unsigned int cmd, + unsigned long arg) +{ + struct fd real; + const struct cred *old_cred; + long ret; + + ret = ovl_real_file(file, &real); + if (ret) + return ret; + + old_cred = ovl_override_creds(file_inode(file)->i_sb); + ret = vfs_ioctl(real.file, cmd, arg); + revert_creds(old_cred); + + fdput(real); + + return ret; +} + +long ovl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + long ret; + struct inode *inode = file_inode(file); + + switch (cmd) { + case FS_IOC_GETFLAGS: + ret = ovl_real_ioctl(file, cmd, arg); + break; + + case FS_IOC_SETFLAGS: + if (!inode_owner_or_capable(inode)) + return -EACCES; + + ret = mnt_want_write_file(file); + if (ret) + return ret; + + ret = ovl_copy_up(file_dentry(file)); + if (!ret) { + ret = ovl_real_ioctl(file, cmd, arg); + + inode_lock(inode); + ovl_copyflags(ovl_inode_real(inode), inode); + inode_unlock(inode); + } + + mnt_drop_write_file(file); + break; + + default: + ret = -ENOTTY; + } + + return ret; +} + const struct file_operations ovl_file_operations = { .open = ovl_open, .release = ovl_release, @@ -300,4 +358,5 @@ const struct file_operations ovl_file_operations = { .fsync = ovl_fsync, .mmap = ovl_mmap, .fallocate = ovl_fallocate, + .unlocked_ioctl = ovl_ioctl, }; diff --git a/include/linux/fs.h b/include/linux/fs.h index 0b215faa30ae..1add10f04b56 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1621,6 +1621,8 @@ int vfs_mkobj(struct dentry *, umode_t, int (*f)(struct dentry *, umode_t, void *), void *); +extern long vfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg); + /* * VFS file helper functions. */ -- 2.14.3