Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
systemd
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
steam
systemd
Commits
742a862b
Commit
742a862b
authored
Sep 11, 2012
by
Lennart Poettering
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
condition: add ConditionFileNotEmpty=
https://bugs.freedesktop.org/show_bug.cgi?id=54448
parent
b5b46d59
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
7 deletions
+26
-7
man/systemd.unit.xml
man/systemd.unit.xml
+15
-7
src/core/condition.c
src/core/condition.c
+10
-0
src/core/condition.h
src/core/condition.h
+1
-0
No files found.
man/systemd.unit.xml
View file @
742a862b
...
...
@@ -755,6 +755,7 @@
<term><varname>
ConditionPathIsMountPoint=
</varname></term>
<term><varname>
ConditionPathIsReadWrite=
</varname></term>
<term><varname>
ConditionDirectoryNotEmpty=
</varname></term>
<term><varname>
ConditionFileNotEmpty=
</varname></term>
<term><varname>
ConditionFileIsExecutable=
</varname></term>
<term><varname>
ConditionKernelCommandLine=
</varname></term>
<term><varname>
ConditionVirtualization=
</varname></term>
...
...
@@ -825,21 +826,28 @@
(i.e. not mounted
read-only).
</para>
<para><varname>
Condition
FileIsExecutable
=
</varname>
<para><varname>
Condition
DirectoryNotEmpty
=
</varname>
is similar to
<varname>
ConditionPathExists=
</varname>
but verifies whether a certain path
exists
, is a regular file and marked
executable
.
</para>
exists
and is a non-empty
directory
.
</para>
<para><varname>
Condition
Directory
NotEmpty=
</varname>
<para><varname>
Condition
File
NotEmpty=
</varname>
is similar to
<varname>
ConditionPathExists=
</varname>
but verifies whether a certain path
exists and is a non-empty
directory.
</para>
exists and refers to a regular file
with a non-zero size.
</para>
<para><varname>
ConditionFileIsExecutable=
</varname>
is similar to
<varname>
ConditionPathExists=
</varname>
but verifies whether a certain path
exists, is a regular file and marked
executable.
</para>
<para>
Similar
ly
,
<para>
Similar,
<varname>
ConditionKernelCommandLine=
</varname>
may be used to check whether a
specific kernel command line option is
...
...
src/core/condition.c
View file @
742a862b
...
...
@@ -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"
,
...
...
src/core/condition.h
View file @
742a862b
...
...
@@ -33,6 +33,7 @@ typedef enum ConditionType {
CONDITION_PATH_IS_MOUNT_POINT
,
CONDITION_PATH_IS_READ_WRITE
,
CONDITION_DIRECTORY_NOT_EMPTY
,
CONDITION_FILE_NOT_EMPTY
,
CONDITION_FILE_IS_EXECUTABLE
,
CONDITION_KERNEL_COMMAND_LINE
,
CONDITION_VIRTUALIZATION
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment