Fixes #38033.
#include "build.h"
#include "device-nodes.h"
+#include "errno-util.h"
#include "fd-util.h"
#include "log.h"
#include "main-func.h"
return r;
fd = open(ASSERT_PTR(arg_device), O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_NOCTTY);
- if (fd < 0)
- return log_error_errno(errno, "Cannot open %s: %m", arg_device);
+ if (fd < 0) {
+ bool ignore = ERRNO_IS_DEVICE_ABSENT(errno);
+ log_full_errno(ignore ? LOG_DEBUG : LOG_WARNING, errno,
+ "Failed to open device node '%s'%s: %m",
+ arg_device, ignore ? ", ignoring" : "");
+ return ignore ? 0 : -errno;
+ }
if (disk_identify(fd, identify.byte, &peripheral_device_type) >= 0) {
/*
#include "alloc-util.h"
#include "build.h"
+#include "errno-util.h"
#include "fd-util.h"
#include "main-func.h"
#include "random-util.h"
return r;
r = open_drive(&c);
+ if (ERRNO_IS_NEG_DEVICE_ABSENT(r))
+ return 0;
if (r < 0)
- return r;
+ return log_warning_errno(r, "Failed to open device node '%s': %m", arg_node);
/* same data as original cdrom_id */
r = cd_capability_compat(&c);
#include <sys/ioctl.h>
#include "build.h"
+#include "errno-util.h"
#include "fd-util.h"
#include "log.h"
#include "main-func.h"
return r;
mtd_fd = open(argv[1], O_RDONLY|O_CLOEXEC|O_NOCTTY);
- if (mtd_fd < 0)
- return log_error_errno(errno, "Failed to open: %m");
+ if (mtd_fd < 0) {
+ bool ignore = ERRNO_IS_DEVICE_ABSENT(errno);
+ log_full_errno(ignore ? LOG_DEBUG : LOG_WARNING, errno,
+ "Failed to open device node '%s'%s: %m",
+ argv[1], ignore ? ", ignoring" : "");
+ return ignore ? 0 : -errno;
+ }
if (ioctl(mtd_fd, MEMGETINFO, &mtd_info) < 0)
return log_error_errno(errno, "MEMGETINFO ioctl failed: %m");
#include <sys/ioctl.h>
#include "device-util.h"
+#include "errno-util.h"
#include "fd-util.h"
#include "parse-util.h"
#include "stdio-util.h"
if (fd < 0) {
fd = sd_device_open(dev, O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
- if (fd < 0)
- return log_device_error_errno(dev, fd, "Failed to open device '%s': %m", node);
+ if (fd < 0) {
+ bool ignore = ERRNO_IS_DEVICE_ABSENT(fd);
+ log_device_full_errno(dev, ignore ? LOG_DEBUG : LOG_WARNING, fd,
+ "Failed to open device '%s'%s: %m",
+ node, ignore ? ", ignoring" : "");
+ return ignore ? 0 : fd;
+ }
}
(void) map_keycode(dev, fd, scancode, keycode);
if (fd < 0) {
fd = sd_device_open(dev, O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
- if (fd < 0)
- return log_device_error_errno(dev, fd, "Failed to open device '%s': %m", node);
+ if (fd < 0) {
+ bool ignore = ERRNO_IS_DEVICE_ABSENT(fd);
+ log_device_full_errno(dev, ignore ? LOG_DEBUG : LOG_WARNING, fd,
+ "Failed to open device '%s'%s: %m",
+ node, ignore ? ", ignoring" : "");
+ return ignore ? 0 : fd;
+ }
}
if (has_abs == -1) {
return 0;
_cleanup_close_ int fd = sd_device_open(dev, O_CLOEXEC|O_PATH);
- if (fd < 0)
- return log_device_error_errno(dev, fd, "Failed to open device node: %m");
+ if (fd < 0) {
+ bool ignore = ERRNO_IS_DEVICE_ABSENT(fd);
+ log_device_full_errno(dev, ignore ? LOG_DEBUG : LOG_WARNING, fd,
+ "Failed to open device node%s: %m",
+ ignore ? ", ignoring" : "");
+ return ignore ? 0 : fd;
+ }
const char *seat;
r = device_get_seat(dev, &seat);
node_fd = open(devnode, O_PATH|O_CLOEXEC);
if (node_fd < 0) {
- if (errno != ENOENT)
- return log_error_errno(errno, "Failed to open %s: %m", devnode);
- return 0;
+ bool ignore = ERRNO_IS_DEVICE_ABSENT(errno);
+ log_full_errno(ignore ? LOG_DEBUG : LOG_WARNING, errno,
+ "Failed to open device node '%s'%s: %m",
+ devnode, ignore ? ", ignoring" : "");
+ return ignore ? 0 : -errno;
}
if (fstat(node_fd, &stats) < 0)
if (r > 0)
return 0;
- const char *val;
- r = sd_device_get_devname(dev, &val);
+ const char *node;
+ r = sd_device_get_devname(dev, &node);
if (r < 0)
return log_device_debug_errno(dev, r, "Failed to get device node: %m");
_cleanup_close_ int fd = sd_device_open(dev, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
- if (fd < 0)
- return log_device_debug_errno(dev, fd, "Failed to open '%s', ignoring: %m", val);
+ if (fd < 0) {
+ bool ignore = ERRNO_IS_DEVICE_ABSENT(fd);
+ log_device_full_errno(dev, ignore ? LOG_DEBUG : LOG_WARNING, fd,
+ "Failed to open device node '%s'%s: %m",
+ node, ignore ? ", ignoring" : "");
+ return ignore ? 0 : fd;
+ }
int state = 1;
if (ioctl(fd, BLKROSET, &state) < 0)
- return log_device_warning_errno(dev, errno, "Failed to mark block device '%s' read-only: %m", val);
+ return log_device_warning_errno(dev, errno, "Failed to mark block device '%s' read-only: %m", node);
- log_device_info(dev, "Successfully marked block device '%s' read-only.", val);
+ log_device_info(dev, "Successfully marked block device '%s' read-only.", node);
return 0;
}
#include <sys/ioctl.h>
#include "build.h"
+#include "errno-util.h"
#include "fd-util.h"
#include "log.h"
#include "main-func.h"
return r;
fd = open(arg_device, O_RDONLY|O_CLOEXEC|O_NOCTTY);
- if (fd < 0)
- return log_error_errno(errno, "Failed to open %s: %m", arg_device);
+ if (fd < 0) {
+ bool ignore = ERRNO_IS_DEVICE_ABSENT(errno);
+ log_full_errno(ignore ? LOG_DEBUG : LOG_WARNING, errno,
+ "Failed to open device node '%s'%s: %m",
+ arg_device, ignore ? ", ignoring" : "");
+ return ignore ? 0 : -errno;
+ }
if (ioctl(fd, VIDIOC_QUERYCAP, &v2cap) == 0) {
int capabilities;