From patchwork Fri May 5 18:51:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabian Frederick X-Patchwork-Id: 9714223 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 6CB0B6034B for ; Fri, 5 May 2017 18:52:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61A7D28210 for ; Fri, 5 May 2017 18:52:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5698B2861C; Fri, 5 May 2017 18:52:21 +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=-6.9 required=2.0 tests=BAYES_00,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 0E59328210 for ; Fri, 5 May 2017 18:52:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752762AbdEESwF (ORCPT ); Fri, 5 May 2017 14:52:05 -0400 Received: from mailrelay104.isp.belgacom.be ([195.238.20.131]:34490 "EHLO mailrelay104.isp.belgacom.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752735AbdEESwD (ORCPT ); Fri, 5 May 2017 14:52:03 -0400 X-Belgacom-Dynamic: yes IronPort-PHdr: =?us-ascii?q?9a23=3A1/TUzBeabUDf0d3wFarBoLN+lGMj4u6mDksu8pMi?= =?us-ascii?q?zoh2WeGdxc2zbR7h7PlgxGXEQZ/co6odzbGJ4+a9ASQp2tWojjMrSNR0TRgLiM?= =?us-ascii?q?EbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpRZbIBj0NBJ0?= =?us-ascii?q?K+LpAcaSyp3vj6Hhs6HUNixMiSq0Z79/Nl2IrB/W/p0IgJFlArQ8zBrX5H9Jff?= =?us-ascii?q?lGg2RyKhSOnECvyN23+ctN+i5RsvRp2dRNXajgfq87BehWBT4oG3s29cvmqV/J?= =?us-ascii?q?QF3ctTMnTmwKn08QUED+5xbgU8K063Oiuw=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2AJAgDIyAxZ/zfGs1tcHAELAQUBgmpsK?= =?us-ascii?q?IFGjnORDgGVRIIPIYYDhEpAGAEBAQEBAQEBAQEBaiiCMwQBHQEEgmkvI4EaJBO?= =?us-ascii?q?KExGzDDqEEYcJhl+BXosZgkoFkBqNVZMKDZFolDcfOIEKTh4YhGkBglA+Nocmg?= =?us-ascii?q?U8BAQE?= X-IPAS-Result: =?us-ascii?q?A2AJAgDIyAxZ/zfGs1tcHAELAQUBgmpsKIFGjnORDgGVRII?= =?us-ascii?q?PIYYDhEpAGAEBAQEBAQEBAQEBaiiCMwQBHQEEgmkvI4EaJBOKExGzDDqEEYcJh?= =?us-ascii?q?l+BXosZgkoFkBqNVZMKDZFolDcfOIEKTh4YhGkBglA+NocmgU8BAQE?= Received: from 55.198-179-91.adsl-dyn.isp.belgacom.be (HELO localhost.localdomain) ([91.179.198.55]) by relay.skynet.be with ESMTP; 05 May 2017 20:51:56 +0200 From: Fabian Frederick To: Alexander Viro Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, fabf@skynet.be Subject: [PATCH 1/2 linux-next] fs/affs: add rename2 to prepare multiple methods Date: Fri, 5 May 2017 20:51:42 +0200 Message-Id: <20170505185142.26012-1-fabf@skynet.be> X-Mailer: git-send-email 2.9.3 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 Currently AFFS only supports RENAME_NOREPLACE. This patch isolates that method to a static function to prepare RENAME_EXCHANGE addition. Signed-off-by: Fabian Frederick --- fs/affs/affs.h | 2 +- fs/affs/dir.c | 2 +- fs/affs/namei.c | 25 ++++++++++++++++--------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/fs/affs/affs.h b/fs/affs/affs.h index ba26a31..773749b 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h @@ -173,7 +173,7 @@ extern int affs_link(struct dentry *olddentry, struct inode *dir, struct dentry *dentry); extern int affs_symlink(struct inode *dir, struct dentry *dentry, const char *symname); -extern int affs_rename(struct inode *old_dir, struct dentry *old_dentry, +extern int affs_rename2(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry, unsigned int flags); diff --git a/fs/affs/dir.c b/fs/affs/dir.c index f1e7294..591ecd7 100644 --- a/fs/affs/dir.c +++ b/fs/affs/dir.c @@ -35,7 +35,7 @@ const struct inode_operations affs_dir_inode_operations = { .symlink = affs_symlink, .mkdir = affs_mkdir, .rmdir = affs_rmdir, - .rename = affs_rename, + .rename = affs_rename2, .setattr = affs_notify_change, }; diff --git a/fs/affs/namei.c b/fs/affs/namei.c index d9a40b5..49a8dc1 100644 --- a/fs/affs/namei.c +++ b/fs/affs/namei.c @@ -394,21 +394,14 @@ affs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) return affs_add_entry(dir, inode, dentry, ST_LINKFILE); } -int +static int affs_rename(struct inode *old_dir, struct dentry *old_dentry, - struct inode *new_dir, struct dentry *new_dentry, - unsigned int flags) + struct inode *new_dir, struct dentry *new_dentry) { struct super_block *sb = old_dir->i_sb; struct buffer_head *bh = NULL; int retval; - if (flags & ~RENAME_NOREPLACE) - return -EINVAL; - - pr_debug("%s(old=%lu,\"%pd\" to new=%lu,\"%pd\")\n", __func__, - old_dir->i_ino, old_dentry, new_dir->i_ino, new_dentry); - retval = affs_check_name(new_dentry->d_name.name, new_dentry->d_name.len, affs_nofilenametruncate(old_dentry)); @@ -448,6 +441,20 @@ affs_rename(struct inode *old_dir, struct dentry *old_dentry, return retval; } +int affs_rename2(struct inode *old_dir, struct dentry *old_dentry, + struct inode *new_dir, struct dentry *new_dentry, + unsigned int flags) +{ + + if (flags & ~RENAME_NOREPLACE) + return -EINVAL; + + pr_debug("%s(old=%lu,\"%pd\" to new=%lu,\"%pd\")\n", __func__, + old_dir->i_ino, old_dentry, new_dir->i_ino, new_dentry); + + return affs_rename(old_dir, old_dentry, new_dir, new_dentry); +} + static struct dentry *affs_get_parent(struct dentry *child) { struct inode *parent;