summaryrefslogtreecommitdiff
path: root/src/core/condition.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-09-11 01:29:46 +0200
committerLennart Poettering <lennart@poettering.net>2012-09-11 01:29:46 +0200
commit742a862bb803641b78a40f6b498486397a321294 (patch)
treed4a3f3d4fb4e8e6d4a25f8e597f15ce6d7fcf7bf /src/core/condition.c
parentb5b46d599524341ddd7407e5dff1021af8ff5089 (diff)
condition: add ConditionFileNotEmpty=
https://bugs.freedesktop.org/show_bug.cgi?id=54448
Diffstat (limited to 'src/core/condition.c')
-rw-r--r--src/core/condition.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/core/condition.c b/src/core/condition.c
index e5cda21c37..32a37ccad6 100644
--- a/src/core/condition.c
+++ b/src/core/condition.c
@@ -261,6 +261,15 @@ bool condition_test(Condition *c) {
return !(k == -ENOENT || k > 0) == !c->negate;
}
+ case CONDITION_FILE_NOT_EMPTY: {
+ struct stat st;
+
+ if (stat(c->parameter, &st) < 0)
+ return c->negate;
+
+ return (S_ISREG(st.st_mode) && st.st_size > 0) == !c->negate;
+ }
+
case CONDITION_FILE_IS_EXECUTABLE: {
struct stat st;
@@ -350,6 +359,7 @@ static const char* const condition_type_table[_CONDITION_TYPE_MAX] = {
[CONDITION_PATH_IS_MOUNT_POINT] = "ConditionPathIsMountPoint",
[CONDITION_PATH_IS_READ_WRITE] = "ConditionPathIsReadWrite",
[CONDITION_DIRECTORY_NOT_EMPTY] = "ConditionDirectoryNotEmpty",
+ [CONDITION_FILE_NOT_EMPTY] = "ConditionFileNotEmpty",
[CONDITION_KERNEL_COMMAND_LINE] = "ConditionKernelCommandLine",
[CONDITION_VIRTUALIZATION] = "ConditionVirtualization",
[CONDITION_SECURITY] = "ConditionSecurity",