[PATCH 2/4] fs: Introduce devpath_to_name()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux