From a92a63473ee2b9079d1f3e6a158b8255074c069a Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Mon, 4 Dec 2017 07:37:24 -0800 Subject: 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 Signed-off-by: Sascha Hauer --- include/fs.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/fs.h') 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 #include #include +#include #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 */ -- cgit v1.2.3