From patchwork Mon May 15 15:59:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9727539 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 ECFCD60380 for ; Mon, 15 May 2017 16:00:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5FDC289A2 for ; Mon, 15 May 2017 16:00:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A09762899D; Mon, 15 May 2017 16:00:13 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 8121B2899D for ; Mon, 15 May 2017 16:00:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933713AbdEOP71 (ORCPT ); Mon, 15 May 2017 11:59:27 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:56295 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932368AbdEOP70 (ORCPT ); Mon, 15 May 2017 11:59:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=j3pA3gtsBRAWSaA+ZJBWoNTymRxtcj/McQcidCOb9AI=; b=hoWtOaHCoj93GcsxgOWMImXiK erLrMd13FHvoUlAmVIBMRiSbbzyLKo7/ca6o0nUKvfy09TfHkRX5pLOybP5IPqWtQwdSICwjq+xO8 w+MvHcF9g/iuQfE/dggY2cRHE8TOxwL4PGdIhUTTI6cT7G7KXu5LYvcitoJuSNgSWIOsE310GcITN 0qtoHEz+ODZ5ysGunKtm7QBsQ3Ei2u1YU9w7BQk4ZfBFETmo1BfIa03RlQBF8qKOpWa55TWqU3ZlA xbe77uOfVW+XkL4ppm1tHhIuwg9Z24kS8eGJQuFe/+L85rrzpUoa3unU5/JW3IGtk8NAq69ll14Da IyQ9js9rA==; Received: from clnet-p099-196.ikbnet.co.at ([83.175.99.196] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1dAIP7-0005NS-Ne; Mon, 15 May 2017 15:59:26 +0000 From: Christoph Hellwig To: viro@ZenIV.linux.org.uk Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] fs: expose do_unlinkat for built-in callers Date: Mon, 15 May 2017 17:59:21 +0200 Message-Id: <20170515155922.1847-1-hch@lst.de> X-Mailer: git-send-email 2.11.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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 And make it take a struct filename instead of a user pointer. Signed-off-by: Christoph Hellwig --- fs/internal.h | 1 + fs/namei.c | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/fs/internal.h b/fs/internal.h index 9676fe11c093..c127454fe4af 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -55,6 +55,7 @@ extern void __init chrdev_init(void); extern int user_path_mountpoint_at(int, const char __user *, unsigned int, struct path *); extern int vfs_path_lookup(struct dentry *, struct vfsmount *, const char *, unsigned int, struct path *); +long do_unlinkat(int dfd, struct filename *name); /* * namespace.c diff --git a/fs/namei.c b/fs/namei.c index 6571a5f5112e..75e90a083369 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -4002,10 +4002,9 @@ EXPORT_SYMBOL(vfs_unlink); * writeout happening, and we don't want to prevent access to the directory * while waiting on the I/O. */ -static long do_unlinkat(int dfd, const char __user *pathname) +long do_unlinkat(int dfd, struct filename *name) { int error; - struct filename *name; struct dentry *dentry; struct path path; struct qstr last; @@ -4014,8 +4013,7 @@ static long do_unlinkat(int dfd, const char __user *pathname) struct inode *delegated_inode = NULL; unsigned int lookup_flags = 0; retry: - name = filename_parentat(dfd, getname(pathname), lookup_flags, - &path, &last, &type); + name = filename_parentat(dfd, name, lookup_flags, &path, &last, &type); if (IS_ERR(name)) return PTR_ERR(name); @@ -4057,12 +4055,12 @@ static long do_unlinkat(int dfd, const char __user *pathname) mnt_drop_write(path.mnt); exit1: path_put(&path); - putname(name); if (retry_estale(error, lookup_flags)) { lookup_flags |= LOOKUP_REVAL; inode = NULL; goto retry; } + putname(name); return error; slashes: @@ -4083,12 +4081,12 @@ SYSCALL_DEFINE3(unlinkat, int, dfd, const char __user *, pathname, int, flag) if (flag & AT_REMOVEDIR) return do_rmdir(dfd, pathname); - return do_unlinkat(dfd, pathname); + return do_unlinkat(dfd, getname(pathname)); } SYSCALL_DEFINE1(unlink, const char __user *, pathname) { - return do_unlinkat(AT_FDCWD, pathname); + return do_unlinkat(AT_FDCWD, getname(pathname)); } int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)