summaryrefslogtreecommitdiffstats
path: root/src/shared/open-file.h
diff options
context:
space:
mode:
authorRichard Phibel <rphibel@googlemail.com>2022-11-07 17:13:15 +0100
committerLennart Poettering <lennart@poettering.net>2023-01-10 15:16:26 +0100
commitcd48e23f6a33c9acb47a06b99d9bdc84ee42cebe (patch)
tree4c241fe4081efeb70aa6b33ff9a7613b2b0b2720 /src/shared/open-file.h
parentci: Remove a bunch of labels when a PR is merged (diff)
downloadsystemd-cd48e23f6a33c9acb47a06b99d9bdc84ee42cebe.tar.xz
systemd-cd48e23f6a33c9acb47a06b99d9bdc84ee42cebe.zip
core: add OpenFile setting
Diffstat (limited to 'src/shared/open-file.h')
-rw-r--r--src/shared/open-file.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/shared/open-file.h b/src/shared/open-file.h
new file mode 100644
index 0000000000..bb63ec8f9c
--- /dev/null
+++ b/src/shared/open-file.h
@@ -0,0 +1,36 @@
+
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include "list.h"
+
+typedef enum OpenFileFlag {
+ OPENFILE_READ_ONLY = 1 << 0,
+ OPENFILE_APPEND = 1 << 1,
+ OPENFILE_TRUNCATE = 1 << 2,
+ OPENFILE_GRACEFUL = 1 << 3,
+ _OPENFILE_MAX,
+ _OPENFILE_INVALID = -EINVAL,
+ _OPENFILE_MASK_PUBLIC = OPENFILE_READ_ONLY | OPENFILE_APPEND | OPENFILE_TRUNCATE | OPENFILE_GRACEFUL,
+} OpenFileFlag;
+
+typedef struct OpenFile {
+ char *path;
+ char *fdname;
+ OpenFileFlag flags;
+ LIST_FIELDS(struct OpenFile, open_files);
+} OpenFile;
+
+int open_file_parse(const char *v, OpenFile **ret);
+
+int open_file_validate(const OpenFile *of);
+
+int open_file_to_string(const OpenFile *of, char **ret);
+
+OpenFile *open_file_free(OpenFile *of);
+DEFINE_TRIVIAL_CLEANUP_FUNC(OpenFile*, open_file_free);
+
+void open_file_free_many(OpenFile **head);
+
+const char *open_file_flags_to_string(OpenFileFlag t) _const_;
+OpenFileFlag open_file_flags_from_string(const char *t) _pure_;