@@ -19,6 +19,8 @@
#include <linux/backing-dev-defs.h>
#include <linux/slab.h>
+#define BDI_DEV_NAME_LEN 32
+
static inline struct backing_dev_info *bdi_get(struct backing_dev_info *bdi)
{
kref_get(&bdi->refcnt);
@@ -514,4 +516,21 @@ static inline const char *bdi_dev_name(struct backing_dev_info *bdi)
return dev_name(bdi->dev);
}
+/**
+ * bdi_get_dev_name - copy bdi device name into buffer
+ * @bdi: target bdi
+ * @dname: Where to copy the device name to
+ * @len: size of destination buffer
+ */
+static inline char *bdi_get_dev_name(struct backing_dev_info *bdi,
+ char *dname, int len)
+{
+ if (!bdi || !bdi->dev) {
+ strlcpy(dname, bdi_unknown_name, len);
+ return NULL;
+ }
+
+ strlcpy(dname, dev_name(bdi->dev), len);
+ return dname;
+}
#endif /* _LINUX_BACKING_DEV_H */
We add this new function to copy device name into buffer. This is prepare for following patch. Signed-off-by: Yufen Yu <yuyufen@huawei.com> --- include/linux/backing-dev.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)