diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2017-12-04 07:37:24 -0800 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2017-12-06 15:49:56 +0100 |
commit | a92a63473ee2b9079d1f3e6a158b8255074c069a (patch) | |
tree | a9ba88c0ee33752eb0747160f61ea722133ece4c /include/fs.h | |
parent | dbe6452b93d2929e0d9e26f2e7d69448d74c0fe8 (diff) | |
download | barebox-a92a63473ee2b9079d1f3e6a158b8255074c069a.tar.gz barebox-a92a63473ee2b9079d1f3e6a158b8255074c069a.tar.xz |
fs: Introduce devpath_to_name()
Add a simple function to simplify the task of accepting both full path
in "/dev" and just device name as a parameter.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/fs.h')
-rw-r--r-- | include/fs.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/fs.h b/include/fs.h index 5c5fff8701..3d88bfad4a 100644 --- a/include/fs.h +++ b/include/fs.h @@ -10,6 +10,7 @@ #include <driver.h> #include <filetype.h> #include <linux/fs.h> +#include <linux/string.h> #define PATH_MAX 1024 /* include/linux/limits.h */ @@ -171,4 +172,12 @@ void mount_all(void); void fsdev_set_linux_rootarg(struct fs_device_d *fsdev, const char *str); char *path_get_linux_rootarg(const char *path); +static inline const char *devpath_to_name(const char *devpath) +{ + if (devpath && !strncmp(devpath, "/dev/", 5)) + return devpath + 5; + + return devpath; +} + #endif /* __FS_H */ |