diff options
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c index 85ee09d142..12c19b353b 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", |