#include <errno.h>
#include "libsysfs/sysfs/libsysfs.h"
-#include "libsysfs/dlist.h"
#include "udev_libc_wrapper.h"
#include "udev.h"
#include "udev_utils.h"
#ifdef USE_LOG
-void log_message (int level, const char *format, ...)
+void log_message (int priority, const char *format, ...)
{
va_list args;
+ if (priority > udev_log_priority)
+ return;
+
va_start(args, format);
- vsyslog(level, format, args);
+ vsyslog(priority, format, args);
va_end(args);
}
#endif
len--;
}
if (len == 0)
- printf(" SYSFS{%s}=\"%s\"\n", attr->name, value);
+ printf(" SYSFS{%s}==\"%s\"\n", attr->name, value);
}
}
printf("\n");
/* get the class dev */
class_dev = sysfs_open_class_device_path(path);
if (class_dev == NULL) {
- printf("couldn't get the class device\n");
+ fprintf(stderr, "couldn't get the class device\n");
return -1;
}
/* open sysfs class device directory and print all attributes */
printf(" looking at class device '%s':\n", class_dev->path);
- printf(" SUBSYSTEM=\"%s\"\n", class_dev->classname);
+ printf(" SUBSYSTEM==\"%s\"\n", class_dev->classname);
attr_list = sysfs_get_classdev_attributes(class_dev);
if (attr_list == NULL) {
- printf("couldn't open class device directory\n");
+ fprintf(stderr, "couldn't open class device directory\n");
retval = -1;
goto exit;
}
while (sysfs_dev != NULL) {
attr_list = sysfs_get_device_attributes(sysfs_dev);
if (attr_list == NULL) {
- printf("couldn't open device directory\n");
+ fprintf(stderr, "couldn't open device directory\n");
retval = -1;
goto exit;
}
printf(" looking at the device chain at '%s':\n", sysfs_dev->path);
- printf(" BUS=\"%s\"\n", sysfs_dev->bus);
- printf(" ID=\"%s\"\n", sysfs_dev->bus_id);
- printf(" DRIVER=\"%s\"\n", sysfs_dev->driver_name);
+ printf(" BUS==\"%s\"\n", sysfs_dev->bus);
+ printf(" ID==\"%s\"\n", sysfs_dev->bus_id);
+ printf(" DRIVER==\"%s\"\n", sysfs_dev->driver_name);
/* open sysfs device directory and print all attributes */
print_all_attributes(attr_list);
break;
}
- printf("unknown query type\n");
+ fprintf(stderr, "unknown query type\n");
retval = 1;
goto exit;
}
retval = udev_db_get_device(&udev, pos);
if (retval != 0) {
- printf("device not found in database\n");
+ fprintf(stderr, "device not found in database\n");
goto exit;
}
goto print;
retval = udev_db_search_name(devpath, sizeof(devpath), pos);
if (retval != 0) {
- printf("device not found in database\n");
+ fprintf(stderr, "device not found in database\n");
goto exit;
}
udev_db_get_device(&udev, devpath);
goto print;
}
- printf("query needs device path(-p) or node name(-n) specified\n");
+ fprintf(stderr, "query needs device path(-p) or node name(-n) specified\n");
retval = 3;
goto exit;
if (attributes) {
if (path[0] == '\0') {
- printf("attribute walk on device chain needs path(-p) specified\n");
+ fprintf(stderr, "attribute walk on device chain needs path(-p) specified\n");
retval = 4;
goto exit;
} else {
}
help:
- printf("Usage: udevinfo [-anpqrVh]\n"
+ fprintf(stderr, "Usage: udevinfo [-anpqrVh]\n"
" -q TYPE query database for the specified value:\n"
" 'name' name of device node\n"
" 'symlink' pointing to node\n"