[PATCH 2/4] fs: Introduce devpath_to_name()
Andrey Smirnov
andrew.smirnov at gmail.com
Mon Dec 4 07:37:24 PST 2017
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 at gmail.com>
---
include/fs.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/include/fs.h b/include/fs.h
index d7fa7714b..79ae404bb 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 */
@@ -151,4 +152,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 */
--
2.14.3
More information about the barebox
mailing list