return 0;
}
+int state_directory_generic(RuntimeScope scope, const char *suffix, char **ret) {
+ assert(ret);
+
+ /* This does not bother with $STATE_DIRECTORY, and hence can be applied to get other service's state
+ * dir */
+
+ switch (scope) {
+
+ case RUNTIME_SCOPE_USER:
+ return xdg_user_state_dir(suffix, ret);
+
+ case RUNTIME_SCOPE_SYSTEM: {
+ char *d = path_join("/var/lib", suffix);
+ if (!d)
+ return -ENOMEM;
+ *ret = d;
+ return 0;
+ }
+
+ default:
+ return -EINVAL;
+ }
+}
+
static const char* const user_data_unit_paths[] = {
"/usr/local/lib/systemd/user",
"/usr/local/share/systemd/user",
int runtime_directory_generic(RuntimeScope scope, const char *suffix, char **ret);
int runtime_directory(RuntimeScope scope, const char *fallback_suffix, char **ret);
int runtime_directory_make(RuntimeScope scope, const char *subdir, char **ret_dir, char **ret_dir_destroy);
+int state_directory_generic(RuntimeScope scope, const char *suffix, char **ret);
/* We don't treat /etc/xdg/systemd/ in these functions as the xdg base dir spec suggests because we assume
* that is a link to /etc/systemd/ anyway. */
static inline int xdg_user_data_dir(const char *suffix, char **ret) {
return sd_path_lookup(SD_PATH_USER_SHARED, suffix, ret);
}
+static inline int xdg_user_state_dir(const char *suffix, char **ret) {
+ return sd_path_lookup(SD_PATH_USER_STATE_PRIVATE, suffix, ret);
+}
bool path_is_user_data_dir(const char *path);
bool path_is_user_config_dir(const char *path);