X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Futil.c;h=12c19b353b0f0e9b5883baacfca7ee681742db40;hb=00dc5d769ac4a4019d6b6fe22e8383ec8b030a96;hp=85ee09d1422ed33cca8bec09e8fb4774cbf9ed30;hpb=3c14d26c4746768f1dc63d4b7ac0278a7abe5da1;p=elogind.git diff --git a/src/util.c b/src/util.c index 85ee09d14..12c19b353 100644 --- a/src/util.c +++ b/src/util.c @@ -3313,6 +3313,21 @@ void freeze(void) { pause(); } +bool null_or_empty(struct stat *st) { + assert(st); + + if (S_ISREG(st->st_mode) && st->st_size <= 0) + return true; + + /* /dev/null has major/minor of 1:3 */ + if (S_ISCHR(st->st_mode) && + major(st->st_rdev) == 1 && + minor(st->st_rdev) == 3) + return true; + + return false; +} + static const char *const ioprio_class_table[] = { [IOPRIO_CLASS_NONE] = "none", [IOPRIO_CLASS_RT] = "realtime",