summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-10-08 02:31:36 +0200
committerLennart Poettering <lennart@poettering.net>2010-10-08 02:31:36 +0200
commit00dc5d769ac4a4019d6b6fe22e8383ec8b030a96 (patch)
treedb347d86cae6f68f70c085b6560cb313248f2166 /src/util.c
parentc2b3f093d98a9751ba413c9b5d5c572a8a15932c (diff)
unit: introduce 'banned' load state for units symlinked to /dev/null
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c15
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",