mkdir_parents(filename_tmp, 0755);
f = fopen(filename_tmp, "we");
if (f == NULL) {
- err(udev, "unable to create temporary db file '%s': %m\n", filename_tmp);
+ udev_err(udev, "unable to create temporary db file '%s': %m\n", filename_tmp);
return -1;
}
fclose(f);
rename(filename_tmp, filename);
- dbg(udev, "created %s file '%s' for '%s'\n", has_info ? "db" : "empty",
+ udev_dbg(udev, "created %s file '%s' for '%s'\n", has_info ? "db" : "empty",
filename, udev_device_get_devpath(udev_device));
return 0;
}
f = fopen(dbfile, "re");
if (f == NULL) {
- dbg(udev_device->udev, "no db file to read %s: %m\n", dbfile);
+ udev_dbg(udev_device->udev, "no db file to read %s: %m\n", dbfile);
return -1;
}
udev_device->is_initialized = true;
}
fclose(f);
- dbg(udev_device->udev, "device %p filled with db file data\n", udev_device);
+ udev_dbg(udev_device->udev, "device %p filled with db file data\n", udev_device);
return 0;
}
/* path starts in sys */
if (!startswith(syspath, TEST_PREFIX "/sys")) {
- dbg(udev, "not in sys :%s\n", syspath);
+ udev_dbg(udev, "not in sys :%s\n", syspath);
return NULL;
}
return NULL;
udev_device_set_syspath(udev_device, path);
- dbg(udev, "device %p has devpath '%s'\n", udev_device, udev_device_get_devpath(udev_device));
+ udev_dbg(udev, "device %p has devpath '%s'\n", udev_device, udev_device_get_devpath(udev_device));
return udev_device;
}
udev_device_add_property_from_string_parse(udev_device, environ[i]);
if (udev_device_add_property_from_string_parse_finish(udev_device) < 0) {
- dbg(udev, "missing values, invalid device\n");
+ udev_dbg(udev, "missing values, invalid device\n");
udev_device_unref(udev_device);
udev_device = NULL;
}
struct udev_monitor *udev_monitor_new_from_socket(struct udev *udev, const char *socket_path);
_public_ struct udev_monitor *udev_monitor_new_from_socket(struct udev *udev, const char *socket_path)
{
- err(udev, "udev_monitor_new_from_socket() does not do anything; please migrate to netlink\n");
+ udev_err(udev, "udev_monitor_new_from_socket() does not do anything; please migrate to netlink\n");
errno = ENOSYS;
return NULL;
}
if (fd < 0) {
udev_monitor->sock = socket(PF_NETLINK, SOCK_RAW|SOCK_CLOEXEC|SOCK_NONBLOCK, NETLINK_KOBJECT_UEVENT);
if (udev_monitor->sock == -1) {
- err(udev, "error getting socket: %m\n");
+ udev_err(udev, "error getting socket: %m\n");
free(udev_monitor);
return NULL;
}
if (err == 0)
udev_monitor->snl.nl.nl_pid = snl.nl.nl_pid;
} else {
- err(udev_monitor->udev, "bind failed: %m\n");
+ udev_err(udev_monitor->udev, "bind failed: %m\n");
return err;
}
buflen = recvmsg(udev_monitor->sock, &smsg, 0);
if (buflen < 0) {
if (errno != EINTR)
- dbg(udev_monitor->udev, "unable to receive message\n");
+ udev_dbg(udev_monitor->udev, "unable to receive message\n");
return NULL;
}
if (buflen < 32 || (size_t)buflen >= sizeof(buf)) {
- dbg(udev_monitor->udev, "invalid message length\n");
+ udev_dbg(udev_monitor->udev, "invalid message length\n");
return NULL;
}
/* unicast message, check if we trust the sender */
if (udev_monitor->snl_trusted_sender.nl.nl_pid == 0 ||
snl.nl.nl_pid != udev_monitor->snl_trusted_sender.nl.nl_pid) {
- dbg(udev_monitor->udev, "unicast netlink message ignored\n");
+ udev_dbg(udev_monitor->udev, "unicast netlink message ignored\n");
return NULL;
}
} else if (snl.nl.nl_groups == UDEV_MONITOR_KERNEL) {
if (snl.nl.nl_pid > 0) {
- dbg(udev_monitor->udev, "multicast kernel netlink message from pid %d ignored\n",
+ udev_dbg(udev_monitor->udev, "multicast kernel netlink message from pid %d ignored\n",
snl.nl.nl_pid);
return NULL;
}
cmsg = CMSG_FIRSTHDR(&smsg);
if (cmsg == NULL || cmsg->cmsg_type != SCM_CREDENTIALS) {
- dbg(udev_monitor->udev, "no sender credentials received, message ignored\n");
+ udev_dbg(udev_monitor->udev, "no sender credentials received, message ignored\n");
return NULL;
}
cred = (struct ucred *)CMSG_DATA(cmsg);
if (cred->uid != 0) {
- dbg(udev_monitor->udev, "sender uid=%d, message ignored\n", cred->uid);
+ udev_dbg(udev_monitor->udev, "sender uid=%d, message ignored\n", cred->uid);
return NULL;
}
/* udev message needs proper version magic */
nlh = (struct udev_monitor_netlink_header *) buf;
if (nlh->magic != htonl(UDEV_MONITOR_MAGIC)) {
- err(udev_monitor->udev, "unrecognized message signature (%x != %x)\n",
+ udev_err(udev_monitor->udev, "unrecognized message signature (%x != %x)\n",
nlh->magic, htonl(UDEV_MONITOR_MAGIC));
return NULL;
}
/* kernel message with header */
bufpos = strlen(buf) + 1;
if ((size_t)bufpos < sizeof("a@/d") || bufpos >= buflen) {
- dbg(udev_monitor->udev, "invalid message length\n");
+ udev_dbg(udev_monitor->udev, "invalid message length\n");
return NULL;
}
/* check message header */
if (strstr(buf, "@/") == NULL) {
- dbg(udev_monitor->udev, "unrecognized message header\n");
+ udev_dbg(udev_monitor->udev, "unrecognized message header\n");
return NULL;
}
}
}
if (udev_device_add_property_from_string_parse_finish(udev_device) < 0) {
- dbg(udev_monitor->udev, "missing values, invalid device\n");
+ udev_dbg(udev_monitor->udev, "missing values, invalid device\n");
udev_device_unref(udev_device);
return NULL;
}
smsg.msg_name = &udev_monitor->snl_destination;
smsg.msg_namelen = sizeof(struct sockaddr_nl);
count = sendmsg(udev_monitor->sock, &smsg, 0);
- dbg(udev_monitor->udev, "passed %zi bytes to netlink monitor %p\n", count, udev_monitor);
+ udev_dbg(udev_monitor->udev, "passed %zi bytes to netlink monitor %p\n", count, udev_monitor);
return count;
}
udev_log(udev, prio, __FILE__, __LINE__, __FUNCTION__, ## arg); \
} while (0)
-#define dbg(udev, arg...) udev_log_cond(udev, LOG_DEBUG, ## arg)
-#define info(udev, arg...) udev_log_cond(udev, LOG_INFO, ## arg)
-#define err(udev, arg...) udev_log_cond(udev, LOG_ERR, ## arg)
+#define udev_dbg(udev, arg...) udev_log_cond(udev, LOG_DEBUG, ## arg)
+#define udev_info(udev, arg...) udev_log_cond(udev, LOG_INFO, ## arg)
+#define udev_err(udev, arg...) udev_log_cond(udev, LOG_ERR, ## arg)
/* libudev.c */
void udev_log(struct udev *udev,
/* allocate the table */
range = udev_queue_export->seqnum_min - udev_queue_export->seqnum_max;
if (range - 1 > INT_MAX) {
- err(udev_queue_export->udev, "queue file overflow\n");
+ udev_err(udev_queue_export->udev, "queue file overflow\n");
return NULL;
}
devpaths = calloc(1, sizeof(struct queue_devpaths) + (range + 1) * sizeof(long));
return devpaths;
read_error:
- err(udev_queue_export->udev, "queue file corrupted\n");
+ udev_err(udev_queue_export->udev, "queue file corrupted\n");
free(devpaths);
return NULL;
}
return 0;
error:
- err(udev_queue_export->udev, "failed to create queue file: %m\n");
+ udev_err(udev_queue_export->udev, "failed to create queue file: %m\n");
udev_queue_export_cleanup(udev_queue_export);
if (udev_queue_export->queue_file != NULL) {
write_error:
/* if we failed half way through writing a record to a file,
we should not try to write any further records to it. */
- err(udev_queue_export->udev, "error writing to queue file: %m\n");
+ udev_err(udev_queue_export->udev, "error writing to queue file: %m\n");
fclose(udev_queue_export->queue_file);
udev_queue_export->queue_file = NULL;
return NULL;
if (udev_queue_read_seqnum(queue_file, seqnum_start) < 0) {
- err(udev_queue->udev, "corrupt queue file\n");
+ udev_err(udev_queue->udev, "corrupt queue file\n");
fclose(queue_file);
return NULL;
}
struct udev_list_entry *udev_queue_get_failed_list_entry(struct udev_queue *udev_queue);
_public_ struct udev_list_entry *udev_queue_get_failed_list_entry(struct udev_queue *udev_queue)
{
- err(udev_queue->udev, "udev_queue_get_failed_list_entry() does not return anything; failed events are not recorded\n");
+ udev_err(udev_queue->udev, "udev_queue_get_failed_list_entry() does not return anything; failed events are not recorded\n");
errno = ENOSYS;
return NULL;
}
if (pw != NULL)
return pw->pw_uid;
if (errno == 0 || errno == ENOENT || errno == ESRCH)
- err(udev, "specified user '%s' unknown\n", user);
+ udev_err(udev, "specified user '%s' unknown\n", user);
else
- err(udev, "error resolving user '%s': %m\n", user);
+ udev_err(udev, "error resolving user '%s': %m\n", user);
return 0;
}
buflen *= 2;
continue;
} else if (errno == 0 || errno == ENOENT || errno == ESRCH) {
- err(udev, "specified group '%s' unknown\n", group);
+ udev_err(udev, "specified group '%s' unknown\n", group);
} else {
- err(udev, "error resolving group '%s': %m\n", group);
+ udev_err(udev, "error resolving group '%s': %m\n", group);
}
break;
}
util_strscpy(result, maxsize, val);
else
result[0] = '\0';
- dbg(udev, "value '[%s/%s]%s' is '%s'\n", subsys, sysname, attr, result);
+ udev_dbg(udev, "value '[%s/%s]%s' is '%s'\n", subsys, sysname, attr, result);
} else {
size_t l;
char *s;
l = util_strpcpyl(&s, maxsize, udev_device_get_syspath(dev), NULL);
if (attr != NULL)
util_strpcpyl(&s, l, "/", attr, NULL);
- dbg(udev, "path '[%s/%s]%s' is '%s'\n", subsys, sysname, attr, result);
+ udev_dbg(udev, "path '[%s/%s]%s' is '%s'\n", subsys, sysname, attr, result);
}
udev_device_unref(dev);
return 0;
/* split key/value */
val = strchr(key, '=');
if (val == NULL) {
- err(udev, "missing <key>=<value> in " SYSCONFDIR "/udev/udev.conf[%i]; skip line\n", line_nr);
+ udev_err(udev, "missing <key>=<value> in " SYSCONFDIR "/udev/udev.conf[%i]; skip line\n", line_nr);
continue;
}
val[0] = '\0';
/* unquote */
if (val[0] == '"' || val[0] == '\'') {
if (val[len-1] != val[0]) {
- err(udev, "inconsistent quoting in " SYSCONFDIR "/udev/udev.conf[%i]; skip line\n", line_nr);
+ udev_err(udev, "inconsistent quoting in " SYSCONFDIR "/udev/udev.conf[%i]; skip line\n", line_nr);
continue;
}
val[len-1] = '\0';
const char *format, va_list args))
{
udev->log_fn = log_fn;
- dbg(udev, "custom logging function %p registered\n", log_fn);
+ udev_dbg(udev, "custom logging function %p registered\n", log_fn);
}
/**