core: allow guse created gpiochip nshubin/guse-fix
authorNikita Shubin <nikita.shubin@maquefel.me>
Thu, 13 Mar 2025 08:13:13 +0000 (11:13 +0300)
committerNikita Shubin <nikita.shubin@maquefel.me>
Thu, 13 Mar 2025 08:13:13 +0000 (11:13 +0300)
Add this to check if device was created via guse and allow it.

Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
lib/internal.c

index 56cb8b9b44b6a81735b40b5a191631a00e0e8638..546ab3cac03284c5cfe3a20bda97be3d1a223cc5 100644 (file)
@@ -63,13 +63,14 @@ bool gpiod_check_gpiochip_device(const char *path, bool set_errno)
         * perfectly normal when resolving paths), errno is not cleared.
         */
        errno = 0;
-
-       if (strcmp(sysfsp, "/sys/bus/gpio") != 0) {
-               /* This is a character device but not the one we're after. */
-               errno = ENODEV;
-               goto out_free_sysfsp;
-       }
-
+       if (strcmp(sysfsp, "/sys/class/guse") == 0)
+               goto out_ok;
+       else if (strcmp(sysfsp, "/sys/bus/gpio") == 0)
+               goto out_ok;
+
+       errno = ENODEV;
+       goto out_free_sysfsp;
+out_ok:
        ret = true;
 
 out_free_sysfsp: