[systemd-commits] man/systemd.unit.xml src/condition.c src/condition.h src/load-fragment-gperf.gperf.m4 units/var-lock.mount units/var-run.mount
Michal Schmidt
michich at kemper.freedesktop.org
Tue Sep 20 16:58:48 PDT 2011
man/systemd.unit.xml | 13 ++++++++++---
src/condition.c | 9 +++++++++
src/condition.h | 1 +
src/load-fragment-gperf.gperf.m4 | 1 +
units/var-lock.mount | 1 +
units/var-run.mount | 1 +
6 files changed, 23 insertions(+), 3 deletions(-)
New commits:
commit 0d60602c3b4d4b65da672d75c6146f2ea4b27f88
Author: Michal Schmidt <mschmidt at redhat.com>
Date: Wed Sep 21 01:29:38 2011 +0200
condition: add ConditionPathIsSymbolicLink
diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml
index 4437510..f4764f9 100644
--- a/man/systemd.unit.xml
+++ b/man/systemd.unit.xml
@@ -665,6 +665,7 @@
<term><varname>ConditionPathExists=</varname></term>
<term><varname>ConditionPathExistsGlob=</varname></term>
<term><varname>ConditionPathIsDirectory=</varname></term>
+ <term><varname>ConditionPathIsSymbolicLink=</varname></term>
<term><varname>ConditionPathIsMountPoint=</varname></term>
<term><varname>ConditionDirectoryNotEmpty=</varname></term>
<term><varname>ConditionFileIsExecutable=</varname></term>
@@ -702,7 +703,12 @@
<varname>ConditionPathExists=</varname>
but verifies whether a certain path
exists and is a
- directory. <varname>ConditionPathIsMountPoint=</varname>
+ directory. <varname>ConditionPathIsSymbolicLink=</varname>
+ is similar to
+ <varname>ConditionPathExists=</varname>
+ but verifies whether a certain path
+ exists and is a
+ symbolic link. <varname>ConditionPathIsMountPoint=</varname>
is similar to
<varname>ConditionPathExists=</varname>
but verifies whether a certain path
@@ -780,8 +786,9 @@
prefix an argument with the pipe
symbol and an exclamation mark the
pipe symbol must be passed first, the
- exclamation second. All path checks
- follow symlinks.</para></listitem>
+ exclamation second. Except for
+ <varname>ConditionPathIsSymbolicLink=</varname>,
+ all path checks follow symlinks.</para></listitem>
</varlistentry>
<varlistentry>
diff --git a/src/condition.c b/src/condition.c
index 7f85649..f84c81b 100644
--- a/src/condition.c
+++ b/src/condition.c
@@ -167,6 +167,14 @@ bool condition_test(Condition *c) {
return S_ISDIR(st.st_mode) == !c->negate;
}
+ case CONDITION_PATH_IS_SYMBOLIC_LINK: {
+ struct stat st;
+
+ if (lstat(c->parameter, &st) < 0)
+ return !c->negate;
+ return S_ISLNK(st.st_mode) == !c->negate;
+ }
+
case CONDITION_PATH_IS_MOUNT_POINT:
return (path_is_mount_point(c->parameter, true) > 0) == !c->negate;
@@ -256,6 +264,7 @@ static const char* const condition_type_table[_CONDITION_TYPE_MAX] = {
[CONDITION_PATH_EXISTS] = "ConditionPathExists",
[CONDITION_PATH_EXISTS_GLOB] = "ConditionPathExistsGlob",
[CONDITION_PATH_IS_DIRECTORY] = "ConditionPathIsDirectory",
+ [CONDITION_PATH_IS_SYMBOLIC_LINK] = "ConditionPathIsSymbolicLink",
[CONDITION_PATH_IS_MOUNT_POINT] = "ConditionPathIsMountPoint",
[CONDITION_DIRECTORY_NOT_EMPTY] = "ConditionDirectoryNotEmpty",
[CONDITION_KERNEL_COMMAND_LINE] = "ConditionKernelCommandLine",
diff --git a/src/condition.h b/src/condition.h
index 66b020f..dd65aa6 100644
--- a/src/condition.h
+++ b/src/condition.h
@@ -30,6 +30,7 @@ typedef enum ConditionType {
CONDITION_PATH_EXISTS,
CONDITION_PATH_EXISTS_GLOB,
CONDITION_PATH_IS_DIRECTORY,
+ CONDITION_PATH_IS_SYMBOLIC_LINK,
CONDITION_PATH_IS_MOUNT_POINT,
CONDITION_DIRECTORY_NOT_EMPTY,
CONDITION_FILE_IS_EXECUTABLE,
diff --git a/src/load-fragment-gperf.gperf.m4 b/src/load-fragment-gperf.gperf.m4
index 370a7a7..7749b88 100644
--- a/src/load-fragment-gperf.gperf.m4
+++ b/src/load-fragment-gperf.gperf.m4
@@ -112,6 +112,7 @@ Unit.JobTimeoutSec, config_parse_usec, 0,
Unit.ConditionPathExists, config_parse_unit_condition_path, CONDITION_PATH_EXISTS, 0
Unit.ConditionPathExistsGlob, config_parse_unit_condition_path, CONDITION_PATH_EXISTS_GLOB, 0
Unit.ConditionPathIsDirectory, config_parse_unit_condition_path, CONDITION_PATH_IS_DIRECTORY, 0
+Unit.ConditionPathIsSymbolicLink,config_parse_unit_condition_path, CONDITION_PATH_IS_SYMBOLIC_LINK,0
Unit.ConditionPathIsMountPoint, config_parse_unit_condition_path, CONDITION_PATH_IS_MOUNT_POINT, 0
Unit.ConditionDirectoryNotEmpty, config_parse_unit_condition_path, CONDITION_DIRECTORY_NOT_EMPTY, 0
Unit.ConditionFileIsExecutable, config_parse_unit_condition_path, CONDITION_FILE_IS_EXECUTABLE, 0
diff --git a/units/var-lock.mount b/units/var-lock.mount
index 80e1bab..07277ad 100644
--- a/units/var-lock.mount
+++ b/units/var-lock.mount
@@ -10,6 +10,7 @@ Description=Lock Directory
Before=local-fs.target
# skip mounting if the directory does not exist or is a symlink
ConditionPathIsDirectory=/var/lock
+ConditionPathIsSymbolicLink=!/var/lock
[Mount]
What=/run/lock
diff --git a/units/var-run.mount b/units/var-run.mount
index c513dfe..ab4da42 100644
--- a/units/var-run.mount
+++ b/units/var-run.mount
@@ -10,6 +10,7 @@ Description=Runtime Directory
Before=local-fs.target
# skip mounting if the directory does not exist or is a symlink
ConditionPathIsDirectory=/var/run
+ConditionPathIsSymbolicLink=!/var/run
[Mount]
What=/run
More information about the systemd-commits
mailing list