* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
-
#include <stddef.h>
#include <signal.h>
#include <unistd.h>
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:
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;
}
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;
}
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;
const char *value;
int daemonize = 0;
static const struct option options[] = {
- { "daemon", 0, NULL, 'd' },
- { "debug-trace", 0, NULL, 't' },
- { "debug", 0, NULL, 'D' },
- { "help", 0, NULL, 'h' },
- { "version", 0, NULL, 'V' },
+ { "daemon", no_argument, NULL, 'd' },
+ { "debug-trace", no_argument, NULL, 't' },
+ { "debug", no_argument, NULL, 'D' },
+ { "help", no_argument, NULL, 'h' },
+ { "version", no_argument, NULL, 'V' },
{}
};
int rc = 1;
logging_init("udevd");
udev_set_log_fn(udev, log_fn);
dbg(udev, "version %s\n", VERSION);
+ selinux_init(udev);
while (1) {
int option;
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;
}
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:
/* 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);
fd = open("/dev/kmsg", O_WRONLY);
if (fd > 0) {
- const char *str = "<6>udevd version " VERSION " started\n";
-
- write(fd, str, strlen(str));
+ const char *ver_str = "<6>udev: starting version " VERSION "\n";
+ char path[UTIL_PATH_SIZE];
+ struct stat statbuf;
+
+ write(fd, ver_str, strlen(ver_str));
+ util_strlcpy(path, udev_get_sys_path(udev), sizeof(path));
+ util_strlcat(path, "/class/mem/null", sizeof(path));
+ if (lstat(path, &statbuf) == 0) {
+ if (S_ISDIR(statbuf.st_mode)) {
+ const char *depr_str = "<6>udev: deprecated sysfs layout (kernel too old, "
+ "or CONFIG_SYSFS_DEPRECATED) is unsupported, some "
+ "udev features may fail\n";
+
+ write(fd, depr_str, strlen(depr_str));
+ }
+ }
close(fd);
}
} 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");
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;
}
if (uevent_netlink_sock >= 0)
close(uevent_netlink_sock);
+ selinux_exit(udev);
+ udev_unref(udev);
logging_close();
return rc;
}