diff options
author | Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> | 2021-05-17 16:39:01 +0200 |
---|---|---|
committer | Jes Sorensen <jsorensen@fb.com> | 2021-05-26 13:26:30 +0200 |
commit | fcebeb77b18842876295b1a0dbc22d173a709434 (patch) | |
tree | 3bbdf4265ebba5a92ea7d878798f8caa667a590a /platform-intel.c | |
parent | imsm: add generic method to resolve "device" links (diff) | |
download | mdadm-fcebeb77b18842876295b1a0dbc22d173a709434.tar.xz mdadm-fcebeb77b18842876295b1a0dbc22d173a709434.zip |
imsm: add devpath_to_char method
Add method for reading sysfs attributes and propagate it across IMSM code.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'platform-intel.c')
-rw-r--r-- | platform-intel.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/platform-intel.c b/platform-intel.c index 2ed63ed3..94017841 100644 --- a/platform-intel.c +++ b/platform-intel.c @@ -239,6 +239,29 @@ __u16 devpath_to_vendor(const char *dev_path) return id; } +/* Description: Read text value of dev_path/entry field + * Parameters: + * dev_path - sysfs path to the device + * entry - entry to be read + * buf - buffer for read value + * len - size of buf + * verbose - error logging level + */ +int devpath_to_char(const char *dev_path, const char *entry, char *buf, int len, + int verbose) +{ + char path[PATH_MAX]; + + snprintf(path, sizeof(path), "%s/%s", dev_path, entry); + if (load_sys(path, buf, len)) { + if (verbose) + pr_err("Cannot read %s, aborting\n", path); + return 1; + } + + return 0; +} + struct sys_dev *find_intel_devices(void) { struct sys_dev *ahci, *isci, *nvme; |