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 /lib | |
parent | 3e06eceaf441cfbe02dc4c436dc77ac28a0e5cb9 (diff) | |
download | barebox-c41dfceb951b795357a014205faebac2853f7c02.tar.gz |
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 'lib')
-rw-r--r-- | lib/libgen.c | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/lib/libgen.c b/lib/libgen.c index 08ef3528af..61a8670fb5 100644 --- a/lib/libgen.c +++ b/lib/libgen.c @@ -17,23 +17,11 @@ #include <common.h> #include <libgen.h> +#include <linux/string.h> char *basename (char *path) { - char *fname; - - if(!strchr(path, '/')) - return path; - - fname = path + strlen(path) - 1; - while (fname >= path) { - if (*fname == '/') { - fname++; - break; - } - fname--; - } - return fname; + return (char *)kbasename(path); } EXPORT_SYMBOL(basename); |