Logging fixlets (#38313)
This commit is contained in:
@@ -212,6 +212,13 @@ static inline bool ERRNO_IS_NEG_DEVICE_ABSENT(intmax_t r) {
|
||||
}
|
||||
_DEFINE_ABS_WRAPPER(DEVICE_ABSENT);
|
||||
|
||||
/* Device is absent or "empty". We get -ENOMEDIUM from CD/DVD devices, also in VMs. */
|
||||
static inline bool ERRNO_IS_NEG_DEVICE_ABSENT_OR_EMPTY(intmax_t r) {
|
||||
return ERRNO_IS_NEG_DEVICE_ABSENT(r) ||
|
||||
r == -ENOMEDIUM;
|
||||
}
|
||||
_DEFINE_ABS_WRAPPER(DEVICE_ABSENT_OR_EMPTY);
|
||||
|
||||
/* Quite often we want to handle cases where the backing FS doesn't support extended attributes at all and
|
||||
* where it simply doesn't have the requested xattr the same way */
|
||||
static inline bool ERRNO_IS_NEG_XATTR_ABSENT(intmax_t r) {
|
||||
|
||||
+8
-8
@@ -1931,9 +1931,9 @@ static int socket_coldplug(Unit *u) {
|
||||
SOCKET_RUNNING)) {
|
||||
|
||||
/* Originally, we used to simply reopen all sockets here that we didn't have file descriptors
|
||||
* for. However, this is problematic, as we won't traverse through the SOCKET_START_CHOWN state for
|
||||
* them, and thus the UID/GID wouldn't be right. Hence, instead simply check if we have all fds open,
|
||||
* and if there's a mismatch, warn loudly.
|
||||
* for. However, this is problematic, as we won't traverse through the SOCKET_START_CHOWN
|
||||
* state for them, and thus the UID/GID wouldn't be right. Hence, instead simply check if we
|
||||
* have all fds open, and if there's a mismatch, warn loudly.
|
||||
*
|
||||
* Note that SOCKET_START_OPEN requires no special treatment, as it's only intermediate
|
||||
* between SOCKET_START_PRE and SOCKET_START_CHOWN and shall otherwise not be observed.
|
||||
@@ -1942,14 +1942,14 @@ static int socket_coldplug(Unit *u) {
|
||||
r = socket_check_open(s);
|
||||
if (r == SOCKET_OPEN_NONE)
|
||||
log_unit_warning(UNIT(s),
|
||||
"Socket unit configuration has changed while unit has been running, "
|
||||
"no open socket file descriptor left. "
|
||||
"The socket unit is not functional until restarted.");
|
||||
"Unit configuration changed while unit was running, "
|
||||
"and no socket file descriptors are open. "
|
||||
"Unit not functional until restarted.");
|
||||
else if (r == SOCKET_OPEN_SOME)
|
||||
log_unit_warning(UNIT(s),
|
||||
"Socket unit configuration has changed while unit has been running, "
|
||||
"Unit configuration changed while unit was running, "
|
||||
"and some socket file descriptors have not been opened yet. "
|
||||
"The socket unit is not fully functional until restarted.");
|
||||
"Unit not fully functional until restarted.");
|
||||
}
|
||||
|
||||
if (s->deserialized_state == SOCKET_LISTENING) {
|
||||
|
||||
@@ -413,7 +413,7 @@ static int run(int argc, char *argv[]) {
|
||||
|
||||
fd = open(ASSERT_PTR(arg_device), O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_NOCTTY);
|
||||
if (fd < 0) {
|
||||
bool ignore = ERRNO_IS_DEVICE_ABSENT(errno);
|
||||
bool ignore = ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(errno);
|
||||
log_full_errno(ignore ? LOG_DEBUG : LOG_WARNING, errno,
|
||||
"Failed to open device node '%s'%s: %m",
|
||||
arg_device, ignore ? ", ignoring" : "");
|
||||
|
||||
@@ -75,7 +75,7 @@ static int run(int argc, char** argv) {
|
||||
|
||||
mtd_fd = open(argv[1], O_RDONLY|O_CLOEXEC|O_NOCTTY);
|
||||
if (mtd_fd < 0) {
|
||||
bool ignore = ERRNO_IS_DEVICE_ABSENT(errno);
|
||||
bool ignore = ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(errno);
|
||||
log_full_errno(ignore ? LOG_DEBUG : LOG_WARNING, errno,
|
||||
"Failed to open device node '%s'%s: %m",
|
||||
argv[1], ignore ? ", ignoring" : "");
|
||||
|
||||
@@ -499,7 +499,7 @@ static int builtin_blkid(UdevEvent *event, int argc, char *argv[]) {
|
||||
|
||||
fd = sd_device_open(dev, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
|
||||
if (fd < 0) {
|
||||
bool ignore = ERRNO_IS_DEVICE_ABSENT(fd);
|
||||
bool ignore = ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(fd);
|
||||
log_device_debug_errno(dev, fd, "Failed to open block device %s%s: %m",
|
||||
devnode, ignore ? ", ignoring" : "");
|
||||
return ignore ? 0 : fd;
|
||||
|
||||
@@ -35,7 +35,7 @@ static int builtin_btrfs(UdevEvent *event, int argc, char *argv[]) {
|
||||
|
||||
_cleanup_close_ int fd = open("/dev/btrfs-control", O_RDWR|O_CLOEXEC|O_NOCTTY);
|
||||
if (fd < 0) {
|
||||
if (ERRNO_IS_DEVICE_ABSENT(errno)) {
|
||||
if (ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(errno)) {
|
||||
/* Driver not installed? Then we aren't ready. This is useful in initrds that lack
|
||||
* btrfs.ko. After the host transition (where btrfs.ko will hopefully become
|
||||
* available) the device can be retriggered and will then be considered ready. */
|
||||
|
||||
@@ -201,7 +201,7 @@ static int builtin_keyboard(UdevEvent *event, int argc, char *argv[]) {
|
||||
if (fd < 0) {
|
||||
fd = sd_device_open(dev, O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
|
||||
if (fd < 0) {
|
||||
bool ignore = ERRNO_IS_DEVICE_ABSENT(fd);
|
||||
bool ignore = ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(fd);
|
||||
log_device_full_errno(dev, ignore ? LOG_DEBUG : LOG_WARNING, fd,
|
||||
"Failed to open device '%s'%s: %m",
|
||||
node, ignore ? ", ignoring" : "");
|
||||
@@ -223,7 +223,7 @@ static int builtin_keyboard(UdevEvent *event, int argc, char *argv[]) {
|
||||
if (fd < 0) {
|
||||
fd = sd_device_open(dev, O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
|
||||
if (fd < 0) {
|
||||
bool ignore = ERRNO_IS_DEVICE_ABSENT(fd);
|
||||
bool ignore = ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(fd);
|
||||
log_device_full_errno(dev, ignore ? LOG_DEBUG : LOG_WARNING, fd,
|
||||
"Failed to open device '%s'%s: %m",
|
||||
node, ignore ? ", ignoring" : "");
|
||||
|
||||
@@ -122,7 +122,7 @@ static int builtin_uaccess(UdevEvent *event, int argc, char *argv[]) {
|
||||
|
||||
_cleanup_close_ int fd = sd_device_open(dev, O_CLOEXEC|O_PATH);
|
||||
if (fd < 0) {
|
||||
bool ignore = ERRNO_IS_DEVICE_ABSENT(fd);
|
||||
bool ignore = ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(fd);
|
||||
log_device_full_errno(dev, ignore ? LOG_DEBUG : LOG_WARNING, fd,
|
||||
"Failed to open device node%s: %m",
|
||||
ignore ? ", ignoring" : "");
|
||||
|
||||
@@ -431,7 +431,7 @@ static int link_update(sd_device *dev, const char *slink, bool add) {
|
||||
return r;
|
||||
|
||||
r = node_get_current(slink, dirfd, ¤t_id, add ? ¤t_prio : NULL);
|
||||
if (r < 0 && !ERRNO_IS_DEVICE_ABSENT(r))
|
||||
if (r < 0 && !ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(r))
|
||||
return log_device_debug_errno(dev, r, "Failed to get the current device node priority for '%s': %m", slink);
|
||||
|
||||
r = stack_directory_update(dev, dirfd, add);
|
||||
@@ -702,7 +702,7 @@ int udev_node_apply_permissions(
|
||||
|
||||
node_fd = sd_device_open(dev, O_PATH|O_CLOEXEC);
|
||||
if (node_fd < 0) {
|
||||
if (ERRNO_IS_DEVICE_ABSENT(node_fd)) {
|
||||
if (ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(node_fd)) {
|
||||
log_device_debug_errno(dev, node_fd, "Device node %s is missing, skipping handling.", devnode);
|
||||
return 0; /* This is necessarily racey, so ignore missing the device */
|
||||
}
|
||||
@@ -735,7 +735,7 @@ int static_node_apply_permissions(
|
||||
|
||||
node_fd = open(devnode, O_PATH|O_CLOEXEC);
|
||||
if (node_fd < 0) {
|
||||
bool ignore = ERRNO_IS_DEVICE_ABSENT(errno);
|
||||
bool ignore = ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(errno);
|
||||
log_full_errno(ignore ? LOG_DEBUG : LOG_WARNING, errno,
|
||||
"Failed to open device node '%s'%s: %m",
|
||||
devnode, ignore ? ", ignoring" : "");
|
||||
|
||||
@@ -112,7 +112,7 @@ static int worker_lock_whole_disk(UdevWorker *worker, sd_device *dev, int *ret_f
|
||||
|
||||
fd = sd_device_open(dev_whole_disk, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
|
||||
if (fd < 0) {
|
||||
bool ignore = ERRNO_IS_DEVICE_ABSENT(fd);
|
||||
bool ignore = ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(fd);
|
||||
|
||||
log_device_debug_errno(dev, fd, "Failed to open '%s'%s: %m", whole_disk, ignore ? ", ignoring" : "");
|
||||
if (!ignore)
|
||||
@@ -178,7 +178,7 @@ static int worker_mark_block_device_read_only(sd_device *dev) {
|
||||
|
||||
_cleanup_close_ int fd = sd_device_open(dev, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
|
||||
if (fd < 0) {
|
||||
bool ignore = ERRNO_IS_DEVICE_ABSENT(fd);
|
||||
bool ignore = ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(fd);
|
||||
log_device_full_errno(dev, ignore ? LOG_DEBUG : LOG_WARNING, fd,
|
||||
"Failed to open device node '%s'%s: %m",
|
||||
node, ignore ? ", ignoring" : "");
|
||||
|
||||
@@ -61,7 +61,7 @@ static int run(int argc, char *argv[]) {
|
||||
|
||||
fd = open(arg_device, O_RDONLY|O_CLOEXEC|O_NOCTTY);
|
||||
if (fd < 0) {
|
||||
bool ignore = ERRNO_IS_DEVICE_ABSENT(errno);
|
||||
bool ignore = ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(errno);
|
||||
log_full_errno(ignore ? LOG_DEBUG : LOG_WARNING, errno,
|
||||
"Failed to open device node '%s'%s: %m",
|
||||
arg_device, ignore ? ", ignoring" : "");
|
||||
|
||||
Reference in New Issue
Block a user