From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9vxz-0002iJ-Ot for barebox@lists.infradead.org; Tue, 09 Oct 2018 17:38:52 +0000 Received: by mail-pg1-x532.google.com with SMTP id r9-v6so1159961pgv.6 for ; Tue, 09 Oct 2018 10:38:33 -0700 (PDT) From: Andrey Smirnov Date: Tue, 9 Oct 2018 10:37:56 -0700 Message-Id: <20181009173805.26181-9-andrew.smirnov@gmail.com> In-Reply-To: <20181009173805.26181-1-andrew.smirnov@gmail.com> References: <20181009173805.26181-1-andrew.smirnov@gmail.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH v2 08/17] linux: string: Port kbasename() To: barebox@lists.infradead.org Cc: Andrey Smirnov Signed-off-by: Andrey Smirnov --- include/linux/string.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/string.h b/include/linux/string.h index 3418b4fbe..c9823dab8 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -111,6 +111,18 @@ extern char *strim(char *); void *memchr_inv(const void *start, int c, size_t bytes); +/** + * kbasename - return the last part of a pathname. + * + * @path: path to extract the filename from. + */ +static inline const char *kbasename(const char *path) +{ + const char *tail = strrchr(path, '/'); + return tail ? tail + 1 : path; +} + + #ifdef __cplusplus } #endif -- 2.17.1 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox