From patchwork Mon May 7 08:37:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10383585 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F3F0A60159 for ; Mon, 7 May 2018 08:46:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6565286DF for ; Mon, 7 May 2018 08:46:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA53928A96; Mon, 7 May 2018 08:46:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85BEB286DF for ; Mon, 7 May 2018 08:46:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752592AbeEGIqT (ORCPT ); Mon, 7 May 2018 04:46:19 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:54694 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752147AbeEGIic (ORCPT ); Mon, 7 May 2018 04:38:32 -0400 Received: by mail-wm0-f67.google.com with SMTP id f6so12028001wmc.4 for ; Mon, 07 May 2018 01:38:32 -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=pwB4toT5HgzNWNcEeKnojJdrKVF7+wE9DkBhcJnRoFU=; b=IanIHmpilVgVL98qRJvzoiMdDIlltKhCiWOU3pGbDquanq0T18z33sFn1P6H9uteOc ef+Pq2s/Zbmksf0HnRR1/JKGhyV2jc6+EBJBBfCeWv2cgfpRGAxRgEdDNa8M7PPH59Hc OUfioV+RZsCXmY0QXNw2Rlesf4BZSjtiCc2y7W+QGbM4pC4nRTFF7PtQmXsOg1eGsf50 FqpMzJWgYbu6EVgqnJWfGrDSpwV2vL/Kf4uF7tZwdZgQ+1DEio7bkHMar04MBQuhmxyU gnOa9Klg5e4zDSkKTKlbpIPnXctEauYIBGLc4U2kqIeVi/3Ht+J+1zMUSo8rhqj5RBZ+ suSA== X-Gm-Message-State: ALKqPwfL+6FDjnt+MIQzX53fXzRoCE27HWuduAqCr43gAtnQDR5sRX7F rdRwd2FOaWtT7E/gjU4l/Dlu2A== X-Google-Smtp-Source: AB8JxZr/MhZkc7DZCv3xFL6ZT1qLboJl11JBEvlEEEtStiHGaQsstcCetHQv4a58AOhAXP4kA7of7w== X-Received: by 10.28.140.207 with SMTP id o198mr189997wmd.82.1525682311427; Mon, 07 May 2018 01:38:31 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (C2B0E321.catv.pool.telekom.hu. [194.176.227.33]) by smtp.gmail.com with ESMTPSA id h8-v6sm5908050wmc.16.2018.05.07.01.38.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 May 2018 01:38:30 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 16/35] ovl: add ovl_mmap() Date: Mon, 7 May 2018 10:37:48 +0200 Message-Id: <20180507083807.28792-17-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180507083807.28792-1-mszeredi@redhat.com> References: <20180507083807.28792-1-mszeredi@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Implement stacked mmap. Signed-off-by: Miklos Szeredi --- fs/overlayfs/file.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index 419aa3f9967b..b75ee0a3655e 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -252,6 +252,33 @@ static int ovl_fsync(struct file *file, loff_t start, loff_t end, int datasync) return ret; } +static int ovl_mmap(struct file *file, struct vm_area_struct *vma) +{ + struct fd real; + const struct cred *old_cred; + int ret; + + ret = ovl_real_fdget(file, &real); + if (ret) + return ret; + + /* transfer ref: */ + fput(vma->vm_file); + vma->vm_file = get_file(real.file); + fdput(real); + + if (!vma->vm_file->f_op->mmap) + return -ENODEV; + + old_cred = ovl_override_creds(file_inode(file)->i_sb); + ret = call_mmap(vma->vm_file, vma); + revert_creds(old_cred); + + ovl_file_accessed(file); + + return ret; +} + const struct file_operations ovl_file_operations = { .open = ovl_open, .release = ovl_release, @@ -259,4 +286,5 @@ const struct file_operations ovl_file_operations = { .read_iter = ovl_read_iter, .write_iter = ovl_write_iter, .fsync = ovl_fsync, + .mmap = ovl_mmap, };