summaryrefslogtreecommitdiff
path: root/src/shared/volatile-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/volatile-util.c')
-rw-r--r--src/shared/volatile-util.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/shared/volatile-util.c b/src/shared/volatile-util.c
index 1329b51f4e..e7e9721411 100644
--- a/src/shared/volatile-util.c
+++ b/src/shared/volatile-util.c
@@ -17,8 +17,10 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include "alloc-util.h"
#include "macro.h"
#include "parse-util.h"
+#include "proc-cmdline.h"
#include "string-util.h"
#include "volatile-util.h"
@@ -39,3 +41,28 @@ VolatileMode volatile_mode_from_string(const char *s) {
return _VOLATILE_MODE_INVALID;
}
+
+int query_volatile_mode(VolatileMode *ret) {
+ _cleanup_free_ char *mode = NULL;
+ VolatileMode m = VOLATILE_NO;
+ int r;
+
+ r = proc_cmdline_get_key("systemd.volatile", PROC_CMDLINE_VALUE_OPTIONAL, &mode);
+ if (r < 0)
+ return r;
+ if (r == 0)
+ goto finish;
+
+ if (mode) {
+ m = volatile_mode_from_string(mode);
+ if (m < 0)
+ return -EINVAL;
+ } else
+ m = VOLATILE_YES;
+
+ r = 1;
+
+finish:
+ *ret = m;
+ return r;
+}