use /run instead of /dev/.run

Instead of the /dev/.run trick we have currently implemented, we decided
to move the early-boot runtime dir to /run.

An existing /var/run directory is bind-mounted to /run. If /var/run is
already a symlink, no action is taken.

An existing /var/lock directory is bind-mounted to /run/lock.
If /var/lock is already a symlink, no action is taken.

To implement the directory vs. symlink logic, we have a:
  ConditionPathIsDirectory=
now, which is used in the mount units.

Skipped mount unit in case of symlink:
  $ systemctl status var-run.mount
  var-run.mount - Runtime Directory
    Loaded: loaded (/lib/systemd/system/var-run.mount)
    Active: inactive (dead)
            start condition failed at Fri, 25 Mar 2011 04:51:41 +0100; 6min ago
     Where: /var/run
      What: /run
    CGroup: name=systemd:/system/var-run.mount

The systemd rpm needs to make sure to add something like:
  %pre
  mkdir -p -m0755 /run >/dev/null 2>&1 || :
or it needs to be added to filesystem.rpm.

Udev -git already uses /run if that exists, and is writable at bootup.
Otherwise it falls back to the current /dev/.udev.

Dracut and plymouth need to be adopted to switch from /dev/.run to run
too.

Cheers,
Kay
This commit is contained in:
Kay Sievers
2011-03-25 05:07:20 +01:00
committed by Lennart Poettering
parent 37f85e66e8
commit 2b583ce657
38 changed files with 329 additions and 258 deletions

View File

@@ -123,7 +123,7 @@
reference implementation.</para>
<para>Internally, this function creates a file in
<filename>/dev/.run/systemd/readahead/</filename> which is
<filename>/run/systemd/readahead/</filename> which is
then used as flag file to notify the read-ahead
subsystem.</para>

View File

@@ -99,7 +99,7 @@
<para>Note that <command>systemd-nspawn</command> will
mount file systems private to the container to
<filename>/dev</filename>,
<filename>/dev/.run</filename> and similar. These will
<filename>/run</filename> and similar. These will
not be visible outside of the container, and their
contents will be lost when the container exits.</para>

View File

@@ -223,7 +223,7 @@ static int create_socket(char **name) {
zero(sa);
sa.un.sun_family = AF_UNIX;
snprintf(sa.un.sun_path, sizeof(sa.un.sun_path)-1, "/dev/.run/systemd/ask-password/sck.%llu", random_ull());
snprintf(sa.un.sun_path, sizeof(sa.un.sun_path)-1, "/run/systemd/ask-password/sck.%llu", random_ull());
if (bind(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path)) < 0) {
r = -errno;
@@ -265,7 +265,7 @@ int ask_password_agent(
_FD_MAX
};
char temp[] = "/dev/.run/systemd/ask-password/tmp.XXXXXX";
char temp[] = "/run/systemd/ask-password/tmp.XXXXXX";
char final[sizeof(temp)] = "";
int fd = -1, r;
FILE *f = NULL;
@@ -280,7 +280,7 @@ int ask_password_agent(
sigset_add_many(&mask, SIGINT, SIGTERM, -1);
assert_se(sigprocmask(SIG_BLOCK, &mask, &oldmask) == 0);
mkdir_p("/dev/.run/systemd/ask-password", 0755);
mkdir_p("/run/systemd/ask-password", 0755);
if ((fd = mkostemp(temp, O_CLOEXEC|O_CREAT|O_WRONLY)) < 0) {
log_error("Failed to create password file: %m");

View File

@@ -49,7 +49,7 @@ int main(int argc, char *argv[]) {
* this to avoid an activation loop when we start dbus when we
* are called when the dbus service is shut down. */
if (!(bus = dbus_connection_open_private("unix:path=/dev/.run/systemd/private", &error))) {
if (!(bus = dbus_connection_open_private("unix:path=/run/systemd/private", &error))) {
#ifndef LEGACY
dbus_error_free(&error);

View File

@@ -134,6 +134,14 @@ bool condition_test(Condition *c) {
case CONDITION_PATH_EXISTS:
return (access(c->parameter, F_OK) >= 0) == !c->negate;
case CONDITION_PATH_IS_DIRECTORY: {
struct stat st;
if (lstat(c->parameter, &st) < 0)
return !c->negate;
return S_ISDIR(st.st_mode) == !c->negate;
}
case CONDITION_DIRECTORY_NOT_EMPTY: {
int k;

View File

@@ -28,6 +28,7 @@
typedef enum ConditionType {
CONDITION_PATH_EXISTS,
CONDITION_PATH_IS_DIRECTORY,
CONDITION_DIRECTORY_NOT_EMPTY,
CONDITION_KERNEL_COMMAND_LINE,
CONDITION_VIRTUALIZATION,

View File

@@ -61,7 +61,7 @@ static int next_assignment(
if (!t->parse)
return 0;
return t->parse(filename, line, section, lvalue, rvalue, t->data, userdata);
return t->parse(filename, line, section, lvalue, t->ltype, rvalue, t->data, userdata);
}
/* Warn about unknown non-extension fields. */
@@ -226,6 +226,7 @@ int config_parse_int(
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
@@ -251,6 +252,7 @@ int config_parse_uint64(
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
@@ -276,6 +278,7 @@ int config_parse_unsigned(
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
@@ -301,6 +304,7 @@ int config_parse_size(
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
@@ -328,6 +332,7 @@ int config_parse_bool(
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
@@ -354,6 +359,7 @@ int config_parse_string(
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
@@ -383,6 +389,7 @@ int config_parse_path(
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
@@ -416,6 +423,7 @@ int config_parse_strv(
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
@@ -468,6 +476,7 @@ int config_parse_path_strv(
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {

View File

@@ -28,12 +28,13 @@
/* An abstract parser for simple, line based, shallow configuration
* files consisting of variable assignments only. */
typedef int (*ConfigParserCallback)(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
typedef int (*ConfigParserCallback)(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
/* Wraps info for parsing a specific configuration variable */
typedef struct ConfigItem {
const char *lvalue; /* name of the variable */
ConfigParserCallback parse; /* Function that is called to parse the variable's value */
int ltype; /* Distinguish differnt variables passed to the same callback */
void *data; /* Where to store the variable's data */
const char *section;
} ConfigItem;
@@ -44,15 +45,15 @@ typedef struct ConfigItem {
int config_parse(const char *filename, FILE *f, const char* const *sections, const ConfigItem *t, bool relaxed, void *userdata);
/* Generic parsers */
int config_parse_int(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
int config_parse_unsigned(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
int config_parse_uint64(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
int config_parse_size(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
int config_parse_bool(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
int config_parse_string(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
int config_parse_path(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
int config_parse_strv(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
int config_parse_path_strv(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
int config_parse_int(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_unsigned(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_uint64(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_size(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_bool(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_string(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_path(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_strv(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_path_strv(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
#define DEFINE_CONFIG_PARSE_ENUM(function,name,type,msg) \
int function( \
@@ -60,6 +61,7 @@ int config_parse_path_strv(const char *filename, unsigned line, const char *sect
unsigned line, \
const char *section, \
const char *lvalue, \
int ltype, \
const char *rvalue, \
void *data, \
void *userdata) { \

View File

@@ -104,7 +104,7 @@ int bus_connect(DBusBusType t, DBusConnection **_bus, bool *private, DBusError *
/* If we are root, then let's not go via the bus */
if (geteuid() == 0 && t == DBUS_BUS_SYSTEM) {
if (!(bus = dbus_connection_open_private("unix:path=/dev/.run/systemd/private", error))) {
if (!(bus = dbus_connection_open_private("unix:path=/run/systemd/private", error))) {
#ifndef LEGACY
dbus_error_free(error);

View File

@@ -955,8 +955,8 @@ static int bus_init_private(Manager *m) {
if (getpid() != 1)
return 0;
unlink("/dev/.run/systemd/private");
if (!(m->private_bus = dbus_server_listen("unix:path=/dev/.run/systemd/private", &error))) {
unlink("/run/systemd/private");
if (!(m->private_bus = dbus_server_listen("unix:path=/run/systemd/private", &error))) {
log_error("Failed to create private D-Bus server: %s", error.message);
r = -EIO;
goto fail;

View File

@@ -40,7 +40,7 @@ struct CGroupBonding;
#include "util.h"
/* Abstract namespace! */
#define LOGGER_SOCKET "/dev/.run/systemd/logger"
#define LOGGER_SOCKET "/run/systemd/logger"
typedef enum KillMode {
KILL_CONTROL_GROUP = 0,

View File

@@ -265,7 +265,7 @@ int main(int argc, char *argv[]) {
r = EXIT_SUCCESS;
if (status.si_code == CLD_EXITED && (status.si_status & 1))
touch("/dev/.run/systemd/quotacheck");
touch("/run/systemd/quotacheck");
finish:
if (udev_device)

File diff suppressed because it is too large Load Diff

View File

@@ -142,20 +142,20 @@ int machine_id_setup(void) {
fd = -1;
/* Hmm, we couldn't write it? So let's write it to
* /dev/.run/systemd/machine-id as a replacement */
* /run/systemd/machine-id as a replacement */
mkdir_p("/dev/.run/systemd", 0755);
mkdir_p("/run/systemd", 0755);
if ((r = write_one_line_file("/dev/.run/systemd/machine-id", id)) < 0) {
log_error("Cannot write /dev/.run/systemd/machine-id: %s", strerror(-r));
if ((r = write_one_line_file("/run/systemd/machine-id", id)) < 0) {
log_error("Cannot write /run/systemd/machine-id: %s", strerror(-r));
unlink("/dev/.run/systemd/machine-id");
unlink("/run/systemd/machine-id");
goto finish;
}
/* And now, let's mount it over */
r = mount("/dev/.run/systemd/machine-id", "/etc/machine-id", "bind", MS_BIND|MS_RDONLY, NULL) < 0 ? -errno : 0;
unlink("/dev/.run/systemd/machine-id");
r = mount("/run/systemd/machine-id", "/etc/machine-id", "bind", MS_BIND|MS_RDONLY, NULL) < 0 ? -errno : 0;
unlink("/run/systemd/machine-id");
if (r < 0)
log_error("Failed to mount /etc/machine-id: %s", strerror(-r));

View File

@@ -494,24 +494,24 @@ static DEFINE_CONFIG_PARSE_ENUM(config_parse_output, exec_output, ExecOutput, "F
static int parse_config_file(void) {
const ConfigItem items[] = {
{ "LogLevel", config_parse_level, NULL, "Manager" },
{ "LogTarget", config_parse_target, NULL, "Manager" },
{ "LogColor", config_parse_color, NULL, "Manager" },
{ "LogLocation", config_parse_location, NULL, "Manager" },
{ "DumpCore", config_parse_bool, &arg_dump_core, "Manager" },
{ "CrashShell", config_parse_bool, &arg_crash_shell, "Manager" },
{ "ShowStatus", config_parse_bool, &arg_show_status, "Manager" },
{ "LogLevel", config_parse_level, 0, NULL, "Manager" },
{ "LogTarget", config_parse_target, 0, NULL, "Manager" },
{ "LogColor", config_parse_color, 0, NULL, "Manager" },
{ "LogLocation", config_parse_location, 0, NULL, "Manager" },
{ "DumpCore", config_parse_bool, 0, &arg_dump_core, "Manager" },
{ "CrashShell", config_parse_bool, 0, &arg_crash_shell, "Manager" },
{ "ShowStatus", config_parse_bool, 0, &arg_show_status, "Manager" },
#ifdef HAVE_SYSV_COMPAT
{ "SysVConsole", config_parse_bool, &arg_sysv_console, "Manager" },
{ "SysVConsole", config_parse_bool, 0, &arg_sysv_console, "Manager" },
#endif
{ "CrashChVT", config_parse_int, &arg_crash_chvt, "Manager" },
{ "CPUAffinity", config_parse_cpu_affinity, NULL, "Manager" },
{ "MountAuto", config_parse_bool, &arg_mount_auto, "Manager" },
{ "SwapAuto", config_parse_bool, &arg_swap_auto, "Manager" },
{ "DefaultControllers", config_parse_strv, &arg_default_controllers, "Manager" },
{ "DefaultStandardOutput", config_parse_output, &arg_default_std_output, "Manager" },
{ "DefaultStandardError", config_parse_output, &arg_default_std_error, "Manager" },
{ NULL, NULL, NULL, NULL }
{ "CrashChVT", config_parse_int, 0, &arg_crash_chvt, "Manager" },
{ "CPUAffinity", config_parse_cpu_affinity, 0, NULL, "Manager" },
{ "MountAuto", config_parse_bool, 0, &arg_mount_auto, "Manager" },
{ "SwapAuto", config_parse_bool, 0, &arg_swap_auto, "Manager" },
{ "DefaultControllers", config_parse_strv, 0, &arg_default_controllers, "Manager" },
{ "DefaultStandardOutput", config_parse_output, 0, &arg_default_std_output, "Manager" },
{ "DefaultStandardError", config_parse_output, 0, &arg_default_std_error, "Manager" },
{ NULL, NULL, 0, NULL, NULL }
};
static const char * const sections[] = {
@@ -1074,7 +1074,7 @@ int main(int argc, char *argv[]) {
/* If Plymouth is being run make sure we show the status, so
* that there's something nice to see when people press Esc */
if (access("/dev/.run/initramfs/plymouth", F_OK) >= 0)
if (access("/run/initramfs/plymouth", F_OK) >= 0)
arg_show_status = true;
if (arg_action == ACTION_HELP) {

View File

@@ -66,7 +66,7 @@
#define GC_QUEUE_USEC_MAX (10*USEC_PER_SEC)
/* Where clients shall send notification messages to */
#define NOTIFY_SOCKET_SYSTEM "/dev/.run/systemd/notify"
#define NOTIFY_SOCKET_SYSTEM "/run/systemd/notify"
#define NOTIFY_SOCKET_USER "@/org/freedesktop/systemd1/notify"
static int manager_setup_notify(Manager *m) {
@@ -2592,7 +2592,7 @@ int manager_open_serialization(Manager *m, FILE **_f) {
assert(_f);
if (m->running_as == MANAGER_SYSTEM)
asprintf(&path, "/dev/.run/systemd/dump-%lu-XXXXXX", (unsigned long) getpid());
asprintf(&path, "/run/systemd/dump-%lu-XXXXXX", (unsigned long) getpid());
else
asprintf(&path, "/tmp/systemd-dump-%lu-XXXXXX", (unsigned long) getpid());
@@ -2895,7 +2895,7 @@ void manager_run_generators(Manager *m) {
if (!m->generator_unit_path) {
char *p;
char system_path[] = "/dev/.run/systemd/generator-XXXXXX",
char system_path[] = "/run/systemd/generator-XXXXXX",
user_path[] = "/tmp/systemd-generator-XXXXXX";
if (!(p = mkdtemp(m->running_as == MANAGER_SYSTEM ? system_path : user_path))) {

View File

@@ -54,7 +54,7 @@ static const MountPoint mount_table[] = {
{ "devtmpfs", "/dev", "devtmpfs", "mode=755", MS_NOSUID, true },
{ "tmpfs", "/dev/shm", "tmpfs", "mode=1777", MS_NOSUID|MS_NODEV, true },
{ "devpts", "/dev/pts", "devpts", "mode=620,gid=" STRINGIFY(TTY_GID), MS_NOSUID|MS_NOEXEC, false },
{ "tmpfs", "/dev/.run", "tmpfs", "mode=755", MS_NOSUID|MS_NOEXEC|MS_NODEV, true },
{ "tmpfs", "/run", "tmpfs", "mode=755", MS_NOSUID|MS_NOEXEC|MS_NODEV, true },
{ "tmpfs", "/sys/fs/cgroup", "tmpfs", "mode=755", MS_NOSUID|MS_NOEXEC|MS_NODEV, true },
{ "cgroup", "/sys/fs/cgroup/systemd", "cgroup", "none,name=systemd", MS_NOSUID|MS_NOEXEC|MS_NODEV, true },
};
@@ -253,8 +253,8 @@ int mount_setup(void) {
symlink_and_label(j, k);
/* Create a few directories we always want around */
mkdir("/dev/.run/systemd", 0755);
mkdir("/dev/.run/systemd/ask-password", 0755);
mkdir("/run/systemd", 0755);
mkdir("/run/systemd/ask-password", 0755);
return mount_cgroup_controllers();
}

View File

@@ -844,6 +844,10 @@ static void mount_enter_mounting(Mount *m) {
mkdir_p(m->where, m->directory_mode);
/* create the source directory for bind-mounts if needed */
if (m->parameters_fragment.fstype && strcmp(m->parameters_fragment.fstype, "bind") == 0)
mkdir_p(m->parameters_fragment.what, m->directory_mode);
if (m->from_fragment)
r = exec_command_set(
m->control_command,

View File

@@ -117,7 +117,7 @@ static int mount_all(const char *dest) {
{ "sysfs", "/sys", "sysfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY, true },
{ "tmpfs", "/dev", "tmpfs", "mode=755", MS_NOSUID, true },
{ "/dev/pts", "/dev/pts", "bind", NULL, MS_BIND, true },
{ "tmpfs", "/dev/.run", "tmpfs", "mode=755", MS_NOSUID|MS_NOEXEC|MS_NODEV, true },
{ "tmpfs", "/run", "tmpfs", "mode=755", MS_NOSUID|MS_NOEXEC|MS_NODEV, true },
#ifdef HAVE_SELINUX
{ "selinux", "/selinux", "selinuxfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY, false },
#endif

View File

@@ -183,7 +183,7 @@ int lookup_paths_init(LookupPaths *p, ManagerRunningAs running_as) {
if (!(p->unit_path = strv_new(
/* If you modify this you also want to modify
* systemdsystemunitpath= in systemd.pc.in! */
"/dev/.run/systemd/system",
"/run/systemd/system",
SYSTEM_CONFIG_UNIT_PATH,
"/etc/systemd/system",
"/usr/local/share/systemd/system",

Some files were not shown because too many files have changed in this diff Show More