errno-util: add ERRNO_IS_DEVICE_ABSENT() macro

Inspired by: https://github.com/systemd/systemd/pull/22717#discussion_r834254495
This commit is contained in:
Lennart Poettering
2022-03-24 16:19:48 +01:00
parent 4029328014
commit 3f2ada89f3
4 changed files with 14 additions and 5 deletions
+9 -1
View File
@@ -138,10 +138,18 @@ static inline bool ERRNO_IS_PRIVILEGE(int r) {
EPERM);
}
/* Three difference errors for "not enough disk space" */
/* Three different errors for "not enough disk space" */
static inline bool ERRNO_IS_DISK_SPACE(int r) {
return IN_SET(abs(r),
ENOSPC,
EDQUOT,
EFBIG);
}
/* Three different errors for "this device does not quite exist" */
static inline bool ERRNO_IS_DEVICE_ABSENT(int r) {
return IN_SET(abs(r),
ENODEV,
ENXIO,
ENOENT);
}