From patchwork Thu Apr 12 15:08:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10338803 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 592CC604D4 for ; Thu, 12 Apr 2018 15:21:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 485CE2835B for ; Thu, 12 Apr 2018 15:21:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4693A28384; Thu, 12 Apr 2018 15:21:29 +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=unavailable 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 AD01A283C8 for ; Thu, 12 Apr 2018 15:21:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753103AbeDLPUi (ORCPT ); Thu, 12 Apr 2018 11:20:38 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:53010 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753100AbeDLPIt (ORCPT ); Thu, 12 Apr 2018 11:08:49 -0400 Received: by mail-wm0-f65.google.com with SMTP id g8so12316469wmd.2 for ; Thu, 12 Apr 2018 08:08:48 -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=BBauazHZ3czbbSflHS/x8wcRy7H2UaFOYvWhsOIkCw4=; b=APMok0DK8QJ8jFF78VHJy3r2QQBCMtaeGUMFdwzcoKZEj6WzWZ/XW87IjaBjdOMvE5 wA9Gzv61XhxoU+BfBmc/lJqFynNM2ALx93hNFqLvqK2g3iAG1qKEidz41qpPTMDuPWxw D7P5/qNIiDzN7/3dSYJtKe7Dzp+2vZrvvBjvAhmAIBpoOeRYj9VaWuBbHRUdKu+KsyD0 wiCmLksa1fcaaeoF6mQJG5YYCAHOBlRiyqA118j5HEwNvG17SXbCR4nUDFQCAElwoOvg 665zSLW9hlEezoYpOXcsE6gDk5zN8e5buuQWBdNFAklI88a9+5eav1ShnbWPCjQ7JIFO EGjQ== X-Gm-Message-State: ALQs6tBuGyU2eA0BgP62bLZlhVSdCV3LfkaSp9FU37XWRvz0/Ny0QpUo GvdmE+2Mi/FH/vTTSCiJsNYKdlUWgPM= X-Google-Smtp-Source: AIpwx4/TUtJY5EbSFJUpKT321lkp+WuCNrOzXueCp6zHgOZUy6ZWJBC2C7KXn89OgqXLHYUQDSPUcw== X-Received: by 10.28.108.20 with SMTP id h20mr1063338wmc.69.1523545727904; Thu, 12 Apr 2018 08:08:47 -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.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Apr 2018 08:08:47 -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 14/35] ovl: readd mmap Date: Thu, 12 Apr 2018 17:08:05 +0200 Message-Id: <20180412150826.20988-15-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-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 4417527667ff..f1cc2fdc62c1 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -241,6 +241,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_file(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, @@ -248,4 +275,5 @@ const struct file_operations ovl_file_operations = { .read_iter = ovl_read_iter, .write_iter = ovl_write_iter, .fsync = ovl_fsync, + .mmap = ovl_mmap, };