mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
replace strerror() usage with threadsafe "%m" format string
strerror() is not threadsafe. It uses a buffer to build messages of the form "Unknown error 387689". syslog() provides a %m format which is equivalent to strerror(errno). As a GNU extension, this is also accepted by printf and friends. At least in the current implementation, it is correctly threadsafe. Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
This commit is contained in:
parent
5c0f595d91
commit
659353f5a9
@ -79,7 +79,7 @@ struct udev_ctrl *udev_ctrl_new_from_socket(struct udev *udev, const char *socke
|
||||
|
||||
uctrl->sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
|
||||
if (uctrl->sock < 0) {
|
||||
err(udev, "error getting socket: %s\n", strerror(errno));
|
||||
err(udev, "error getting socket: %m\n");
|
||||
udev_ctrl_unref(uctrl);
|
||||
return NULL;
|
||||
}
|
||||
@ -101,7 +101,7 @@ int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl)
|
||||
|
||||
err= bind(uctrl->sock, (struct sockaddr *)&uctrl->saddr, uctrl->addrlen);
|
||||
if (err < 0) {
|
||||
err(uctrl->udev, "bind failed: %s\n", strerror(errno));
|
||||
err(uctrl->udev, "bind failed: %m\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ static int ctrl_send(struct udev_ctrl *uctrl, enum udev_ctrl_msg_type type, int
|
||||
|
||||
err = sendto(uctrl->sock, &ctrl_msg_wire, sizeof(ctrl_msg_wire), 0, (struct sockaddr *)&uctrl->saddr, uctrl->addrlen);
|
||||
if (err == -1) {
|
||||
err(uctrl->udev, "error sending message: %s\n", strerror(errno));
|
||||
err(uctrl->udev, "error sending message: %m\n");
|
||||
}
|
||||
return err;
|
||||
}
|
||||
@ -227,7 +227,7 @@ struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl *uctrl)
|
||||
|
||||
size = recvmsg(uctrl->sock, &smsg, 0);
|
||||
if (size < 0) {
|
||||
err(uctrl->udev, "unable to receive user udevd message: %s\n", strerror(errno));
|
||||
err(uctrl->udev, "unable to receive user udevd message: %m\n");
|
||||
goto err;
|
||||
}
|
||||
cmsg = CMSG_FIRSTHDR(&smsg);
|
||||
|
@ -77,7 +77,7 @@ static int device_read_db(struct udev_device *udev_device)
|
||||
syspath_to_db_path(udev_device, filename, sizeof(filename));
|
||||
|
||||
if (lstat(filename, &stats) != 0) {
|
||||
info(udev_device->udev, "no db file to read %s: %s\n", filename, strerror(errno));
|
||||
info(udev_device->udev, "no db file to read %s: %m\n", filename);
|
||||
return -1;
|
||||
}
|
||||
if ((stats.st_mode & S_IFMT) == S_IFLNK) {
|
||||
@ -88,7 +88,7 @@ static int device_read_db(struct udev_device *udev_device)
|
||||
if (target_len > 0)
|
||||
target[target_len] = '\0';
|
||||
else {
|
||||
info(udev_device->udev, "error reading db link %s: %s\n", filename, strerror(errno));
|
||||
info(udev_device->udev, "error reading db link %s: %m\n", filename);
|
||||
return -1;
|
||||
}
|
||||
if (asprintf(&udev_device->devnode, "%s/%s", udev_get_dev_path(udev_device->udev), target) < 0)
|
||||
@ -99,7 +99,7 @@ static int device_read_db(struct udev_device *udev_device)
|
||||
|
||||
f = fopen(filename, "r");
|
||||
if (f == NULL) {
|
||||
info(udev_device->udev, "error reading db file %s: %s\n", filename, strerror(errno));
|
||||
info(udev_device->udev, "error reading db file %s: %m\n", filename);
|
||||
return -1;
|
||||
}
|
||||
while (fgets(line, sizeof(line), f)) {
|
||||
@ -653,7 +653,7 @@ const char *udev_device_get_attr_value(struct udev_device *udev_device, const ch
|
||||
util_strlcat(path, attr, sizeof(path));
|
||||
|
||||
if (lstat(path, &statbuf) != 0) {
|
||||
info(udev_device->udev, "stat '%s' failed: %s\n", path, strerror(errno));
|
||||
info(udev_device->udev, "stat '%s' failed: %m\n", path);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ struct udev_monitor *udev_monitor_new_from_socket(struct udev *udev, const char
|
||||
|
||||
udev_monitor->sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
|
||||
if (udev_monitor->sock == -1) {
|
||||
err(udev, "error getting socket: %s\n", strerror(errno));
|
||||
err(udev, "error getting socket: %m\n");
|
||||
free(udev_monitor);
|
||||
return NULL;
|
||||
}
|
||||
@ -106,7 +106,7 @@ struct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev)
|
||||
|
||||
udev_monitor->sock = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
|
||||
if (udev_monitor->sock == -1) {
|
||||
err(udev, "error getting socket: %s\n", strerror(errno));
|
||||
err(udev, "error getting socket: %m\n");
|
||||
free(udev_monitor);
|
||||
return NULL;
|
||||
}
|
||||
@ -127,14 +127,14 @@ int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor)
|
||||
if (udev_monitor->snl.nl_family != 0) {
|
||||
err = bind(udev_monitor->sock, (struct sockaddr *)&udev_monitor->snl, sizeof(struct sockaddr_nl));
|
||||
if (err < 0) {
|
||||
err(udev_monitor->udev, "bind failed: %s\n", strerror(errno));
|
||||
err(udev_monitor->udev, "bind failed: %m\n");
|
||||
return err;
|
||||
}
|
||||
info(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) {
|
||||
err(udev_monitor->udev, "bind failed: %s\n", strerror(errno));
|
||||
err(udev_monitor->udev, "bind failed: %m\n");
|
||||
return err;
|
||||
}
|
||||
/* enable receiving of the sender credentials */
|
||||
|
@ -131,7 +131,7 @@ void udev_selinux_lsetfilecon(struct udev *udev, const char *file, unsigned int
|
||||
return;
|
||||
}
|
||||
if (lsetfilecon(file, scontext) < 0)
|
||||
err(udev, "setfilecon %s failed: %s\n", file, strerror(errno));
|
||||
err(udev, "setfilecon %s failed: %m\n", file);
|
||||
freecon(scontext);
|
||||
}
|
||||
#endif
|
||||
@ -150,7 +150,7 @@ void udev_selinux_setfscreatecon(struct udev *udev, const char *file, unsigned i
|
||||
return;
|
||||
}
|
||||
if (setfscreatecon(scontext) < 0)
|
||||
err(udev, "setfscreatecon %s failed: %s\n", file, strerror(errno));
|
||||
err(udev, "setfscreatecon %s failed: %m\n", file);
|
||||
freecon(scontext);
|
||||
}
|
||||
#endif
|
||||
@ -163,7 +163,7 @@ void udev_selinux_resetfscreatecon(struct udev *udev)
|
||||
selinux_init(udev);
|
||||
if (udev->selinux_enabled) {
|
||||
if (setfscreatecon(udev->selinux_prev_scontext) < 0)
|
||||
err(udev, "setfscreatecon failed: %s\n", strerror(errno));
|
||||
err(udev, "setfscreatecon failed: %m\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ int udev_db_get_devices_by_name(struct udev *udev, const char *name, struct list
|
||||
|
||||
dir = opendir(dirname);
|
||||
if (dir == NULL) {
|
||||
info(udev, "no index directory '%s': %s\n", dirname, strerror(errno));
|
||||
info(udev, "no index directory '%s': %m\n", dirname);
|
||||
rc = -1;
|
||||
goto out;
|
||||
}
|
||||
@ -147,7 +147,7 @@ int udev_db_add_device(struct udevice *udevice)
|
||||
ret = symlink(udevice->name, filename);
|
||||
udev_selinux_resetfscreatecon(udevice->udev);
|
||||
if (ret != 0) {
|
||||
err(udevice->udev, "unable to create db link '%s': %s\n", filename, strerror(errno));
|
||||
err(udevice->udev, "unable to create db link '%s': %m\n", filename);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
@ -156,7 +156,7 @@ int udev_db_add_device(struct udevice *udevice)
|
||||
|
||||
f = fopen(filename, "w");
|
||||
if (f == NULL) {
|
||||
err(udevice->udev, "unable to create db file '%s': %s\n", filename, strerror(errno));
|
||||
err(udevice->udev, "unable to create db file '%s': %m\n", filename);
|
||||
return -1;
|
||||
}
|
||||
dbg(udevice->udev, "storing data for device '%s' in '%s'\n", udevice->dev->devpath, filename);
|
||||
@ -203,7 +203,7 @@ int udev_db_get_device(struct udevice *udevice, const char *devpath)
|
||||
devpath_to_db_path(udevice->udev, devpath, filename, sizeof(filename));
|
||||
|
||||
if (lstat(filename, &stats) != 0) {
|
||||
info(udevice->udev, "no db file to read %s: %s\n", filename, strerror(errno));
|
||||
info(udevice->udev, "no db file to read %s: %m\n", filename);
|
||||
return -1;
|
||||
}
|
||||
if ((stats.st_mode & S_IFMT) == S_IFLNK) {
|
||||
@ -215,7 +215,7 @@ int udev_db_get_device(struct udevice *udevice, const char *devpath)
|
||||
if (target_len > 0)
|
||||
target[target_len] = '\0';
|
||||
else {
|
||||
info(udevice->udev, "error reading db link %s: %s\n", filename, strerror(errno));
|
||||
info(udevice->udev, "error reading db link %s: %m\n", filename);
|
||||
return -1;
|
||||
}
|
||||
dbg(udevice->udev, "db link points to '%s'\n", target);
|
||||
@ -224,7 +224,7 @@ int udev_db_get_device(struct udevice *udevice, const char *devpath)
|
||||
}
|
||||
|
||||
if (file_map(filename, &buf, &bufsize) != 0) {
|
||||
info(udevice->udev, "error reading db file %s: %s\n", filename, strerror(errno));
|
||||
info(udevice->udev, "error reading db file %s: %m\n", filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ static int rename_netif(struct udevice *udevice)
|
||||
|
||||
sk = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
if (sk < 0) {
|
||||
err(udevice->udev, "error opening socket: %s\n", strerror(errno));
|
||||
err(udevice->udev, "error opening socket: %m\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -78,8 +78,8 @@ static int rename_netif(struct udevice *udevice)
|
||||
|
||||
/* see if the destination interface name already exists */
|
||||
if (errno != EEXIST) {
|
||||
err(udevice->udev, "error changing netif name %s to %s: %s\n",
|
||||
ifr.ifr_name, ifr.ifr_newname, strerror(errno));
|
||||
err(udevice->udev, "error changing netif name %s to %s: %m\n",
|
||||
ifr.ifr_name, ifr.ifr_newname);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@ -88,8 +88,8 @@ static int rename_netif(struct udevice *udevice)
|
||||
util_strlcat(ifr.ifr_newname, "_rename", IFNAMSIZ);
|
||||
retval = ioctl(sk, SIOCSIFNAME, &ifr);
|
||||
if (retval != 0) {
|
||||
err(udevice->udev, "error changing netif name %s to %s: %s\n",
|
||||
ifr.ifr_name, ifr.ifr_newname, strerror(errno));
|
||||
err(udevice->udev, "error changing netif name %s to %s: %m\n",
|
||||
ifr.ifr_name, ifr.ifr_newname);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@ -105,8 +105,8 @@ static int rename_netif(struct udevice *udevice)
|
||||
}
|
||||
|
||||
if (errno != EEXIST) {
|
||||
err(udevice->udev, "error changing net interface name %s to %s: %s\n",
|
||||
ifr.ifr_name, ifr.ifr_newname, strerror(errno));
|
||||
err(udevice->udev, "error changing net interface name %s to %s: %m\n",
|
||||
ifr.ifr_name, ifr.ifr_newname);
|
||||
break;
|
||||
}
|
||||
dbg(udevice->udev, "wait for netif '%s' to become free, loop=%i\n",
|
||||
|
@ -58,13 +58,13 @@ int udev_node_mknod(struct udevice *udevice, const char *file, dev_t devt, mode_
|
||||
err = mknod(file_tmp, mode, devt);
|
||||
udev_selinux_resetfscreatecon(udevice->udev);
|
||||
if (err != 0) {
|
||||
err(udevice->udev, "mknod(%s, %#o, %u, %u) failed: %s\n",
|
||||
file_tmp, mode, major(devt), minor(devt), strerror(errno));
|
||||
err(udevice->udev, "mknod(%s, %#o, %u, %u) failed: %m\n",
|
||||
file_tmp, mode, major(devt), minor(devt));
|
||||
goto exit;
|
||||
}
|
||||
err = rename(file_tmp, file);
|
||||
if (err != 0) {
|
||||
err(udevice->udev, "rename(%s, %s) failed: %s\n", file_tmp, file, strerror(errno));
|
||||
err(udevice->udev, "rename(%s, %s) failed: %m\n", file_tmp, file);
|
||||
unlink(file_tmp);
|
||||
}
|
||||
}
|
||||
@ -74,8 +74,8 @@ int udev_node_mknod(struct udevice *udevice, const char *file, dev_t devt, mode_
|
||||
err = mknod(file, mode, devt);
|
||||
udev_selinux_resetfscreatecon(udevice->udev);
|
||||
if (err != 0) {
|
||||
err(udevice->udev, "mknod(%s, %#o, (%u,%u) failed: %s\n",
|
||||
file, mode, major(devt), minor(devt), strerror(errno));
|
||||
err(udevice->udev, "mknod(%s, %#o, (%u,%u) failed: %m\n",
|
||||
file, mode, major(devt), minor(devt));
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
@ -84,7 +84,7 @@ int udev_node_mknod(struct udevice *udevice, const char *file, dev_t devt, mode_
|
||||
info(udevice->udev, "chmod(%s, %#o)\n", file, mode);
|
||||
err = chmod(file, mode);
|
||||
if (err != 0) {
|
||||
err(udevice->udev, "chmod(%s, %#o) failed: %s\n", file, mode, strerror(errno));
|
||||
err(udevice->udev, "chmod(%s, %#o) failed: %m\n", file, mode);
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
@ -93,7 +93,7 @@ int udev_node_mknod(struct udevice *udevice, const char *file, dev_t devt, mode_
|
||||
info(udevice->udev, "chown(%s, %u, %u)\n", file, uid, gid);
|
||||
err = chown(file, uid, gid);
|
||||
if (err != 0) {
|
||||
err(udevice->udev, "chown(%s, %u, %u) failed: %s\n", file, uid, gid, strerror(errno));
|
||||
err(udevice->udev, "chown(%s, %u, %u) failed: %m\n", file, uid, gid);
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
@ -170,12 +170,12 @@ static int node_symlink(struct udevice *udevice, const char *node, const char *s
|
||||
retval = symlink(target, slink_tmp);
|
||||
udev_selinux_resetfscreatecon(udevice->udev);
|
||||
if (retval != 0) {
|
||||
err(udevice->udev, "symlink(%s, %s) failed: %s\n", target, slink_tmp, strerror(errno));
|
||||
err(udevice->udev, "symlink(%s, %s) failed: %m\n", target, slink_tmp);
|
||||
goto exit;
|
||||
}
|
||||
retval = rename(slink_tmp, slink);
|
||||
if (retval != 0) {
|
||||
err(udevice->udev, "rename(%s, %s) failed: %s\n", slink_tmp, slink, strerror(errno));
|
||||
err(udevice->udev, "rename(%s, %s) failed: %m\n", slink_tmp, slink);
|
||||
unlink(slink_tmp);
|
||||
goto exit;
|
||||
}
|
||||
|
@ -159,13 +159,13 @@ static int run_program(struct udev *udev, const char *command, const char *subsy
|
||||
/* prepare pipes from child to parent */
|
||||
if (result != NULL || udev_get_log_priority(udev) >= LOG_INFO) {
|
||||
if (pipe(outpipe) != 0) {
|
||||
err(udev, "pipe failed: %s\n", strerror(errno));
|
||||
err(udev, "pipe failed: %m\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (udev_get_log_priority(udev) >= LOG_INFO) {
|
||||
if (pipe(errpipe) != 0) {
|
||||
err(udev, "pipe failed: %s\n", strerror(errno));
|
||||
err(udev, "pipe failed: %m\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -196,7 +196,7 @@ static int run_program(struct udev *udev, const char *command, const char *subsy
|
||||
dup2(devnull, STDERR_FILENO);
|
||||
close(devnull);
|
||||
} else
|
||||
err(udev, "open /dev/null failed: %s\n", strerror(errno));
|
||||
err(udev, "open /dev/null failed: %m\n");
|
||||
if (outpipe[WRITE_END] > 0) {
|
||||
dup2(outpipe[WRITE_END], STDOUT_FILENO);
|
||||
close(outpipe[WRITE_END]);
|
||||
@ -215,7 +215,7 @@ static int run_program(struct udev *udev, const char *command, const char *subsy
|
||||
}
|
||||
_exit(1);
|
||||
case -1:
|
||||
err(udev, "fork of '%s' failed: %s\n", argv[0], strerror(errno));
|
||||
err(udev, "fork of '%s' failed: %m\n", argv[0]);
|
||||
return -1;
|
||||
default:
|
||||
/* read from child if requested */
|
||||
@ -258,7 +258,7 @@ static int run_program(struct udev *udev, const char *command, const char *subsy
|
||||
close(outpipe[READ_END]);
|
||||
outpipe[READ_END] = -1;
|
||||
if (count < 0) {
|
||||
err(udev, "stdin read failed: %s\n", strerror(errno));
|
||||
err(udev, "stdin read failed: %m\n");
|
||||
retval = -1;
|
||||
}
|
||||
continue;
|
||||
@ -292,7 +292,7 @@ static int run_program(struct udev *udev, const char *command, const char *subsy
|
||||
close(errpipe[READ_END]);
|
||||
errpipe[READ_END] = -1;
|
||||
if (count < 0)
|
||||
err(udev, "stderr read failed: %s\n", strerror(errno));
|
||||
err(udev, "stderr read failed: %m\n");
|
||||
continue;
|
||||
}
|
||||
errbuf[count] = '\0';
|
||||
@ -392,7 +392,7 @@ static int import_file_into_env(struct udevice *udevice, const char *filename)
|
||||
size_t bufsize;
|
||||
|
||||
if (file_map(filename, &buf, &bufsize) != 0) {
|
||||
err(udevice->udev, "can't open '%s': %s\n", filename, strerror(errno));
|
||||
err(udevice->udev, "can't open '%s': %m\n", filename);
|
||||
return -1;
|
||||
}
|
||||
import_keys_into_env(udevice, buf, bufsize);
|
||||
@ -1352,10 +1352,10 @@ try_parent:
|
||||
if (f != NULL) {
|
||||
if (!udevice->test_run)
|
||||
if (fprintf(f, "%s", value) <= 0)
|
||||
err(udevice->udev, "error writing ATTR{%s}: %s\n", attr, strerror(errno));
|
||||
err(udevice->udev, "error writing ATTR{%s}: %m\n", attr);
|
||||
fclose(f);
|
||||
} else
|
||||
err(udevice->udev, "error opening ATTR{%s} for writing: %s\n", attr, strerror(errno));
|
||||
err(udevice->udev, "error opening ATTR{%s} for writing: %m\n", attr);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -692,7 +692,7 @@ static int parse_file(struct udev_rules *rules, const char *filename)
|
||||
start = rules->bufsize;
|
||||
|
||||
if (file_map(filename, &buf, &bufsize) != 0) {
|
||||
err(rules->udev, "can't open '%s' as rules file: %s\n", filename, strerror(errno));
|
||||
err(rules->udev, "can't open '%s' as rules file: %m\n", filename);
|
||||
return -1;
|
||||
}
|
||||
info(rules->udev, "reading '%s' as rules file\n", filename);
|
||||
@ -831,7 +831,7 @@ int udev_rules_init(struct udev *udev, struct udev_rules *rules, int resolve_nam
|
||||
else
|
||||
dbg(udev, "empty rules file '%s'\n", name_loop->name);
|
||||
} else
|
||||
err(udev, "could not read '%s': %s\n", name_loop->name, strerror(errno));
|
||||
err(udev, "could not read '%s': %m\n", name_loop->name);
|
||||
list_del(&name_loop->node);
|
||||
free(name_loop);
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ struct sysfs_device *sysfs_device_get(struct udev *udev, const char *devpath)
|
||||
util_strlcpy(path, udev_get_sys_path(udev), sizeof(path));
|
||||
util_strlcat(path, devpath_real, sizeof(path));
|
||||
if (lstat(path, &statbuf) != 0) {
|
||||
dbg(udev, "stat '%s' failed: %s\n", path, strerror(errno));
|
||||
dbg(udev, "stat '%s' failed: %m\n", path);
|
||||
return NULL;
|
||||
}
|
||||
if (S_ISLNK(statbuf.st_mode)) {
|
||||
@ -352,7 +352,7 @@ char *sysfs_attr_get_value(struct udev *udev, const char *devpath, const char *a
|
||||
list_add(&attr->node, &attr_list);
|
||||
|
||||
if (lstat(path_full, &statbuf) != 0) {
|
||||
dbg(udev, "stat '%s' failed: %s\n", path_full, strerror(errno));
|
||||
dbg(udev, "stat '%s' failed: %m\n", path_full);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ int add_matching_files(struct udev *udev, struct list_head *name_list, const cha
|
||||
dbg(udev, "open directory '%s'\n", dirname);
|
||||
dir = opendir(dirname);
|
||||
if (dir == NULL) {
|
||||
err(udev, "unable to open '%s': %s\n", dirname, strerror(errno));
|
||||
err(udev, "unable to open '%s': %m\n", dirname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ uid_t lookup_user(struct udev *udev, const char *user)
|
||||
if (errno == 0 || errno == ENOENT || errno == ESRCH)
|
||||
err(udev, "specified user '%s' unknown\n", user);
|
||||
else
|
||||
err(udev, "error resolving user '%s': %s\n", user, strerror(errno));
|
||||
err(udev, "error resolving user '%s': %m\n", user);
|
||||
} else
|
||||
uid = pw->pw_uid;
|
||||
|
||||
@ -194,7 +194,7 @@ extern gid_t lookup_group(struct udev *udev, const char *group)
|
||||
if (errno == 0 || errno == ENOENT || errno == ESRCH)
|
||||
err(udev, "specified group '%s' unknown\n", group);
|
||||
else
|
||||
err(udev, "error resolving group '%s': %s\n", group, strerror(errno));
|
||||
err(udev, "error resolving group '%s': %m\n", group);
|
||||
} else
|
||||
gid = gr->gr_gid;
|
||||
|
||||
|
@ -91,7 +91,7 @@ int delete_path(struct udev *udev, const char *path)
|
||||
if (retval) {
|
||||
if (errno == ENOTEMPTY)
|
||||
return 0;
|
||||
err(udev, "rmdir(%s) failed: %s\n", p, strerror(errno));
|
||||
err(udev, "rmdir(%s) failed: %m\n", p);
|
||||
break;
|
||||
}
|
||||
dbg(udev, "removed '%s'\n", p);
|
||||
@ -108,18 +108,18 @@ int unlink_secure(struct udev *udev, const char *filename)
|
||||
|
||||
retval = chown(filename, 0, 0);
|
||||
if (retval)
|
||||
err(udev, "chown(%s, 0, 0) failed: %s\n", filename, strerror(errno));
|
||||
err(udev, "chown(%s, 0, 0) failed: %m\n", filename);
|
||||
|
||||
retval = chmod(filename, 0000);
|
||||
if (retval)
|
||||
err(udev, "chmod(%s, 0000) failed: %s\n", filename, strerror(errno));
|
||||
err(udev, "chmod(%s, 0000) failed: %m\n", filename);
|
||||
|
||||
retval = unlink(filename);
|
||||
if (errno == ENOENT)
|
||||
retval = 0;
|
||||
|
||||
if (retval)
|
||||
err(udev, "unlink(%s) failed: %s\n", filename, strerror(errno));
|
||||
err(udev, "unlink(%s) failed: %m\n", filename);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ int udevadm_monitor(struct udev *udev, int argc, char *argv[])
|
||||
&readfds, NULL, NULL, NULL);
|
||||
if (fdcount < 0) {
|
||||
if (errno != EINTR)
|
||||
fprintf(stderr, "error receiving uevent message: %s\n", strerror(errno));
|
||||
fprintf(stderr, "error receiving uevent message: %m\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -105,12 +105,12 @@ static void trigger_uevent(struct udev *udev, const char *syspath, const char *a
|
||||
|
||||
fd = open(filename, O_WRONLY);
|
||||
if (fd < 0) {
|
||||
dbg(udev, "error on opening %s: %s\n", filename, strerror(errno));
|
||||
dbg(udev, "error on opening %s: %m\n", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
if (write(fd, action, strlen(action)) < 0)
|
||||
info(udev, "error writing '%s' to '%s': %s\n", action, filename, strerror(errno));
|
||||
info(udev, "error writing '%s' to '%s': %m\n", action, filename);
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
26
udev/udevd.c
26
udev/udevd.c
@ -264,7 +264,7 @@ static void udev_event_run(struct udevd_uevent_msg *msg)
|
||||
exit(1);
|
||||
exit(0);
|
||||
case -1:
|
||||
err(msg->udev, "fork of child failed: %s\n", strerror(errno));
|
||||
err(msg->udev, "fork of child failed: %m\n");
|
||||
msg_queue_delete(msg);
|
||||
break;
|
||||
default:
|
||||
@ -619,7 +619,7 @@ static struct udevd_uevent_msg *get_netlink_msg(struct udev *udev)
|
||||
size = recv(uevent_netlink_sock, &buffer, sizeof(buffer), 0);
|
||||
if (size < 0) {
|
||||
if (errno != EINTR)
|
||||
err(udev, "unable to receive kernel netlink message: %s\n", strerror(errno));
|
||||
err(udev, "unable to receive kernel netlink message: %m\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -729,7 +729,7 @@ static int init_uevent_netlink_sock(struct udev *udev)
|
||||
|
||||
uevent_netlink_sock = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
|
||||
if (uevent_netlink_sock == -1) {
|
||||
err(udev, "error getting socket: %s\n", strerror(errno));
|
||||
err(udev, "error getting socket: %m\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -738,7 +738,7 @@ static int init_uevent_netlink_sock(struct udev *udev)
|
||||
|
||||
retval = bind(uevent_netlink_sock, (struct sockaddr *) &snl, sizeof(struct sockaddr_nl));
|
||||
if (retval < 0) {
|
||||
err(udev, "bind failed: %s\n", strerror(errno));
|
||||
err(udev, "bind failed: %m\n");
|
||||
close(uevent_netlink_sock);
|
||||
uevent_netlink_sock = -1;
|
||||
return -1;
|
||||
@ -876,29 +876,29 @@ int main(int argc, char *argv[])
|
||||
|
||||
retval = pipe(signal_pipe);
|
||||
if (retval < 0) {
|
||||
err(udev, "error getting pipes: %s\n", strerror(errno));
|
||||
err(udev, "error getting pipes: %m\n");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
retval = fcntl(signal_pipe[READ_END], F_GETFL, 0);
|
||||
if (retval < 0) {
|
||||
err(udev, "error fcntl on read pipe: %s\n", strerror(errno));
|
||||
err(udev, "error fcntl on read pipe: %m\n");
|
||||
goto exit;
|
||||
}
|
||||
retval = fcntl(signal_pipe[READ_END], F_SETFL, retval | O_NONBLOCK);
|
||||
if (retval < 0) {
|
||||
err(udev, "error fcntl on read pipe: %s\n", strerror(errno));
|
||||
err(udev, "error fcntl on read pipe: %m\n");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
retval = fcntl(signal_pipe[WRITE_END], F_GETFL, 0);
|
||||
if (retval < 0) {
|
||||
err(udev, "error fcntl on write pipe: %s\n", strerror(errno));
|
||||
err(udev, "error fcntl on write pipe: %m\n");
|
||||
goto exit;
|
||||
}
|
||||
retval = fcntl(signal_pipe[WRITE_END], F_SETFL, retval | O_NONBLOCK);
|
||||
if (retval < 0) {
|
||||
err(udev, "error fcntl on write pipe: %s\n", strerror(errno));
|
||||
err(udev, "error fcntl on write pipe: %m\n");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@ -917,7 +917,7 @@ int main(int argc, char *argv[])
|
||||
dbg(udev, "daemonized fork running\n");
|
||||
break;
|
||||
case -1:
|
||||
err(udev, "fork of daemon failed: %s\n", strerror(errno));
|
||||
err(udev, "fork of daemon failed: %m\n");
|
||||
rc = 4;
|
||||
goto exit;
|
||||
default:
|
||||
@ -945,7 +945,7 @@ int main(int argc, char *argv[])
|
||||
/* OOM_DISABLE == -17 */
|
||||
fd = open("/proc/self/oom_adj", O_RDWR);
|
||||
if (fd < 0)
|
||||
err(udev, "error disabling OOM: %s\n", strerror(errno));
|
||||
err(udev, "error disabling OOM: %m\n");
|
||||
else {
|
||||
write(fd, "-17", 3);
|
||||
close(fd);
|
||||
@ -992,7 +992,7 @@ int main(int argc, char *argv[])
|
||||
} else if (errno == ENOSYS)
|
||||
err(udev, "the kernel does not support inotify, udevd can't monitor rules file changes\n");
|
||||
else
|
||||
err(udev, "inotify_init failed: %s\n", strerror(errno));
|
||||
err(udev, "inotify_init failed: %m\n");
|
||||
|
||||
/* maximum limit of forked childs */
|
||||
value = getenv("UDEVD_MAX_CHILDS");
|
||||
@ -1035,7 +1035,7 @@ int main(int argc, char *argv[])
|
||||
fdcount = select(maxfd+1, &readfds, NULL, NULL, NULL);
|
||||
if (fdcount < 0) {
|
||||
if (errno != EINTR)
|
||||
err(udev, "error in select: %s\n", strerror(errno));
|
||||
err(udev, "error in select: %m\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user