goto err;
}
- info(uctrl->udev, "created ctrl_msg %p (%i)\n", uctrl_msg, uctrl_msg->ctrl_msg_wire.type);
+ dbg(uctrl->udev, "created ctrl_msg %p (%i)\n", uctrl_msg, uctrl_msg->ctrl_msg_wire.type);
return uctrl_msg;
err:
udev_ctrl_msg_unref(uctrl_msg);
ctrl_msg->refcount--;
if (ctrl_msg->refcount > 0)
return;
- info(ctrl_msg->uctrl->udev, "release ctrl_msg %p\n", ctrl_msg);
+ dbg(ctrl_msg->uctrl->udev, "release ctrl_msg %p\n", ctrl_msg);
free(ctrl_msg);
}
devpath_to_db_path(udev_device->udev, udev_device->devpath, filename, sizeof(filename));
if (lstat(filename, &stats) != 0) {
- info(udev_device->udev, "no db file to read %s: %m\n", filename);
+ dbg(udev_device->udev, "no db file to read %s: %m\n", filename);
return -1;
}
if ((stats.st_mode & S_IFMT) == S_IFLNK) {
if (target_len > 0)
target[target_len] = '\0';
else {
- info(udev_device->udev, "error reading db link %s: %m\n", filename);
+ dbg(udev_device->udev, "error reading db link %s: %m\n", filename);
return -1;
}
f = fopen(filename, "r");
if (f == NULL) {
- info(udev_device->udev, "error reading db file %s: %m\n", filename);
+ dbg(udev_device->udev, "error reading db file %s: %m\n", filename);
return -1;
}
while (fgets(line, sizeof(line), f)) {
udev_device_add_property(udev_device,
udev_list_entry_get_name(list_entry),
udev_list_entry_get_value(list_entry));
- info(udev_device->udev, "udev_device: %p created\n", udev_device);
+ dbg(udev_device->udev, "udev_device: %p created\n", udev_device);
return udev_device;
}
subdir = &syspath[len+1];
pos = strrchr(subdir, '/');
if (pos == NULL || pos < &subdir[2]) {
- info(udev, "not a subdir :%s\n", syspath);
+ dbg(udev, "not a subdir :%s\n", syspath);
return NULL;
}
util_strlcpy(file, path, sizeof(file));
util_strlcat(file, "/uevent", sizeof(file));
if (stat(file, &statbuf) != 0) {
- info(udev, "not a device: %s\n", syspath);
+ dbg(udev, "not a device: %s\n", syspath);
return NULL;
}
} else {
/* everything else just needs to be a directory */
if (stat(path, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode)) {
- info(udev, "directory not found: %s\n", syspath);
+ dbg(udev, "directory not found: %s\n", syspath);
return NULL;
}
}
udev_device->parent_device = device_new_from_parent(udev_device);
}
if (udev_device->parent_device != NULL)
- info(udev_device->udev, "returning existing parent %p\n", udev_device->parent_device);
+ dbg(udev_device->udev, "returning existing parent %p\n", udev_device->parent_device);
return udev_device->parent_device;
}
udev_list_cleanup_entries(udev_device->udev, &udev_device->sysattr_list);
free(udev_device->envp);
free(udev_device->monitor_buf);
- info(udev_device->udev, "udev_device: %p released\n", udev_device);
+ dbg(udev_device->udev, "udev_device: %p released\n", udev_device);
free(udev_device);
}
/* look for possibly already cached result */
udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_device->sysattr_list)) {
if (strcmp(udev_list_entry_get_name(list_entry), sysattr) == 0) {
- info(udev_device->udev, "got '%s' (%s) from cache\n",
- sysattr, udev_list_entry_get_value(list_entry));
+ dbg(udev_device->udev, "got '%s' (%s) from cache\n",
+ sysattr, udev_list_entry_get_value(list_entry));
return udev_list_entry_get_value(list_entry);
}
}
util_strlcat(path, sysattr, sizeof(path));
if (lstat(path, &statbuf) != 0) {
- info(udev_device->udev, "no attribute '%s', keep negative entry\n", path);
+ dbg(udev_device->udev, "no attribute '%s', keep negative entry\n", path);
udev_list_entry_add(udev_device->udev, &udev_device->sysattr_list, sysattr, NULL, 0, 0);
goto out;
}
pos = strrchr(target, '/');
if (pos != NULL) {
pos = &pos[1];
- info(udev_device->udev, "cache '%s' with link value '%s'\n", sysattr, pos);
+ dbg(udev_device->udev, "cache '%s' with link value '%s'\n", sysattr, pos);
list_entry = udev_list_entry_add(udev_device->udev, &udev_device->sysattr_list, sysattr, pos, 0, 0);
val = udev_list_entry_get_value(list_entry);
}
/* read attribute value */
fd = open(path, O_RDONLY);
if (fd < 0) {
- info(udev_device->udev, "attribute '%s' can not be opened\n", path);
+ dbg(udev_device->udev, "attribute '%s' can not be opened\n", path);
goto out;
}
size = read(fd, value, sizeof(value));
/* got a valid value, store it in cache and return it */
value[size] = '\0';
util_remove_trailing_chars(value, '\n');
- info(udev_device->udev, "'%s' has attribute value '%s'\n", path, value);
+ dbg(udev_device->udev, "'%s' has attribute value '%s'\n", path, value);
list_entry = udev_list_entry_add(udev_device->udev, &udev_device->sysattr_list, sysattr, value, 0, 0);
val = udev_list_entry_get_value(list_entry);
out:
udev_device->envp[i] = NULL;
udev_device->monitor_buf_len = bufpos;
udev_device->envp_uptodate = 1;
- info(udev_device->udev, "filled envp/monitor buffer, %u properties, %zu bytes\n", i, bufpos);
+ dbg(udev_device->udev, "filled envp/monitor buffer, %u properties, %zu bytes\n", i, bufpos);
return 0;
}
len = strlen(udev_get_sys_path(udev));
for (i = 0; delay_device_list[i] != NULL; i++) {
if (strstr(&syspath[len], delay_device_list[i]) != NULL) {
- info(udev, "delaying: %s\n", syspath);
+ dbg(udev, "delaying: %s\n", syspath);
return 1;
}
}
util_strlcat(base, "/subsystem", sizeof(base));
if (stat(base, &statbuf) == 0) {
/* we have /subsystem/, forget all the old stuff */
- info(udev, "searching '/subsystem/*/devices/*' dir\n");
+ dbg(udev, "searching '/subsystem/*/devices/*' dir\n");
scan_dir(udev_enumerate, "subsystem", "devices", NULL);
} else {
- info(udev, "searching '/bus/*/devices/*' dir\n");
+ dbg(udev, "searching '/bus/*/devices/*' dir\n");
scan_dir(udev_enumerate, "bus", "devices", NULL);
- info(udev, "searching '/class/*' dir\n");
+ dbg(udev, "searching '/class/*' dir\n");
scan_dir(udev_enumerate, "class", NULL, NULL);
/* if block isn't a class, scan /block/ */
util_strlcpy(base, udev_get_sys_path(udev), sizeof(base));
util_strlcat(base, "/class/block", sizeof(base));
if (stat(base, &statbuf) != 0) {
if (match_subsystem(udev_enumerate, "block")) {
- info(udev, "searching '/block/*' dir\n");
+ dbg(udev, "searching '/block/*' dir\n");
/* scan disks */
scan_dir_and_add_devices(udev_enumerate, "block", NULL, NULL);
/* scan partitions */
- info(udev, "searching '/block/*/*' dir\n");
+ dbg(udev, "searching '/block/*/*' dir\n");
scan_dir(udev_enumerate, "block", NULL, "block");
}
}
else
subsysdir = "bus";
if (match_subsystem(udev_enumerate, "subsystem")) {
- info(udev, "searching '%s/*' dir\n", subsysdir);
+ dbg(udev, "searching '%s/*' dir\n", subsysdir);
scan_dir_and_add_devices(udev_enumerate, subsysdir, NULL, NULL);
}
if (match_subsystem(udev_enumerate, "drivers")) {
- info(udev, "searching '%s/*/drivers/*' dir\n", subsysdir);
+ dbg(udev, "searching '%s/*/drivers/*' dir\n", subsysdir);
scan_dir(udev_enumerate, subsysdir, "drivers", "drivers");
}
return 0;
if (unique)
udev_list_entry_foreach(entry_loop, udev_list_get_entry(list)) {
if (strcmp(entry_loop->name, name) == 0) {
- info(udev, "'%s' is already in the list\n", name);
+ dbg(udev, "'%s' is already in the list\n", name);
free(entry_loop->value);
if (value == NULL) {
entry_loop->value = NULL;
- info(udev, "'%s' value unset\n", name);
+ dbg(udev, "'%s' value unset\n", name);
return entry_loop;
}
entry_loop->value = strdup(value);
if (entry_loop->value == NULL)
return NULL;
- info(udev, "'%s' value replaced with '%s'\n", name, value);
+ dbg(udev, "'%s' value replaced with '%s'\n", name, value);
return entry_loop;
}
}
free(udev_monitor);
return NULL;
}
- info(udev, "monitor %p created with '%s'\n", udev_monitor, socket_path);
+ dbg(udev, "monitor %p created with '%s'\n", udev_monitor, socket_path);
return udev_monitor;
}
udev_monitor->snl.nl_pid = getpid();
udev_monitor->snl.nl_groups = 1;
- info(udev, "monitor %p created with NETLINK_KOBJECT_UEVENT\n", udev_monitor);
+ dbg(udev, "monitor %p created with NETLINK_KOBJECT_UEVENT\n", udev_monitor);
return udev_monitor;
}
err(udev_monitor->udev, "bind failed: %m\n");
return err;
}
- info(udev_monitor->udev, "monitor %p listening on netlink\n", udev_monitor);
+ dbg(udev_monitor->udev, "monitor %p listening on netlink\n", udev_monitor);
} else if (udev_monitor->sun.sun_family != 0) {
err = bind(udev_monitor->sock, (struct sockaddr *)&udev_monitor->sun, udev_monitor->addrlen);
if (err < 0) {
}
/* enable receiving of the sender credentials */
setsockopt(udev_monitor->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
- info(udev_monitor->udev, "monitor %p listening on socket\n", udev_monitor);
+ dbg(udev_monitor->udev, "monitor %p listening on socket\n", udev_monitor);
}
return 0;
}
return;
if (udev_monitor->sock >= 0)
close(udev_monitor->sock);
- info(udev_monitor->udev, "monitor %p released\n", udev_monitor);
+ dbg(udev_monitor->udev, "monitor %p released\n", udev_monitor);
free(udev_monitor);
}
return 0;
buf[len-1] = '\0';
seqnum = strtoull(buf, NULL, 10);
- info(udev_queue->udev, "seqnum=%llu\n", seqnum);
+ dbg(udev_queue->udev, "seqnum=%llu\n", seqnum);
return seqnum;
}
return 0;
buf[len-1] = '\0';
seqnum = strtoull(buf, NULL, 10);
- info(udev_queue->udev, "seqnum=%llu\n", seqnum);
+ dbg(udev_queue->udev, "seqnum=%llu\n", seqnum);
udev_queue->last_seen_udev_seqnum = seqnum;
return seqnum;
}
util_strlcpy(queuename, udev_get_dev_path(udev_queue->udev), sizeof(queuename));
util_strlcat(queuename, "/.udev/queue", sizeof(queuename));
if (stat(queuename, &statbuf) == 0) {
- info(udev_queue->udev, "queue is not empty\n");
+ dbg(udev_queue->udev, "queue is not empty\n");
return 0;
}
seqnum_kernel = udev_queue_get_kernel_seqnum(udev_queue);
if (seqnum_kernel <= udev_queue->last_seen_udev_seqnum) {
- info(udev_queue->udev, "queue is empty\n");
+ dbg(udev_queue->udev, "queue is empty\n");
return 1;
}
udev_queue_get_udev_seqnum(udev_queue);
if (seqnum_kernel <= udev_queue->last_seen_udev_seqnum) {
- info(udev_queue->udev, "queue is empty\n");
+ dbg(udev_queue->udev, "queue is empty\n");
return 1;
}
- info(udev_queue->udev, "queue is empty, but kernel events still pending [%llu]<->[%llu]\n",
+ dbg(udev_queue->udev, "queue is empty, but kernel events still pending [%llu]<->[%llu]\n",
seqnum_kernel, udev_queue->last_seen_udev_seqnum);
return 0;
}
udev_get_dev_path(udev_queue->udev), seqnum);
if (stat(filename, &statbuf) == 0)
return 0;
- info(udev_queue->udev, "seqnum: %llu finished\n", seqnum);
+ dbg(udev_queue->udev, "seqnum: %llu finished\n", seqnum);
return 1;
}
if (len < 0 || len >= (ssize_t)(sizeof(syspath)-syslen))
continue;
syspath[syslen + len] = '\0';
- info(udev_queue->udev, "found '%s' [%s]\n", syspath, dent->d_name);
+ dbg(udev_queue->udev, "found '%s' [%s]\n", syspath, dent->d_name);
udev_list_entry_add(udev_queue->udev, &udev_queue->queue_list, syspath, dent->d_name, 0, 0);
}
closedir(dir);
if (len < 0 || len >= (ssize_t)(sizeof(syspath)-syslen))
continue;
syspath[syslen + len] = '\0';
- info(udev_queue->udev, "found '%s' [%s]\n", syspath, dent->d_name);
+ dbg(udev_queue->udev, "found '%s' [%s]\n", syspath, dent->d_name);
util_strlcpy(filename, syspath, sizeof(filename));
util_strlcat(filename, "/uevent", sizeof(filename));
if (stat(filename, &statbuf) != 0)
if (pos == NULL)
return -1;
pos = &pos[1];
- info(udev, "resolved link to: '%s'\n", pos);
+ dbg(udev, "resolved link to: '%s'\n", pos);
return util_strlcpy(value, pos, size);
}
if (udev->dev_path == NULL || udev->sys_path == NULL)
goto err;
- info(udev, "context %p created\n", udev);
- info(udev, "log_priority=%d\n", udev->log_priority);
- info(udev, "config_file='%s'\n", config_file);
- info(udev, "dev_path='%s'\n", udev->dev_path);
- info(udev, "sys_path='%s'\n", udev->sys_path);
+ dbg(udev, "context %p created\n", udev);
+ dbg(udev, "log_priority=%d\n", udev->log_priority);
+ dbg(udev, "config_file='%s'\n", config_file);
+ dbg(udev, "dev_path='%s'\n", udev->dev_path);
+ dbg(udev, "sys_path='%s'\n", udev->sys_path);
if (udev->rules_path != NULL)
- info(udev, "rules_path='%s'\n", udev->rules_path);
+ dbg(udev, "rules_path='%s'\n", udev->rules_path);
free(config_file);
return udev;
err:
free(udev->dev_path);
free(udev->sys_path);
free(udev->rules_path);
- info(udev, "context %p released\n", udev);
+ dbg(udev, "context %p released\n", udev);
free(udev);
}
buf = realloc(rules->buf, rules->buf_max + add);
if (buf == NULL)
return -1;
- info(rules->udev, "extend buffer from %zu to %zu\n", rules->buf_max, rules->buf_max + add);
+ dbg(rules->udev, "extend buffer from %zu to %zu\n", rules->buf_max, rules->buf_max + add);
rules->buf = buf;
rules->buf_max += add;
}
tokens = realloc(rules->tokens, (rules->token_max + add ) * sizeof(struct token));
if (tokens == NULL)
return -1;
- info(rules->udev, "extend tokens from %u to %u\n", rules->token_max, rules->token_max + add);
+ dbg(rules->udev, "extend tokens from %u to %u\n", rules->token_max, rules->token_max + add);
rules->tokens = tokens;
rules->token_max += add;
}
uids = realloc(rules->uids, (rules->uids_max + add ) * sizeof(struct uid_gid));
if (uids == NULL)
return uid;
- info(rules->udev, "extend uids from %u to %u\n", rules->uids_max, rules->uids_max + add);
+ dbg(rules->udev, "extend uids from %u to %u\n", rules->uids_max, rules->uids_max + add);
rules->uids = uids;
rules->uids_max += add;
}
gids = realloc(rules->gids, (rules->gids_max + add ) * sizeof(struct uid_gid));
if (gids == NULL)
return gid;
- info(rules->udev, "extend gids from %u to %u\n", rules->gids_max, rules->gids_max + add);
+ dbg(rules->udev, "extend gids from %u to %u\n", rules->gids_max, rules->gids_max + add);
rules->gids = gids;
rules->gids_max += add;
}
val++;
}
- info(udev, "adding '%s'='%s'\n", key, val);
+ dbg(udev, "adding '%s'='%s'\n", key, val);
/* handle device, renamed by external tool, returning new path */
if (strcmp(key, "DEVPATH") == 0) {
/* offset 0 is always '\0' */
rules->buf[0] = '\0';
rules->buf_cur = 1;
- info(udev, "prealloc %zu bytes tokens (%u * %zu bytes), %zu bytes buffer\n",
- rules->token_max * sizeof(struct token), rules->token_max, sizeof(struct token), rules->buf_max);
+ dbg(udev, "prealloc %zu bytes tokens (%u * %zu bytes), %zu bytes buffer\n",
+ rules->token_max * sizeof(struct token), rules->token_max, sizeof(struct token), rules->buf_max);
if (udev_get_rules_path(udev) != NULL) {
/* custom rules location for testing */
attr_subst_subdir(filename, sizeof(filename));
match = (stat(filename, &statbuf) == 0);
- info(event->udev, "'%s' %s", filename, match ? "exists\n" : "does not exist\n");
+ dbg(event->udev, "'%s' %s", filename, match ? "exists\n" : "does not exist\n");
if (match && cur->key.mode > 0) {
match = ((statbuf.st_mode & cur->key.mode) > 0);
- info(event->udev, "'%s' has mode=%#o and %s %#o\n", filename, statbuf.st_mode,
- match ? "matches" : "does not match", cur->key.mode);
+ dbg(event->udev, "'%s' has mode=%#o and %s %#o\n", filename, statbuf.st_mode,
+ match ? "matches" : "does not match", cur->key.mode);
}
if (match && cur->key.op == OP_NOMATCH)
goto nomatch;
util_strlcpy(value, &rules->buf[cur->key.value_off], sizeof(value));
udev_event_apply_format(event, value, sizeof(value));
- info(event->udev, "writing '%s' to sysfs file '%s'\n", value, attr);
+ info(event->udev, "ATTR '%s' writing '%s' %s:%u\n", attr, value,
+ &rules->buf[rule->rule.filename_off],
+ rule->rule.filename_line);
f = fopen(attr, "w");
if (f != NULL) {
if (!event->test)