#include "tmpfile-util.h"
#include "user-util.h"
-int runtime_directory(char **ret, RuntimeScope scope, const char *suffix) {
+int runtime_directory(RuntimeScope scope, const char *suffix, char **ret) {
int r;
- assert(ret);
+ assert(IN_SET(scope, RUNTIME_SCOPE_SYSTEM, RUNTIME_SCOPE_USER));
assert(suffix);
- assert(IN_SET(scope, RUNTIME_SCOPE_SYSTEM, RUNTIME_SCOPE_USER, RUNTIME_SCOPE_GLOBAL));
+ assert(ret);
/* Accept $RUNTIME_DIRECTORY as authoritative
- * If its missing apply the suffix to /run or $XDG_RUNTIME_DIR
- * if we are in a user runtime scope.
+ * If it's missing, apply the suffix to /run/, or $XDG_RUNTIME_DIR if we are in a user runtime scope.
*
* Return value indicates whether the suffix was applied or not */
*ret = d;
}
- return true;
+ return 1;
}
static const char* const user_data_unit_paths[] = {
void lookup_paths_log(LookupPaths *p);
void lookup_paths_done(LookupPaths *p);
+int runtime_directory(RuntimeScope scope, const char *suffix, char **ret);
+
int xdg_user_dirs(char ***ret_config_dirs, char ***ret_data_dirs);
/* We don't treat /etc/xdg/systemd/ in these functions as the xdg base dir spec suggests because we assume
static inline int xdg_user_data_dir(const char *suffix, char **ret) {
return sd_path_lookup(SD_PATH_USER_SHARED, suffix, ret);
}
-int runtime_directory(char **ret, RuntimeScope scope, const char *suffix);
bool path_is_user_data_dir(const char *path);
bool path_is_user_config_dir(const char *path);
/* if we are going to be starting any units with state then create our runtime dir */
if (arg_tpm != 0 || arg_directory || arg_runtime_mounts.n_mounts != 0) {
- r = runtime_directory(&arg_runtime_directory, arg_privileged ? RUNTIME_SCOPE_SYSTEM : RUNTIME_SCOPE_USER, "systemd/vmspawn");
+ r = runtime_directory(arg_privileged ? RUNTIME_SCOPE_SYSTEM : RUNTIME_SCOPE_USER, "systemd/vmspawn",
+ &arg_runtime_directory);
if (r < 0)
return log_error_errno(r, "Failed to lookup runtime directory: %m");
- if (r) {
- /* r > 0 means we need to create our own runtime dir */
+ if (r > 0) { /* We need to create our own runtime dir */
r = mkdir_p(arg_runtime_directory, 0755);
if (r < 0)
return log_error_errno(r, "Failed to create runtime directory: %m");