summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2021-03-16 10:54:05 +0100
committerBastien Nocera <hadess@hadess.net>2021-03-16 11:05:03 +0100
commite186dac0c69edbb53b1456a25cb076e20eb576d6 (patch)
tree63dcc0352068feac8004b0e411d55c1544c4b416
parent1c7e05b40b92b67dac7a6cd27b70ba08956e4815 (diff)
downloadlibgudev-e186dac0c69edbb53b1456a25cb076e20eb576d6.tar.gz
gudev: Add support for Y/N, y/n as bool sysfs attributes
Which matches the string representation of a "bool" as used in module parameters: " Standard types are: [...] * bool: a bool, values 0/1, y/n, Y/N. " See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/moduleparam.h#n123
-rw-r--r--gudev/gudevdevice.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/gudev/gudevdevice.c b/gudev/gudevdevice.c
index df6ebd1..e14f367 100644
--- a/gudev/gudevdevice.c
+++ b/gudev/gudevdevice.c
@@ -613,7 +613,7 @@ out:
*
* Look up the value for @key on @device and convert it to an
* boolean. This is done by doing a case-insensitive string comparison
- * on the string value against "1" and "true".
+ * on the string value against "1", "true", "Y" and "y".
*
* Returns: The value for @key or %FALSE if @key doesn't exist or
* isn't a #gboolean.
@@ -926,8 +926,12 @@ g_udev_device_get_sysfs_attr_as_boolean (GUdevDevice *device,
if (s == NULL)
goto out;
- if (strcmp (s, "1") == 0 || g_ascii_strcasecmp (s, "true") == 0)
+ if (strcmp (s, "1") == 0 ||
+ g_ascii_strcasecmp (s, "true") == 0 ||
+ g_ascii_strcasecmp (s, "y") == 0) {
result = TRUE;
+ }
+
out:
return result;
}
@@ -1141,7 +1145,7 @@ out:
*
* Look up the sysfs attribute with @name on @device and convert it to an
* boolean. This is done by doing a case-insensitive string comparison
- * on the string value against "1" and "true". This function does
+ * on the string value against "1", "true", "Y" and "y". This function does
* blocking I/O, and updates the sysfs attributes cache.
*
* Returns: The value of the sysfs attribute or %FALSE if there is no such