+static bool device_has_attribute(const char *path, const char *attr,
+ mode_t mode)
+{
+ char filename[PATH_SIZE];
+ struct stat statbuf;
+
+ strlcpy(filename, path, sizeof(filename));
+ strlcat(filename, attr, sizeof(filename));
+
+ if (stat(filename, &statbuf) < 0)
+ return false;
+
+ if (!(statbuf.st_mode & mode))
+ return false;
+
+ return true;
+}