summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKrzysztof Opasiak <k.opasiak@samsung.com>2016-12-16 12:58:12 +0100
committerKrzysztof Opasiak <k.opasiak@samsung.com>2017-03-03 14:02:27 +0100
commit7b0ef8b934ac7f122a07491f1352608681c37d41 (patch)
tree576d94987dc35001f185677ddab0ade627f76491 /src
parent6bdf0a3b93f2ad465cb8755b68ae1726152a5711 (diff)
downloadlibusbg-7b0ef8b934ac7f122a07491f1352608681c37d41.tar.gz
libusbg-7b0ef8b934ac7f122a07491f1352608681c37d41.tar.bz2
libusbg-7b0ef8b934ac7f122a07491f1352608681c37d41.zip
libusbgx: common: Add function for reading dev_t from ConfigFS
As some of kernel functions expose details about device node which is assigned to this instance in form: <major>:<minor> Let's add a convenient helper which will read those values form file and convert them to dev_t. Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Diffstat (limited to 'src')
-rw-r--r--src/usbg_common.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/usbg_common.c b/src/usbg_common.c
index 907dbac..99bc99b 100644
--- a/src/usbg_common.c
+++ b/src/usbg_common.c
@@ -339,6 +339,26 @@ int usbg_set_ether_addr(const char *path, const char *name,
return usbg_write_string(path, name, attr, str_addr);
}
+int usbg_get_dev(const char *path, const char *name, const char *attr,
+ void *val)
+{
+ int major, minor;
+ char str_dev[USBG_MAX_STR_LENGTH];
+ int ret;
+
+ ret = usbg_read_string_limited(path, name, attr,
+ str_dev, sizeof(str_dev));
+ if (ret < 0)
+ return ret;
+
+ ret = sscanf(str_dev, "%d:%d", &major, &minor);
+ if (ret < 2)
+ return USBG_ERROR_INVALID_VALUE;
+
+ *(dev_t *)val = makedev(major, minor);
+ return 0;
+}
+
int usbg_get_config_node_int(config_setting_t *root,
const char *node_name, void *val)
{