*
*/
-#undef DEBUG
+/* define this to enable parsing debugging */
+/* #define DEBUG_PARSER */
#include <stddef.h>
#include <stdlib.h>
{
switch (dev->type) {
case KERNEL_NAME:
- dbg("KERNEL name ='%s'"
+ dbg_parse("KERNEL name ='%s'"
" owner = '%s', group = '%s', mode = '%#o'",
dev->attr.name,
dev->attr.owner, dev->attr.group, dev->attr.mode);
break;
case LABEL:
- dbg("LABEL name = '%s', bus = '%s', sysfs_file = '%s', sysfs_value = '%s'"
+ dbg_parse("LABEL name = '%s', bus = '%s', sysfs_file = '%s', sysfs_value = '%s'"
" owner = '%s', group = '%s', mode = '%#o'",
dev->attr.name, dev->bus, dev->sysfs_file, dev->sysfs_value,
dev->attr.owner, dev->attr.group, dev->attr.mode);
break;
case NUMBER:
- dbg("NUMBER name = '%s', bus = '%s', id = '%s'"
+ dbg_parse("NUMBER name = '%s', bus = '%s', id = '%s'"
" owner = '%s', group = '%s', mode = '%#o'",
dev->attr.name, dev->bus, dev->id,
dev->attr.owner, dev->attr.group, dev->attr.mode);
break;
case TOPOLOGY:
- dbg("TOPOLOGY name = '%s', bus = '%s', place = '%s'"
+ dbg_parse("TOPOLOGY name = '%s', bus = '%s', place = '%s'"
" owner = '%s', group = '%s', mode = '%#o'",
dev->attr.name, dev->bus, dev->place,
dev->attr.owner, dev->attr.group, dev->attr.mode);
break;
case REPLACE:
- dbg("REPLACE name = %s, kernel_name = %s"
+ dbg_parse("REPLACE name = %s, kernel_name = %s"
" owner = '%s', group = '%s', mode = '%#o'",
dev->attr.name, dev->kernel_name,
dev->attr.owner, dev->attr.group, dev->attr.mode);
break;
case CALLOUT:
- dbg("CALLOUT name = '%s', program ='%s', bus = '%s', id = '%s'"
+ dbg_parse("CALLOUT name = '%s', program ='%s', bus = '%s', id = '%s'"
" owner = '%s', group = '%s', mode = '%#o'",
dev->attr.name, dev->exec_program, dev->bus, dev->id,
dev->attr.owner, dev->attr.group, dev->attr.mode);
break;
default:
- dbg("Unknown type of device!");
+ dbg_parse("Unknown type of device!");
}
}
int retval = 0;
struct config_device dev;
- strcpy(filename, NAMEDEV_CONFIG_ROOT NAMEDEV_CONFIG_FILE);
+ strcpy(filename, UDEV_CONFIG_DIR NAMEDEV_CONFIG_FILE);
dbg("opening %s to read as permissions config", filename);
fd = fopen(filename, "r");
if (fd == NULL) {
if (temp == NULL)
break;
- dbg("read %s", temp);
+ dbg_parse("read %s", temp);
/* eat the whitespace at the beginning of the line */
while (isspace(*temp))
continue;
strcpy(dev.attr.name, temp3);
- dbg("LABEL name = '%s', bus = '%s', sysfs_file = '%s', sysfs_value = '%s'", dev.attr.name, dev.bus, dev.sysfs_file, dev.sysfs_value);
+ dbg_parse("LABEL name = '%s', bus = '%s', "
+ "sysfs_file = '%s', sysfs_value = '%s'",
+ dev.attr.name, dev.bus, dev.sysfs_file,
+ dev.sysfs_value);
}
if (strcasecmp(temp2, TYPE_NUMBER) == 0) {
continue;
strcpy(dev.attr.name, temp3);
- dbg("NUMBER name = '%s', bus = '%s', id = '%s'", dev.attr.name, dev.bus, dev.id);
+ dbg_parse("NUMBER name = '%s', bus = '%s', id = '%s'",
+ dev.attr.name, dev.bus, dev.id);
}
if (strcasecmp(temp2, TYPE_TOPOLOGY) == 0) {
continue;
strcpy(dev.attr.name, temp3);
- dbg("TOPOLOGY name = '%s', bus = '%s', place = '%s'", dev.attr.name, dev.bus, dev.place);
+ dbg_parse("TOPOLOGY name = '%s', bus = '%s', place = '%s'",
+ dev.attr.name, dev.bus, dev.place);
}
if (strcasecmp(temp2, TYPE_REPLACE) == 0) {
if (retval)
continue;
strcpy(dev.attr.name, temp3);
- dbg("REPLACE name = %s, kernel_name = %s", dev.attr.name, dev.kernel_name);
+ dbg_parse("REPLACE name = %s, kernel_name = %s",
+ dev.attr.name, dev.kernel_name);
}
if (strcasecmp(temp2, TYPE_CALLOUT) == 0) {
/* number type */
if (retval)
continue;
strcpy(dev.attr.name, temp3);
- dbg("CALLOUT name = %s, program = %s", dev.attr.name, dev.exec_program);
+ dbg_parse("CALLOUT name = %s, program = %s",
+ dev.attr.name, dev.exec_program);
}
retval = add_dev(&dev);
int retval = 0;
struct config_device dev;
- strcpy(filename, NAMEDEV_CONFIG_ROOT NAMEDEV_CONFIG_PERMISSION_FILE);
+ strcpy(filename, UDEV_CONFIG_DIR NAMEDEV_CONFIG_PERMISSION_FILE);
dbg("opening %s to read as permissions config", filename);
fd = fopen(filename, "r");
if (fd == NULL) {
if (temp == NULL)
break;
- dbg("read %s", temp);
+ dbg_parse("read %s", temp);
/* eat the whitespace at the beginning of the line */
while (isspace(*temp))
dev.attr.mode = strtol(temp, NULL, 8);
- dbg("name = %s, owner = %s, group = %s, mode = %#o", dev.attr.name, dev.attr.owner, dev.attr.group, dev.attr.mode);
+ dbg_parse("name = %s, owner = %s, group = %s, mode = %#o",
+ dev.attr.name, dev.attr.owner, dev.attr.group, dev.attr.mode);
retval = add_dev(&dev);
if (retval) {
dbg("add_dev returned with error %d", retval);
attr->mode = -1;
if (class_dev->sysdevice) {
- dbg("class_dev->sysdevice->directory->path = '%s'", class_dev->sysdevice->directory->path);
- dbg("class_dev->sysdevice->bus_id = '%s'", class_dev->sysdevice->bus_id);
+ dbg_parse("class_dev->sysdevice->directory->path = '%s'", class_dev->sysdevice->directory->path);
+ dbg_parse("class_dev->sysdevice->bus_id = '%s'", class_dev->sysdevice->bus_id);
} else {
- dbg("class_dev->name = '%s'", class_dev->name);
+ dbg_parse("class_dev->name = '%s'", class_dev->name);
}
list_for_each(tmp, &config_device_list) {
struct config_device *dev = list_entry(tmp, struct config_device, node);
{
char *temp;
- dbg("LABEL: match file '%s' with value '%s'", dev->sysfs_file, dev->sysfs_value);
+ dbg_parse("LABEL: match file '%s' with value '%s'",
+ dev->sysfs_file, dev->sysfs_value);
/* try to find the attribute in the class device directory */
temp = sysfs_get_value_from_attributes(class_dev->directory->attributes, dev->sysfs_file);
if (temp)
* up in the kernel...
*/
if (strstr(class_dev->directory->path, "block")) {
- dbg("looking at block device...");
+ dbg_parse("looking at block device...");
if (isdigit(class_dev->directory->path[strlen(class_dev->directory->path)-1])) {
char path[SYSFS_PATH_MAX];
struct sysfs_class_device *class_dev_parent;
- dbg("really is a partition...");
+ dbg_parse("really is a partition...");
strcpy(path, class_dev->directory->path);
temp = strrchr(path, '/');
*temp = 0x00;
- dbg("looking for a class device at '%s'", path);
+ dbg_parse("looking for a class device at '%s'", path);
class_dev_parent = sysfs_open_class_device(path);
if (class_dev_parent == NULL) {
- dbg ("sysfs_open_class_device failed");
+ dbg("sysfs_open_class_device at '%s' failed", path);
continue;
}
- dbg("class_dev_parent->name = %s", class_dev_parent->name);
+ dbg_parse("class_dev_parent->name = %s", class_dev_parent->name);
/* try to find the attribute in the class device directory */
temp = sysfs_get_value_from_attributes(class_dev_parent->directory->attributes, dev->sysfs_file);
label_found:
temp[strlen(temp)-1] = 0x00;
- dbg("file '%s' found with value '%s' compare with '%s'", dev->sysfs_file, temp, dev->sysfs_value);
+ dbg_parse("file '%s' found with value '%s' compare with '%s'", dev->sysfs_file, temp, dev->sysfs_value);
if (strcmp(dev->sysfs_value, temp) != 0)
continue;
strcpy(attr->owner, dev->attr.owner);
strcpy(attr->group, dev->attr.group);
}
- dbg("file '%s' with value '%s' becomes '%s' - owner = %s, group = %s, mode = %#o",
+ dbg_parse("file '%s' with value '%s' becomes '%s' - owner = %s, group = %s, mode = %#o",
dev->sysfs_file, dev->sysfs_value, attr->name,
dev->attr.owner, dev->attr.group, dev->attr.mode);
goto done;
continue;
strcpy(path, class_dev->sysdevice->directory->path);
temp = strrchr(path, '/');
- dbg("NUMBER path = '%s'", path);
- dbg("NUMBER temp = '%s' id = '%s'", temp, dev->id);
+ dbg_parse("NUMBER path = '%s'", path);
+ dbg_parse("NUMBER temp = '%s' id = '%s'", temp, dev->id);
if (strstr(temp, dev->id) != NULL) {
found = 1;
} else {
*temp = 0x00;
temp = strrchr(path, '/');
- dbg("NUMBERY temp = '%s' id = '%s'", temp, dev->id);
+ dbg_parse("NUMBERY temp = '%s' id = '%s'", temp, dev->id);
if (strstr(temp, dev->id) != NULL)
found = 1;
}
strcpy(attr->owner, dev->attr.owner);
strcpy(attr->group, dev->attr.group);
}
- dbg("device id '%s' becomes '%s' - owner = %s, group = %s, mode = %#o",
+ dbg_parse("device id '%s' becomes '%s' - owner = %s, group = %s, mode = %#o",
dev->id, attr->name,
dev->attr.owner, dev->attr.group, dev->attr.mode);
goto done;
found = 0;
strcpy(path, class_dev->sysdevice->directory->path);
temp = strrchr(path, '/');
- dbg("TOPOLOGY path = '%s'", path);
- dbg("TOPOLOGY temp = '%s' place = '%s'", temp, dev->place);
+ dbg_parse("TOPOLOGY path = '%s'", path);
+ dbg_parse("TOPOLOGY temp = '%s' place = '%s'", temp, dev->place);
if (strstr(temp, dev->place) != NULL) {
found = 1;
} else {
*temp = 0x00;
temp = strrchr(path, '/');
- dbg("TOPOLOGY temp = '%s' place = '%s'", temp, dev->place);
+ dbg_parse("TOPOLOGY temp = '%s' place = '%s'", temp, dev->place);
if (strstr(temp, dev->place) != NULL)
found = 1;
}
strcpy(attr->owner, dev->attr.owner);
strcpy(attr->group, dev->attr.group);
}
- dbg("device at '%s' becomes '%s' - owner = %s, group = %s, mode = %#o",
+ dbg_parse("device at '%s' becomes '%s' - owner = %s, group = %s, mode = %#o",
dev->place, attr->name,
dev->attr.owner, dev->attr.group, dev->attr.mode);
goto done;
strcpy(attr->owner, dev->attr.owner);
strcpy(attr->group, dev->attr.group);
}
- dbg("device callout '%s' becomes '%s' - owner = %s, group = %s, mode = %#o",
+ dbg_parse("device callout '%s' becomes '%s' - owner = %s, group = %s, mode = %#o",
dev->id, attr->name,
dev->attr.owner, dev->attr.group, dev->attr.mode);
goto done;
strcpy(attr->owner, dev->attr.owner);
strcpy(attr->group, dev->attr.group);
}
- dbg("'%s' becomes '%s' - owner = %s, group = %s, mode = %#o",
+ dbg_parse("'%s' becomes '%s' - owner = %s, group = %s, mode = %#o",
dev->kernel_name, attr->name,
dev->attr.owner, dev->attr.group, dev->attr.mode);
goto done;
case KERNEL_NAME:
break;
default:
- dbg("Unknown type of device '%d'", dev->type);
+ dbg_parse("Unknown type of device '%d'", dev->type);
break;
}
}