From patchwork Thu Aug 20 18:19:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Andreas_Gr=C3=BCnbacher?= X-Patchwork-Id: 7046461 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DC4869F372 for ; Thu, 20 Aug 2015 18:22:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1583D20569 for ; Thu, 20 Aug 2015 18:22:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0DCDC2054D for ; Thu, 20 Aug 2015 18:22:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751754AbbHTSWW (ORCPT ); Thu, 20 Aug 2015 14:22:22 -0400 Received: from mail-wi0-f179.google.com ([209.85.212.179]:33164 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751608AbbHTSWV (ORCPT ); Thu, 20 Aug 2015 14:22:21 -0400 Received: by wijp15 with SMTP id p15so513413wij.0; Thu, 20 Aug 2015 11:22:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qI21fjO6StcWC6gsgJxM8phwwgyGAs7Y5XWZbi8USMA=; b=mpUMHc2DDGlYQZSlblz58go9LlVaViFX7qWCSWxDwApGYP+0f3VjD7OZeElsRvLAOC PVPrT3N+rCQuOxO9H6aJpymbQOncRcZLwavmWMHJZlQVGlkbdjddph6TomnFq+oqjt31 DYI8FCJ+0SZ46VChqQtKcLILqWuV+lEb5iLu8gWkwj6Wh0xiahBHNvyLGW2GANMxnRKT XwKd7U0Hx8I3Fx1NLFQIakr1o07H7KwaILT5+c2bCLWGpPdT/dl4BcYcyQYT/K5UvuEv c9PLUpzxvcwCgJRDm5z6OU9PNHVOC2Lavz/M7yGe6dQMWc8zNvT5vlMdAC62w9aIyvVq 1NbA== X-Received: by 10.194.191.164 with SMTP id gz4mr8432193wjc.21.1440094940152; Thu, 20 Aug 2015 11:22:20 -0700 (PDT) Received: from nuc.home.com (p549817FE.dip0.t-ipconnect.de. [84.152.23.254]) by smtp.gmail.com with ESMTPSA id ma4sm6598334wjb.38.2015.08.20.11.22.04 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Aug 2015 11:22:19 -0700 (PDT) From: Andreas Gruenbacher X-Google-Original-From: Andreas Gruenbacher To: Alexander Viro , Christoph Hellwig , Eric Paris , "Aneesh Kumar K.V" , linux-fsdevel@vger.kernel.org, David Quigley , "J. Bruce Fields" Cc: linux-security-module@vger.kernel.org, cluster-devel@redhat.com Subject: [RFC 06/11] lib: Move strcmp_prefix into string.c Date: Thu, 20 Aug 2015 20:19:53 +0200 Message-Id: <1440094798-1411-7-git-send-email-agruenba@redhat.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1440094798-1411-1-git-send-email-agruenba@redhat.com> References: <1440094798-1411-1-git-send-email-agruenba@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move strcmp_prefix from fs/xattr.c into lib/string.h to make it available elsewhere; export it to modules. Signed-off-by: Andreas Gruenbacher --- fs/xattr.c | 11 ----------- include/linux/string.h | 1 + lib/string.c | 16 ++++++++++++++++ 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/fs/xattr.c b/fs/xattr.c index efa16ce..9584808 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -663,17 +663,6 @@ SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name) return error; } - -static const char * -strcmp_prefix(const char *a, const char *a_prefix) -{ - while (*a_prefix && *a == *a_prefix) { - a++; - a_prefix++; - } - return *a_prefix ? NULL : a; -} - /* * In order to implement different sets of xattr operations for each xattr * prefix with the generic xattr API, a filesystem should create a diff --git a/include/linux/string.h b/include/linux/string.h index a8d90db..edc155d 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -37,6 +37,7 @@ extern size_t strlcat(char *, const char *, __kernel_size_t); #ifndef __HAVE_ARCH_STRCMP extern int strcmp(const char *,const char *); #endif +extern const char *strcmp_prefix(const char *, const char *); #ifndef __HAVE_ARCH_STRNCMP extern int strncmp(const char *,const char *,__kernel_size_t); #endif diff --git a/lib/string.c b/lib/string.c index 13d1e84..697572d 100644 --- a/lib/string.c +++ b/lib/string.c @@ -246,6 +246,22 @@ int strcmp(const char *cs, const char *ct) EXPORT_SYMBOL(strcmp); #endif +/** + * strcmp_prefix - check string for given prefix + * + * Returns @str + strlen(@prefix) if @str has the given @prefix, and NULL + * otherwise. + */ +const char *strcmp_prefix(const char *str, const char *prefix) +{ + while (*prefix && *str == *prefix) { + str++; + prefix++; + } + return *prefix ? NULL : str; +} +EXPORT_SYMBOL(strcmp_prefix); + #ifndef __HAVE_ARCH_STRNCMP /** * strncmp - Compare two length-limited strings