errno-util: introduce ERRNO_IS_NEG_FS_WRITE_REFUSED()

This commit is contained in:
Yu Watanabe
2025-07-10 14:02:00 +09:00
parent f436c64e61
commit e28d408c6b
11 changed files with 26 additions and 21 deletions
+1 -1
View File
@@ -62,7 +62,7 @@
/* Returns the log level to use when cgroup attribute writes fail. When an attribute is missing or we have access
* problems we downgrade to LOG_DEBUG. This is supposed to be nice to container managers and kernels which want to mask
* out specific attributes from us. */
#define LOG_LEVEL_CGROUP_WRITE(r) (IN_SET(ABS(r), ENOENT, EROFS, EACCES, EPERM) ? LOG_DEBUG : LOG_WARNING)
#define LOG_LEVEL_CGROUP_WRITE(r) ((ABS(r) == ENOENT || ERRNO_IS_FS_WRITE_REFUSED(r)) ? LOG_DEBUG : LOG_WARNING)
static void unit_remove_from_cgroup_empty_queue(Unit *u);
+5 -4
View File
@@ -1271,8 +1271,8 @@ static void bump_file_max_and_nr_open(void) {
* different, but the operation would fail silently.) */
r = sysctl_write("fs/file-max", LONG_MAX_STR);
if (r < 0)
log_full_errno(IN_SET(r, -EROFS, -EPERM, -EACCES) ? LOG_DEBUG : LOG_WARNING,
r, "Failed to bump fs.file-max, ignoring: %m");
log_full_errno(ERRNO_IS_NEG_FS_WRITE_REFUSED(r) ? LOG_DEBUG : LOG_WARNING, r,
"Failed to bump fs.file-max, ignoring: %m");
#endif
#if BUMP_PROC_SYS_FS_NR_OPEN
@@ -1293,7 +1293,8 @@ static void bump_file_max_and_nr_open(void) {
continue;
}
if (r < 0) {
log_full_errno(IN_SET(r, -EROFS, -EPERM, -EACCES) ? LOG_DEBUG : LOG_WARNING, r, "Failed to bump fs.nr_open, ignoring: %m");
log_full_errno(ERRNO_IS_NEG_FS_WRITE_REFUSED(r) ? LOG_DEBUG : LOG_WARNING, r,
"Failed to bump fs.nr_open, ignoring: %m");
break;
}
@@ -1534,7 +1535,7 @@ static int bump_unix_max_dgram_qlen(void) {
r = sysctl_write("net/unix/max_dgram_qlen", STRINGIFY(DEFAULT_UNIX_MAX_DGRAM_QLEN));
if (r < 0)
return log_full_errno(IN_SET(r, -EROFS, -EPERM, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
return log_full_errno(ERRNO_IS_NEG_FS_WRITE_REFUSED(r) ? LOG_DEBUG : LOG_WARNING, r,
"Failed to bump AF_UNIX datagram queue length, ignoring: %m");
return 1;
+1 -1
View File
@@ -1269,7 +1269,7 @@ static void mount_enter_mounting(Mount *m) {
* when the path is on NFS. See issue #24120. All such errors will be logged in the debug level. */
if (r < 0 && r != -EEXIST)
log_unit_full_errno(UNIT(m),
(r == -EROFS || ERRNO_IS_PRIVILEGE(r)) ? LOG_DEBUG : LOG_WARNING,
ERRNO_IS_NEG_FS_WRITE_REFUSED(r) ? LOG_DEBUG : LOG_WARNING,
r, "Failed to make bind mount source '%s', ignoring: %m", p->what);
}