diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2018-10-16 12:15:43 -0700 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-10-18 09:02:24 +0200 |
commit | c41dfceb951b795357a014205faebac2853f7c02 (patch) | |
tree | ca80fb7dc8912779b3143b9d163e61fb1aa9fe3f /include | |
parent | 3e06eceaf441cfbe02dc4c436dc77ac28a0e5cb9 (diff) | |
download | barebox-c41dfceb951b795357a014205faebac2853f7c02.tar.gz barebox-c41dfceb951b795357a014205faebac2853f7c02.tar.xz |
linux: string: Port kbasename()
Port kbasename() from Linux and use it to implement basename() we
already have.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/string.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/linux/string.h b/include/linux/string.h index 3418b4fbe4..c9823dab8e 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 |